diff options
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r-- | mesalib/src/mesa/main/attrib.c | 20 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.h | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/main/drawpix.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/errors.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/ff_fragment_shader.cpp | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/format_unpack.c | 80 | ||||
-rw-r--r-- | mesalib/src/mesa/main/imports.h | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/main/macros.h | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/main/pack.c | 116 | ||||
-rw-r--r-- | mesalib/src/mesa/main/shader_query.cpp | 36 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texcompress_etc.c | 78 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texformat.c | 22 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texobj.c | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texparam.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texstore.c | 30 | ||||
-rw-r--r-- | mesalib/src/mesa/main/vdpau.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/main/version.c | 2 |
19 files changed, 255 insertions, 189 deletions
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 5a626f2f4..c656845df 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -217,7 +217,7 @@ push_attrib(struct gl_context *ctx, struct gl_attrib_node **head, { void *attribute; - attribute = MALLOC(attr_size); + attribute = malloc(attr_size); if (attribute == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); return false; @@ -227,7 +227,7 @@ push_attrib(struct gl_context *ctx, struct gl_attrib_node **head, memcpy(attribute, attr_data, attr_size); } else { - FREE(attribute); + free(attribute); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); return false; } @@ -277,7 +277,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; } else { - FREE(attr); + free(attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); goto end; } @@ -374,7 +374,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->FragmentProgram = ctx->FragmentProgram.Enabled; if (!save_attrib_data(&head, GL_ENABLE_BIT, attr)) { - FREE(attr); + free(attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); goto end; } @@ -440,7 +440,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->ReadBuffer = ctx->ReadBuffer->ColorReadBuffer; } else { - FREE(attr); + free(attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib"); goto end; } @@ -491,7 +491,7 @@ _mesa_PushAttrib(GLbitfield mask) } if (!save_attrib_data(&head, GL_TEXTURE_BIT, texstate)) { - FREE(texstate); + free(texstate); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); goto end; } @@ -1626,7 +1626,7 @@ _mesa_PushClientAttrib(GLbitfield mask) } else { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib" ); - FREE(attr); + free(attr); goto end; } @@ -1642,7 +1642,7 @@ _mesa_PushClientAttrib(GLbitfield mask) } else { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib" ); - FREE(attr); + free(attr); goto end; } } @@ -1656,7 +1656,7 @@ _mesa_PushClientAttrib(GLbitfield mask) } if (!init_array_attrib_data(ctx, attr)) { - FREE(attr); + free(attr); goto end; } @@ -1666,7 +1666,7 @@ _mesa_PushClientAttrib(GLbitfield mask) else { free_array_attrib_data(ctx, attr); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushClientAttrib"); - FREE(attr); + free(attr); /* goto to keep safe from possible later changes */ goto end; } diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 2e9e05918..36acd64ce 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -665,7 +665,7 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset, * \sa glClearBufferSubData, glClearBufferData and * dd_function_table::ClearBufferSubData. */ -static void +void _mesa_buffer_clear_subdata(struct gl_context *ctx, GLintptr offset, GLsizeiptr size, const GLvoid *clearValue, @@ -1458,7 +1458,7 @@ _mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, if (data == NULL) { /* clear to zeros, per the spec */ ctx->Driver.ClearBufferSubData(ctx, 0, bufObj->Size, - NULL, 0, bufObj); + NULL, clearValueSize, bufObj); return; } @@ -1510,7 +1510,7 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat, /* clear to zeros, per the spec */ if (size > 0) { ctx->Driver.ClearBufferSubData(ctx, offset, size, - NULL, 0, bufObj); + NULL, clearValueSize, bufObj); } return; } diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h index 9814552eb..c08c4fdf2 100644 --- a/mesalib/src/mesa/main/bufferobj.h +++ b/mesalib/src/mesa/main/bufferobj.h @@ -115,6 +115,13 @@ extern void _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, struct gl_buffer_object *bufObj); +extern void +_mesa_buffer_clear_subdata(struct gl_context *ctx, + GLintptr offset, GLsizeiptr size, + const GLvoid *clearValue, + GLsizeiptr clearValueSize, + struct gl_buffer_object *bufObj); + /* * API functions */ diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c index 63e5870e6..1865a66b9 100644 --- a/mesalib/src/mesa/main/drawpix.c +++ b/mesalib/src/mesa/main/drawpix.c @@ -109,7 +109,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, /* these buffers must exist */ if (!_mesa_dest_buffer_exists(ctx, format)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glDrawPixels(missing deest buffer)"); + "glDrawPixels(missing dest buffer)"); goto end; } break; diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c index 9151718ea..d80fda0db 100644 --- a/mesalib/src/mesa/main/errors.c +++ b/mesalib/src/mesa/main/errors.c @@ -980,7 +980,7 @@ _mesa_free_errors_data(struct gl_context *ctx) for (i = 0; i <= ctx->Debug->GroupStackDepth; i++) { free_errors_data(ctx, i); } - FREE(ctx->Debug); + free(ctx->Debug); /* set to NULL just in case it is used before context is completely gone. */ ctx->Debug = NULL; } diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index 1d2ad604b..66c18fa16 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -1344,7 +1344,8 @@ create_new_program(struct gl_context *ctx, struct state_key *key) const struct gl_shader_compiler_options *options = &ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; - while (do_common_optimization(p.shader->ir, false, false, 32, options)) + while (do_common_optimization(p.shader->ir, false, false, options, + ctx->Const.NativeIntegers)) ; reparent_ir(p.shader->ir, p.shader->ir); diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c index 2ef2e31d6..cf96609ea 100644 --- a/mesalib/src/mesa/main/format_unpack.c +++ b/mesalib/src/mesa/main/format_unpack.c @@ -645,7 +645,7 @@ unpack_R10G10B10A2_UINT(const void *src, GLfloat dst[][4], GLuint n) static void -unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n) +unpack_S8_UINT_Z24_UNORM(const void *src, GLfloat dst[][4], GLuint n) { /* only return Z, not stencil data */ const GLuint *s = ((const GLuint *) src); @@ -662,7 +662,7 @@ unpack_Z24_S8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_S8_Z24(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z24_UNORM_S8_UINT(const void *src, GLfloat dst[][4], GLuint n) { /* only return Z, not stencil data */ const GLuint *s = ((const GLuint *) src); @@ -679,7 +679,7 @@ unpack_S8_Z24(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_Z16(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z_UNORM16(const void *src, GLfloat dst[][4], GLuint n) { const GLushort *s = ((const GLushort *) src); GLuint i; @@ -692,19 +692,19 @@ unpack_Z16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_X8_Z24(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z24_UNORM_X8_UINT(const void *src, GLfloat dst[][4], GLuint n) { - unpack_S8_Z24(src, dst, n); + unpack_Z24_UNORM_S8_UINT(src, dst, n); } static void -unpack_Z24_X8(const void *src, GLfloat dst[][4], GLuint n) +unpack_X8_UINT_Z24_UNORM(const void *src, GLfloat dst[][4], GLuint n) { - unpack_Z24_S8(src, dst, n); + unpack_S8_UINT_Z24_UNORM(src, dst, n); } static void -unpack_Z32(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z_UNORM32(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -717,7 +717,7 @@ unpack_Z32(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_Z32_FLOAT_X24S8(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z32_FLOAT_S8X24_UINT(const void *src, GLfloat dst[][4], GLuint n) { const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src; GLuint i; @@ -730,7 +730,7 @@ unpack_Z32_FLOAT_X24S8(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_Z32_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +unpack_Z_FLOAT32(const void *src, GLfloat dst[][4], GLuint n) { const GLfloat *s = ((const GLfloat *) src); GLuint i; @@ -2391,12 +2391,12 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_B10G10R10A2_UNORM] = unpack_B10G10R10A2_UNORM; table[MESA_FORMAT_B10G10R10A2_UINT] = unpack_B10G10R10A2_UINT; table[MESA_FORMAT_R10G10B10A2_UINT] = unpack_R10G10B10A2_UINT; - table[MESA_FORMAT_S8_UINT_Z24_UNORM] = unpack_Z24_S8; - table[MESA_FORMAT_Z24_UNORM_S8_UINT] = unpack_S8_Z24; - table[MESA_FORMAT_Z_UNORM16] = unpack_Z16; - table[MESA_FORMAT_Z24_UNORM_X8_UINT] = unpack_X8_Z24; - table[MESA_FORMAT_X8_UINT_Z24_UNORM] = unpack_Z24_X8; - table[MESA_FORMAT_Z_UNORM32] = unpack_Z32; + table[MESA_FORMAT_S8_UINT_Z24_UNORM] = unpack_S8_UINT_Z24_UNORM; + table[MESA_FORMAT_Z24_UNORM_S8_UINT] = unpack_Z24_UNORM_S8_UINT; + table[MESA_FORMAT_Z_UNORM16] = unpack_Z_UNORM16; + table[MESA_FORMAT_Z24_UNORM_X8_UINT] = unpack_Z24_UNORM_X8_UINT; + table[MESA_FORMAT_X8_UINT_Z24_UNORM] = unpack_X8_UINT_Z24_UNORM; + table[MESA_FORMAT_Z_UNORM32] = unpack_Z_UNORM32; table[MESA_FORMAT_S_UINT8] = unpack_S8; table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8; table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB; @@ -2533,8 +2533,8 @@ get_unpack_rgba_function(mesa_format format) table[MESA_FORMAT_R9G9B9E5_FLOAT] = unpack_R9G9B9E5_FLOAT; table[MESA_FORMAT_R11G11B10_FLOAT] = unpack_R11G11B10_FLOAT; - table[MESA_FORMAT_Z_FLOAT32] = unpack_Z32_FLOAT; - table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = unpack_Z32_FLOAT_X24S8; + table[MESA_FORMAT_Z_FLOAT32] = unpack_Z_FLOAT32; + table[MESA_FORMAT_Z32_FLOAT_S8X24_UINT] = unpack_Z32_FLOAT_S8X24_UINT; table[MESA_FORMAT_B4G4R4X4_UNORM] = unpack_XRGB4444_UNORM; table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM; @@ -3935,7 +3935,7 @@ _mesa_unpack_rgba_block(mesa_format format, typedef void (*unpack_float_z_func)(GLuint n, const void *src, GLfloat *dst); static void -unpack_float_z_Z24_X8(GLuint n, const void *src, GLfloat *dst) +unpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst) { /* only return Z, not stencil data */ const GLuint *s = ((const GLuint *) src); @@ -3949,7 +3949,7 @@ unpack_float_z_Z24_X8(GLuint n, const void *src, GLfloat *dst) } static void -unpack_float_z_X8_Z24(GLuint n, const void *src, GLfloat *dst) +unpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst) { /* only return Z, not stencil data */ const GLuint *s = ((const GLuint *) src); @@ -3983,7 +3983,7 @@ unpack_float_Z_UNORM32(GLuint n, const void *src, GLfloat *dst) } static void -unpack_float_z_Z32F(GLuint n, const void *src, GLfloat *dst) +unpack_float_Z_FLOAT32(GLuint n, const void *src, GLfloat *dst) { memcpy(dst, src, n * sizeof(float)); } @@ -4013,11 +4013,11 @@ _mesa_unpack_float_z_row(mesa_format format, GLuint n, switch (format) { case MESA_FORMAT_S8_UINT_Z24_UNORM: case MESA_FORMAT_X8_UINT_Z24_UNORM: - unpack = unpack_float_z_Z24_X8; + unpack = unpack_float_z_X8_UINT_Z24_UNORM; break; case MESA_FORMAT_Z24_UNORM_S8_UINT: case MESA_FORMAT_Z24_UNORM_X8_UINT: - unpack = unpack_float_z_X8_Z24; + unpack = unpack_float_z_Z24_UNORM_X8_UINT; break; case MESA_FORMAT_Z_UNORM16: unpack = unpack_float_Z_UNORM16; @@ -4026,7 +4026,7 @@ _mesa_unpack_float_z_row(mesa_format format, GLuint n, unpack = unpack_float_Z_UNORM32; break; case MESA_FORMAT_Z_FLOAT32: - unpack = unpack_float_z_Z32F; + unpack = unpack_float_Z_FLOAT32; break; case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: unpack = unpack_float_z_Z32X24S8; @@ -4045,7 +4045,7 @@ _mesa_unpack_float_z_row(mesa_format format, GLuint n, typedef void (*unpack_uint_z_func)(const void *src, GLuint *dst, GLuint n); static void -unpack_uint_z_Z24_X8(const void *src, GLuint *dst, GLuint n) +unpack_uint_z_X8_UINT_Z24_UNORM(const void *src, GLuint *dst, GLuint n) { /* only return Z, not stencil data */ const GLuint *s = ((const GLuint *) src); @@ -4056,7 +4056,7 @@ unpack_uint_z_Z24_X8(const void *src, GLuint *dst, GLuint n) } static void -unpack_uint_z_X8_Z24(const void *src, GLuint *dst, GLuint n) +unpack_uint_z_Z24_UNORM_X8_UINT(const void *src, GLuint *dst, GLuint n) { /* only return Z, not stencil data */ const GLuint *s = ((const GLuint *) src); @@ -4118,11 +4118,11 @@ _mesa_unpack_uint_z_row(mesa_format format, GLuint n, switch (format) { case MESA_FORMAT_S8_UINT_Z24_UNORM: case MESA_FORMAT_X8_UINT_Z24_UNORM: - unpack = unpack_uint_z_Z24_X8; + unpack = unpack_uint_z_X8_UINT_Z24_UNORM; break; case MESA_FORMAT_Z24_UNORM_S8_UINT: case MESA_FORMAT_Z24_UNORM_X8_UINT: - unpack = unpack_uint_z_X8_Z24; + unpack = unpack_uint_z_Z24_UNORM_X8_UINT; break; case MESA_FORMAT_Z_UNORM16: unpack = unpack_uint_Z_UNORM16; @@ -4147,13 +4147,13 @@ _mesa_unpack_uint_z_row(mesa_format format, GLuint n, static void -unpack_ubyte_s_S8(const void *src, GLubyte *dst, GLuint n) +unpack_ubyte_s_S_UINT8(const void *src, GLubyte *dst, GLuint n) { memcpy(dst, src, n); } static void -unpack_ubyte_s_Z24_S8(const void *src, GLubyte *dst, GLuint n) +unpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src, GLubyte *dst, GLuint n) { GLuint i; const GLuint *src32 = src; @@ -4163,7 +4163,7 @@ unpack_ubyte_s_Z24_S8(const void *src, GLubyte *dst, GLuint n) } static void -unpack_ubyte_s_S8_Z24(const void *src, GLubyte *dst, GLuint n) +unpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src, GLubyte *dst, GLuint n) { GLuint i; const GLuint *src32 = src; @@ -4173,7 +4173,7 @@ unpack_ubyte_s_S8_Z24(const void *src, GLubyte *dst, GLuint n) } static void -unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src, GLubyte *dst, GLuint n) +unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src, GLubyte *dst, GLuint n) { GLuint i; const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src; @@ -4188,16 +4188,16 @@ _mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n, { switch (format) { case MESA_FORMAT_S_UINT8: - unpack_ubyte_s_S8(src, dst, n); + unpack_ubyte_s_S_UINT8(src, dst, n); break; case MESA_FORMAT_S8_UINT_Z24_UNORM: - unpack_ubyte_s_Z24_S8(src, dst, n); + unpack_ubyte_s_S8_UINT_Z24_UNORM(src, dst, n); break; case MESA_FORMAT_Z24_UNORM_S8_UINT: - unpack_ubyte_s_S8_Z24(src, dst, n); + unpack_ubyte_s_Z24_UNORM_S8_UINT(src, dst, n); break; case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: - unpack_ubyte_s_Z32_FLOAT_X24S8(src, dst, n); + unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src, dst, n); break; default: _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row", @@ -4207,7 +4207,7 @@ _mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n, } static void -unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint *src, GLuint *dst, GLuint n) +unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const GLuint *src, GLuint *dst, GLuint n) { GLuint i; @@ -4233,7 +4233,7 @@ unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint *src, } static void -unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint *src, GLuint *dst, GLuint n) +unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const GLuint *src, GLuint *dst, GLuint n) { memcpy(dst, src, n * 4); } @@ -4248,10 +4248,10 @@ _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n, { switch (format) { case MESA_FORMAT_S8_UINT_Z24_UNORM: - unpack_uint_24_8_depth_stencil_Z24_S8(src, dst, n); + unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src, dst, n); break; case MESA_FORMAT_Z24_UNORM_S8_UINT: - unpack_uint_24_8_depth_stencil_S8_Z24(src, dst, n); + unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src, dst, n); break; case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n); diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h index 9e221cccb..17a9bd099 100644 --- a/mesalib/src/mesa/main/imports.h +++ b/mesalib/src/mesa/main/imports.h @@ -49,16 +49,10 @@ extern "C" { /** Memory macros */ /*@{*/ -/** Allocate \p BYTES bytes */ -#define MALLOC(BYTES) malloc(BYTES) -/** Allocate and zero \p BYTES bytes */ -#define CALLOC(BYTES) calloc(1, BYTES) /** Allocate a structure of type \p T */ #define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) /** Allocate and zero a structure of type \p T */ #define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) -/** Free memory */ -#define FREE(PTR) free(PTR) /*@}*/ diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h index dafeaa372..5228c3a8f 100644 --- a/mesalib/src/mesa/main/macros.h +++ b/mesalib/src/mesa/main/macros.h @@ -685,6 +685,17 @@ minify(unsigned value, unsigned levels) } /** + * Return true if the given value is a power of two. + * + * Note that this considers 0 a power of two. + */ +static inline bool +is_power_of_two(unsigned value) +{ + return (value & (value - 1)) == 0; +} + +/** * Align a value up to an alignment value * * If \c value is not already aligned to the requested alignment value, it diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 33cb88881..4d014d1ee 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2421,8 +2421,7 @@ struct gl_shader /** * This shader's uniform block information. * - * The offsets of the variables are assigned only for shaders in a program's - * _LinkedShaders[]. + * These fields are only set post-linking. */ struct gl_uniform_block *UniformBlocks; unsigned NumUniformBlocks; @@ -3472,6 +3471,8 @@ struct gl_constants /** GL_ARB_gpu_shader5 */ GLfloat MinFragmentInterpolationOffset; GLfloat MaxFragmentInterpolationOffset; + + GLboolean FakeSWMSAA; }; diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index d976e5aae..1df656832 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -1489,72 +1489,72 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], switch (dstFormat) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i] = FLOAT_TO_BYTE_TEX(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]); + dst[i] = FLOAT_TO_BYTE_TEX(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(luminance[i]); + dst[i] = FLOAT_TO_BYTE_TEX(luminance[i]); break; case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { - dst[i*2+0] = FLOAT_TO_BYTE(luminance[i]); - dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][ACOMP]); + dst[i*2+0] = FLOAT_TO_BYTE_TEX(luminance[i]); + dst[i*2+1] = FLOAT_TO_BYTE_TEX(rgba[i][ACOMP]); } break; case GL_RG: for (i=0;i<n;i++) { - dst[i*2+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*2+0] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); + dst[i*2+1] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*3+0] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_BYTE_TEX(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]); - dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]); + dst[i*4+0] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE_TEX(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE_TEX(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]); - dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*3+0] = FLOAT_TO_BYTE_TEX(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]); - dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]); + dst[i*4+0] = FLOAT_TO_BYTE_TEX(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE_TEX(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]); - dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][BCOMP]); - dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][GCOMP]); - dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*4+0] = FLOAT_TO_BYTE_TEX(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_BYTE_TEX(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); } break; case GL_RED_INTEGER_EXT: @@ -1631,8 +1631,8 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], case GL_DUDV_ATI: case GL_DU8DV8_ATI: for (i=0;i<n;i++) { - dst[i*2+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); - dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*2+0] = FLOAT_TO_BYTE_TEX(rgba[i][RCOMP]); + dst[i*2+1] = FLOAT_TO_BYTE_TEX(rgba[i][GCOMP]); } break; default: @@ -1803,72 +1803,72 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], switch (dstFormat) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i] = FLOAT_TO_SHORT_TEX(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]); + dst[i] = FLOAT_TO_SHORT_TEX(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(luminance[i]); + dst[i] = FLOAT_TO_SHORT_TEX(luminance[i]); break; case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { - dst[i*2+0] = FLOAT_TO_SHORT(luminance[i]); - dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][ACOMP]); + dst[i*2+0] = FLOAT_TO_SHORT_TEX(luminance[i]); + dst[i*2+1] = FLOAT_TO_SHORT_TEX(rgba[i][ACOMP]); } break; case GL_RG: for (i=0;i<n;i++) { - dst[i*2+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); - dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*2+0] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); + dst[i*2+1] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); - dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); - dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*3+0] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_SHORT_TEX(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); - dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); - dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]); - dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]); + dst[i*4+0] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT_TEX(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT_TEX(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]); - dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); - dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*3+0] = FLOAT_TO_SHORT_TEX(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]); - dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); - dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]); - dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]); + dst[i*4+0] = FLOAT_TO_SHORT_TEX(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT_TEX(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]); - dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][BCOMP]); - dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][GCOMP]); - dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*4+0] = FLOAT_TO_SHORT_TEX(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_SHORT_TEX(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); } break; case GL_RED_INTEGER_EXT: @@ -1945,8 +1945,8 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], case GL_DUDV_ATI: case GL_DU8DV8_ATI: for (i=0;i<n;i++) { - dst[i*2+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); - dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*2+0] = FLOAT_TO_SHORT_TEX(rgba[i][RCOMP]); + dst[i*2+1] = FLOAT_TO_SHORT_TEX(rgba[i][GCOMP]); } break; default: diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp index e1afe5315..f66c11733 100644 --- a/mesalib/src/mesa/main/shader_query.cpp +++ b/mesalib/src/mesa/main/shader_query.cpp @@ -76,6 +76,30 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index, */ } +static bool +is_active_attrib(const ir_variable *var) +{ + if (!var) + return false; + + switch (var->data.mode) { + case ir_var_shader_in: + return var->data.location != -1; + + case ir_var_system_value: + /* From GL 4.3 core spec, section 11.1.1 (Vertex Attributes): + * "For GetActiveAttrib, all active vertex shader input variables + * are enumerated, including the special built-in inputs gl_VertexID + * and gl_InstanceID." + */ + return !strcmp(var->name, "gl_VertexID") || + !strcmp(var->name, "gl_InstanceID"); + + default: + return false; + } +} + void GLAPIENTRY _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, GLsizei maxLength, GLsizei * length, GLint * size, @@ -105,10 +129,8 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, foreach_list(node, ir) { const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var == NULL - || var->data.mode != ir_var_shader_in - || var->data.location == -1) - continue; + if (!is_active_attrib(var)) + continue; if (current_index == desired_index) { _mesa_copy_string(name, maxLength, length, var->name); @@ -196,10 +218,8 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg) foreach_list(node, ir) { const ir_variable *const var = ((ir_instruction *) node)->as_variable(); - if (var == NULL - || var->data.mode != ir_var_shader_in - || var->data.location == -1) - continue; + if (!is_active_attrib(var)) + continue; i++; } diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c index cbda68940..ae973b001 100644 --- a/mesalib/src/mesa/main/texcompress_etc.c +++ b/mesalib/src/mesa/main/texcompress_etc.c @@ -678,14 +678,25 @@ etc2_unpack_rgb8(uint8_t *dst_row, for (y = 0; y < height; y += bh) { const uint8_t *src = src_row; + /* + * Destination texture may not be a multiple of four texels in + * height. Compute a safe height to avoid writing outside the texture. + */ + const unsigned h = MIN2(bh, height - y); for (x = 0; x < width; x+= bw) { + /* + * Destination texture may not be a multiple of four texels in + * width. Compute a safe width to avoid writing outside the texture. + */ + const unsigned w = MIN2(bw, width - x); + etc2_rgb8_parse_block(&block, src, false /* punchthrough_alpha */); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_rgb8_fetch_texel(&block, i, j, dst, false /* punchthrough_alpha */); dst[3] = 255; @@ -715,14 +726,17 @@ etc2_unpack_srgb8(uint8_t *dst_row, for (y = 0; y < height; y += bh) { const uint8_t *src = src_row; + const unsigned h = MIN2(bh, height - y); for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_rgb8_parse_block(&block, src, false /* punchthrough_alpha */); - for (j = 0; j < bh; j++) { + + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_rgb8_fetch_texel(&block, i, j, dst, false /* punchthrough_alpha */); /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */ @@ -759,13 +773,15 @@ etc2_unpack_rgba8(uint8_t *dst_row, for (y = 0; y < height; y += bh) { const uint8_t *src = src_row; + const unsigned h = MIN2(bh, height - y); for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_rgba8_parse_block(&block, src); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_rgba8_fetch_texel(&block, i, j, dst); dst += comps; } @@ -795,14 +811,16 @@ etc2_unpack_srgb8_alpha8(uint8_t *dst_row, uint8_t tmp; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_rgba8_parse_block(&block, src); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_rgba8_fetch_texel(&block, i, j, dst); /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */ @@ -837,14 +855,16 @@ etc2_unpack_r11(uint8_t *dst_row, unsigned x, y, i, j; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_r11_parse_block(&block, src); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_r11_fetch_texel(&block, i, j, dst); dst += comps * comp_size; } @@ -872,16 +892,18 @@ etc2_unpack_rg11(uint8_t *dst_row, unsigned x, y, i, j; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); /* red component */ etc2_r11_parse_block(&block, src); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_r11_fetch_texel(&block, i, j, dst); dst += comps * comp_size; } @@ -889,10 +911,10 @@ etc2_unpack_rg11(uint8_t *dst_row, /* green component */ etc2_r11_parse_block(&block, src + 8); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_r11_fetch_texel(&block, i, j, dst + comp_size); dst += comps * comp_size; } @@ -920,15 +942,17 @@ etc2_unpack_signed_r11(uint8_t *dst_row, unsigned x, y, i, j; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_r11_parse_block(&block, src); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_signed_r11_fetch_texel(&block, i, j, dst); dst += comps * comp_size; } @@ -956,16 +980,18 @@ etc2_unpack_signed_rg11(uint8_t *dst_row, unsigned x, y, i, j; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); /* red component */ etc2_r11_parse_block(&block, src); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_signed_r11_fetch_texel(&block, i, j, dst); dst += comps * comp_size; } @@ -973,10 +999,10 @@ etc2_unpack_signed_rg11(uint8_t *dst_row, /* green component */ etc2_r11_parse_block(&block, src + 8); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_signed_r11_fetch_texel(&block, i, j, dst + comp_size); dst += comps * comp_size; } @@ -1001,14 +1027,16 @@ etc2_unpack_rgb8_punchthrough_alpha1(uint8_t *dst_row, unsigned x, y, i, j; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_rgb8_parse_block(&block, src, true /* punchthrough_alpha */); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_rgb8_fetch_texel(&block, i, j, dst, true /* punchthrough_alpha */); dst += comps; @@ -1036,14 +1064,16 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row, uint8_t tmp; for (y = 0; y < height; y += bh) { + const unsigned h = MIN2(bh, height - y); const uint8_t *src = src_row; for (x = 0; x < width; x+= bw) { + const unsigned w = MIN2(bw, width - x); etc2_rgb8_parse_block(&block, src, true /* punchthrough_alpha */); - for (j = 0; j < bh; j++) { + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; - for (i = 0; i < bw; i++) { + for (i = 0; i < w; i++) { etc2_rgb8_fetch_texel(&block, i, j, dst, true /* punchthrough_alpha */); /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */ diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 004e7ebac..d43480482 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -76,11 +76,10 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, } else if (type == GL_UNSIGNED_INT_2_10_10_10_REV) { RETURN_IF_SUPPORTED(MESA_FORMAT_B10G10R10A2_UNORM); } - RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_UNORM); - RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM); - break; + /* fallthrough */ case GL_RGBA8: + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_UNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_UNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM); break; @@ -97,6 +96,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, /* deep RGBA formats */ case GL_RGB10_A2: + RETURN_IF_SUPPORTED(MESA_FORMAT_R10G10B10A2_UNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_B10G10R10A2_UNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM); break; @@ -116,6 +116,10 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, } /* fallthrough */ case GL_RGB8: + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_UNORM8); + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_UNORM); + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_UNORM); + RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_UNORM8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8X8_UNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM); @@ -451,10 +455,14 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, break; case GL_RGB_SNORM: case GL_RGB8_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_SNORM); + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SNORM); - /* FALLTHROUGH */ + RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM); + break; case GL_RGBA_SNORM: case GL_RGBA8_SNORM: + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SNORM); RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SNORM); break; @@ -522,11 +530,17 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_SRGB_EXT: case GL_SRGB8_EXT: + /* there is no MESA_FORMAT_RGB_SRGB8 */ + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); break; case GL_SRGB_ALPHA_EXT: case GL_SRGB8_ALPHA8_EXT: + RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SRGB); + RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); break; diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 8bdbb08c8..918dd59ed 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -559,6 +559,13 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, /* 'q' in the GL spec */ maxLevels - 1); + if (t->Immutable) { + /* Adjust max level for views: the data store may have more levels than + * the view exposes. + */ + t->_MaxLevel = MIN2(t->_MaxLevel, t->NumLevels - 1); + } + /* Compute _MaxLambda = q - p in the spec used during mipmapping */ t->_MaxLambda = (GLfloat) (t->_MaxLevel - baseLevel); diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index bfb2e1b9f..40790ff0e 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -352,7 +352,8 @@ set_tex_parameteri(struct gl_context *ctx, if (texObj->MaxLevel == params[0]) return GL_FALSE; - if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) { + if (params[0] < 0 || + (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] > 0)) { _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param=%d)", params[0]); return GL_FALSE; diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index fe3b07256..d9096abf3 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -3263,20 +3263,7 @@ _mesa_texstore_srgba8(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_R8G8B8X8_SRGB || dstFormat == MESA_FORMAT_R8G8B8A8_SRGB); - /* reuse normal rgba texstore code */ - if (dstFormat == MESA_FORMAT_A8B8G8R8_SRGB) { - newDstFormat = MESA_FORMAT_A8B8G8R8_UNORM; - } - else if (dstFormat == MESA_FORMAT_R8G8B8A8_SRGB) { - newDstFormat = MESA_FORMAT_R8G8B8A8_UNORM; - } - else if (dstFormat == MESA_FORMAT_R8G8B8X8_SRGB) { - newDstFormat = MESA_FORMAT_R8G8B8X8_UNORM; - } - else { - ASSERT(0); - return GL_TRUE; - } + newDstFormat = _mesa_get_srgb_format_linear(dstFormat); k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, newDstFormat, @@ -3294,17 +3281,10 @@ _mesa_texstore_sargb8(TEXSTORE_PARAMS) mesa_format newDstFormat; GLboolean k; - switch (dstFormat) { - case MESA_FORMAT_B8G8R8A8_SRGB: - newDstFormat = MESA_FORMAT_B8G8R8A8_UNORM; - break; - case MESA_FORMAT_B8G8R8X8_SRGB: - newDstFormat = MESA_FORMAT_B8G8R8X8_UNORM; - break; - default: - ASSERT(0); - return GL_FALSE; - } + assert(dstFormat == MESA_FORMAT_B8G8R8A8_SRGB || + dstFormat == MESA_FORMAT_B8G8R8X8_SRGB); + + newDstFormat = _mesa_get_srgb_format_linear(dstFormat); k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat, newDstFormat, diff --git a/mesalib/src/mesa/main/vdpau.c b/mesalib/src/mesa/main/vdpau.c index c2cf20664..d97459393 100644 --- a/mesalib/src/mesa/main/vdpau.c +++ b/mesalib/src/mesa/main/vdpau.c @@ -88,7 +88,7 @@ unregister_surface(struct set_entry *entry) } _mesa_set_remove(ctx->vdpSurfaces, entry); - FREE(surf); + free(surf); } void GLAPIENTRY @@ -145,7 +145,7 @@ register_surface(struct gl_context *ctx, GLboolean isOutput, if (tex->Immutable) { _mesa_unlock_texture(ctx, tex); - FREE(surf); + free(surf); _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAURegisterSurfaceNV(texture is immutable)"); return (GLintptr)NULL; @@ -155,7 +155,7 @@ register_surface(struct gl_context *ctx, GLboolean isOutput, tex->Target = target; else if (tex->Target != target) { _mesa_unlock_texture(ctx, tex); - FREE(surf); + free(surf); _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAURegisterSurfaceNV(target mismatch)"); return (GLintptr)NULL; @@ -254,7 +254,7 @@ _mesa_VDPAUUnregisterSurfaceNV(GLintptr surface) } _mesa_set_remove(ctx->vdpSurfaces, entry); - FREE(surf); + free(surf); } void GLAPIENTRY diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 1c0bedf4b..b7cc50fc1 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -228,7 +228,7 @@ compute_version(struct gl_context *ctx) ctx->Extensions.EXT_texture_sRGB); const GLboolean ver_3_0 = (ver_2_1 && ctx->Const.GLSLVersion >= 130 && - ctx->Const.MaxSamples >= 4 && + (ctx->Const.MaxSamples >= 4 || ctx->Const.FakeSWMSAA) && (ctx->API == API_OPENGL_CORE || ctx->Extensions.ARB_color_buffer_float) && ctx->Extensions.ARB_depth_buffer_float && |