From 438af0c7d4bf60b408b259c88205ff2193195466 Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 21 Sep 2014 18:11:28 +0200 Subject: libxtrans xkeyboard-config xserver mesa plink glproto git update 21 Sep 2014 plink revision 10233 xserver commit 28337cb14e4347e1dd7936c5393a22e042866687 xkeyboard-config commit 48e1c0b351b6711edc0f167cbb81e4424b75291a glproto commit bd3d751e1eb17efb39f65093271bb4ac071aa9e0 libxtrans commit fb7f198c88e97d22c8c89e76e9cd06b2b2720a96 mesa commit 4eb2bbefd2bf0359aff7ebbb8e931a1c7833606f --- mesalib/src/mesa/drivers/dri/common/xmlconfig.c | 4 +- mesalib/src/mesa/drivers/dri/swrast/swrast.c | 3 - mesalib/src/mesa/main/api_validate.c | 66 -- mesalib/src/mesa/main/arrayobj.c | 46 - mesalib/src/mesa/main/arrayobj.h | 4 - mesalib/src/mesa/main/attrib.c | 1 - mesalib/src/mesa/main/buffers.c | 1 - mesalib/src/mesa/main/clear.c | 1 - mesalib/src/mesa/main/context.c | 12 +- mesalib/src/mesa/main/convolve.c | 5 +- mesalib/src/mesa/main/eval.c | 1 - mesalib/src/mesa/main/feedback.c | 1 - mesalib/src/mesa/main/fog.c | 1 - mesalib/src/mesa/main/format_pack.c | 99 +- mesalib/src/mesa/main/format_unpack.c | 77 +- mesalib/src/mesa/main/format_utils.c | 1102 +++++++++++--------- mesalib/src/mesa/main/formats.c | 26 + mesalib/src/mesa/main/formats.csv | 5 + mesalib/src/mesa/main/formats.h | 5 + mesalib/src/mesa/main/histogram.c | 4 +- mesalib/src/mesa/main/macros.h | 8 +- mesalib/src/mesa/main/mtypes.h | 101 +- mesalib/src/mesa/main/pipelineobj.c | 4 +- mesalib/src/mesa/main/shader_query.cpp | 18 +- mesalib/src/mesa/main/state.c | 5 - mesalib/src/mesa/main/texcompress_rgtc.c | 79 +- mesalib/src/mesa/main/texcompress_rgtc_tmp.h | 418 -------- mesalib/src/mesa/main/texformat.c | 13 + mesalib/src/mesa/main/uniform_query.cpp | 16 +- mesalib/src/mesa/main/varray.c | 9 +- mesalib/src/mesa/main/varray.h | 33 - mesalib/src/mesa/program/ir_to_mesa.cpp | 7 +- mesalib/src/mesa/program/prog_optimize.c | 9 +- mesalib/src/mesa/program/register_allocate.c | 1 + mesalib/src/mesa/program/register_allocate.h | 5 +- mesalib/src/mesa/state_tracker/st_atom_texture.c | 30 +- mesalib/src/mesa/state_tracker/st_cb_fbo.c | 10 + mesalib/src/mesa/state_tracker/st_cb_texture.c | 62 +- mesalib/src/mesa/state_tracker/st_context.c | 82 +- mesalib/src/mesa/state_tracker/st_extensions.c | 1 + mesalib/src/mesa/state_tracker/st_format.c | 121 ++- mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 + mesalib/src/mesa/state_tracker/st_texture.c | 15 +- mesalib/src/mesa/swrast/s_texfetch.c | 5 + mesalib/src/mesa/swrast/s_texfetch_tmp.h | 54 +- mesalib/src/mesa/vbo/vbo_exec_array.c | 26 +- mesalib/src/mesa/vbo/vbo_exec_draw.c | 2 - mesalib/src/mesa/vbo/vbo_save_draw.c | 1 - mesalib/src/mesa/vbo/vbo_split_copy.c | 1 - 49 files changed, 1276 insertions(+), 1327 deletions(-) delete mode 100644 mesalib/src/mesa/main/texcompress_rgtc_tmp.h (limited to 'mesalib/src/mesa') diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c index ce376475c..8e48522e2 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c +++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c @@ -429,8 +429,10 @@ static void __driUtilMessage(const char *f, ...) { va_list args; + const char *libgl_debug; - if (getenv("LIBGL_DEBUG")) { + libgl_debug=getenv("LIBGL_DEBUG"); + if (libgl_debug && !strstr(libgl_debug, "quiet")) { fprintf(stderr, "libGL: "); va_start(args, f); vfprintf(stderr, f, args); diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index e28991b0c..e8a2c12d7 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -772,9 +772,6 @@ dri_create_context(gl_api api, driContextSetFlags(mesaCtx, flags); - /* do bounds checking to prevent segfaults and server crashes! */ - mesaCtx->Const.CheckArrayBounds = GL_TRUE; - /* create module contexts */ _swrast_CreateContext( mesaCtx ); _vbo_CreateContext( mesaCtx ); diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c index 8f0b1998d..51a3d1f01 100644 --- a/mesalib/src/mesa/main/api_validate.c +++ b/mesalib/src/mesa/main/api_validate.c @@ -159,47 +159,6 @@ check_valid_to_render(struct gl_context *ctx, const char *function) } -/** - * Do bounds checking on array element indexes. Check that the vertices - * pointed to by the indices don't lie outside buffer object bounds. - * \return GL_TRUE if OK, GL_FALSE if any indexed vertex goes is out of bounds - */ -static GLboolean -check_index_bounds(struct gl_context *ctx, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - struct _mesa_prim prim; - struct _mesa_index_buffer ib; - GLuint min, max; - - /* Only the X Server needs to do this -- otherwise, accessing outside - * array/BO bounds allows application termination. - */ - if (!ctx->Const.CheckArrayBounds) - return GL_TRUE; - - memset(&prim, 0, sizeof(prim)); - prim.count = count; - - memset(&ib, 0, sizeof(ib)); - ib.type = type; - ib.ptr = indices; - ib.obj = ctx->Array.VAO->IndexBufferObj; - - vbo_get_minmax_indices(ctx, &prim, &ib, &min, &max, 1); - - if ((int)(min + basevertex) < 0 || - max + basevertex >= ctx->Array.VAO->_MaxElement) { - /* the max element is out of bounds of one or more enabled arrays */ - _mesa_warning(ctx, "glDrawElements() index=%u is out of bounds (max=%u)", - max, ctx->Array.VAO->_MaxElement); - return GL_FALSE; - } - - return GL_TRUE; -} - - /** * Is 'mode' a valid value for glBegin(), glDrawArrays(), glDrawElements(), * etc? The set of legal values depends on whether geometry shaders/programs @@ -453,9 +412,6 @@ _mesa_validate_DrawElements(struct gl_context *ctx, return GL_FALSE; } - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - if (count == 0) return GL_FALSE; @@ -517,12 +473,6 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx, } } - for (i = 0; i < primcount; i++) { - if (!check_index_bounds(ctx, count[i], type, indices[i], - basevertex ? basevertex[i] : 0)) - return GL_FALSE; - } - return GL_TRUE; } @@ -588,9 +538,6 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, return GL_FALSE; } - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - if (count == 0) return GL_FALSE; @@ -623,11 +570,6 @@ _mesa_validate_DrawArrays(struct gl_context *ctx, if (!check_valid_to_render(ctx, "glDrawArrays")) return GL_FALSE; - if (ctx->Const.CheckArrayBounds) { - if (start + count > (GLint) ctx->Array.VAO->_MaxElement) - return GL_FALSE; - } - /* From the GLES3 specification, section 2.14.2 (Transform Feedback * Primitive Capture): * @@ -692,11 +634,6 @@ _mesa_validate_DrawArraysInstanced(struct gl_context *ctx, GLenum mode, GLint fi if (!check_valid_to_render(ctx, "glDrawArraysInstanced(invalid to render)")) return GL_FALSE; - if (ctx->Const.CheckArrayBounds) { - if (first + count > (GLint) ctx->Array.VAO->_MaxElement) - return GL_FALSE; - } - /* From the GLES3 specification, section 2.14.2 (Transform Feedback * Primitive Capture): * @@ -791,9 +728,6 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, if (count == 0) return GL_FALSE; - if (!check_index_bounds(ctx, count, type, indices, basevertex)) - return GL_FALSE; - return GL_TRUE; } diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c index 1ea319a74..0d77b112b 100644 --- a/mesalib/src/mesa/main/arrayobj.c +++ b/mesalib/src/mesa/main/arrayobj.c @@ -291,52 +291,6 @@ remove_array_object( struct gl_context *ctx, struct gl_vertex_array_object *obj } - -/** - * Helper for _mesa_update_vao_max_element(). - * \return min(vao->_VertexAttrib[*]._MaxElement). - */ -static GLuint -compute_max_element(struct gl_vertex_array_object *vao, GLbitfield64 enabled) -{ - GLuint min = ~((GLuint)0); - - while (enabled) { - struct gl_client_array *client_array; - GLint attrib = ffsll(enabled) - 1; - enabled ^= BITFIELD64_BIT(attrib); - - client_array = &vao->_VertexAttrib[attrib]; - assert(client_array->Enabled); - _mesa_update_array_max_element(client_array); - min = MIN2(min, client_array->_MaxElement); - } - - return min; -} - - -/** - * Examine vertex arrays to update the gl_vertex_array_object::_MaxElement field. - */ -void -_mesa_update_vao_max_element(struct gl_context *ctx, - struct gl_vertex_array_object *vao) -{ - GLbitfield64 enabled; - - if (!ctx->VertexProgram._Current || - ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) { - enabled = _mesa_array_object_get_enabled_ff(vao); - } else { - enabled = _mesa_array_object_get_enabled_arb(vao); - } - - /* _MaxElement is one past the last legal array element */ - vao->_MaxElement = compute_max_element(vao, enabled); -} - - /** * Updates the derived gl_client_arrays when a gl_vertex_attrib_array * or a gl_vertex_buffer_binding has changed. diff --git a/mesalib/src/mesa/main/arrayobj.h b/mesalib/src/mesa/main/arrayobj.h index d72761db1..1819cd12a 100644 --- a/mesalib/src/mesa/main/arrayobj.h +++ b/mesalib/src/mesa/main/arrayobj.h @@ -74,10 +74,6 @@ _mesa_initialize_vao(struct gl_context *ctx, struct gl_vertex_array_object *obj, GLuint name); -extern void -_mesa_update_vao_max_element(struct gl_context *ctx, - struct gl_vertex_array_object *vao); - extern void _mesa_update_vao_client_arrays(struct gl_context *ctx, struct gl_vertex_array_object *vao); diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 2e289b6f1..ef98ba7fd 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1458,7 +1458,6 @@ copy_array_object(struct gl_context *ctx, /* _Enabled must be the same than on push */ dest->_Enabled = src->_Enabled; dest->NewArrays = src->NewArrays; - dest->_MaxElement = src->_MaxElement; } /** diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c index 8a0852c42..1ee20098d 100644 --- a/mesalib/src/mesa/main/buffers.c +++ b/mesalib/src/mesa/main/buffers.c @@ -32,7 +32,6 @@ #include "glheader.h" #include "buffers.h" -#include "colormac.h" #include "context.h" #include "enums.h" #include "fbobject.h" diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c index cf93418d1..f7f15cf59 100644 --- a/mesalib/src/mesa/main/clear.c +++ b/mesalib/src/mesa/main/clear.c @@ -33,7 +33,6 @@ #include "glheader.h" #include "clear.h" #include "context.h" -#include "colormac.h" #include "enums.h" #include "macros.h" #include "mtypes.h" diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index 8b5693e37..682b9c797 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -622,8 +622,11 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) consts->MaxProgramMatrices = MAX_PROGRAM_MATRICES; consts->MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH; - /* CheckArrayBounds is overriden by drivers/x11 for X server */ - consts->CheckArrayBounds = GL_FALSE; + /* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that + * gl_VertexID is implemented using a native hardware register with OpenGL + * semantics. + */ + consts->VertexID_is_zero_based = false; /* GL_ARB_draw_buffers */ consts->MaxDrawBuffers = MAX_DRAW_BUFFERS; @@ -1501,7 +1504,10 @@ handle_first_current(struct gl_context *ctx) GLenum buffer; GLint bufferIndex; - assert(ctx->Version > 0); + if (ctx->Version == 0) { + /* probably in the process of tearing down the context */ + return; + } ctx->Extensions.String = _mesa_make_extension_string(ctx); diff --git a/mesalib/src/mesa/main/convolve.c b/mesalib/src/mesa/main/convolve.c index b13b89535..83d590f4a 100644 --- a/mesalib/src/mesa/main/convolve.c +++ b/mesalib/src/mesa/main/convolve.c @@ -32,11 +32,8 @@ #include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" +#include "context.h" #include "convolve.h" -#include "macros.h" -#include "mtypes.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c index 42793ff4c..84cd7563b 100644 --- a/mesalib/src/mesa/main/eval.c +++ b/mesalib/src/mesa/main/eval.c @@ -39,7 +39,6 @@ #include "glheader.h" #include "imports.h" -#include "colormac.h" #include "context.h" #include "eval.h" #include "macros.h" diff --git a/mesalib/src/mesa/main/feedback.c b/mesalib/src/mesa/main/feedback.c index e751a3c1e..9ea0b92f3 100644 --- a/mesalib/src/mesa/main/feedback.c +++ b/mesalib/src/mesa/main/feedback.c @@ -30,7 +30,6 @@ #include "glheader.h" -#include "colormac.h" #include "context.h" #include "enums.h" #include "feedback.h" diff --git a/mesalib/src/mesa/main/fog.c b/mesalib/src/mesa/main/fog.c index 89153912e..3bce289e7 100644 --- a/mesalib/src/mesa/main/fog.c +++ b/mesalib/src/mesa/main/fog.c @@ -24,7 +24,6 @@ #include "glheader.h" -#include "colormac.h" #include "context.h" #include "fog.h" #include "macros.h" diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c index 6cbf8593b..31c9f7767 100644 --- a/mesalib/src/mesa/main/format_pack.c +++ b/mesalib/src/mesa/main/format_pack.c @@ -1076,6 +1076,31 @@ pack_float_B8G8R8A8_SRGB(const GLfloat src[4], void *dst) } +/* MESA_FORMAT_A8R8G8B8_SRGB */ + +static void +pack_ubyte_A8R8G8B8_SRGB(const GLubyte src[4], void *dst) +{ + GLuint *d = ((GLuint *) dst); + GLubyte r = util_format_linear_to_srgb_8unorm(src[RCOMP]); + GLubyte g = util_format_linear_to_srgb_8unorm(src[GCOMP]); + GLubyte b = util_format_linear_to_srgb_8unorm(src[BCOMP]); + *d = PACK_COLOR_8888(b, g, r, src[ACOMP]); +} + +static void +pack_float_A8R8G8B8_SRGB(const GLfloat src[4], void *dst) +{ + GLuint *d = ((GLuint *) dst); + GLubyte r, g, b, a; + r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]); + g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]); + b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]); + UNCLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]); + *d = PACK_COLOR_8888(b, g, r, a); +} + + /* MESA_FORMAT_R8G8B8A8_SRGB */ static void @@ -1129,6 +1154,16 @@ pack_ubyte_L8A8_SRGB(const GLubyte src[4], void *dst) *d = PACK_COLOR_88(src[ACOMP], l); } +/* MESA_FORMAT_A8L8_SRGB */ + +static void +pack_ubyte_A8L8_SRGB(const GLubyte src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + GLubyte l = util_format_linear_to_srgb_8unorm(src[RCOMP]); + *d = PACK_COLOR_88(l, src[ACOMP]); +} + static void pack_float_L8A8_SRGB(const GLfloat src[4], void *dst) { @@ -1138,6 +1173,15 @@ pack_float_L8A8_SRGB(const GLfloat src[4], void *dst) *d = PACK_COLOR_88(a, l); } +static void +pack_float_A8L8_SRGB(const GLfloat src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + GLubyte a, l = util_format_linear_float_to_srgb_8unorm(src[RCOMP]); + CLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]); + *d = PACK_COLOR_88(l, a); +} + /* MESA_FORMAT_RGBA_FLOAT32 */ @@ -1562,6 +1606,20 @@ pack_float_L8A8_SNORM(const GLfloat src[4], void *dst) } +/* + * MESA_FORMAT_A8L8_SNORM + */ + +static void +pack_float_A8L8_SNORM(const GLfloat src[4], void *dst) +{ + GLushort *d = (GLushort *) dst; + GLbyte l = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); + GLbyte a = FLOAT_TO_BYTE(CLAMP(src[ACOMP], -1.0f, 1.0f)); + *d = (l << 8) | a; +} + + /* * MESA_FORMAT_A_SNORM16 */ @@ -1713,7 +1771,22 @@ pack_float_R8G8B8X8_SRGB(const GLfloat src[4], void *dst) GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]); GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]); GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]); - *d = PACK_COLOR_8888(127, b, g, r); + *d = PACK_COLOR_8888(255, b, g, r); +} + + +/* + * MESA_FORMAT_X8B8G8R8_SRGB + */ + +static void +pack_float_X8B8G8R8_SRGB(const GLfloat src[4], void *dst) +{ + GLuint *d = (GLuint *) dst; + GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]); + GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]); + GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]); + *d = PACK_COLOR_8888(r, g, b, 255); } @@ -1866,6 +1939,20 @@ pack_float_B8G8R8X8_SRGB(const GLfloat src[4], void *dst) *d = PACK_COLOR_8888(127, r, g, b); } +/* + * MESA_FORMAT_X8R8G8B8_SRGB + */ + +static void +pack_float_X8R8G8B8_SRGB(const GLfloat src[4], void *dst) +{ + GLuint *d = (GLuint *) dst; + GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]); + GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]); + GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]); + *d = PACK_COLOR_8888(b, g, r, 255); +} + /** * Return a function that can pack a GLubyte rgba[4] color. */ @@ -1933,9 +2020,11 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_BGR_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_A8B8G8R8_SRGB; table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_B8G8R8A8_SRGB; + table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_ubyte_A8R8G8B8_SRGB; table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_R8G8B8A8_SRGB; table[MESA_FORMAT_L_SRGB8] = pack_ubyte_L_SRGB8; table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_L8A8_SRGB; + table[MESA_FORMAT_A8L8_SRGB] = pack_ubyte_A8L8_SRGB; /* n/a */ table[MESA_FORMAT_SRGB_DXT1] = NULL; /* pack_ubyte_SRGB_DXT1; */ table[MESA_FORMAT_SRGBA_DXT1] = NULL; /* pack_ubyte_SRGBA_DXT1; */ @@ -1989,6 +2078,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_A_SNORM8] = NULL; table[MESA_FORMAT_L_SNORM8] = NULL; table[MESA_FORMAT_L8A8_SNORM] = NULL; + table[MESA_FORMAT_A8L8_SNORM] = NULL; table[MESA_FORMAT_I_SNORM8] = NULL; table[MESA_FORMAT_A_SNORM16] = NULL; table[MESA_FORMAT_L_SNORM16] = NULL; @@ -2005,6 +2095,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_ubyte_XRGB1555_UNORM; table[MESA_FORMAT_R8G8B8X8_SNORM] = NULL; table[MESA_FORMAT_R8G8B8X8_SRGB] = NULL; + table[MESA_FORMAT_X8B8G8R8_SRGB] = NULL; table[MESA_FORMAT_RGBX_UINT8] = NULL; table[MESA_FORMAT_RGBX_SINT8] = NULL; table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_ubyte_B10G10R10X2_UNORM; @@ -2020,6 +2111,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format format) table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_R10G10B10A2_UNORM; table[MESA_FORMAT_B8G8R8X8_SRGB] = NULL; + table[MESA_FORMAT_X8R8G8B8_SRGB] = NULL; initialized = GL_TRUE; } @@ -2096,9 +2188,11 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_BGR_SRGB8] = pack_float_BGR_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_A8B8G8R8_SRGB; table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_B8G8R8A8_SRGB; + table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_float_A8R8G8B8_SRGB; table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_R8G8B8A8_SRGB; table[MESA_FORMAT_L_SRGB8] = pack_float_L_SRGB8; table[MESA_FORMAT_L8A8_SRGB] = pack_float_L8A8_SRGB; + table[MESA_FORMAT_A8L8_SRGB] = pack_float_A8L8_SRGB; /* n/a */ table[MESA_FORMAT_SRGB_DXT1] = NULL; @@ -2153,6 +2247,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_A_SNORM8] = pack_float_A_SNORM8; table[MESA_FORMAT_L_SNORM8] = pack_float_L_SNORM8; table[MESA_FORMAT_L8A8_SNORM] = pack_float_L8A8_SNORM; + table[MESA_FORMAT_A8L8_SNORM] = pack_float_A8L8_SNORM; table[MESA_FORMAT_I_SNORM8] = pack_float_L_SNORM8; /* reused */ table[MESA_FORMAT_A_SNORM16] = pack_float_A_SNORM16; table[MESA_FORMAT_L_SNORM16] = pack_float_L_SNORM16; @@ -2166,6 +2261,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_float_XRGB1555_UNORM; table[MESA_FORMAT_R8G8B8X8_SNORM] = pack_float_XBGR8888_SNORM; table[MESA_FORMAT_R8G8B8X8_SRGB] = pack_float_R8G8B8X8_SRGB; + table[MESA_FORMAT_X8B8G8R8_SRGB] = pack_float_X8B8G8R8_SRGB; table[MESA_FORMAT_RGBX_UINT8] = NULL; table[MESA_FORMAT_RGBX_SINT8] = NULL; table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_float_B10G10R10X2_UNORM; @@ -2184,6 +2280,7 @@ _mesa_get_pack_float_rgba_function(mesa_format format) table[MESA_FORMAT_G16R16_SNORM] = pack_float_G16R16_SNORM; table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_B8G8R8X8_SRGB; + table[MESA_FORMAT_X8R8G8B8_SRGB] = pack_float_X8R8G8B8_SRGB; initialized = GL_TRUE; } diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c index b84ed0248..d5628a9e7 100644 --- a/mesalib/src/mesa/main/format_unpack.c +++ b/mesalib/src/mesa/main/format_unpack.c @@ -769,6 +769,19 @@ unpack_B8G8R8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) } } +static void +unpack_A8R8G8B8_SRGB(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff ); + dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff ); + dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) ); + dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */ + } +} + static void unpack_R8G8B8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) { @@ -808,6 +821,19 @@ unpack_L8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n) } } +static void +unpack_A8L8_SRGB(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLushort *s = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = + dst[i][GCOMP] = + dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float(s[i] >> 8); + dst[i][ACOMP] = UBYTE_TO_FLOAT(s[i] & 0xff); /* linear! */ + } +} + static void unpack_SRGB_DXT1(const void *src, GLfloat dst[][4], GLuint n) { @@ -1965,6 +1991,20 @@ unpack_L8A8_SNORM(const void *src, GLfloat dst[][4], GLuint n) } } + +static void +unpack_A8L8_SNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLshort *s = ((const GLshort *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = + dst[i][GCOMP] = + dst[i][BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) ); + dst[i][ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] & 0xff) ); + } +} + static void unpack_I_SNORM8(const void *src, GLfloat dst[][4], GLuint n) { @@ -2079,7 +2119,7 @@ unpack_XRGB1555_UNORM(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_XBGR8888_SNORM(const void *src, GLfloat dst[][4], GLuint n) +unpack_R8G8B8X8_SNORM(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -2100,7 +2140,20 @@ unpack_R8G8B8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n) dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] ) & 0xff ); dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff ); dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff ); - dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */ + dst[i][ACOMP] = 1.0f; + } +} + +static void +unpack_X8B8G8R8_SRGB(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) ); + dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff ); + dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff ); + dst[i][ACOMP] = 1.0f; } } @@ -2299,6 +2352,19 @@ unpack_B8G8R8X8_SRGB(const void *src, GLfloat dst[][4], GLuint n) } } +static void +unpack_X8R8G8B8_SRGB(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 8) & 0xff ); + dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 16) & 0xff ); + dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >> 24) ); + dst[i][ACOMP] = 1.0F; + } +} + /** * Return the unpacker function for the given format. */ @@ -2361,9 +2427,11 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB; table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_B8G8R8A8_SRGB; + table[MESA_FORMAT_A8R8G8B8_SRGB] = unpack_A8R8G8B8_SRGB; table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB; table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8; table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB; + table[MESA_FORMAT_A8L8_SRGB] = unpack_A8L8_SRGB; table[MESA_FORMAT_SRGB_DXT1] = unpack_SRGB_DXT1; table[MESA_FORMAT_SRGBA_DXT1] = unpack_SRGBA_DXT1; table[MESA_FORMAT_SRGBA_DXT3] = unpack_SRGBA_DXT3; @@ -2483,6 +2551,7 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_A_SNORM8] = unpack_A_SNORM8; table[MESA_FORMAT_L_SNORM8] = unpack_L_SNORM8; table[MESA_FORMAT_L8A8_SNORM] = unpack_L8A8_SNORM; + table[MESA_FORMAT_A8L8_SNORM] = unpack_A8L8_SNORM; table[MESA_FORMAT_I_SNORM8] = unpack_I_SNORM8; table[MESA_FORMAT_A_SNORM16] = unpack_A_SNORM16; table[MESA_FORMAT_L_SNORM16] = unpack_L_SNORM16; @@ -2497,8 +2566,9 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_B4G4R4X4_UNORM] = unpack_XRGB4444_UNORM; table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM; - table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_XBGR8888_SNORM; + table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_R8G8B8X8_SNORM; table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_R8G8B8X8_SRGB; + table[MESA_FORMAT_X8B8G8R8_SRGB] = unpack_X8B8G8R8_SRGB; table[MESA_FORMAT_RGBX_UINT8] = unpack_XBGR8888_UINT; table[MESA_FORMAT_RGBX_SINT8] = unpack_XBGR8888_SINT; table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_B10G10R10X2_UNORM; @@ -2517,6 +2587,7 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_G16R16_SNORM] = unpack_G16R16_SNORM; table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_B8G8R8X8_SRGB; + table[MESA_FORMAT_X8R8G8B8_SRGB] = unpack_X8R8G8B8_SRGB; initialized = GL_TRUE; } diff --git a/mesalib/src/mesa/main/format_utils.c b/mesalib/src/mesa/main/format_utils.c index 240e3bc0c..93a0ceac0 100644 --- a/mesalib/src/mesa/main/format_utils.c +++ b/mesalib/src/mesa/main/format_utils.c @@ -312,25 +312,28 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels, * format */ #define SWIZZLE_CONVERT_LOOP(DST_TYPE, DST_CHANS, SRC_TYPE, SRC_CHANS, CONV) \ - for (s = 0; s < count; ++s) { \ - for (j = 0; j < SRC_CHANS; ++j) { \ - SRC_TYPE src = typed_src[j]; \ - tmp[j] = CONV; \ - } \ - \ - typed_dst[0] = tmp[swizzle_x]; \ - if (DST_CHANS > 1) { \ - typed_dst[1] = tmp[swizzle_y]; \ - if (DST_CHANS > 2) { \ - typed_dst[2] = tmp[swizzle_z]; \ - if (DST_CHANS > 3) { \ - typed_dst[3] = tmp[swizzle_w]; \ - } \ - } \ - } \ - typed_src += SRC_CHANS; \ - typed_dst += DST_CHANS; \ - } \ + do { \ + int s, j; \ + for (s = 0; s < count; ++s) { \ + for (j = 0; j < SRC_CHANS; ++j) { \ + SRC_TYPE src = typed_src[j]; \ + tmp[j] = CONV; \ + } \ + \ + typed_dst[0] = tmp[swizzle_x]; \ + if (DST_CHANS > 1) { \ + typed_dst[1] = tmp[swizzle_y]; \ + if (DST_CHANS > 2) { \ + typed_dst[2] = tmp[swizzle_z]; \ + if (DST_CHANS > 3) { \ + typed_dst[3] = tmp[swizzle_w]; \ + } \ + } \ + } \ + typed_src += SRC_CHANS; \ + typed_dst += DST_CHANS; \ + } \ + } while (0) /** * Represents a single swizzle-and-convert operation @@ -352,6 +355,10 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels, */ #define SWIZZLE_CONVERT(DST_TYPE, SRC_TYPE, CONV) \ do { \ + const uint8_t swizzle_x = swizzle[0]; \ + const uint8_t swizzle_y = swizzle[1]; \ + const uint8_t swizzle_z = swizzle[2]; \ + const uint8_t swizzle_w = swizzle[3]; \ const SRC_TYPE *typed_src = void_src; \ DST_TYPE *typed_dst = void_dst; \ DST_TYPE tmp[7]; \ @@ -361,69 +368,589 @@ swizzle_convert_try_memcpy(void *dst, GLenum dst_type, int num_dst_channels, case 1: \ switch (num_src_channels) { \ case 1: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 1, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 1, CONV); \ break; \ case 2: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 2, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 2, CONV); \ break; \ case 3: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 3, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 3, CONV); \ break; \ case 4: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 4, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 1, SRC_TYPE, 4, CONV); \ break; \ } \ break; \ case 2: \ switch (num_src_channels) { \ case 1: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 1, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 1, CONV); \ break; \ case 2: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 2, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 2, CONV); \ break; \ case 3: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 3, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 3, CONV); \ break; \ case 4: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 4, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 2, SRC_TYPE, 4, CONV); \ break; \ } \ break; \ case 3: \ switch (num_src_channels) { \ case 1: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 1, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 1, CONV); \ break; \ case 2: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 2, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 2, CONV); \ break; \ case 3: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 3, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 3, CONV); \ break; \ case 4: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 4, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 3, SRC_TYPE, 4, CONV); \ break; \ } \ break; \ case 4: \ switch (num_src_channels) { \ case 1: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 1, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 1, CONV); \ break; \ case 2: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 2, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 2, CONV); \ break; \ case 3: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 3, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 3, CONV); \ break; \ case 4: \ - SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 4, CONV) \ + SWIZZLE_CONVERT_LOOP(DST_TYPE, 4, SRC_TYPE, 4, CONV); \ break; \ } \ break; \ } \ - } while (0); + } while (0) + + +static void +convert_float(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const float one = 1.0f; + + switch (src_type) { + case GL_FLOAT: + SWIZZLE_CONVERT(float, float, src); + break; + case GL_HALF_FLOAT: + SWIZZLE_CONVERT(float, uint16_t, _mesa_half_to_float(src)); + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(float, uint8_t, unorm_to_float(src, 8)); + } else { + SWIZZLE_CONVERT(float, uint8_t, src); + } + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(float, int8_t, snorm_to_float(src, 8)); + } else { + SWIZZLE_CONVERT(float, int8_t, src); + } + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(float, uint16_t, unorm_to_float(src, 16)); + } else { + SWIZZLE_CONVERT(float, uint16_t, src); + } + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(float, int16_t, snorm_to_float(src, 16)); + } else { + SWIZZLE_CONVERT(float, int16_t, src); + } + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(float, uint32_t, unorm_to_float(src, 32)); + } else { + SWIZZLE_CONVERT(float, uint32_t, src); + } + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(float, int32_t, snorm_to_float(src, 32)); + } else { + SWIZZLE_CONVERT(float, int32_t, src); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + + +static void +convert_half_float(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const uint16_t one = _mesa_float_to_half(1.0f); + + switch (src_type) { + case GL_FLOAT: + SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_half(src)); + break; + case GL_HALF_FLOAT: + SWIZZLE_CONVERT(uint16_t, uint16_t, src); + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_half(src, 8)); + } else { + SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_float_to_half(src)); + } + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_half(src, 8)); + } else { + SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_float_to_half(src)); + } + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint16_t, unorm_to_half(src, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_float_to_half(src)); + } + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_half(src, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_float_to_half(src)); + } + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_half(src, 32)); + } else { + SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_float_to_half(src)); + } + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_half(src, 32)); + } else { + SWIZZLE_CONVERT(uint16_t, int32_t, _mesa_float_to_half(src)); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + + +static void +convert_ubyte(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const uint8_t one = normalized ? UINT8_MAX : 1; + + switch (src_type) { + case GL_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, float, float_to_unorm(src, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, float, (src < 0) ? 0 : src); + } + break; + case GL_HALF_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_unorm(src, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_uint(src)); + } + break; + case GL_UNSIGNED_BYTE: + SWIZZLE_CONVERT(uint8_t, uint8_t, src); + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, int8_t, snorm_to_unorm(src, 8, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, int8_t, (src < 0) ? 0 : src); + } + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, uint16_t, unorm_to_unorm(src, 16, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, uint16_t, src); + } + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, int16_t, snorm_to_unorm(src, 16, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, int16_t, (src < 0) ? 0 : src); + } + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, uint32_t, unorm_to_unorm(src, 32, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, uint32_t, src); + } + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, int32_t, snorm_to_unorm(src, 32, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, int32_t, (src < 0) ? 0 : src); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + + +static void +convert_byte(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const int8_t one = normalized ? INT8_MAX : 1; + + switch (src_type) { + case GL_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, float, float_to_snorm(src, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, float, src); + } + break; + case GL_HALF_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_snorm(src, 8)); + } else { + SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_float(src)); + } + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(int8_t, uint8_t, unorm_to_snorm(src, 8, 8)); + } else { + SWIZZLE_CONVERT(int8_t, uint8_t, src); + } + break; + case GL_BYTE: + SWIZZLE_CONVERT(int8_t, int8_t, src); + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(int8_t, uint16_t, unorm_to_snorm(src, 16, 8)); + } else { + SWIZZLE_CONVERT(int8_t, uint16_t, src); + } + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(int8_t, int16_t, snorm_to_snorm(src, 16, 8)); + } else { + SWIZZLE_CONVERT(int8_t, int16_t, src); + } + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(int8_t, uint32_t, unorm_to_snorm(src, 32, 8)); + } else { + SWIZZLE_CONVERT(int8_t, uint32_t, src); + } + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(int8_t, int32_t, snorm_to_snorm(src, 32, 8)); + } else { + SWIZZLE_CONVERT(int8_t, int32_t, src); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + + +static void +convert_ushort(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const uint16_t one = normalized ? UINT16_MAX : 1; + + switch (src_type) { + case GL_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, float, float_to_unorm(src, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, float, (src < 0) ? 0 : src); + } + break; + case GL_HALF_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_unorm(src, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_uint(src)); + } + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_unorm(src, 8, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, uint8_t, src); + } + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_unorm(src, 8, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, int8_t, (src < 0) ? 0 : src); + } + break; + case GL_UNSIGNED_SHORT: + SWIZZLE_CONVERT(uint16_t, uint16_t, src); + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_unorm(src, 16, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, int16_t, (src < 0) ? 0 : src); + } + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_unorm(src, 32, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, uint32_t, src); + } + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_unorm(src, 32, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, int32_t, (src < 0) ? 0 : src); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + + +static void +convert_short(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const int16_t one = normalized ? INT16_MAX : 1; + + switch (src_type) { + case GL_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, float, float_to_snorm(src, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, float, src); + } + break; + case GL_HALF_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_snorm(src, 16)); + } else { + SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_float(src)); + } + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(int16_t, uint8_t, unorm_to_snorm(src, 8, 16)); + } else { + SWIZZLE_CONVERT(int16_t, uint8_t, src); + } + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(int16_t, int8_t, snorm_to_snorm(src, 8, 16)); + } else { + SWIZZLE_CONVERT(int16_t, int8_t, src); + } + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(int16_t, uint16_t, unorm_to_snorm(src, 16, 16)); + } else { + SWIZZLE_CONVERT(int16_t, uint16_t, src); + } + break; + case GL_SHORT: + SWIZZLE_CONVERT(int16_t, int16_t, src); + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(int16_t, uint32_t, unorm_to_snorm(src, 32, 16)); + } else { + SWIZZLE_CONVERT(int16_t, uint32_t, src); + } + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(int16_t, int32_t, snorm_to_snorm(src, 32, 16)); + } else { + SWIZZLE_CONVERT(int16_t, int32_t, src); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + +static void +convert_uint(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const uint32_t one = normalized ? UINT32_MAX : 1; + + switch (src_type) { + case GL_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, float, float_to_unorm(src, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, float, (src < 0) ? 0 : src); + } + break; + case GL_HALF_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_unorm(src, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_uint(src)); + } + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, uint8_t, unorm_to_unorm(src, 8, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, uint8_t, src); + } + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, int8_t, snorm_to_unorm(src, 8, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, int8_t, (src < 0) ? 0 : src); + } + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, uint16_t, unorm_to_unorm(src, 16, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, uint16_t, src); + } + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, int16_t, snorm_to_unorm(src, 16, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, int16_t, (src < 0) ? 0 : src); + } + break; + case GL_UNSIGNED_INT: + SWIZZLE_CONVERT(uint32_t, uint32_t, src); + break; + case GL_INT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, int32_t, snorm_to_unorm(src, 32, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, int32_t, (src < 0) ? 0 : src); + } + break; + default: + assert(!"Invalid channel type combination"); + } +} + + +static void +convert_int(void *void_dst, int num_dst_channels, + const void *void_src, GLenum src_type, int num_src_channels, + const uint8_t swizzle[4], bool normalized, int count) +{ + const int32_t one = normalized ? INT32_MAX : 12; + + switch (src_type) { + case GL_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, float, float_to_snorm(src, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, float, src); + } + break; + case GL_HALF_FLOAT: + if (normalized) { + SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_snorm(src, 32)); + } else { + SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_float(src)); + } + break; + case GL_UNSIGNED_BYTE: + if (normalized) { + SWIZZLE_CONVERT(int32_t, uint8_t, unorm_to_snorm(src, 8, 32)); + } else { + SWIZZLE_CONVERT(int32_t, uint8_t, src); + } + break; + case GL_BYTE: + if (normalized) { + SWIZZLE_CONVERT(int32_t, int8_t, snorm_to_snorm(src, 8, 32)); + } else { + SWIZZLE_CONVERT(int32_t, int8_t, src); + } + break; + case GL_UNSIGNED_SHORT: + if (normalized) { + SWIZZLE_CONVERT(int32_t, uint16_t, unorm_to_snorm(src, 16, 32)); + } else { + SWIZZLE_CONVERT(int32_t, uint16_t, src); + } + break; + case GL_SHORT: + if (normalized) { + SWIZZLE_CONVERT(int32_t, int16_t, snorm_to_snorm(src, 16, 32)); + } else { + SWIZZLE_CONVERT(int32_t, int16_t, src); + } + break; + case GL_UNSIGNED_INT: + if (normalized) { + SWIZZLE_CONVERT(int32_t, uint32_t, unorm_to_snorm(src, 32, 32)); + } else { + SWIZZLE_CONVERT(int32_t, uint32_t, src); + } + break; + case GL_INT: + SWIZZLE_CONVERT(int32_t, int32_t, src); + break; + default: + assert(!"Invalid channel type combination"); + } +} + /** * Convert between array-based color formats. @@ -478,499 +1005,44 @@ _mesa_swizzle_and_convert(void *void_dst, GLenum dst_type, int num_dst_channels, const void *void_src, GLenum src_type, int num_src_channels, const uint8_t swizzle[4], bool normalized, int count) { - int s, j; - register uint8_t swizzle_x, swizzle_y, swizzle_z, swizzle_w; - if (swizzle_convert_try_memcpy(void_dst, dst_type, num_dst_channels, void_src, src_type, num_src_channels, swizzle, normalized, count)) return; - swizzle_x = swizzle[0]; - swizzle_y = swizzle[1]; - swizzle_z = swizzle[2]; - swizzle_w = swizzle[3]; - switch (dst_type) { case GL_FLOAT: - { - const float one = 1.0f; - switch (src_type) { - case GL_FLOAT: - SWIZZLE_CONVERT(float, float, src) - break; - case GL_HALF_FLOAT: - SWIZZLE_CONVERT(float, uint16_t, _mesa_half_to_float(src)) - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(float, uint8_t, unorm_to_float(src, 8)) - } else { - SWIZZLE_CONVERT(float, uint8_t, src) - } - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(float, int8_t, snorm_to_float(src, 8)) - } else { - SWIZZLE_CONVERT(float, int8_t, src) - } - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(float, uint16_t, unorm_to_float(src, 16)) - } else { - SWIZZLE_CONVERT(float, uint16_t, src) - } - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(float, int16_t, snorm_to_float(src, 16)) - } else { - SWIZZLE_CONVERT(float, int16_t, src) - } - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(float, uint32_t, unorm_to_float(src, 32)) - } else { - SWIZZLE_CONVERT(float, uint32_t, src) - } - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(float, int32_t, snorm_to_float(src, 32)) - } else { - SWIZZLE_CONVERT(float, int32_t, src) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_float(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_HALF_FLOAT: - { - const uint16_t one = _mesa_float_to_half(1.0f); - switch (src_type) { - case GL_FLOAT: - SWIZZLE_CONVERT(uint16_t, float, _mesa_float_to_half(src)) - break; - case GL_HALF_FLOAT: - SWIZZLE_CONVERT(uint16_t, uint16_t, src) - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_half(src, 8)) - } else { - SWIZZLE_CONVERT(uint16_t, uint8_t, _mesa_float_to_half(src)) - } - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_half(src, 8)) - } else { - SWIZZLE_CONVERT(uint16_t, int8_t, _mesa_float_to_half(src)) - } - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint16_t, unorm_to_half(src, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_float_to_half(src)) - } - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_half(src, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, int16_t, _mesa_float_to_half(src)) - } - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_half(src, 32)) - } else { - SWIZZLE_CONVERT(uint16_t, uint32_t, _mesa_float_to_half(src)) - } - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_half(src, 32)) - } else { - SWIZZLE_CONVERT(uint16_t, int32_t, _mesa_float_to_half(src)) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_half_float(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_UNSIGNED_BYTE: - { - const uint8_t one = normalized ? UINT8_MAX : 1; - switch (src_type) { - case GL_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, float, float_to_unorm(src, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, float, (src < 0) ? 0 : src) - } - break; - case GL_HALF_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_unorm(src, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_uint(src)) - } - break; - case GL_UNSIGNED_BYTE: - SWIZZLE_CONVERT(uint8_t, uint8_t, src) - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, int8_t, snorm_to_unorm(src, 8, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, int8_t, (src < 0) ? 0 : src) - } - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, uint16_t, unorm_to_unorm(src, 16, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, uint16_t, src) - } - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, int16_t, snorm_to_unorm(src, 16, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, int16_t, (src < 0) ? 0 : src) - } - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, uint32_t, unorm_to_unorm(src, 32, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, uint32_t, src) - } - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, int32_t, snorm_to_unorm(src, 32, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, int32_t, (src < 0) ? 0 : src) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_ubyte(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_BYTE: - { - const int8_t one = normalized ? INT8_MAX : 1; - switch (src_type) { - case GL_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, float, float_to_snorm(src, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, float, src) - } - break; - case GL_HALF_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint8_t, uint16_t, half_to_snorm(src, 8)) - } else { - SWIZZLE_CONVERT(uint8_t, uint16_t, _mesa_half_to_float(src)) - } - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(int8_t, uint8_t, unorm_to_snorm(src, 8, 8)) - } else { - SWIZZLE_CONVERT(int8_t, uint8_t, src) - } - break; - case GL_BYTE: - SWIZZLE_CONVERT(int8_t, int8_t, src) - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(int8_t, uint16_t, unorm_to_snorm(src, 16, 8)) - } else { - SWIZZLE_CONVERT(int8_t, uint16_t, src) - } - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(int8_t, int16_t, snorm_to_snorm(src, 16, 8)) - } else { - SWIZZLE_CONVERT(int8_t, int16_t, src) - } - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(int8_t, uint32_t, unorm_to_snorm(src, 32, 8)) - } else { - SWIZZLE_CONVERT(int8_t, uint32_t, src) - } - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(int8_t, int32_t, snorm_to_snorm(src, 32, 8)) - } else { - SWIZZLE_CONVERT(int8_t, int32_t, src) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_byte(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_UNSIGNED_SHORT: - { - const uint16_t one = normalized ? UINT16_MAX : 1; - switch (src_type) { - case GL_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, float, float_to_unorm(src, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, float, (src < 0) ? 0 : src) - } - break; - case GL_HALF_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_unorm(src, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_uint(src)) - } - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint8_t, unorm_to_unorm(src, 8, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, uint8_t, src) - } - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, int8_t, snorm_to_unorm(src, 8, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, int8_t, (src < 0) ? 0 : src) - } - break; - case GL_UNSIGNED_SHORT: - SWIZZLE_CONVERT(uint16_t, uint16_t, src) - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, int16_t, snorm_to_unorm(src, 16, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, int16_t, (src < 0) ? 0 : src) - } - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint32_t, unorm_to_unorm(src, 32, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, uint32_t, src) - } - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, int32_t, snorm_to_unorm(src, 32, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, int32_t, (src < 0) ? 0 : src) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_ushort(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_SHORT: - { - const int16_t one = normalized ? INT16_MAX : 1; - switch (src_type) { - case GL_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, float, float_to_snorm(src, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, float, src) - } - break; - case GL_HALF_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint16_t, uint16_t, half_to_snorm(src, 16)) - } else { - SWIZZLE_CONVERT(uint16_t, uint16_t, _mesa_half_to_float(src)) - } - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(int16_t, uint8_t, unorm_to_snorm(src, 8, 16)) - } else { - SWIZZLE_CONVERT(int16_t, uint8_t, src) - } - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(int16_t, int8_t, snorm_to_snorm(src, 8, 16)) - } else { - SWIZZLE_CONVERT(int16_t, int8_t, src) - } - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(int16_t, uint16_t, unorm_to_snorm(src, 16, 16)) - } else { - SWIZZLE_CONVERT(int16_t, uint16_t, src) - } - break; - case GL_SHORT: - SWIZZLE_CONVERT(int16_t, int16_t, src) - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(int16_t, uint32_t, unorm_to_snorm(src, 32, 16)) - } else { - SWIZZLE_CONVERT(int16_t, uint32_t, src) - } - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(int16_t, int32_t, snorm_to_snorm(src, 32, 16)) - } else { - SWIZZLE_CONVERT(int16_t, int32_t, src) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_short(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_UNSIGNED_INT: - { - const uint32_t one = normalized ? UINT32_MAX : 1; - switch (src_type) { case GL_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, float, float_to_unorm(src, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, float, (src < 0) ? 0 : src) - } - break; - case GL_HALF_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_unorm(src, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_uint(src)) - } - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, uint8_t, unorm_to_unorm(src, 8, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, uint8_t, src) - } - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, int8_t, snorm_to_unorm(src, 8, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, int8_t, (src < 0) ? 0 : src) - } - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, uint16_t, unorm_to_unorm(src, 16, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, uint16_t, src) - } - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, int16_t, snorm_to_unorm(src, 16, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, int16_t, (src < 0) ? 0 : src) - } - break; - case GL_UNSIGNED_INT: - SWIZZLE_CONVERT(uint32_t, uint32_t, src) - break; - case GL_INT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, int32_t, snorm_to_unorm(src, 32, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, int32_t, (src < 0) ? 0 : src) - } - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_uint(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; case GL_INT: - { - const int32_t one = normalized ? INT32_MAX : 1; - switch (src_type) { - case GL_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, float, float_to_snorm(src, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, float, src) - } - break; - case GL_HALF_FLOAT: - if (normalized) { - SWIZZLE_CONVERT(uint32_t, uint16_t, half_to_snorm(src, 32)) - } else { - SWIZZLE_CONVERT(uint32_t, uint16_t, _mesa_half_to_float(src)) - } - break; - case GL_UNSIGNED_BYTE: - if (normalized) { - SWIZZLE_CONVERT(int32_t, uint8_t, unorm_to_snorm(src, 8, 32)) - } else { - SWIZZLE_CONVERT(int32_t, uint8_t, src) - } - break; - case GL_BYTE: - if (normalized) { - SWIZZLE_CONVERT(int32_t, int8_t, snorm_to_snorm(src, 8, 32)) - } else { - SWIZZLE_CONVERT(int32_t, int8_t, src) - } - break; - case GL_UNSIGNED_SHORT: - if (normalized) { - SWIZZLE_CONVERT(int32_t, uint16_t, unorm_to_snorm(src, 16, 32)) - } else { - SWIZZLE_CONVERT(int32_t, uint16_t, src) - } - break; - case GL_SHORT: - if (normalized) { - SWIZZLE_CONVERT(int32_t, int16_t, snorm_to_snorm(src, 16, 32)) - } else { - SWIZZLE_CONVERT(int32_t, int16_t, src) - } - break; - case GL_UNSIGNED_INT: - if (normalized) { - SWIZZLE_CONVERT(int32_t, uint32_t, unorm_to_snorm(src, 32, 32)) - } else { - SWIZZLE_CONVERT(int32_t, uint32_t, src) - } - break; - case GL_INT: - SWIZZLE_CONVERT(int32_t, int32_t, src) - break; - default: - assert(!"Invalid channel type combination"); - } - } - break; + convert_int(void_dst, num_dst_channels, void_src, src_type, + num_src_channels, swizzle, normalized, count); + break; default: assert(!"Invalid channel type"); } diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index db22a45c4..58c32e23b 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -357,9 +357,11 @@ _mesa_get_format_color_encoding(mesa_format format) case MESA_FORMAT_BGR_SRGB8: case MESA_FORMAT_A8B8G8R8_SRGB: case MESA_FORMAT_B8G8R8A8_SRGB: + case MESA_FORMAT_A8R8G8B8_SRGB: case MESA_FORMAT_R8G8B8A8_SRGB: case MESA_FORMAT_L_SRGB8: case MESA_FORMAT_L8A8_SRGB: + case MESA_FORMAT_A8L8_SRGB: case MESA_FORMAT_SRGB_DXT1: case MESA_FORMAT_SRGBA_DXT1: case MESA_FORMAT_SRGBA_DXT3: @@ -419,6 +421,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_B8G8R8A8_SRGB: format = MESA_FORMAT_B8G8R8A8_UNORM; break; + case MESA_FORMAT_A8R8G8B8_SRGB: + format = MESA_FORMAT_A8R8G8B8_UNORM; + break; case MESA_FORMAT_R8G8B8A8_SRGB: format = MESA_FORMAT_R8G8B8A8_UNORM; break; @@ -428,6 +433,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_L8A8_SRGB: format = MESA_FORMAT_L8A8_UNORM; break; + case MESA_FORMAT_A8L8_SRGB: + format = MESA_FORMAT_A8L8_UNORM; + break; case MESA_FORMAT_SRGB_DXT1: format = MESA_FORMAT_RGB_DXT1; break; @@ -443,6 +451,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_R8G8B8X8_SRGB: format = MESA_FORMAT_R8G8B8X8_UNORM; break; + case MESA_FORMAT_X8B8G8R8_SRGB: + format = MESA_FORMAT_X8B8G8R8_UNORM; + break; case MESA_FORMAT_ETC2_SRGB8: format = MESA_FORMAT_ETC2_RGB8; break; @@ -458,6 +469,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_B8G8R8X8_SRGB: format = MESA_FORMAT_B8G8R8X8_UNORM; break; + case MESA_FORMAT_X8R8G8B8_SRGB: + format = MESA_FORMAT_X8R8G8B8_UNORM; + break; default: break; } @@ -919,6 +933,7 @@ _mesa_format_to_type_and_comps(mesa_format format, return; case MESA_FORMAT_R8G8_SNORM: case MESA_FORMAT_L8A8_SNORM: + case MESA_FORMAT_A8L8_SNORM: *datatype = GL_BYTE; *comps = 2; return; @@ -961,6 +976,7 @@ _mesa_format_to_type_and_comps(mesa_format format, return; case MESA_FORMAT_A8B8G8R8_SRGB: case MESA_FORMAT_B8G8R8A8_SRGB: + case MESA_FORMAT_A8R8G8B8_SRGB: case MESA_FORMAT_R8G8B8A8_SRGB: *datatype = GL_UNSIGNED_BYTE; *comps = 4; @@ -970,6 +986,7 @@ _mesa_format_to_type_and_comps(mesa_format format, *comps = 1; return; case MESA_FORMAT_L8A8_SRGB: + case MESA_FORMAT_A8L8_SRGB: *datatype = GL_UNSIGNED_BYTE; *comps = 2; return; @@ -1235,6 +1252,7 @@ _mesa_format_to_type_and_comps(mesa_format format, return; case MESA_FORMAT_R8G8B8X8_SRGB: + case MESA_FORMAT_X8B8G8R8_SRGB: case MESA_FORMAT_RGBX_UINT8: *datatype = GL_UNSIGNED_BYTE; *comps = 4; @@ -1299,6 +1317,7 @@ _mesa_format_to_type_and_comps(mesa_format format, return; case MESA_FORMAT_B8G8R8X8_SRGB: + case MESA_FORMAT_X8R8G8B8_SRGB: *datatype = GL_UNSIGNED_BYTE; *comps = 4; return; @@ -1414,6 +1433,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, return GL_FALSE; case MESA_FORMAT_A8R8G8B8_UNORM: + case MESA_FORMAT_A8R8G8B8_SRGB: if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes) return GL_TRUE; @@ -1475,6 +1495,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_L8A8_SRGB: return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_BYTE && littleEndian; case MESA_FORMAT_A8L8_UNORM: + case MESA_FORMAT_A8L8_SRGB: return GL_FALSE; case MESA_FORMAT_L16A16_UNORM: @@ -1797,6 +1818,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_L8A8_SNORM: return format == GL_LUMINANCE_ALPHA && type == GL_BYTE && littleEndian && !swapBytes; + case MESA_FORMAT_A8L8_SNORM: + return format == GL_LUMINANCE_ALPHA && type == GL_BYTE && + !littleEndian && !swapBytes; case MESA_FORMAT_I_SNORM8: return format == GL_RED && type == GL_BYTE; case MESA_FORMAT_A_SNORM16: @@ -1839,6 +1863,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_B5G5R5X1_UNORM: case MESA_FORMAT_R8G8B8X8_SNORM: case MESA_FORMAT_R8G8B8X8_SRGB: + case MESA_FORMAT_X8B8G8R8_SRGB: case MESA_FORMAT_RGBX_UINT8: case MESA_FORMAT_RGBX_SINT8: case MESA_FORMAT_B10G10R10X2_UNORM: @@ -1865,6 +1890,7 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, !swapBytes; case MESA_FORMAT_B8G8R8X8_SRGB: + case MESA_FORMAT_X8R8G8B8_SRGB: return GL_FALSE; } diff --git a/mesalib/src/mesa/main/formats.csv b/mesalib/src/mesa/main/formats.csv index 4d542b7c6..39bcdbdd2 100644 --- a/mesalib/src/mesa/main/formats.csv +++ b/mesalib/src/mesa/main/formats.csv @@ -119,6 +119,7 @@ MESA_FORMAT_G16R16_SNORM , packed, 1, 1, sn16, sn16, , MESA_FORMAT_R8G8_SNORM , packed, 1, 1, sn8 , sn8 , , , xy01, rgb MESA_FORMAT_G8R8_SNORM , packed, 1, 1, sn8 , sn8 , , , yx01, rgb MESA_FORMAT_L8A8_SNORM , packed, 1, 1, sn8 , sn8 , , , xxxy, rgb +MESA_FORMAT_A8L8_SNORM , packed, 1, 1, sn8 , sn8 , , , yyyx, rgb # Array signed/normalized formats MESA_FORMAT_A_SNORM8 , array , 1, 1, sn8 , , , , 000x, rgb @@ -137,10 +138,14 @@ MESA_FORMAT_RGBX_SNORM16 , array , 1, 1, sn16, sn16, sn16, x16 # Packed sRGB formats MESA_FORMAT_A8B8G8R8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb MESA_FORMAT_B8G8R8A8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb +MESA_FORMAT_A8R8G8B8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb MESA_FORMAT_B8G8R8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb +MESA_FORMAT_X8R8G8B8_SRGB , packed, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb MESA_FORMAT_R8G8B8A8_SRGB , packed, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb MESA_FORMAT_R8G8B8X8_SRGB , packed, 1, 1, un8 , un8 , un8 , x8 , xyz1, srgb +MESA_FORMAT_X8B8G8R8_SRGB , packed, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb MESA_FORMAT_L8A8_SRGB , packed, 1, 1, un8 , un8 , , , xxxy, srgb +MESA_FORMAT_A8L8_SRGB , packed, 1, 1, un8 , un8 , , , yyyx, srgb # Array sRGB formats MESA_FORMAT_L_SRGB8 , array , 1, 1, un8 , , , , xxx1, srgb diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index d6253bf86..213ab563d 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -265,6 +265,7 @@ typedef enum MESA_FORMAT_R8G8_SNORM, /* GGGG GGGG RRRR RRRR */ MESA_FORMAT_G8R8_SNORM, /* RRRR RRRR GGGG GGGG */ MESA_FORMAT_L8A8_SNORM, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_A8L8_SNORM, /* LLLL LLLL AAAA AAAA */ /* Array signed/normalized formats */ MESA_FORMAT_A_SNORM8, /* byte[i] = A */ @@ -283,10 +284,14 @@ typedef enum /* Packed sRGB formats */ MESA_FORMAT_A8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ MESA_FORMAT_B8G8R8A8_SRGB, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_A8R8G8B8_SRGB, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ MESA_FORMAT_B8G8R8X8_SRGB, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */ + MESA_FORMAT_X8R8G8B8_SRGB, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */ MESA_FORMAT_R8G8B8A8_SRGB, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ MESA_FORMAT_R8G8B8X8_SRGB, /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_X8B8G8R8_SRGB, /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */ MESA_FORMAT_L8A8_SRGB, /* AAAA AAAA LLLL LLLL */ + MESA_FORMAT_A8L8_SRGB, /* LLLL LLLL AAAA AAAA */ /* Array sRGB formats */ MESA_FORMAT_L_SRGB8, /* ubyte[i] = L */ diff --git a/mesalib/src/mesa/main/histogram.c b/mesalib/src/mesa/main/histogram.c index e6e6a6fd1..5759763d4 100644 --- a/mesalib/src/mesa/main/histogram.c +++ b/mesalib/src/mesa/main/histogram.c @@ -24,10 +24,8 @@ #include "glheader.h" -#include "bufferobj.h" -#include "colormac.h" +#include "context.h" #include "histogram.h" -#include "macros.h" #include "main/dispatch.h" diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h index 7b6148d09..712699f75 100644 --- a/mesalib/src/mesa/main/macros.h +++ b/mesalib/src/mesa/main/macros.h @@ -144,10 +144,10 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; /* This function/macro is sensitive to precision. Test very carefully * if you change it! */ -#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \ +#define UNCLAMPED_FLOAT_TO_UBYTE(UB, FLT) \ do { \ fi_type __tmp; \ - __tmp.f = (F); \ + __tmp.f = (FLT); \ if (__tmp.i < 0) \ UB = (GLubyte) 0; \ else if (__tmp.i >= IEEE_ONE) \ @@ -157,10 +157,10 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; UB = (GLubyte) __tmp.i; \ } \ } while (0) -#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \ +#define CLAMPED_FLOAT_TO_UBYTE(UB, FLT) \ do { \ fi_type __tmp; \ - __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \ + __tmp.f = (FLT) * (255.0F/256.0F) + 32768.0F; \ UB = (GLubyte) __tmp.i; \ } while (0) #else diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 4fb30ffba..553a21667 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1526,7 +1526,6 @@ struct gl_client_array GLuint _ElementSize; /**< size of each element in bytes */ struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */ - GLuint _MaxElement; /**< max element index into array buffer + 1 */ }; @@ -1629,12 +1628,6 @@ struct gl_vertex_array_object /** Mask of VERT_BIT_* values indicating changed/dirty arrays */ GLbitfield64 NewArrays; - /** - * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs - * we can determine the max legal (in bounds) glDrawElements array index. - */ - GLuint _MaxElement; - /** The index buffer (also known as the element array buffer in OpenGL). */ struct gl_buffer_object *IndexBufferObj; }; @@ -2055,8 +2048,90 @@ typedef enum * \name Vertex shader system values */ /*@{*/ + /** + * OpenGL-style vertex ID. + * + * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the + * OpenGL 3.3 core profile spec says: + * + * "gl_VertexID holds the integer index i implicitly passed by + * DrawArrays or one of the other drawing commands defined in section + * 2.8.3." + * + * Section 2.8.3 (Drawing Commands) of the same spec says: + * + * "The commands....are equivalent to the commands with the same base + * name (without the BaseVertex suffix), except that the ith element + * transferred by the corresponding draw call will be taken from + * element indices[i] + basevertex of each enabled array." + * + * Additionally, the overview in the GL_ARB_shader_draw_parameters spec + * says: + * + * "In unextended GL, vertex shaders have inputs named gl_VertexID and + * gl_InstanceID, which contain, respectively the index of the vertex + * and instance. The value of gl_VertexID is the implicitly passed + * index of the vertex being processed, which includes the value of + * baseVertex, for those commands that accept it." + * + * gl_VertexID gets basevertex added in. This differs from DirectX where + * SV_VertexID does \b not get basevertex added in. + * + * \note + * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be + * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus + * \c SYSTEM_VALUE_BASE_VERTEX. + * + * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX + */ SYSTEM_VALUE_VERTEX_ID, + + /** + * Instanced ID as supplied to gl_InstanceID + * + * Values assigned to gl_InstanceID always begin with zero, regardless of + * the value of baseinstance. + * + * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec + * says: + * + * "gl_InstanceID holds the integer instance number of the current + * primitive in an instanced draw call (see section 10.5)." + * + * Through a big chain of pseudocode, section 10.5 describes that + * baseinstance is not counted by gl_InstanceID. In that section, notice + * + * "If an enabled vertex attribute array is instanced (it has a + * non-zero divisor as specified by VertexAttribDivisor), the element + * index that is transferred to the GL, for all vertices, is given by + * + * floor(instance/divisor) + baseinstance + * + * If an array corresponding to an attribute required by a vertex + * shader is not enabled, then the corresponding element is taken from + * the current attribute state (see section 10.2)." + * + * Note that baseinstance is \b not included in the value of instance. + */ SYSTEM_VALUE_INSTANCE_ID, + + /** + * DirectX-style vertex ID. + * + * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include + * the value of basevertex. + * + * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX + */ + SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, + + /** + * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar + * functions. + * + * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE + */ + SYSTEM_VALUE_BASE_VERTEX, /*@}*/ /** @@ -3350,9 +3425,6 @@ struct gl_constants GLuint PrimitivesWritten; } QueryCounterBits; - /** vertex array / buffer object bounds checking */ - GLboolean CheckArrayBounds; - GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */ GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */ @@ -3405,6 +3477,15 @@ struct gl_constants */ GLboolean NativeIntegers; + /** + * Does VertexID count from zero or from base vertex? + * + * \note + * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is + * ignored and need not be set. + */ + bool VertexID_is_zero_based; + /** * If the driver supports real 32-bit integers, what integer value should be * used for boolean true in uniform uploads? (Usually 1 or ~0.) diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c index 017d4257e..b713d956f 100644 --- a/mesalib/src/mesa/main/pipelineobj.c +++ b/mesalib/src/mesa/main/pipelineobj.c @@ -120,12 +120,12 @@ delete_pipelineobj_cb(GLuint id, void *data, void *userData) void _mesa_free_pipeline_data(struct gl_context *ctx) { + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL); + _mesa_HashDeleteAll(ctx->Pipeline.Objects, delete_pipelineobj_cb, ctx); _mesa_DeleteHashTable(ctx->Pipeline.Objects); - _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL); _mesa_delete_pipeline_object(ctx, ctx->Pipeline.Default); - } /** diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp index 426774316..766ad2965 100644 --- a/mesalib/src/mesa/main/shader_query.cpp +++ b/mesalib/src/mesa/main/shader_query.cpp @@ -92,8 +92,9 @@ is_active_attrib(const ir_variable *var) * are enumerated, including the special built-in inputs gl_VertexID * and gl_InstanceID." */ - return !strcmp(var->name, "gl_VertexID") || - !strcmp(var->name, "gl_InstanceID"); + return var->data.location == SYSTEM_VALUE_VERTEX_ID || + var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE || + var->data.location == SYSTEM_VALUE_INSTANCE_ID; default: return false; @@ -133,7 +134,18 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, continue; if (current_index == desired_index) { - _mesa_copy_string(name, maxLength, length, var->name); + const char *var_name = var->name; + + /* Since gl_VertexID may be lowered to gl_VertexIDMESA, we need to + * consider gl_VertexIDMESA as gl_VertexID for purposes of checking + * active attributes. + */ + if (var->data.mode == ir_var_system_value && + var->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) { + var_name = "gl_VertexID"; + } + + _mesa_copy_string(name, maxLength, length, var_name); if (size) *size = (var->type->is_array()) ? var->type->length : 1; diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c index c122c16aa..80287c470 100644 --- a/mesalib/src/mesa/main/state.c +++ b/mesalib/src/mesa/main/state.c @@ -419,11 +419,6 @@ _mesa_update_state_locked( struct gl_context *ctx ) if (new_state & _NEW_ARRAY) _mesa_update_vao_client_arrays(ctx, ctx->Array.VAO); - if (ctx->Const.CheckArrayBounds && - new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) { - _mesa_update_vao_max_element(ctx, ctx->Array.VAO); - } - out: new_prog_state |= update_program_constants(ctx); diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c index 1012699f5..f7ee24d47 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.c +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -40,23 +40,10 @@ #include "macros.h" #include "mipmap.h" #include "texcompress.h" +#include "util/rgtc.h" #include "texcompress_rgtc.h" #include "texstore.h" - -#define RGTC_DEBUG 0 - -static void unsigned_encode_rgtc_ubyte(GLubyte *blkaddr, GLubyte srccolors[4][4], - GLint numxpixels, GLint numypixels); -static void signed_encode_rgtc_ubyte(GLbyte *blkaddr, GLbyte srccolors[4][4], - GLint numxpixels, GLint numypixels); - -static void unsigned_fetch_texel_rgtc(unsigned srcRowStride, const GLubyte *pixdata, - unsigned i, unsigned j, GLubyte *value, unsigned comps); - -static void signed_fetch_texel_rgtc(unsigned srcRowStride, const GLbyte *pixdata, - unsigned i, unsigned j, GLbyte *value, unsigned comps); - static void extractsrc_u( GLubyte srcpixels[4][4], const GLubyte *srcaddr, GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps) { @@ -121,7 +108,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS) if (srcWidth > i + 3) numxpixels = 4; else numxpixels = srcWidth - i; extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); - unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); + util_format_unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); srcaddr += numxpixels; blkaddr += 8; } @@ -168,7 +155,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS) if (srcWidth > i + 3) numxpixels = 4; else numxpixels = srcWidth - i; extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 1); - signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); + util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); srcaddr += numxpixels; blkaddr += 8; } @@ -216,11 +203,11 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) if (srcWidth > i + 3) numxpixels = 4; else numxpixels = srcWidth - i; extractsrc_u(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); - unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); + util_format_unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); blkaddr += 8; extractsrc_u(srcpixels, (GLubyte *)srcaddr + 1, srcWidth, numxpixels, numypixels, 2); - unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); + util_format_unsigned_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); blkaddr += 8; @@ -271,11 +258,11 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) else numxpixels = srcWidth - i; extractsrc_s(srcpixels, srcaddr, srcWidth, numxpixels, numypixels, 2); - signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); + util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); blkaddr += 8; extractsrc_s(srcpixels, srcaddr + 1, srcWidth, numxpixels, numypixels, 2); - signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); + util_format_signed_encode_rgtc_ubyte(blkaddr, srcpixels, numxpixels, numypixels); blkaddr += 8; srcaddr += numxpixels * 2; @@ -289,40 +276,12 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) return GL_TRUE; } - -#define TAG(x) unsigned_##x - -#define TYPE GLubyte -#define T_MIN 0 -#define T_MAX 0xff - -#include "texcompress_rgtc_tmp.h" - -#undef TAG -#undef TYPE -#undef T_MIN -#undef T_MAX - -#define TAG(x) signed_##x -#define TYPE GLbyte -#define T_MIN (GLbyte)-128 -#define T_MAX (GLbyte)127 - -#include "texcompress_rgtc_tmp.h" - -#undef TAG -#undef TYPE -#undef T_MIN -#undef T_MAX - - - static void fetch_red_rgtc1(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red; - unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); + util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = 0.0; texel[BCOMP] = 0.0; @@ -334,7 +293,7 @@ fetch_l_latc1(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red; - unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); + util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT(red); @@ -346,7 +305,7 @@ fetch_signed_red_rgtc1(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red; - signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map, + util_format_signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map, i, j, &red, 1); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = 0.0; @@ -359,7 +318,7 @@ fetch_signed_l_latc1(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red; - signed_fetch_texel_rgtc(rowStride, (GLbyte *) map, + util_format_signed_fetch_texel_rgtc(rowStride, (GLbyte *) map, i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = @@ -372,10 +331,10 @@ fetch_rg_rgtc2(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red, green; - unsigned_fetch_texel_rgtc(rowStride, + util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 2); - unsigned_fetch_texel_rgtc(rowStride, + util_format_unsigned_fetch_texel_rgtc(rowStride, map + 8, i, j, &green, 2); texel[RCOMP] = UBYTE_TO_FLOAT(red); @@ -389,10 +348,10 @@ fetch_la_latc2(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red, green; - unsigned_fetch_texel_rgtc(rowStride, + util_format_unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 2); - unsigned_fetch_texel_rgtc(rowStride, + util_format_unsigned_fetch_texel_rgtc(rowStride, map + 8, i, j, &green, 2); texel[RCOMP] = @@ -407,10 +366,10 @@ fetch_signed_rg_rgtc2(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red, green; - signed_fetch_texel_rgtc(rowStride, + util_format_signed_fetch_texel_rgtc(rowStride, (GLbyte *) map, i, j, &red, 2); - signed_fetch_texel_rgtc(rowStride, + util_format_signed_fetch_texel_rgtc(rowStride, (GLbyte *) map + 8, i, j, &green, 2); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); @@ -425,10 +384,10 @@ fetch_signed_la_latc2(const GLubyte *map, GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red, green; - signed_fetch_texel_rgtc(rowStride, + util_format_signed_fetch_texel_rgtc(rowStride, (GLbyte *) map, i, j, &red, 2); - signed_fetch_texel_rgtc(rowStride, + util_format_signed_fetch_texel_rgtc(rowStride, (GLbyte *) map + 8, i, j, &green, 2); texel[RCOMP] = diff --git a/mesalib/src/mesa/main/texcompress_rgtc_tmp.h b/mesalib/src/mesa/main/texcompress_rgtc_tmp.h deleted file mode 100644 index 5fa9de630..000000000 --- a/mesalib/src/mesa/main/texcompress_rgtc_tmp.h +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright (C) 2011 Red Hat Inc. - * - * block compression parts are: - * Copyright (C) 2004 Roland Scheidegger All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Author: - * Dave Airlie - */ - -/* included by texcompress_rgtc to define byte/ubyte compressors */ - -static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata, - unsigned i, unsigned j, TYPE *value, unsigned comps) -{ - TYPE decode; - const TYPE *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8 * comps); - const TYPE alpha0 = blksrc[0]; - const TYPE alpha1 = blksrc[1]; - const char bit_pos = ((j&3) * 4 + (i&3)) * 3; - const unsigned char acodelow = blksrc[2 + bit_pos / 8]; - const unsigned char acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0; - const unsigned char code = (acodelow >> (bit_pos & 0x7) | - (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; - - if (code == 0) - decode = alpha0; - else if (code == 1) - decode = alpha1; - else if (alpha0 > alpha1) - decode = ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7); - else if (code < 6) - decode = ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5); - else if (code == 6) - decode = T_MIN; - else - decode = T_MAX; - - *value = decode; -} - -static void TAG(write_rgtc_encoded_channel)(TYPE *blkaddr, - TYPE alphabase1, - TYPE alphabase2, - TYPE alphaenc[16]) -{ - *blkaddr++ = alphabase1; - *blkaddr++ = alphabase2; - *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); - *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); - *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); - *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); - *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); - *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); -} - -static void TAG(encode_rgtc_ubyte)(TYPE *blkaddr, TYPE srccolors[4][4], - int numxpixels, int numypixels) -{ - TYPE alphabase[2], alphause[2]; - short alphatest[2] = { 0 }; - unsigned int alphablockerror1, alphablockerror2, alphablockerror3; - TYPE i, j, aindex, acutValues[7]; - TYPE alphaenc1[16], alphaenc2[16], alphaenc3[16]; - int alphaabsmin = 0, alphaabsmax = 0; - short alphadist; - - /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ - alphabase[0] = T_MAX; alphabase[1] = T_MIN; - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - if (srccolors[j][i] == T_MIN) - alphaabsmin = 1; - else if (srccolors[j][i] == T_MAX) - alphaabsmax = 1; - else { - if (srccolors[j][i] > alphabase[1]) - alphabase[1] = srccolors[j][i]; - if (srccolors[j][i] < alphabase[0]) - alphabase[0] = srccolors[j][i]; - } - } - } - - - if (((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) - || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax)) { /* one color, either max or min */ - /* shortcut here since it is a very common case (and also avoids later problems) */ - /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ - - *blkaddr++ = srccolors[0][0]; - blkaddr++; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; - *blkaddr++ = 0; -#if RGTC_DEBUG - fprintf(stderr, "enc0 used\n"); -#endif - return; - } - - /* find best encoding for alpha0 > alpha1 */ - /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ - alphablockerror1 = 0x0; - alphablockerror2 = 0xffffffff; - alphablockerror3 = 0xffffffff; - if (alphaabsmin) alphause[0] = T_MIN; - else alphause[0] = alphabase[0]; - if (alphaabsmax) alphause[1] = T_MAX; - else alphause[1] = alphabase[1]; - /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ - for (aindex = 0; aindex < 7; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; - } - - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - /* maybe it's overkill to have the most complicated calculation just for the error - calculation which we only need to figure out if encoding1 or encoding2 is better... */ - if (srccolors[j][i] > acutValues[0]) { - alphaenc1[4*j + i] = 0; - alphadist = srccolors[j][i] - alphause[1]; - } - else if (srccolors[j][i] > acutValues[1]) { - alphaenc1[4*j + i] = 2; - alphadist = srccolors[j][i] - (alphause[1] * 6 + alphause[0] * 1) / 7; - } - else if (srccolors[j][i] > acutValues[2]) { - alphaenc1[4*j + i] = 3; - alphadist = srccolors[j][i] - (alphause[1] * 5 + alphause[0] * 2) / 7; - } - else if (srccolors[j][i] > acutValues[3]) { - alphaenc1[4*j + i] = 4; - alphadist = srccolors[j][i] - (alphause[1] * 4 + alphause[0] * 3) / 7; - } - else if (srccolors[j][i] > acutValues[4]) { - alphaenc1[4*j + i] = 5; - alphadist = srccolors[j][i] - (alphause[1] * 3 + alphause[0] * 4) / 7; - } - else if (srccolors[j][i] > acutValues[5]) { - alphaenc1[4*j + i] = 6; - alphadist = srccolors[j][i] - (alphause[1] * 2 + alphause[0] * 5) / 7; - } - else if (srccolors[j][i] > acutValues[6]) { - alphaenc1[4*j + i] = 7; - alphadist = srccolors[j][i] - (alphause[1] * 1 + alphause[0] * 6) / 7; - } - else { - alphaenc1[4*j + i] = 1; - alphadist = srccolors[j][i] - alphause[0]; - } - alphablockerror1 += alphadist * alphadist; - } - } - -#if RGTC_DEBUG - for (i = 0; i < 16; i++) { - fprintf(stderr, "%d ", alphaenc1[i]); - } - fprintf(stderr, "cutVals "); - for (i = 0; i < 7; i++) { - fprintf(stderr, "%d ", acutValues[i]); - } - fprintf(stderr, "srcVals "); - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - fprintf(stderr, "%d ", srccolors[j][i]); - } - } - fprintf(stderr, "\n"); -#endif - - /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax - are false but try it anyway */ - if (alphablockerror1 >= 32) { - - /* don't bother if encoding is already very good, this condition should also imply - we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ - alphablockerror2 = 0; - for (aindex = 0; aindex < 5; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; - } - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - /* maybe it's overkill to have the most complicated calculation just for the error - calculation which we only need to figure out if encoding1 or encoding2 is better... */ - if (srccolors[j][i] == T_MIN) { - alphaenc2[4*j + i] = 6; - alphadist = 0; - } - else if (srccolors[j][i] == T_MAX) { - alphaenc2[4*j + i] = 7; - alphadist = 0; - } - else if (srccolors[j][i] <= acutValues[0]) { - alphaenc2[4*j + i] = 0; - alphadist = srccolors[j][i] - alphabase[0]; - } - else if (srccolors[j][i] <= acutValues[1]) { - alphaenc2[4*j + i] = 2; - alphadist = srccolors[j][i] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; - } - else if (srccolors[j][i] <= acutValues[2]) { - alphaenc2[4*j + i] = 3; - alphadist = srccolors[j][i] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; - } - else if (srccolors[j][i] <= acutValues[3]) { - alphaenc2[4*j + i] = 4; - alphadist = srccolors[j][i] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; - } - else if (srccolors[j][i] <= acutValues[4]) { - alphaenc2[4*j + i] = 5; - alphadist = srccolors[j][i] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; - } - else { - alphaenc2[4*j + i] = 1; - alphadist = srccolors[j][i] - alphabase[1]; - } - alphablockerror2 += alphadist * alphadist; - } - } - - - /* skip this if the error is already very small - this encoding is MUCH better on average than #2 though, but expensive! */ - if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { - short blockerrlin1 = 0; - short blockerrlin2 = 0; - TYPE nralphainrangelow = 0; - TYPE nralphainrangehigh = 0; - alphatest[0] = T_MAX; - alphatest[1] = T_MIN; - /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - if ((srccolors[j][i] > alphatest[1]) && (srccolors[j][i] < (T_MAX -(alphabase[1] - alphabase[0]) / 28))) - alphatest[1] = srccolors[j][i]; - if ((srccolors[j][i] < alphatest[0]) && (srccolors[j][i] > (alphabase[1] - alphabase[0]) / 28)) - alphatest[0] = srccolors[j][i]; - } - } - /* shouldn't happen too often, don't really care about those degenerated cases */ - if (alphatest[1] <= alphatest[0]) { - alphatest[0] = T_MIN+1; - alphatest[1] = T_MAX-1; - } - for (aindex = 0; aindex < 5; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; - } - - /* find the "average" difference between the alpha values and the next encoded value. - This is then used to calculate new base values. - Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, - since they will see more improvement, and also because the values in the middle are somewhat - likely to get no improvement at all (because the base values might move in different directions)? - OTOH it would mean the values in the middle are even less likely to get an improvement - */ - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - if (srccolors[j][i] <= alphatest[0] / 2) { - } - else if (srccolors[j][i] > ((T_MAX + alphatest[1]) / 2)) { - } - else if (srccolors[j][i] <= acutValues[0]) { - blockerrlin1 += (srccolors[j][i] - alphatest[0]); - nralphainrangelow += 1; - } - else if (srccolors[j][i] <= acutValues[1]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else if (srccolors[j][i] <= acutValues[2]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else if (srccolors[j][i] <= acutValues[3]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else if (srccolors[j][i] <= acutValues[4]) { - blockerrlin1 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); - blockerrlin2 += (srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); - nralphainrangelow += 1; - nralphainrangehigh += 1; - } - else { - blockerrlin2 += (srccolors[j][i] - alphatest[1]); - nralphainrangehigh += 1; - } - } - } - /* shouldn't happen often, needed to avoid div by zero */ - if (nralphainrangelow == 0) nralphainrangelow = 1; - if (nralphainrangehigh == 0) nralphainrangehigh = 1; - alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); -#if RGTC_DEBUG - fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); - fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh); -#endif - /* again shouldn't really happen often... */ - if (alphatest[0] < T_MIN) { - alphatest[0] = T_MIN; - } - alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); - if (alphatest[1] > T_MAX) { - alphatest[1] = T_MAX; - } - - alphablockerror3 = 0; - for (aindex = 0; aindex < 5; aindex++) { - /* don't forget here is always rounded down */ - acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; - } - for (j = 0; j < numypixels; j++) { - for (i = 0; i < numxpixels; i++) { - /* maybe it's overkill to have the most complicated calculation just for the error - calculation which we only need to figure out if encoding1 or encoding2 is better... */ - if (srccolors[j][i] <= alphatest[0] / 2) { - alphaenc3[4*j + i] = 6; - alphadist = srccolors[j][i]; - } - else if (srccolors[j][i] > ((T_MAX + alphatest[1]) / 2)) { - alphaenc3[4*j + i] = 7; - alphadist = T_MAX - srccolors[j][i]; - } - else if (srccolors[j][i] <= acutValues[0]) { - alphaenc3[4*j + i] = 0; - alphadist = srccolors[j][i] - alphatest[0]; - } - else if (srccolors[j][i] <= acutValues[1]) { - alphaenc3[4*j + i] = 2; - alphadist = srccolors[j][i] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; - } - else if (srccolors[j][i] <= acutValues[2]) { - alphaenc3[4*j + i] = 3; - alphadist = srccolors[j][i] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; - } - else if (srccolors[j][i] <= acutValues[3]) { - alphaenc3[4*j + i] = 4; - alphadist = srccolors[j][i] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; - } - else if (srccolors[j][i] <= acutValues[4]) { - alphaenc3[4*j + i] = 5; - alphadist = srccolors[j][i] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; - } - else { - alphaenc3[4*j + i] = 1; - alphadist = srccolors[j][i] - alphatest[1]; - } - alphablockerror3 += alphadist * alphadist; - } - } - } - } - - /* write the alpha values and encoding back. */ - if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { -#if RGTC_DEBUG - if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1); - fprintf(stderr,"w1: min %d max %d au0 %d au1 %d\n", - T_MIN, T_MAX, - alphause[1], alphause[0]); -#endif - - TAG(write_rgtc_encoded_channel)( blkaddr, alphause[1], alphause[0], alphaenc1 ); - } - else if (alphablockerror2 <= alphablockerror3) { -#if RGTC_DEBUG - if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2); - fprintf(stderr,"w2: min %d max %d au0 %d au1 %d\n", - T_MIN, T_MAX, - alphabase[0], alphabase[1]); -#endif - - TAG(write_rgtc_encoded_channel)( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); - } - else { -#if RGTC_DEBUG - fprintf(stderr, "enc3 used, error %d\n", alphablockerror3); - fprintf(stderr,"w3: min %d max %d au0 %d au1 %d\n", - T_MIN, T_MAX, - alphatest[0], alphatest[1]); -#endif - - TAG(write_rgtc_encoded_channel)( blkaddr, (TYPE)alphatest[0], (TYPE)alphatest[1], alphaenc3 ); - } -} diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 6d3b80556..832e66128 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -485,6 +485,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_LUMINANCE_ALPHA_SNORM: case GL_LUMINANCE8_ALPHA8_SNORM: RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SNORM); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM); break; @@ -539,6 +540,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + + RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_SRGB_ALPHA_EXT: case GL_SRGB8_ALPHA8_EXT: @@ -546,36 +550,45 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_SLUMINANCE_EXT: case GL_SLUMINANCE8_EXT: RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_SLUMINANCE_ALPHA_EXT: case GL_SLUMINANCE8_ALPHA8_EXT: RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_COMPRESSED_SLUMINANCE_EXT: RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_COMPRESSED_SRGB_EXT: if (ctx->Mesa_DXTn) RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1); RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_COMPRESSED_SRGB_ALPHA_EXT: if (ctx->Mesa_DXTn) RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */ RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); break; case GL_ALPHA8UI_EXT: diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index 4cd2bca01..1592c9bfd 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -226,6 +226,13 @@ validate_uniform_parameters(struct gl_context *ctx, return NULL; } + /* Check that the given location is in bounds of uniform remap table. */ + if (location >= (GLint) shProg->NumUniformRemapTable) { + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", + caller, location); + return NULL; + } + /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says: * * "If any of the following conditions occur, an INVALID_OPERATION @@ -239,19 +246,12 @@ validate_uniform_parameters(struct gl_context *ctx, * - if count is greater than one, and the uniform declared in the * shader is not an array variable, */ - if (location < -1) { + if (location < -1 || !shProg->UniformRemapTable[location]) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", caller, location); return NULL; } - /* Check that the given location is in bounds of uniform remap table. */ - if (location >= (GLint) shProg->NumUniformRemapTable) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(location=%d)", - caller, location); - return NULL; - } - /* If the driver storage pointer in remap table is -1, we ignore silently. * * GL_ARB_explicit_uniform_location spec says: diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 7d169f9d4..ead78649d 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -1867,7 +1867,6 @@ _mesa_copy_client_array(struct gl_context *ctx, dst->InstanceDivisor = src->InstanceDivisor; dst->_ElementSize = src->_ElementSize; _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); - dst->_MaxElement = src->_MaxElement; } void @@ -1911,11 +1910,10 @@ print_array(const char *name, GLint index, const struct gl_client_array *array) printf(" %s[%d]: ", name, index); else printf(" %s: ", name); - printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu), MaxElem=%u\n", + printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu)\n", array->Ptr, array->Type, array->Size, array->_ElementSize, array->StrideB, - array->BufferObj->Name, (unsigned long) array->BufferObj->Size, - array->_MaxElement); + array->BufferObj->Name, (unsigned long) array->BufferObj->Size); } @@ -1928,8 +1926,6 @@ _mesa_print_arrays(struct gl_context *ctx) struct gl_vertex_array_object *vao = ctx->Array.VAO; GLuint i; - _mesa_update_vao_max_element(ctx, vao); - printf("Array Object %u\n", vao->Name); if (vao->_VertexAttrib[VERT_ATTRIB_POS].Enabled) print_array("Vertex", -1, &vao->_VertexAttrib[VERT_ATTRIB_POS]); @@ -1943,7 +1939,6 @@ _mesa_print_arrays(struct gl_context *ctx) for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) if (vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) print_array("Attrib", i, &vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]); - printf(" _MaxElement = %u\n", vao->_MaxElement); } diff --git a/mesalib/src/mesa/main/varray.h b/mesalib/src/mesa/main/varray.h index d5d8b363d..4e4bd5f80 100644 --- a/mesalib/src/mesa/main/varray.h +++ b/mesalib/src/mesa/main/varray.h @@ -34,39 +34,6 @@ struct gl_client_array; struct gl_context; - -/** - * Compute the index of the last array element that can be safely accessed in - * a vertex array. We can really only do this when the array lives in a VBO. - * The array->_MaxElement field will be updated. - * Later in glDrawArrays/Elements/etc we can do some bounds checking. - */ -static inline void -_mesa_update_array_max_element(struct gl_client_array *array) -{ - assert(array->Enabled); - - if (array->BufferObj->Name) { - GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr; - GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size; - - if (offset < bufSize) { - const GLuint stride = array->StrideB ? - array->StrideB : array->_ElementSize; - array->_MaxElement = (bufSize - offset + stride - - array->_ElementSize) / stride; - } - else { - array->_MaxElement = 0; - } - } - else { - /* user-space array, no idea how big it is */ - array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ - } -} - - /** * Returns a pointer to the vertex attribute data in a client array, * or the offset into the vertex buffer for an array that resides in diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index 49e4a7a40..293fe34b9 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -2505,12 +2505,7 @@ _mesa_associate_uniform_storage(struct gl_context *ctx, columns = storage->type->matrix_columns; break; case GLSL_TYPE_BOOL: - if (ctx->Const.NativeIntegers) { - format = (ctx->Const.UniformBooleanTrue == 1) - ? uniform_bool_int_0_1 : uniform_bool_int_0_not0; - } else { - format = uniform_bool_float; - } + format = uniform_native; columns = 1; break; case GLSL_TYPE_SAMPLER: diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c index 08c1c3046..60530ebf0 100644 --- a/mesalib/src/mesa/program/prog_optimize.c +++ b/mesalib/src/mesa/program/prog_optimize.c @@ -114,7 +114,6 @@ get_src_arg_mask(const struct prog_instruction *inst, read_mask = 0x0; for (comp = 0; comp < 4; ++comp) { const GLuint coord = GET_SWZ(inst->SrcReg[arg].Swizzle, comp); - ASSERT(coord < 4); if (channel_mask & (1 << comp) && coord <= SWIZZLE_W) read_mask |= 1 << coord; } @@ -284,11 +283,11 @@ _mesa_remove_dead_code_global(struct gl_program *prog) for (comp = 0; comp < 4; comp++) { const GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, comp); - ASSERT(swz < 4); - if ((read_mask & (1 << swz)) == 0) - continue; - if (swz <= SWIZZLE_W) + if (swz <= SWIZZLE_W) { + if ((read_mask & (1 << swz)) == 0) + continue; tempRead[index][swz] = GL_TRUE; + } } } } diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c index db2be5dfa..7faf67215 100644 --- a/mesalib/src/mesa/program/register_allocate.c +++ b/mesalib/src/mesa/program/register_allocate.c @@ -434,6 +434,7 @@ decrement_q(struct ra_graph *g, unsigned int n) unsigned int n2_class = g->nodes[n2].class; if (n != n2 && !g->nodes[n2].in_stack) { + assert(g->nodes[n2].q_total >= g->regs->classes[n2_class]->q[n_class]); g->nodes[n2].q_total -= g->regs->classes[n2_class]->q[n_class]; } } diff --git a/mesalib/src/mesa/program/register_allocate.h b/mesalib/src/mesa/program/register_allocate.h index bfc9190dc..dc6874495 100644 --- a/mesalib/src/mesa/program/register_allocate.h +++ b/mesalib/src/mesa/program/register_allocate.h @@ -56,7 +56,10 @@ void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts); * Each interference graph node is a virtual variable in the IL. It * is up to the user to ra_set_node_class() for the virtual variable, * and compute live ranges and ra_node_interfere() between conflicting - * live ranges. + * live ranges. Note that an interference *must not* be added between + * two nodes if their classes haven't been assigned yet. The user + * should set the class of each node before building the interference + * graph. */ struct ra_graph *ra_alloc_interference_graph(struct ra_regs *regs, unsigned int count); diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index 03d05932a..ed9a44429 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -192,9 +192,9 @@ get_texture_format_swizzle(const struct st_texture_object *stObj) return swizzle_swizzle(stObj->base._Swizzle, tex_swizzle); } - + /** - * Return TRUE if the texture's sampler view swizzle is equal to + * Return TRUE if the texture's sampler view swizzle is not equal to * the texture's swizzle. * * \param stObj the st texture object, @@ -214,9 +214,20 @@ check_sampler_swizzle(const struct st_texture_object *stObj, static unsigned last_level(struct st_texture_object *stObj) { - return MIN2(stObj->base._MaxLevel, stObj->pt->last_level); + unsigned ret = MIN2(stObj->base.MinLevel + stObj->base._MaxLevel, + stObj->pt->last_level); + if (stObj->base.Immutable) + ret = MIN2(ret, stObj->base.MinLevel + stObj->base.NumLevels - 1); + return ret; } +static unsigned last_layer(struct st_texture_object *stObj) +{ + if (stObj->base.Immutable) + return MIN2(stObj->base.MinLayer + stObj->base.NumLayers - 1, + stObj->pt->array_size - 1); + return stObj->pt->array_size - 1; +} static struct pipe_sampler_view * st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe, @@ -249,9 +260,13 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe, templ.u.buf.first_element = f; templ.u.buf.last_element = f + (n - 1); } else { - templ.u.tex.first_level = stObj->base.BaseLevel; + templ.u.tex.first_level = stObj->base.MinLevel + stObj->base.BaseLevel; templ.u.tex.last_level = last_level(stObj); assert(templ.u.tex.first_level <= templ.u.tex.last_level); + templ.u.tex.first_layer = stObj->base.MinLayer; + templ.u.tex.last_layer = last_layer(stObj); + assert(templ.u.tex.first_layer <= templ.u.tex.last_layer); + templ.target = gl_target_to_pipe(stObj->base.Target); } if (swizzle != SWIZZLE_NOOP) { @@ -287,8 +302,11 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st, if (*sv) { if (check_sampler_swizzle(stObj, *sv) || (format != (*sv)->format) || - stObj->base.BaseLevel != (*sv)->u.tex.first_level || - last_level(stObj) != (*sv)->u.tex.last_level) { + gl_target_to_pipe(stObj->base.Target) != (*sv)->target || + stObj->base.MinLevel + stObj->base.BaseLevel != (*sv)->u.tex.first_level || + last_level(stObj) != (*sv)->u.tex.last_level || + stObj->base.MinLayer != (*sv)->u.tex.first_layer || + last_layer(stObj) != (*sv)->u.tex.last_layer) { pipe_sampler_view_reference(sv, NULL); } } diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index 7cfd3dade..470ab278b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -450,6 +450,16 @@ st_update_renderbuffer_surface(struct st_context *st, last_layer = strb->rtt_face + strb->rtt_slice; } + /* Adjust for texture views */ + if (strb->is_rtt) { + struct gl_texture_object *tex = strb->Base.TexImage->TexObject; + first_layer += tex->MinLayer; + if (!strb->rtt_layered) + last_layer += tex->MinLayer; + else + last_layer = MIN2(first_layer + tex->NumLayers - 1, last_layer); + } + if (!strb->surface || strb->surface->texture->nr_samples != strb->Base.NumSamples || strb->surface->format != format || diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index ad14bd939..dfa188a3f 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -829,12 +829,12 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, blit.src.level = 0; blit.src.format = src_format; blit.dst.resource = dst; - blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->Level; + blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->TexObject->MinLevel + texImage->Level; blit.dst.format = dst_format; blit.src.box.x = blit.src.box.y = blit.src.box.z = 0; blit.dst.box.x = xoffset; blit.dst.box.y = yoffset; - blit.dst.box.z = zoffset + texImage->Face; + blit.dst.box.z = zoffset + texImage->Face + texImage->TexObject->MinLayer; blit.src.box.width = blit.dst.box.width = width; blit.src.box.height = blit.dst.box.height = height; blit.src.box.depth = blit.dst.box.depth = depth; @@ -916,7 +916,8 @@ st_GetTexImage(struct gl_context * ctx, GLuint height = texImage->Height; GLuint depth = texImage->Depth; struct st_texture_image *stImage = st_texture_image(texImage); - struct pipe_resource *src = st_texture_object(texImage->TexObject)->pt; + struct st_texture_object *stObj = st_texture_object(texImage->TexObject); + struct pipe_resource *src = stObj->pt; struct pipe_resource *dst = NULL; struct pipe_resource dst_templ; enum pipe_format dst_format, src_format; @@ -970,7 +971,10 @@ st_GetTexImage(struct gl_context * ctx, * - Luminance alpha must be returned as (L,0,0,A). * - Intensity must be returned as (I,0,0,1) */ - src_format = util_format_linear(src->format); + if (stObj->surface_based) + src_format = util_format_linear(stObj->surface_format); + else + src_format = util_format_linear(src->format); src_format = util_format_luminance_to_red(src_format); src_format = util_format_intensity_to_red(src_format); @@ -1069,14 +1073,14 @@ st_GetTexImage(struct gl_context * ctx, memset(&blit, 0, sizeof(blit)); blit.src.resource = src; - blit.src.level = texImage->Level; + blit.src.level = texImage->Level + texImage->TexObject->MinLevel; blit.src.format = src_format; blit.dst.resource = dst; blit.dst.level = 0; blit.dst.format = dst->format; blit.src.box.x = blit.dst.box.x = 0; blit.src.box.y = blit.dst.box.y = 0; - blit.src.box.z = texImage->Face; + blit.src.box.z = texImage->Face + texImage->TexObject->MinLayer; blit.dst.box.z = 0; blit.src.box.width = blit.dst.box.width = width; blit.src.box.height = blit.dst.box.height = height; @@ -1441,10 +1445,10 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims, blit.src.box.depth = 1; blit.dst.resource = stImage->pt; blit.dst.format = dst_format; - blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->Level; + blit.dst.level = stObj->pt != stImage->pt ? 0 : texImage->Level + texImage->TexObject->MinLevel; blit.dst.box.x = destX; blit.dst.box.y = destY; - blit.dst.box.z = stImage->base.Face + slice; + blit.dst.box.z = stImage->base.Face + slice + texImage->TexObject->MinLayer; blit.dst.box.width = width; blit.dst.box.height = height; blit.dst.box.depth = 1; @@ -1545,6 +1549,9 @@ st_finalize_texture(struct gl_context *ctx, enum pipe_format firstImageFormat; GLuint ptWidth, ptHeight, ptDepth, ptLayers, ptNumSamples; + if (tObj->Immutable) + return GL_TRUE; + if (_mesa_is_texture_complete(tObj, &tObj->Sampler)) { /* The texture is complete and we know exactly how many mipmap levels * are present/needed. This is conditional because we may be called @@ -1824,6 +1831,44 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target, } } +static GLboolean +st_TextureView(struct gl_context *ctx, + struct gl_texture_object *texObj, + struct gl_texture_object *origTexObj) +{ + struct st_texture_object *orig = st_texture_object(origTexObj); + struct st_texture_object *tex = st_texture_object(texObj); + struct gl_texture_image *image = texObj->Image[0][0]; + + const int numFaces = _mesa_num_tex_faces(texObj->Target); + const int numLevels = texObj->NumLevels; + + int face; + int level; + + pipe_resource_reference(&tex->pt, orig->pt); + + /* Set image resource pointers */ + for (level = 0; level < numLevels; level++) { + for (face = 0; face < numFaces; face++) { + struct st_texture_image *stImage = + st_texture_image(texObj->Image[face][level]); + pipe_resource_reference(&stImage->pt, tex->pt); + } + } + + tex->surface_based = GL_TRUE; + tex->surface_format = + st_mesa_format_to_pipe_format(st_context(ctx), image->TexFormat); + + tex->width0 = image->Width; + tex->height0 = image->Height; + tex->depth0 = image->Depth; + tex->lastLevel = numLevels - 1; + + return GL_TRUE; +} + void st_init_texture_functions(struct dd_function_table *functions) @@ -1855,4 +1900,5 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TestProxyTexImage = st_TestProxyTexImage; functions->AllocTextureStorage = st_AllocTextureStorage; + functions->TextureView = st_TextureView; } diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 09b615465..768a66790 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -104,6 +104,42 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state) _vbo_InvalidateState(ctx, new_state); } + +static void +st_destroy_context_priv(struct st_context *st) +{ + uint shader, i; + + st_destroy_atoms( st ); + st_destroy_draw( st ); + st_destroy_clear(st); + st_destroy_bitmap(st); + st_destroy_drawpix(st); + st_destroy_drawtex(st); + + for (shader = 0; shader < Elements(st->state.sampler_views); shader++) { + for (i = 0; i < Elements(st->state.sampler_views[0]); i++) { + pipe_sampler_view_release(st->pipe, + &st->state.sampler_views[shader][i]); + } + } + + if (st->default_texture) { + st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture); + st->default_texture = NULL; + } + + u_upload_destroy(st->uploader); + if (st->indexbuf_uploader) { + u_upload_destroy(st->indexbuf_uploader); + } + if (st->constbuf_uploader) { + u_upload_destroy(st->constbuf_uploader); + } + free( st ); +} + + static struct st_context * st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, const struct st_config_options *options) @@ -238,6 +274,14 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, _mesa_compute_version(ctx); + if (ctx->Version == 0) { + /* This can happen when a core profile was requested, but the driver + * does not support some features of GL 3.1 or later. + */ + st_destroy_context_priv(st); + return NULL; + } + _mesa_initialize_dispatch_tables(ctx); _mesa_initialize_vbo_vtxfmt(ctx); @@ -259,6 +303,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, struct gl_context *ctx; struct gl_context *shareCtx = share ? share->ctx : NULL; struct dd_function_table funcs; + struct st_context *st; memset(&funcs, 0, sizeof(funcs)); st_init_driver_functions(&funcs); @@ -276,41 +321,12 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe, if (debug_get_option_mesa_mvp_dp4()) ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE; - return st_create_context_priv(ctx, pipe, options); -} - - -static void st_destroy_context_priv( struct st_context *st ) -{ - uint shader, i; - - st_destroy_atoms( st ); - st_destroy_draw( st ); - st_destroy_clear(st); - st_destroy_bitmap(st); - st_destroy_drawpix(st); - st_destroy_drawtex(st); - - for (shader = 0; shader < Elements(st->state.sampler_views); shader++) { - for (i = 0; i < Elements(st->state.sampler_views[0]); i++) { - pipe_sampler_view_release(st->pipe, - &st->state.sampler_views[shader][i]); - } + st = st_create_context_priv(ctx, pipe, options); + if (!st) { + _mesa_destroy_context(ctx); } - if (st->default_texture) { - st->ctx->Driver.DeleteTexture(st->ctx, st->default_texture); - st->default_texture = NULL; - } - - u_upload_destroy(st->uploader); - if (st->indexbuf_uploader) { - u_upload_destroy(st->indexbuf_uploader); - } - if (st->constbuf_uploader) { - u_upload_destroy(st->constbuf_uploader); - } - free( st ); + return st; } diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 07bd12567..c7bc0ca50 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -463,6 +463,7 @@ void st_init_extensions(struct pipe_screen *screen, { o(ARB_draw_indirect), PIPE_CAP_DRAW_INDIRECT }, { o(ARB_derivative_control), PIPE_CAP_TGSI_FS_FINE_DERIVATIVE }, { o(ARB_conditional_render_inverted), PIPE_CAP_CONDITIONAL_RENDER_INVERTED }, + { o(ARB_texture_view), PIPE_CAP_SAMPLER_VIEW_TARGET }, }; /* Required: render target and sampler support */ diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index b5e03b0f8..6c53567fc 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -88,9 +88,13 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat) case MESA_FORMAT_L4A4_UNORM: return PIPE_FORMAT_L4A4_UNORM; case MESA_FORMAT_L8A8_UNORM: - return PIPE_FORMAT_L8A8_UNORM; + return PIPE_FORMAT_LA88_UNORM; + case MESA_FORMAT_A8L8_UNORM: + return PIPE_FORMAT_AL88_UNORM; case MESA_FORMAT_L16A16_UNORM: - return PIPE_FORMAT_L16A16_UNORM; + return PIPE_FORMAT_LA1616_UNORM; + case MESA_FORMAT_A16L16_UNORM: + return PIPE_FORMAT_AL1616_UNORM; case MESA_FORMAT_A_UNORM8: return PIPE_FORMAT_A8_UNORM; case MESA_FORMAT_A_UNORM16: @@ -142,17 +146,21 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat) case MESA_FORMAT_SRGBA_DXT5: return PIPE_FORMAT_DXT5_SRGBA; case MESA_FORMAT_L8A8_SRGB: - return PIPE_FORMAT_L8A8_SRGB; + return PIPE_FORMAT_LA88_SRGB; + case MESA_FORMAT_A8L8_SRGB: + return PIPE_FORMAT_AL88_SRGB; case MESA_FORMAT_L_SRGB8: return PIPE_FORMAT_L8_SRGB; case MESA_FORMAT_BGR_SRGB8: return PIPE_FORMAT_R8G8B8_SRGB; case MESA_FORMAT_A8B8G8R8_SRGB: - return PIPE_FORMAT_A8B8G8R8_SRGB; - case MESA_FORMAT_B8G8R8A8_SRGB: - return PIPE_FORMAT_B8G8R8A8_SRGB; + return PIPE_FORMAT_ABGR8888_SRGB; case MESA_FORMAT_R8G8B8A8_SRGB: - return PIPE_FORMAT_R8G8B8A8_SRGB; + return PIPE_FORMAT_RGBA8888_SRGB; + case MESA_FORMAT_B8G8R8A8_SRGB: + return PIPE_FORMAT_BGRA8888_SRGB; + case MESA_FORMAT_A8R8G8B8_SRGB: + return PIPE_FORMAT_ARGB8888_SRGB; case MESA_FORMAT_RGBA_FLOAT32: return PIPE_FORMAT_R32G32B32A32_FLOAT; case MESA_FORMAT_RGBA_FLOAT16: @@ -191,9 +199,13 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat) case MESA_FORMAT_R_UNORM16: return PIPE_FORMAT_R16_UNORM; case MESA_FORMAT_R8G8_UNORM: - return PIPE_FORMAT_R8G8_UNORM; + return PIPE_FORMAT_RG88_UNORM; + case MESA_FORMAT_G8R8_UNORM: + return PIPE_FORMAT_GR88_UNORM; case MESA_FORMAT_R16G16_UNORM: - return PIPE_FORMAT_R16G16_UNORM; + return PIPE_FORMAT_RG1616_UNORM; + case MESA_FORMAT_G16R16_UNORM: + return PIPE_FORMAT_GR1616_UNORM; case MESA_FORMAT_RGBA_UNORM16: return PIPE_FORMAT_R16G16B16A16_UNORM; @@ -341,23 +353,31 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat) case MESA_FORMAT_R_SNORM8: return PIPE_FORMAT_R8_SNORM; case MESA_FORMAT_R8G8_SNORM: - return PIPE_FORMAT_R8G8_SNORM; + return PIPE_FORMAT_RG88_SNORM; + case MESA_FORMAT_G8R8_SNORM: + return PIPE_FORMAT_GR88_SNORM; case MESA_FORMAT_R8G8B8A8_SNORM: - return PIPE_FORMAT_R8G8B8A8_SNORM; + return PIPE_FORMAT_RGBA8888_SNORM; + case MESA_FORMAT_A8B8G8R8_SNORM: + return PIPE_FORMAT_ABGR8888_SNORM; case MESA_FORMAT_A_SNORM8: return PIPE_FORMAT_A8_SNORM; case MESA_FORMAT_L_SNORM8: return PIPE_FORMAT_L8_SNORM; case MESA_FORMAT_L8A8_SNORM: - return PIPE_FORMAT_L8A8_SNORM; + return PIPE_FORMAT_LA88_SNORM; + case MESA_FORMAT_A8L8_SNORM: + return PIPE_FORMAT_AL88_SNORM; case MESA_FORMAT_I_SNORM8: return PIPE_FORMAT_I8_SNORM; case MESA_FORMAT_R_SNORM16: return PIPE_FORMAT_R16_SNORM; case MESA_FORMAT_R16G16_SNORM: - return PIPE_FORMAT_R16G16_SNORM; + return PIPE_FORMAT_RG1616_SNORM; + case MESA_FORMAT_G16R16_SNORM: + return PIPE_FORMAT_GR1616_SNORM; case MESA_FORMAT_RGBA_SNORM16: return PIPE_FORMAT_R16G16B16A16_SNORM; @@ -384,9 +404,13 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat) case MESA_FORMAT_B5G5R5X1_UNORM: return PIPE_FORMAT_B5G5R5X1_UNORM; case MESA_FORMAT_R8G8B8X8_SNORM: - return PIPE_FORMAT_R8G8B8X8_SNORM; + return PIPE_FORMAT_RGBX8888_SNORM; + case MESA_FORMAT_X8B8G8R8_SNORM: + return PIPE_FORMAT_XBGR8888_SNORM; case MESA_FORMAT_R8G8B8X8_SRGB: - return PIPE_FORMAT_R8G8B8X8_SRGB; + return PIPE_FORMAT_RGBX8888_SRGB; + case MESA_FORMAT_X8B8G8R8_SRGB: + return PIPE_FORMAT_XBGR8888_SRGB; case MESA_FORMAT_RGBX_UINT8: return PIPE_FORMAT_R8G8B8X8_UINT; case MESA_FORMAT_RGBX_SINT8: @@ -411,7 +435,9 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat) return PIPE_FORMAT_R32G32B32X32_SINT; case MESA_FORMAT_B8G8R8X8_SRGB: - return PIPE_FORMAT_B8G8R8X8_SRGB; + return PIPE_FORMAT_BGRX8888_SRGB; + case MESA_FORMAT_X8R8G8B8_SRGB: + return PIPE_FORMAT_XRGB8888_SRGB; /* ETC2 formats are emulated as uncompressed ones. * The destination formats mustn't be changed, because they are also @@ -476,10 +502,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_R10G10B10A2_UNORM; case PIPE_FORMAT_L4A4_UNORM: return MESA_FORMAT_L4A4_UNORM; - case PIPE_FORMAT_L8A8_UNORM: + case PIPE_FORMAT_LA88_UNORM: return MESA_FORMAT_L8A8_UNORM; - case PIPE_FORMAT_L16A16_UNORM: + case PIPE_FORMAT_AL88_UNORM: + return MESA_FORMAT_A8L8_UNORM; + case PIPE_FORMAT_LA1616_UNORM: return MESA_FORMAT_L16A16_UNORM; + case PIPE_FORMAT_AL1616_UNORM: + return MESA_FORMAT_A16L16_UNORM; case PIPE_FORMAT_A8_UNORM: return MESA_FORMAT_A_UNORM8; case PIPE_FORMAT_A16_UNORM: @@ -536,16 +566,22 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_SRGBA_DXT3; case PIPE_FORMAT_DXT5_SRGBA: return MESA_FORMAT_SRGBA_DXT5; - case PIPE_FORMAT_L8A8_SRGB: + case PIPE_FORMAT_LA88_SRGB: return MESA_FORMAT_L8A8_SRGB; + case PIPE_FORMAT_AL88_SRGB: + return MESA_FORMAT_A8L8_SRGB; case PIPE_FORMAT_L8_SRGB: return MESA_FORMAT_L_SRGB8; case PIPE_FORMAT_R8G8B8_SRGB: return MESA_FORMAT_BGR_SRGB8; - case PIPE_FORMAT_A8B8G8R8_SRGB: + case PIPE_FORMAT_ABGR8888_SRGB: return MESA_FORMAT_A8B8G8R8_SRGB; - case PIPE_FORMAT_B8G8R8A8_SRGB: + case PIPE_FORMAT_RGBA8888_SRGB: + return MESA_FORMAT_R8G8B8A8_SRGB; + case PIPE_FORMAT_BGRA8888_SRGB: return MESA_FORMAT_B8G8R8A8_SRGB; + case PIPE_FORMAT_ARGB8888_SRGB: + return MESA_FORMAT_A8R8G8B8_SRGB; case PIPE_FORMAT_R32G32B32A32_FLOAT: return MESA_FORMAT_RGBA_FLOAT32; case PIPE_FORMAT_R16G16B16A16_FLOAT: @@ -583,10 +619,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_R_UNORM8; case PIPE_FORMAT_R16_UNORM: return MESA_FORMAT_R_UNORM16; - case PIPE_FORMAT_R8G8_UNORM: + case PIPE_FORMAT_RG88_UNORM: return MESA_FORMAT_R8G8_UNORM; - case PIPE_FORMAT_R16G16_UNORM: + case PIPE_FORMAT_GR88_UNORM: + return MESA_FORMAT_G8R8_UNORM; + case PIPE_FORMAT_RG1616_UNORM: return MESA_FORMAT_R16G16_UNORM; + case PIPE_FORMAT_GR1616_UNORM: + return MESA_FORMAT_G16R16_UNORM; case PIPE_FORMAT_A8_UINT: return MESA_FORMAT_A_UINT8; @@ -728,24 +768,32 @@ st_pipe_format_to_mesa_format(enum pipe_format format) /* signed normalized formats */ case PIPE_FORMAT_R8_SNORM: return MESA_FORMAT_R_SNORM8; - case PIPE_FORMAT_R8G8_SNORM: + case PIPE_FORMAT_RG88_SNORM: return MESA_FORMAT_R8G8_SNORM; - case PIPE_FORMAT_R8G8B8A8_SNORM: + case PIPE_FORMAT_GR88_SNORM: + return MESA_FORMAT_G8R8_SNORM; + case PIPE_FORMAT_RGBA8888_SNORM: return MESA_FORMAT_R8G8B8A8_SNORM; + case PIPE_FORMAT_ABGR8888_SNORM: + return MESA_FORMAT_A8B8G8R8_SNORM; case PIPE_FORMAT_A8_SNORM: return MESA_FORMAT_A_SNORM8; case PIPE_FORMAT_L8_SNORM: return MESA_FORMAT_L_SNORM8; - case PIPE_FORMAT_L8A8_SNORM: + case PIPE_FORMAT_LA88_SNORM: return MESA_FORMAT_L8A8_SNORM; + case PIPE_FORMAT_AL88_SNORM: + return MESA_FORMAT_A8L8_SNORM; case PIPE_FORMAT_I8_SNORM: return MESA_FORMAT_I_SNORM8; case PIPE_FORMAT_R16_SNORM: return MESA_FORMAT_R_SNORM16; - case PIPE_FORMAT_R16G16_SNORM: + case PIPE_FORMAT_RG1616_SNORM: return MESA_FORMAT_R16G16_SNORM; + case PIPE_FORMAT_GR1616_SNORM: + return MESA_FORMAT_G16R16_SNORM; case PIPE_FORMAT_R16G16B16A16_SNORM: return MESA_FORMAT_RGBA_SNORM16; @@ -772,10 +820,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_B4G4R4X4_UNORM; case PIPE_FORMAT_B5G5R5X1_UNORM: return MESA_FORMAT_B5G5R5X1_UNORM; - case PIPE_FORMAT_R8G8B8X8_SNORM: + case PIPE_FORMAT_RGBX8888_SNORM: return MESA_FORMAT_R8G8B8X8_SNORM; - case PIPE_FORMAT_R8G8B8X8_SRGB: + case PIPE_FORMAT_XBGR8888_SNORM: + return MESA_FORMAT_X8B8G8R8_SNORM; + case PIPE_FORMAT_RGBX8888_SRGB: return MESA_FORMAT_R8G8B8X8_SRGB; + case PIPE_FORMAT_XBGR8888_SRGB: + return MESA_FORMAT_X8B8G8R8_SRGB; case PIPE_FORMAT_R8G8B8X8_UINT: return MESA_FORMAT_RGBX_UINT8; case PIPE_FORMAT_R8G8B8X8_SINT: @@ -799,10 +851,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_R32G32B32X32_SINT: return MESA_FORMAT_RGBX_SINT32; - case PIPE_FORMAT_B8G8R8X8_SRGB: + case PIPE_FORMAT_BGRX8888_SRGB: return MESA_FORMAT_B8G8R8X8_SRGB; - case PIPE_FORMAT_R8G8B8A8_SRGB: - return MESA_FORMAT_R8G8B8A8_SRGB; + case PIPE_FORMAT_XRGB8888_SRGB: + return MESA_FORMAT_X8R8G8B8_SRGB; default: return MESA_FORMAT_NONE; @@ -879,6 +931,7 @@ struct format_mapping #define DEFAULT_SRGBA_FORMATS \ PIPE_FORMAT_B8G8R8A8_SRGB, \ + PIPE_FORMAT_R8G8B8A8_SRGB, \ PIPE_FORMAT_A8R8G8B8_SRGB, \ PIPE_FORMAT_A8B8G8R8_SRGB, \ 0 @@ -919,11 +972,11 @@ static const struct format_mapping format_map[] = { }, { { 4, GL_RGBA, GL_RGBA8, 0 }, - { PIPE_FORMAT_R8G8B8A8_UNORM, DEFAULT_RGBA_FORMATS } + { DEFAULT_RGBA_FORMATS } }, { { GL_BGRA, 0 }, - { PIPE_FORMAT_B8G8R8A8_UNORM, DEFAULT_RGBA_FORMATS } + { DEFAULT_RGBA_FORMATS } }, { { 3, GL_RGB, GL_RGB8, 0 }, diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 62e4101d1..b338a9836 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -3172,6 +3172,7 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor() shader_program = NULL; shader = NULL; options = NULL; + have_sqrt = false; } glsl_to_tgsi_visitor::~glsl_to_tgsi_visitor() @@ -4167,6 +4168,8 @@ const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = { */ TGSI_SEMANTIC_VERTEXID, TGSI_SEMANTIC_INSTANCEID, + 0, + 0, /* Geometry shader */ diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index af9b7675f..c84aa4566 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -260,6 +260,12 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, else level = stImage->base.Level; + if (stObj->base.Immutable) { + level += stObj->base.MinLevel; + z += stObj->base.MinLayer; + d = MIN2(d, stObj->base.NumLayers); + } + z += stImage->base.Face; map = pipe_transfer_map_3d(st->pipe, stImage->pt, level, usage, @@ -289,8 +295,13 @@ st_texture_image_unmap(struct st_context *st, struct st_texture_image *stImage, unsigned slice) { struct pipe_context *pipe = st->pipe; - struct pipe_transfer **transfer = - &stImage->transfer[slice + stImage->base.Face].transfer; + struct st_texture_object *stObj = + st_texture_object(stImage->base.TexObject); + struct pipe_transfer **transfer; + + if (stObj->base.Immutable) + slice += stObj->base.MinLayer; + transfer = &stImage->transfer[slice + stImage->base.Face].transfer; DBG("%s\n", __FUNCTION__); diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c index 38d71caa3..0f6da919d 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.c +++ b/mesalib/src/mesa/swrast/s_texfetch.c @@ -210,6 +210,7 @@ texfetch_funcs[] = FETCH_FUNCS(R8G8_SNORM), FETCH_NULL(G8R8_SNORM), FETCH_FUNCS(L8A8_SNORM), + FETCH_FUNCS(A8L8_SNORM), /* Array signed/normalized formats */ FETCH_FUNCS(A_SNORM8), @@ -228,10 +229,14 @@ texfetch_funcs[] = /* Packed sRGB formats */ FETCH_FUNCS(A8B8G8R8_SRGB), FETCH_FUNCS(B8G8R8A8_SRGB), + FETCH_FUNCS(A8R8G8B8_SRGB), FETCH_NULL(B8G8R8X8_SRGB), + FETCH_NULL(X8R8G8B8_SRGB), FETCH_FUNCS(R8G8B8A8_SRGB), FETCH_FUNCS(R8G8B8X8_SRGB), + FETCH_FUNCS(X8B8G8R8_SRGB), FETCH_FUNCS(L8A8_SRGB), + FETCH_FUNCS(A8L8_SRGB), /* Array sRGB formats */ FETCH_FUNCS(L_SRGB8), diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h index 72037ec00..7ff30f6b4 100644 --- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h +++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h @@ -768,6 +768,18 @@ FETCH(B8G8R8A8_SRGB)(const struct swrast_texture_image *texImage, } +static void +FETCH(A8R8G8B8_SRGB)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff ); + texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff ); + texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) ); + texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); /* linear! */ +} + + static void FETCH(R8G8B8A8_SRGB)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) @@ -792,6 +804,18 @@ FETCH(R8G8B8X8_SRGB)(const struct swrast_texture_image *texImage, } +static void +FETCH(X8B8G8R8_SRGB)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) ); + texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff ); + texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff ); + texel[ACOMP] = 1.0f; +} + + static void FETCH(L_SRGB8)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) @@ -808,11 +832,23 @@ static void FETCH(L8A8_SRGB)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { - const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 2); + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = texel[GCOMP] = - texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]); - texel[ACOMP] = UBYTE_TO_FLOAT(src[1]); /* linear */ + texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s & 0xff); + texel[ACOMP] = UBYTE_TO_FLOAT(s >> 8); /* linear */ +} + + +static void +FETCH(A8L8_SRGB)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 2); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s >> 8); + texel[ACOMP] = UBYTE_TO_FLOAT(s & 0xff); /* linear */ } @@ -960,6 +996,18 @@ FETCH(L8A8_SNORM)(const struct swrast_texture_image *texImage, } +static void +FETCH(A8L8_SNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); + texel[RCOMP] = + texel[GCOMP] = + texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) ); + texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) ); +} + + static void FETCH(X8B8G8R8_SNORM)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index 22557e168..111321bd7 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -1032,7 +1032,12 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, { static GLuint warnCount = 0; GLboolean index_bounds_valid = GL_TRUE; - GLuint max_element; + + /* This is only useful to catch invalid values in the "end" parameter + * like ~0. + */ + GLuint max_element = 2 * 1000 * 1000 * 1000; /* just a big number */ + GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_DRAW) @@ -1045,25 +1050,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, type, indices, basevertex )) return; - if (ctx->Const.CheckArrayBounds) { - /* _MaxElement was computed, so we can use it. - * This path is used for drivers which need strict bounds checking. - */ - max_element = ctx->Array.VAO->_MaxElement; - } - else { - /* Generally, hardware drivers don't need to know the buffer bounds - * if all vertex attributes are in VBOs. - * However, if none of vertex attributes are in VBOs, _MaxElement - * is always set to some random big number anyway, so bounds checking - * is mostly useless. - * - * This is only useful to catch invalid values in the "end" parameter - * like ~0. - */ - max_element = 2 * 1000 * 1000 * 1000; /* just a big number */ - } - if ((int) end + basevertex < 0 || start + basevertex >= max_element) { /* The application requested we draw using a range of indices that's diff --git a/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c index c454c6943..362cc1040 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_draw.c +++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c @@ -159,7 +159,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) struct vbo_context *vbo = vbo_context(ctx); struct vbo_exec_context *exec = &vbo->exec; struct gl_client_array *arrays = exec->vtx.arrays; - const GLuint count = exec->vtx.vert_count; const GLuint *map; GLuint attr; GLbitfield64 varying_inputs = 0x0; @@ -241,7 +240,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) _mesa_reference_buffer_object(ctx, &arrays[attr].BufferObj, exec->vtx.bufferobj); - arrays[attr]._MaxElement = count; /* ??? */ varying_inputs |= VERT_BIT(attr); } diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c index 89fd30e0f..d0521d794 100644 --- a/mesalib/src/mesa/vbo/vbo_save_draw.c +++ b/mesalib/src/mesa/vbo/vbo_save_draw.c @@ -203,7 +203,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx, _mesa_reference_buffer_object(ctx, &arrays[attr].BufferObj, node->vertex_store->bufferobj); - arrays[attr]._MaxElement = node->count; /* ??? */ assert(arrays[attr].BufferObj->Name); diff --git a/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c index 719ad651a..ca752e810 100644 --- a/mesalib/src/mesa/vbo/vbo_split_copy.c +++ b/mesalib/src/mesa/vbo/vbo_split_copy.c @@ -533,7 +533,6 @@ replay_init( struct copy_context *copy ) dst->Integer = src->Integer; dst->BufferObj = ctx->Shared->NullBufferObj; dst->_ElementSize = src->_ElementSize; - dst->_MaxElement = copy->dstbuf_size; /* may be less! */ offset += copy->varying[i].size; } -- cgit v1.2.3