diff options
Diffstat (limited to 'mesalib/src/mesa')
44 files changed, 1054 insertions, 2014 deletions
diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am index f1fee122c..e8076120d 100644 --- a/mesalib/src/mesa/drivers/dri/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/Makefile.am @@ -9,37 +9,37 @@ SUBDIRS+=common if HAVE_I915_DRI SUBDIRS += i915 MEGADRIVERS_DEPS += i915/libi915_dri.la -MEGADRIVERS += i915_dri.@LIB_EXT@ +MEGADRIVERS += i915_dri.so endif if HAVE_I965_DRI SUBDIRS += i965 MEGADRIVERS_DEPS += i965/libi965_dri.la -MEGADRIVERS += i965_dri.@LIB_EXT@ +MEGADRIVERS += i965_dri.so endif if HAVE_NOUVEAU_DRI SUBDIRS += nouveau MEGADRIVERS_DEPS += nouveau/libnouveau_dri.la -MEGADRIVERS += nouveau_vieux_dri.@LIB_EXT@ +MEGADRIVERS += nouveau_vieux_dri.so endif if HAVE_R200_DRI SUBDIRS += r200 MEGADRIVERS_DEPS += r200/libr200_dri.la -MEGADRIVERS += r200_dri.@LIB_EXT@ +MEGADRIVERS += r200_dri.so endif if HAVE_RADEON_DRI SUBDIRS += radeon MEGADRIVERS_DEPS += radeon/libradeon_dri.la -MEGADRIVERS += radeon_dri.@LIB_EXT@ +MEGADRIVERS += radeon_dri.so endif if HAVE_SWRAST_DRI SUBDIRS += swrast MEGADRIVERS_DEPS += swrast/libswrast_dri.la -MEGADRIVERS += swrast_dri.@LIB_EXT@ +MEGADRIVERS += swrast_dri.so endif pkgconfigdir = $(libdir)/pkgconfig @@ -51,7 +51,7 @@ driinclude_HEADERS = $(top_srcdir)/include/GL/internal/dri_interface.h nodist_EXTRA_mesa_dri_drivers_la_SOURCES = dummy.cpp mesa_dri_drivers_la_SOURCES = mesa_dri_drivers_la_LDFLAGS = \ - -module -avoid-version -shared \ + -module -avoid-version -shared -shrext .so \ -Wl,-Bsymbolic \ $(GC_SECTIONS) \ $() @@ -70,22 +70,22 @@ if HAVE_COMPAT_SYMLINKS # Add a link to allow setting LD_LIBRARY_PATH/LIBGL_DRIVERS_PATH to /lib of the build tree. all-local: mesa_dri_drivers.la $(AM_V_at)$(MKDIR_P) $(top_builddir)/$(LIB_DIR); - $(AM_V_GEN)ln -f .libs/mesa_dri_drivers.@LIB_EXT@ \ - $(top_builddir)/$(LIB_DIR)/mesa_dri_drivers.@LIB_EXT@; + $(AM_V_GEN)ln -f .libs/mesa_dri_drivers.so \ + $(top_builddir)/$(LIB_DIR)/mesa_dri_drivers.so; $(AM_V_GEN)for i in $(MEGADRIVERS); do \ - ln -f $(top_builddir)/$(LIB_DIR)/mesa_dri_drivers.@LIB_EXT@ \ + ln -f $(top_builddir)/$(LIB_DIR)/mesa_dri_drivers.so \ $(top_builddir)/$(LIB_DIR)/$$i; \ done; endif # hardlink each megadriver instance, but don't actually have -# mesa_dri_drivers.@LIB_EXT@ in the set of final installed files. +# mesa_dri_drivers.so in the set of final installed files. install-data-hook: for i in $(MEGADRIVERS); do \ - ln -f $(DESTDIR)$(dridir)/mesa_dri_drivers.@LIB_EXT@ \ + ln -f $(DESTDIR)$(dridir)/mesa_dri_drivers.so \ $(DESTDIR)$(dridir)/$$i; \ done; - $(RM) -f $(DESTDIR)$(dridir)/mesa_dri_drivers.@LIB_EXT@ + $(RM) -f $(DESTDIR)$(dridir)/mesa_dri_drivers.so $(RM) -f $(DESTDIR)$(dridir)/mesa_dri_drivers.la endif diff --git a/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c b/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c index a8217703d..7b6d13450 100644 --- a/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c +++ b/mesalib/src/mesa/drivers/dri/common/megadriver_stub.c @@ -31,7 +31,7 @@ * Dl_info, and RTLD_DEFAULT are only defined when _GNU_SOURCE is * defined.) */ -#ifdef _GNU_SOURCE +#ifdef RTLD_DEFAULT #define MEGADRIVER_STUB_MAX_EXTENSIONS 10 #define LIB_PATH_SUFFIX "_dri.so" @@ -148,7 +148,7 @@ megadriver_stub_init(void) } } -#endif /* _GNU_SOURCE */ +#endif /* RTLD_DEFAULT */ static const __DRIconfig **stub_error_init_screen(__DRIscreen *psp) 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 && diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index 0923357b1..59cf1232a 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -3007,8 +3007,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress; progress = do_common_optimization(ir, true, true, - options->MaxUnrollIterations, - options) + options, ctx->Const.NativeIntegers) || progress; progress = lower_quadop_vector(ir, true) || progress; diff --git a/mesalib/src/mesa/program/prog_noise.c b/mesalib/src/mesa/program/prog_noise.c index c258c5e2e..ac920c23f 100644 --- a/mesalib/src/mesa/program/prog_noise.c +++ b/mesalib/src/mesa/program/prog_noise.c @@ -257,12 +257,12 @@ _mesa_noise2(GLfloat x, GLfloat y) float y0 = y - Y0; float x1, y1, x2, y2; - int ii, jj; + unsigned int ii, jj; float t0, t1, t2; /* For the 2D case, the simplex shape is an equilateral triangle. */ /* Determine which simplex we are in. */ - int i1, j1; /* Offsets for second (middle) corner of simplex in (i,j) coords */ + unsigned int i1, j1; /* Offsets for second (middle) corner of simplex in (i,j) coords */ if (x0 > y0) { i1 = 1; j1 = 0; @@ -282,8 +282,8 @@ _mesa_noise2(GLfloat x, GLfloat y) y2 = y0 - 1.0f + 2.0f * G2; /* Wrap the integer indices at 256, to avoid indexing perm[] out of bounds */ - ii = i % 256; - jj = j % 256; + ii = i & 0xff; + jj = j & 0xff; /* Calculate the contribution from the three corners */ t0 = 0.5f - x0 * x0 - y0 * y0; @@ -344,13 +344,13 @@ _mesa_noise3(GLfloat x, GLfloat y, GLfloat z) float z0 = z - Z0; float x1, y1, z1, x2, y2, z2, x3, y3, z3; - int ii, jj, kk; + unsigned int ii, jj, kk; float t0, t1, t2, t3; /* For the 3D case, the simplex shape is a slightly irregular tetrahedron. */ /* Determine which simplex we are in. */ - int i1, j1, k1; /* Offsets for second corner of simplex in (i,j,k) coords */ - int i2, j2, k2; /* Offsets for third corner of simplex in (i,j,k) coords */ + unsigned int i1, j1, k1; /* Offsets for second corner of simplex in (i,j,k) coords */ + unsigned int i2, j2, k2; /* Offsets for third corner of simplex in (i,j,k) coords */ /* This code would benefit from a backport from the GLSL version! */ if (x0 >= y0) { @@ -423,9 +423,9 @@ _mesa_noise3(GLfloat x, GLfloat y, GLfloat z) z3 = z0 - 1.0f + 3.0f * G3; /* Wrap the integer indices at 256 to avoid indexing perm[] out of bounds */ - ii = i % 256; - jj = j % 256; - kk = k % 256; + ii = i & 0xff; + jj = j & 0xff; + kk = k & 0xff; /* Calculate the contribution from the four corners */ t0 = 0.6f - x0 * x0 - y0 * y0 - z0 * z0; @@ -522,12 +522,12 @@ _mesa_noise4(GLfloat x, GLfloat y, GLfloat z, GLfloat w) int c6 = (z0 > w0) ? 1 : 0; int c = c1 + c2 + c3 + c4 + c5 + c6; - int i1, j1, k1, l1; /* The integer offsets for the second simplex corner */ - int i2, j2, k2, l2; /* The integer offsets for the third simplex corner */ - int i3, j3, k3, l3; /* The integer offsets for the fourth simplex corner */ + unsigned int i1, j1, k1, l1; /* The integer offsets for the second simplex corner */ + unsigned int i2, j2, k2, l2; /* The integer offsets for the third simplex corner */ + unsigned int i3, j3, k3, l3; /* The integer offsets for the fourth simplex corner */ float x1, y1, z1, w1, x2, y2, z2, w2, x3, y3, z3, w3, x4, y4, z4, w4; - int ii, jj, kk, ll; + unsigned int ii, jj, kk, ll; float t0, t1, t2, t3, t4; /* @@ -573,10 +573,10 @@ _mesa_noise4(GLfloat x, GLfloat y, GLfloat z, GLfloat w) w4 = w0 - 1.0f + 4.0f * G4; /* Wrap the integer indices at 256, to avoid indexing perm[] out of bounds */ - ii = i % 256; - jj = j % 256; - kk = k % 256; - ll = l % 256; + ii = i & 0xff; + jj = j & 0xff; + kk = k & 0xff; + ll = l & 0xff; /* Calculate the contribution from the five corners */ t0 = 0.6f - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; diff --git a/mesalib/src/mesa/program/program_parse.y b/mesalib/src/mesa/program/program_parse.y index 6dde69d53..1664740b4 100644 --- a/mesalib/src/mesa/program/program_parse.y +++ b/mesalib/src/mesa/program/program_parse.y @@ -2749,6 +2749,11 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st */ state->prog->Instructions = _mesa_alloc_instructions(state->prog->NumInstructions + 1); + + if (state->prog->Instructions == NULL) { + goto error; + } + inst = state->inst_head; for (i = 0; i < state->prog->NumInstructions; i++) { struct asm_instruction *const temp = inst->next; diff --git a/mesalib/src/mesa/program/symbol_table.c b/mesalib/src/mesa/program/symbol_table.c index 2f41322f6..9462978ee 100644 --- a/mesalib/src/mesa/program/symbol_table.c +++ b/mesalib/src/mesa/program/symbol_table.c @@ -115,7 +115,7 @@ struct _mesa_symbol_table { static void check_symbol_table(struct _mesa_symbol_table *table) { -#if 1 +#if !defined(NDEBUG) struct scope_level *scope; for (scope = table->current_scope; scope != NULL; scope = scope->next) { @@ -134,7 +134,9 @@ check_symbol_table(struct _mesa_symbol_table *table) } } } -#endif +#else + (void) table; +#endif /* !defined(NDEBUG) */ } void diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c index ec2bab20b..3929251f8 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c +++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c @@ -182,15 +182,27 @@ convert_sampler(struct st_context *st, msamp->BorderColor.ui[3]) { const struct st_texture_object *stobj = st_texture_object_const(texobj); const GLboolean is_integer = texobj->_IsIntegerFormat; + const struct pipe_sampler_view *sv = NULL; union pipe_color_union border_color; + GLuint i; + + /* Just search for the first used view. We can do this because the + swizzle is per-texture, not per context. */ + /* XXX: clean that up to not use the sampler view at all */ + for (i = 0; i < stobj->num_sampler_views; ++i) { + if (stobj->sampler_views[i]) { + sv = stobj->sampler_views[i]; + break; + } + } - if (st->apply_texture_swizzle_to_border_color && stobj->sampler_view) { + if (st->apply_texture_swizzle_to_border_color && sv) { const unsigned char swz[4] = { - stobj->sampler_view->swizzle_r, - stobj->sampler_view->swizzle_g, - stobj->sampler_view->swizzle_b, - stobj->sampler_view->swizzle_a, + sv->swizzle_r, + sv->swizzle_g, + sv->swizzle_b, + sv->swizzle_a, }; st_translate_color(&msamp->BorderColor, diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index c9bffce4f..afc6d9dab 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -200,9 +200,9 @@ get_texture_format_swizzle(const struct st_texture_object *stObj) * \param stObj the st texture object, */ static boolean -check_sampler_swizzle(const struct st_texture_object *stObj) +check_sampler_swizzle(const struct st_texture_object *stObj, + struct pipe_sampler_view *sv) { - const struct pipe_sampler_view *sv = stObj->sampler_view; unsigned swizzle = get_texture_format_swizzle(stObj); return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) || @@ -258,40 +258,47 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe, static struct pipe_sampler_view * -st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj, - struct pipe_context *pipe, +st_get_texture_sampler_view_from_stobj(struct st_context *st, + struct st_texture_object *stObj, const struct gl_sampler_object *samp, enum pipe_format format) { + struct pipe_sampler_view **sv; + if (!stObj || !stObj->pt) { return NULL; } - if (!stObj->sampler_view) { - stObj->sampler_view = - st_create_texture_sampler_view_from_stobj(pipe, stObj, samp, format); + sv = st_texture_get_sampler_view(st, stObj); + + /* if sampler view has changed dereference it */ + if (*sv) { + if (check_sampler_swizzle(stObj, *sv) || + (format != (*sv)->format) || + stObj->base.BaseLevel != (*sv)->u.tex.first_level) { + pipe_sampler_view_reference(sv, NULL); + } + } + + if (!*sv) { + *sv = st_create_texture_sampler_view_from_stobj(st->pipe, stObj, samp, format); - } else if (stObj->sampler_view->context != pipe) { + } else if ((*sv)->context != st->pipe) { /* Recreate view in correct context, use existing view as template */ - /* XXX: This isn't optimal, we should try to use more than one view. - Otherwise we create/destroy the view all the time - */ - struct pipe_sampler_view *sv = - pipe->create_sampler_view(pipe, stObj->pt, stObj->sampler_view); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); - stObj->sampler_view = sv; + struct pipe_sampler_view *new_sv = + st->pipe->create_sampler_view(st->pipe, stObj->pt, *sv); + pipe_sampler_view_reference(sv, NULL); + *sv = new_sv; } - return stObj->sampler_view; + return *sv; } - static GLboolean update_single_texture(struct st_context *st, struct pipe_sampler_view **sampler_view, GLuint texUnit) { - struct pipe_context *pipe = st->pipe; struct gl_context *ctx = st->ctx; const struct gl_sampler_object *samp; struct gl_texture_object *texObj; @@ -330,17 +337,7 @@ update_single_texture(struct st_context *st, } } - /* if sampler view has changed dereference it */ - if (stObj->sampler_view) { - if (check_sampler_swizzle(stObj) || - (view_format != stObj->sampler_view->format) || - stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) { - pipe_sampler_view_release(pipe, &stObj->sampler_view); - } - } - - *sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe, - samp, + *sampler_view = st_get_texture_sampler_view_from_stobj(st, stObj, samp, view_format); return GL_TRUE; } diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index 49c4b903e..02624617b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -447,6 +447,33 @@ st_copy_buffer_subdata(struct gl_context *ctx, srcObj->buffer, 0, &box); } +/** + * Called via glClearBufferSubData(). + */ +static void +st_clear_buffer_subdata(struct gl_context *ctx, + GLintptr offset, GLsizeiptr size, + const GLvoid *clearValue, + GLsizeiptr clearValueSize, + struct gl_buffer_object *bufObj) +{ + struct pipe_context *pipe = st_context(ctx)->pipe; + struct st_buffer_object *buf = st_buffer_object(bufObj); + static const char zeros[16] = {0}; + + if (!pipe->clear_buffer) { + _mesa_buffer_clear_subdata(ctx, offset, size, + clearValue, clearValueSize, bufObj); + return; + } + + if (!clearValue) + clearValue = zeros; + + pipe->clear_buffer(pipe, buf->buffer, offset, size, + clearValue, clearValueSize); +} + /* TODO: if buffer wasn't created with appropriate usage flags, need * to recreate it now and copy contents -- or possibly create a @@ -476,6 +503,7 @@ st_init_bufferobject_functions(struct dd_function_table *functions) functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range; functions->UnmapBuffer = st_bufferobj_unmap; functions->CopyBufferSubData = st_copy_buffer_subdata; + functions->ClearBufferSubData = st_clear_buffer_subdata; /* For GL_APPLE_vertex_array_object */ functions->NewArrayObject = _mesa_new_vao; diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c index 561967d6c..34eb80959 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c +++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c @@ -124,7 +124,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target, /* FIXME create a non-default sampler view from the pipe_surface? */ pipe_resource_reference(&stObj->pt, ps->texture); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); + st_texture_release_all_sampler_views(stObj); pipe_resource_reference(&stImage->pt, stObj->pt); stObj->width0 = ps->width; diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index f0bf3745b..97bba8b7d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -151,13 +151,11 @@ static void st_DeleteTextureObject(struct gl_context *ctx, struct gl_texture_object *texObj) { - struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(texObj); - if (stObj->pt) - pipe_resource_reference(&stObj->pt, NULL); - if (stObj->sampler_view) { - pipe_sampler_view_release(st->pipe, &stObj->sampler_view); - } + + pipe_resource_reference(&stObj->pt, NULL); + st_texture_release_all_sampler_views(stObj); + st_texture_free_sampler_views(stObj); _mesa_delete_texture_object(ctx, texObj); } @@ -177,6 +175,10 @@ st_FreeTextureImageBuffer(struct gl_context *ctx, _mesa_align_free(stImage->TexData); stImage->TexData = NULL; + + free(stImage->transfer); + stImage->transfer = NULL; + stImage->num_transfers = 0; } @@ -192,6 +194,7 @@ st_MapTextureImage(struct gl_context *ctx, struct st_texture_image *stImage = st_texture_image(texImage); unsigned pipeMode; GLubyte *map; + struct pipe_transfer *transfer; pipeMode = 0x0; if (mode & GL_MAP_READ_BIT) @@ -201,10 +204,11 @@ st_MapTextureImage(struct gl_context *ctx, if (mode & GL_MAP_INVALIDATE_RANGE_BIT) pipeMode |= PIPE_TRANSFER_DISCARD_RANGE; - map = st_texture_image_map(st, stImage, pipeMode, x, y, slice, w, h, 1); + map = st_texture_image_map(st, stImage, pipeMode, x, y, slice, w, h, 1, + &transfer); if (map) { *mapOut = map; - *rowStrideOut = stImage->transfer->stride; + *rowStrideOut = transfer->stride; } else { *mapOut = NULL; @@ -221,7 +225,7 @@ st_UnmapTextureImage(struct gl_context *ctx, { struct st_context *st = st_context(ctx); struct st_texture_image *stImage = st_texture_image(texImage); - st_texture_image_unmap(st, stImage); + st_texture_image_unmap(st, stImage, slice); } @@ -454,7 +458,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, /* The parent texture object does not have space for this image */ pipe_resource_reference(&stObj->pt, NULL); - pipe_sampler_view_release(st->pipe, &stObj->sampler_view); + st_texture_release_all_sampler_views(stObj); if (!guess_and_alloc_texture(st, stObj, stImage)) { /* Probably out of memory. @@ -1146,6 +1150,7 @@ fallback_copy_texsubimage(struct gl_context *ctx, unsigned dst_width = width; unsigned dst_height = height; unsigned dst_depth = 1; + struct pipe_transfer *transfer; if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); @@ -1171,7 +1176,8 @@ fallback_copy_texsubimage(struct gl_context *ctx, texDest = st_texture_image_map(st, stImage, transfer_usage, destX, destY, slice, - dst_width, dst_height, dst_depth); + dst_width, dst_height, dst_depth, + &transfer); if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL) { @@ -1201,13 +1207,11 @@ fallback_copy_texsubimage(struct gl_context *ctx, } if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { - pipe_put_tile_z(stImage->transfer, - texDest + row*stImage->transfer->layer_stride, + pipe_put_tile_z(transfer, texDest + row*transfer->layer_stride, 0, 0, width, 1, data); } else { - pipe_put_tile_z(stImage->transfer, texDest, 0, row, width, 1, - data); + pipe_put_tile_z(transfer, texDest, 0, row, width, 1, data); } } } @@ -1233,10 +1237,10 @@ fallback_copy_texsubimage(struct gl_context *ctx, } if (stImage->pt->target == PIPE_TEXTURE_1D_ARRAY) { - dstRowStride = stImage->transfer->layer_stride; + dstRowStride = transfer->layer_stride; } else { - dstRowStride = stImage->transfer->stride; + dstRowStride = transfer->stride; } /* get float/RGBA image from framebuffer */ @@ -1269,7 +1273,7 @@ fallback_copy_texsubimage(struct gl_context *ctx, free(tempSrc); } - st_texture_image_unmap(st, stImage); + st_texture_image_unmap(st, stImage, slice); pipe->transfer_unmap(pipe, src_trans); } @@ -1487,13 +1491,13 @@ st_finalize_texture(struct gl_context *ctx, if (!st_obj) { pipe_resource_reference(&stObj->pt, NULL); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); + st_texture_release_all_sampler_views(stObj); return GL_TRUE; } if (st_obj->buffer != stObj->pt) { pipe_resource_reference(&stObj->pt, st_obj->buffer); - pipe_sampler_view_release(st->pipe, &stObj->sampler_view); + st_texture_release_all_sampler_views(stObj); stObj->width0 = stObj->pt->width0 / _mesa_get_format_bytes(tObj->_BufferObjectFormat); stObj->height0 = 1; stObj->depth0 = 1; @@ -1514,7 +1518,7 @@ st_finalize_texture(struct gl_context *ctx, firstImage->pt != stObj->pt && (!stObj->pt || firstImage->pt->last_level >= stObj->pt->last_level)) { pipe_resource_reference(&stObj->pt, firstImage->pt); - pipe_sampler_view_release(st->pipe, &stObj->sampler_view); + st_texture_release_all_sampler_views(stObj); } /* If this texture comes from a window system, there is nothing else to do. */ @@ -1561,7 +1565,7 @@ st_finalize_texture(struct gl_context *ctx, * gallium texture now. We'll make a new one below. */ pipe_resource_reference(&stObj->pt, NULL); - pipe_sampler_view_release(st->pipe, &stObj->sampler_view); + st_texture_release_all_sampler_views(stObj); st->dirty.st |= ST_NEW_FRAMEBUFFER; } } diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 807a86fdf..c7f3ec6be 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -152,7 +152,6 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, st_init_bitmap(st); st_init_clear(st); st_init_draw( st ); - st_init_generate_mipmap(st); /* Choose texture target for glDrawPixels, glBitmap, renderbuffers */ if (pipe->screen->get_param(pipe->screen, PIPE_CAP_NPOT_TEXTURES)) @@ -254,7 +253,6 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_atoms( st ); st_destroy_draw( st ); - st_destroy_generate_mipmap(st); st_destroy_clear(st); st_destroy_bitmap(st); st_destroy_drawpix(st); diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index 0e00dd4fa..361a24b1d 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -188,7 +188,6 @@ struct st_context void *passthrough_fs; /**< simple pass-through frag shader */ enum pipe_texture_target internal_target; - struct gen_mipmap_state *gen_mipmap; struct cso_context *cso_context; diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 18ddd4e47..059989342 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -275,6 +275,9 @@ void st_init_limits(struct st_context *st) c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET); c->MaxProgramTextureGatherComponents = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS); + c->MinProgramTextureGatherOffset = screen->get_param(screen, PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET); + c->MaxProgramTextureGatherOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET); + c->UniformBooleanTrue = ~0; c->MaxTransformFeedbackBuffers = @@ -421,7 +424,8 @@ void st_init_extensions(struct st_context *st) { o(OES_standard_derivatives), PIPE_CAP_SM3 }, { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY }, - { o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE } + { o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE }, + { o(ARB_texture_query_lod), PIPE_CAP_TEXTURE_QUERY_LOD } }; /* Required: render target and sampler support */ @@ -728,6 +732,13 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_framebuffer_multisample_blit_scaled = GL_TRUE; } + if (ctx->Const.MaxSamples == 0 && screen->get_param(screen, PIPE_CAP_FAKE_SW_MSAA)) { + ctx->Const.FakeSWMSAA = GL_TRUE; + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; + ctx->Extensions.EXT_framebuffer_multisample_blit_scaled = GL_TRUE; + ctx->Extensions.ARB_texture_multisample = GL_TRUE; + } + if (ctx->Const.MaxDualSourceDrawBuffers > 0 && !st->options.disable_blend_func_extended) ctx->Extensions.ARB_blend_func_extended = GL_TRUE; diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c index b615575b5..18cf504a7 100644 --- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c +++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c @@ -44,64 +44,6 @@ /** - * one-time init for generate mipmap - * XXX Note: there may be other times we need no-op/simple state like this. - * In that case, some code refactoring would be good. - */ -void -st_init_generate_mipmap(struct st_context *st) -{ - st->gen_mipmap = util_create_gen_mipmap(st->pipe, st->cso_context); -} - - -void -st_destroy_generate_mipmap(struct st_context *st) -{ - util_destroy_gen_mipmap(st->gen_mipmap); - st->gen_mipmap = NULL; -} - - -/** - * Generate mipmap levels using hardware rendering. - * \return TRUE if successful, FALSE if not possible - */ -static boolean -st_render_mipmap(struct st_context *st, - GLenum target, - struct st_texture_object *stObj, - uint baseLevel, uint lastLevel) -{ - struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; - struct pipe_sampler_view *psv; - const uint face = _mesa_tex_target_to_face(target); - -#if 0 - assert(target != GL_TEXTURE_3D); /* implemented but untested */ -#endif - - /* check if we can render in the texture's format */ - /* XXX should probably kill this and always use util_gen_mipmap - since this implements a sw fallback as well */ - if (!screen->is_format_supported(screen, stObj->pt->format, - stObj->pt->target, - 0, PIPE_BIND_RENDER_TARGET)) { - return FALSE; - } - - psv = st_create_texture_sampler_view(pipe, stObj->pt); - - util_gen_mipmap(st->gen_mipmap, psv, face, baseLevel, lastLevel, - PIPE_TEX_FILTER_LINEAR); - - pipe_sampler_view_reference(&psv, NULL); - - return TRUE; -} - -/** * Compute the expected number of mipmap levels in the texture given * the width/height/depth of the base image and the GL_TEXTURE_BASE_LEVEL/ * GL_TEXTURE_MAX_LEVEL settings. This will tell us how many mipmap @@ -136,7 +78,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, struct st_texture_object *stObj = st_texture_object(texObj); struct pipe_resource *pt = st_get_texobj_resource(texObj); const uint baseLevel = texObj->BaseLevel; - uint lastLevel; + uint lastLevel, first_layer, last_layer; uint dstLevel; if (!pt) @@ -182,7 +124,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, /* release the old tex (will likely be freed too) */ pipe_resource_reference(&oldTex, NULL); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); + st_texture_release_all_sampler_views(stObj); } else { /* Make sure that the base texture image data is present in the @@ -195,12 +137,19 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, assert(pt->last_level >= lastLevel); + if (pt->target == PIPE_TEXTURE_CUBE) { + first_layer = last_layer = _mesa_tex_target_to_face(target); + } + else { + first_layer = 0; + last_layer = util_max_layer(pt, baseLevel); + } + /* Try to generate the mipmap by rendering/texturing. If that fails, * use the software fallback. */ - if (!st_render_mipmap(st, target, stObj, baseLevel, lastLevel)) { - /* since the util code actually also has a fallback, should - probably make it never fail and kill this */ + if (!util_gen_mipmap(st->pipe, pt, pt->format, baseLevel, lastLevel, + first_layer, last_layer, PIPE_TEX_FILTER_LINEAR)) { _mesa_generate_mipmap(ctx, target, texObj); } diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.h b/mesalib/src/mesa/state_tracker/st_gen_mipmap.h index 64eb39723..4cc208951 100644 --- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.h +++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.h @@ -34,14 +34,6 @@ struct gl_context; struct gl_texture_object; -struct st_context; - -extern void -st_init_generate_mipmap(struct st_context *st); - - -extern void -st_destroy_generate_mipmap(struct st_context *st); extern void 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 f019a55c2..edd0aa765 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2793,7 +2793,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) } break; case ir_lod: - assert(!"Unexpected ir_lod opcode"); + opcode = TGSI_OPCODE_LODQ; break; case ir_query_levels: assert(!"Unexpected ir_query_levels opcode"); @@ -4513,6 +4513,7 @@ compile_tgsi_instruction(struct st_translate *t, case TGSI_OPCODE_TXB2: case TGSI_OPCODE_TXL2: case TGSI_OPCODE_TG4: + case TGSI_OPCODE_LODQ: src[num_src++] = t->samplers[inst->sampler]; for (i = 0; i < inst->tex_offset_num_offset; i++) { texoffsets[i] = translate_tex_offset(t, &inst->tex_offsets[i], i); @@ -5356,8 +5357,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress; - progress = do_common_optimization(ir, true, true, - options->MaxUnrollIterations, options) + progress = do_common_optimization(ir, true, true, options, + ctx->Const.NativeIntegers) || progress; progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress; diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index a3b345356..f664ef5f1 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -40,6 +40,7 @@ #include "util/u_format.h" #include "util/u_rect.h" #include "util/u_math.h" +#include "util/u_memory.h" #define DBG if(0) printf @@ -240,11 +241,13 @@ GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, enum pipe_transfer_usage usage, GLuint x, GLuint y, GLuint z, - GLuint w, GLuint h, GLuint d) + GLuint w, GLuint h, GLuint d, + struct pipe_transfer **transfer) { struct st_texture_object *stObj = st_texture_object(stImage->base.TexObject); GLuint level; + void *map; DBG("%s \n", __FUNCTION__); @@ -256,22 +259,41 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, else level = stImage->base.Level; - return pipe_transfer_map_3d(st->pipe, stImage->pt, level, usage, - x, y, z + stImage->base.Face, - w, h, d, &stImage->transfer); + z += stImage->base.Face; + + map = pipe_transfer_map_3d(st->pipe, stImage->pt, level, usage, + x, y, z, w, h, d, transfer); + if (map) { + /* Enlarge the transfer array if it's not large enough. */ + if (z >= stImage->num_transfers) { + unsigned new_size = z + 1; + + stImage->transfer = realloc(stImage->transfer, + new_size * sizeof(void*)); + memset(&stImage->transfer[stImage->num_transfers], 0, + (new_size - stImage->num_transfers) * sizeof(void*)); + stImage->num_transfers = new_size; + } + + assert(!stImage->transfer[z]); + stImage->transfer[z] = *transfer; + } + return map; } void st_texture_image_unmap(struct st_context *st, - struct st_texture_image *stImage) + struct st_texture_image *stImage, unsigned slice) { struct pipe_context *pipe = st->pipe; + struct pipe_transfer **transfer = + &stImage->transfer[slice + stImage->base.Face]; DBG("%s\n", __FUNCTION__); - pipe_transfer_unmap(pipe, stImage->transfer); - stImage->transfer = NULL; + pipe_transfer_unmap(pipe, *transfer); + *transfer = NULL; } @@ -412,10 +434,85 @@ st_create_color_map_texture(struct gl_context *ctx) return pt; } +/** + * Try to find a matching sampler view for the given context. + * If none is found an empty slot is initialized with a + * template and returned instead. + */ +struct pipe_sampler_view ** +st_texture_get_sampler_view(struct st_context *st, + struct st_texture_object *stObj) +{ + struct pipe_sampler_view **used = NULL, **free = NULL; + GLuint i; + + for (i = 0; i < stObj->num_sampler_views; ++i) { + struct pipe_sampler_view **sv = &stObj->sampler_views[i]; + /* Is the array entry used ? */ + if (*sv) { + /* Yes, check if it's the right one */ + if ((*sv)->context == st->pipe) + return sv; + + /* Wasn't the right one, but remember it as template */ + used = sv; + } else { + /* Found a free slot, remember that */ + free = sv; + } + } + + /* Couldn't find a slot for our context, create a new one */ + + if (!free) { + /* Haven't even found a free one, resize the array */ + GLuint old_size = stObj->num_sampler_views * sizeof(void *); + GLuint new_size = old_size + sizeof(void *); + stObj->sampler_views = REALLOC(stObj->sampler_views, old_size, new_size); + free = &stObj->sampler_views[stObj->num_sampler_views++]; + *free = NULL; + } + + /* Add just any sampler view to be used as a template */ + if (used) + pipe_sampler_view_reference(free, *used); + + return free; +} + void st_texture_release_sampler_view(struct st_context *st, struct st_texture_object *stObj) { - if (stObj->sampler_view && stObj->sampler_view->context == st->pipe) - pipe_sampler_view_reference(&stObj->sampler_view, NULL); + GLuint i; + + for (i = 0; i < stObj->num_sampler_views; ++i) { + struct pipe_sampler_view **sv = &stObj->sampler_views[i]; + + if (*sv && (*sv)->context == st->pipe) { + pipe_sampler_view_reference(sv, NULL); + break; + } + } +} + +void +st_texture_release_all_sampler_views(struct st_texture_object *stObj) +{ + GLuint i; + + for (i = 0; i < stObj->num_sampler_views; ++i) + pipe_sampler_view_reference(&stObj->sampler_views[i], NULL); +} + + +void +st_texture_free_sampler_views(struct st_texture_object *stObj) +{ + /* NOTE: + * We use FREE() here to match REALLOC() above. Both come from + * u_memory.h, not imports.h. If we mis-match MALLOC/FREE from + * those two headers we can trash the heap. + */ + FREE(stObj->sampler_views); } diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index b4a27a00a..affb56812 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -56,7 +56,11 @@ struct st_texture_image */ struct pipe_resource *pt; - struct pipe_transfer *transfer; + /* List of transfers, allocated on demand. + * transfer[layer] is a mapping for that layer. + */ + struct pipe_transfer **transfer; + unsigned num_transfers; }; @@ -82,10 +86,13 @@ struct st_texture_object */ struct pipe_resource *pt; - /* Default sampler view attached to this texture object. Created lazily - * on first binding. + /* Number of views in sampler_views array */ + GLuint num_sampler_views; + + /* Array of sampler views (one per context) attached to this texture + * object. Created lazily on first binding in context. */ - struct pipe_sampler_view *sampler_view; + struct pipe_sampler_view **sampler_views; /* True if this texture comes from the window system. Such a texture * cannot be reallocated and the format can only be changed with a sampler @@ -192,11 +199,12 @@ extern GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, enum pipe_transfer_usage usage, GLuint x, GLuint y, GLuint z, - GLuint w, GLuint h, GLuint d); + GLuint w, GLuint h, GLuint d, + struct pipe_transfer **transfer); extern void st_texture_image_unmap(struct st_context *st, - struct st_texture_image *stImage); + struct st_texture_image *stImage, unsigned slice); /* Return pointers to each 2d slice within an image. Indexed by depth @@ -227,8 +235,18 @@ st_texture_image_copy(struct pipe_context *pipe, extern struct pipe_resource * st_create_color_map_texture(struct gl_context *ctx); +extern struct pipe_sampler_view ** +st_texture_get_sampler_view(struct st_context *st, + struct st_texture_object *stObj); + extern void st_texture_release_sampler_view(struct st_context *st, struct st_texture_object *stObj); +extern void +st_texture_release_all_sampler_views(struct st_texture_object *stObj); + +void +st_texture_free_sampler_views(struct st_texture_object *stObj); + #endif diff --git a/mesalib/src/mesa/state_tracker/st_vdpau.c b/mesalib/src/mesa/state_tracker/st_vdpau.c index c5b4780ce..8c10cdaf3 100644 --- a/mesalib/src/mesa/state_tracker/st_vdpau.c +++ b/mesalib/src/mesa/state_tracker/st_vdpau.c @@ -63,7 +63,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, struct st_texture_image *stImage = st_texture_image(texImage); struct pipe_resource *res; - struct pipe_sampler_view *sv, templ; + struct pipe_sampler_view templ, **sampler_view; mesa_format texFormat; getProcAddr = ctx->vdpGetProcAddress; @@ -83,6 +83,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, } } else { + struct pipe_sampler_view *sv; VdpVideoSurfaceGallium *f; struct pipe_video_buffer *buffer; @@ -138,7 +139,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, texFormat); pipe_resource_reference(&stObj->pt, res); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); + st_texture_release_all_sampler_views(stObj); pipe_resource_reference(&stImage->pt, res); u_sampler_view_default_template(&templ, res, res->format); @@ -148,7 +149,9 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, templ.swizzle_g = GET_SWZ(stObj->base._Swizzle, 1); templ.swizzle_b = GET_SWZ(stObj->base._Swizzle, 2); templ.swizzle_a = GET_SWZ(stObj->base._Swizzle, 3); - stObj->sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ); + + sampler_view = st_texture_get_sampler_view(st, stObj); + *sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ); stObj->width0 = res->width0; stObj->height0 = res->height0; @@ -169,7 +172,7 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, struct st_texture_image *stImage = st_texture_image(texImage); pipe_resource_reference(&stObj->pt, NULL); - pipe_sampler_view_reference(&stObj->sampler_view, NULL); + st_texture_release_all_sampler_views(stObj); pipe_resource_reference(&stImage->pt, NULL); _mesa_dirty_texobj(ctx, texObj); diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c index cd0982705..90a514c16 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.c +++ b/mesalib/src/mesa/swrast/s_texfetch.c @@ -129,9 +129,24 @@ static void fetch_null_texelf( const struct swrast_texture_image *texImage, } +#define FETCH_FUNCS(NAME) \ + { \ + MESA_FORMAT_ ## NAME, \ + fetch_texel_1d_ ## NAME, \ + fetch_texel_2d_ ## NAME, \ + fetch_texel_3d_ ## NAME, \ + } + +#define FETCH_NULL(NAME) \ + { \ + MESA_FORMAT_ ## NAME, \ + NULL, \ + NULL, \ + NULL \ + } + /** * Table to map MESA_FORMAT_ to texel fetch/store funcs. - * XXX this is somewhat temporary. */ static struct { mesa_format Name; @@ -149,978 +164,198 @@ texfetch_funcs[] = }, /* Packed unorm formats */ - { - MESA_FORMAT_A8B8G8R8_UNORM, - fetch_texel_1d_f_rgba8888, - fetch_texel_2d_f_rgba8888, - fetch_texel_3d_f_rgba8888 - }, - { - MESA_FORMAT_X8B8G8R8_UNORM, - fetch_texel_1d_f_rgbx8888, - fetch_texel_2d_f_rgbx8888, - fetch_texel_3d_f_rgbx8888 - }, - { - MESA_FORMAT_R8G8B8A8_UNORM, - fetch_texel_1d_f_rgba8888_rev, - fetch_texel_2d_f_rgba8888_rev, - fetch_texel_3d_f_rgba8888_rev - }, - { - MESA_FORMAT_R8G8B8X8_UNORM, - fetch_texel_1d_f_rgbx8888_rev, - fetch_texel_2d_f_rgbx8888_rev, - fetch_texel_3d_f_rgbx8888_rev - }, - { - MESA_FORMAT_B8G8R8A8_UNORM, - fetch_texel_1d_f_argb8888, - fetch_texel_2d_f_argb8888, - fetch_texel_3d_f_argb8888 - }, - { - MESA_FORMAT_B8G8R8X8_UNORM, - fetch_texel_1d_f_xrgb8888, - fetch_texel_2d_f_xrgb8888, - fetch_texel_3d_f_xrgb8888 - }, - { - MESA_FORMAT_A8R8G8B8_UNORM, - fetch_texel_1d_f_argb8888_rev, - fetch_texel_2d_f_argb8888_rev, - fetch_texel_3d_f_argb8888_rev - }, - { - MESA_FORMAT_X8R8G8B8_UNORM, - fetch_texel_1d_f_xrgb8888_rev, - fetch_texel_2d_f_xrgb8888_rev, - fetch_texel_3d_f_xrgb8888_rev - }, - { - MESA_FORMAT_L16A16_UNORM, - fetch_texel_1d_f_al1616, - fetch_texel_2d_f_al1616, - fetch_texel_3d_f_al1616 - }, - { - MESA_FORMAT_A16L16_UNORM, - fetch_texel_1d_f_al1616_rev, - fetch_texel_2d_f_al1616_rev, - fetch_texel_3d_f_al1616_rev - }, - { - MESA_FORMAT_B5G6R5_UNORM, - fetch_texel_1d_f_rgb565, - fetch_texel_2d_f_rgb565, - fetch_texel_3d_f_rgb565 - }, - { - MESA_FORMAT_R5G6B5_UNORM, - fetch_texel_1d_f_rgb565_rev, - fetch_texel_2d_f_rgb565_rev, - fetch_texel_3d_f_rgb565_rev - }, - { - MESA_FORMAT_B4G4R4A4_UNORM, - fetch_texel_1d_f_argb4444, - fetch_texel_2d_f_argb4444, - fetch_texel_3d_f_argb4444 - }, - { - MESA_FORMAT_B4G4R4X4_UNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A4R4G4B4_UNORM, - fetch_texel_1d_f_argb4444_rev, - fetch_texel_2d_f_argb4444_rev, - fetch_texel_3d_f_argb4444_rev - }, - { - MESA_FORMAT_A1B5G5R5_UNORM, - fetch_texel_1d_f_rgba5551, - fetch_texel_2d_f_rgba5551, - fetch_texel_3d_f_rgba5551 - }, - { - MESA_FORMAT_B5G5R5A1_UNORM, - fetch_texel_1d_f_argb1555, - fetch_texel_2d_f_argb1555, - fetch_texel_3d_f_argb1555 - }, - { - MESA_FORMAT_B5G5R5X1_UNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A1R5G5B5_UNORM, - fetch_texel_1d_f_argb1555_rev, - fetch_texel_2d_f_argb1555_rev, - fetch_texel_3d_f_argb1555_rev - }, - { - MESA_FORMAT_L8A8_UNORM, - fetch_texel_1d_f_al88, - fetch_texel_2d_f_al88, - fetch_texel_3d_f_al88 - }, - { - MESA_FORMAT_A8L8_UNORM, - fetch_texel_1d_f_al88_rev, - fetch_texel_2d_f_al88_rev, - fetch_texel_3d_f_al88_rev - }, - { - MESA_FORMAT_R8G8_UNORM, - fetch_texel_1d_f_gr88, - fetch_texel_2d_f_gr88, - fetch_texel_3d_f_gr88 - }, - { - MESA_FORMAT_G8R8_UNORM, - fetch_texel_1d_f_rg88, - fetch_texel_2d_f_rg88, - fetch_texel_3d_f_rg88 - }, - { - MESA_FORMAT_L4A4_UNORM, - fetch_texel_1d_f_al44, - fetch_texel_2d_f_al44, - fetch_texel_3d_f_al44 - }, - { - MESA_FORMAT_B2G3R3_UNORM, - fetch_texel_1d_f_rgb332, - fetch_texel_2d_f_rgb332, - fetch_texel_3d_f_rgb332 - }, - { - MESA_FORMAT_R16G16_UNORM, - fetch_texel_1d_f_rg1616, - fetch_texel_2d_f_rg1616, - fetch_texel_3d_f_rg1616 - }, - { - MESA_FORMAT_G16R16_UNORM, - fetch_texel_1d_f_rg1616_rev, - fetch_texel_2d_f_rg1616_rev, - fetch_texel_3d_f_rg1616_rev - }, - { - MESA_FORMAT_B10G10R10A2_UNORM, - fetch_texel_1d_f_argb2101010, - fetch_texel_2d_f_argb2101010, - fetch_texel_3d_f_argb2101010 - }, - { - MESA_FORMAT_B10G10R10X2_UNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R10G10B10A2_UNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_S8_UINT_Z24_UNORM, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8 - }, + FETCH_FUNCS(A8B8G8R8_UNORM), + FETCH_FUNCS(X8B8G8R8_UNORM), + FETCH_FUNCS(R8G8B8A8_UNORM), + FETCH_FUNCS(R8G8B8X8_UNORM), + FETCH_FUNCS(B8G8R8A8_UNORM), + FETCH_FUNCS(B8G8R8X8_UNORM), + FETCH_FUNCS(A8R8G8B8_UNORM), + FETCH_FUNCS(X8R8G8B8_UNORM), + FETCH_FUNCS(L16A16_UNORM), + FETCH_FUNCS(A16L16_UNORM), + FETCH_FUNCS(B5G6R5_UNORM), + FETCH_FUNCS(R5G6B5_UNORM), + FETCH_FUNCS(B4G4R4A4_UNORM), + FETCH_NULL(B4G4R4X4_UNORM), + FETCH_FUNCS(A4R4G4B4_UNORM), + FETCH_FUNCS(A1B5G5R5_UNORM), + FETCH_FUNCS(B5G5R5A1_UNORM), + FETCH_NULL(B5G5R5X1_UNORM), + FETCH_FUNCS(A1R5G5B5_UNORM), + FETCH_FUNCS(L8A8_UNORM), + FETCH_FUNCS(A8L8_UNORM), + FETCH_FUNCS(R8G8_UNORM), + FETCH_FUNCS(G8R8_UNORM), + FETCH_FUNCS(L4A4_UNORM), + FETCH_FUNCS(B2G3R3_UNORM), + FETCH_FUNCS(R16G16_UNORM), + FETCH_FUNCS(G16R16_UNORM), + FETCH_FUNCS(B10G10R10A2_UNORM), + FETCH_NULL(B10G10R10X2_UNORM), + FETCH_FUNCS(R10G10B10A2_UNORM), + FETCH_FUNCS(S8_UINT_Z24_UNORM), { MESA_FORMAT_X8_UINT_Z24_UNORM, - fetch_texel_1d_f_z24_s8, - fetch_texel_2d_f_z24_s8, - fetch_texel_3d_f_z24_s8 - }, - { - MESA_FORMAT_Z24_UNORM_S8_UINT, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24 + fetch_texel_1d_S8_UINT_Z24_UNORM, + fetch_texel_2d_S8_UINT_Z24_UNORM, + fetch_texel_3d_S8_UINT_Z24_UNORM }, + FETCH_FUNCS(Z24_UNORM_S8_UINT), { MESA_FORMAT_Z24_UNORM_X8_UINT, - fetch_texel_1d_f_s8_z24, - fetch_texel_2d_f_s8_z24, - fetch_texel_3d_f_s8_z24 - }, - { - MESA_FORMAT_YCBCR, - fetch_texel_1d_f_ycbcr, - fetch_texel_2d_f_ycbcr, - fetch_texel_3d_f_ycbcr - }, - { - MESA_FORMAT_YCBCR_REV, - fetch_texel_1d_f_ycbcr_rev, - fetch_texel_2d_f_ycbcr_rev, - fetch_texel_3d_f_ycbcr_rev - }, - { - MESA_FORMAT_DUDV8, - fetch_texel_1d_dudv8, - fetch_texel_2d_dudv8, - fetch_texel_3d_dudv8 + fetch_texel_1d_Z24_UNORM_S8_UINT, + fetch_texel_2d_Z24_UNORM_S8_UINT, + fetch_texel_3d_Z24_UNORM_S8_UINT }, + FETCH_FUNCS(YCBCR), + FETCH_FUNCS(YCBCR_REV), + FETCH_FUNCS(DUDV8), /* Array unorm formats */ - { - MESA_FORMAT_A_UNORM8, - fetch_texel_1d_f_a8, - fetch_texel_2d_f_a8, - fetch_texel_3d_f_a8 - }, - { - MESA_FORMAT_A_UNORM16, - fetch_texel_1d_f_a16, - fetch_texel_2d_f_a16, - fetch_texel_3d_f_a16 - }, - { - MESA_FORMAT_L_UNORM8, - fetch_texel_1d_f_l8, - fetch_texel_2d_f_l8, - fetch_texel_3d_f_l8 - }, - { - MESA_FORMAT_L_UNORM16, - fetch_texel_1d_f_l16, - fetch_texel_2d_f_l16, - fetch_texel_3d_f_l16 - }, - { - MESA_FORMAT_I_UNORM8, - fetch_texel_1d_f_i8, - fetch_texel_2d_f_i8, - fetch_texel_3d_f_i8 - }, - { - MESA_FORMAT_I_UNORM16, - fetch_texel_1d_f_i16, - fetch_texel_2d_f_i16, - fetch_texel_3d_f_i16 - }, - { - MESA_FORMAT_R_UNORM8, - fetch_texel_1d_f_r8, - fetch_texel_2d_f_r8, - fetch_texel_3d_f_r8 - }, - { - MESA_FORMAT_R_UNORM16, - fetch_texel_1d_f_r16, - fetch_texel_2d_f_r16, - fetch_texel_3d_f_r16 - }, - { - MESA_FORMAT_BGR_UNORM8, - fetch_texel_1d_f_rgb888, - fetch_texel_2d_f_rgb888, - fetch_texel_3d_f_rgb888 - }, - { - MESA_FORMAT_RGB_UNORM8, - fetch_texel_1d_f_bgr888, - fetch_texel_2d_f_bgr888, - fetch_texel_3d_f_bgr888 - }, - { - MESA_FORMAT_RGBA_UNORM16, - fetch_texel_1d_rgba_16, - fetch_texel_2d_rgba_16, - fetch_texel_3d_rgba_16 - }, - { - MESA_FORMAT_RGBX_UNORM16, - fetch_texel_1d_xbgr16161616_unorm, - fetch_texel_2d_xbgr16161616_unorm, - fetch_texel_3d_xbgr16161616_unorm - }, - { - MESA_FORMAT_Z_UNORM16, - fetch_texel_1d_f_z16, - fetch_texel_2d_f_z16, - fetch_texel_3d_f_z16 - }, - { - MESA_FORMAT_Z_UNORM32, - fetch_texel_1d_f_z32, - fetch_texel_2d_f_z32, - fetch_texel_3d_f_z32 - }, - { - MESA_FORMAT_S_UINT8, - NULL, - NULL, - NULL - }, + FETCH_FUNCS(A_UNORM8), + FETCH_FUNCS(A_UNORM16), + FETCH_FUNCS(L_UNORM8), + FETCH_FUNCS(L_UNORM16), + FETCH_FUNCS(I_UNORM8), + FETCH_FUNCS(I_UNORM16), + FETCH_FUNCS(R_UNORM8), + FETCH_FUNCS(R_UNORM16), + FETCH_FUNCS(BGR_UNORM8), + FETCH_FUNCS(RGB_UNORM8), + FETCH_FUNCS(RGBA_UNORM16), + FETCH_FUNCS(RGBX_UNORM16), + FETCH_FUNCS(Z_UNORM16), + FETCH_FUNCS(Z_UNORM32), + FETCH_NULL(S_UINT8), /* Packed signed/normalized formats */ - { - MESA_FORMAT_A8B8G8R8_SNORM, - fetch_texel_1d_signed_rgba8888, - fetch_texel_2d_signed_rgba8888, - fetch_texel_3d_signed_rgba8888 - }, - { - MESA_FORMAT_X8B8G8R8_SNORM, - fetch_texel_1d_signed_rgbx8888, - fetch_texel_2d_signed_rgbx8888, - fetch_texel_3d_signed_rgbx8888 - }, - { - MESA_FORMAT_R8G8B8A8_SNORM, - fetch_texel_1d_signed_rgba8888_rev, - fetch_texel_2d_signed_rgba8888_rev, - fetch_texel_3d_signed_rgba8888_rev - }, - { - MESA_FORMAT_R8G8B8X8_SNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R16G16_SNORM, - fetch_texel_1d_signed_rg1616, - fetch_texel_2d_signed_rg1616, - fetch_texel_3d_signed_rg1616 - }, - { - MESA_FORMAT_G16R16_SNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R8G8_SNORM, - fetch_texel_1d_signed_rg88_rev, - fetch_texel_2d_signed_rg88_rev, - fetch_texel_3d_signed_rg88_rev - }, - { - MESA_FORMAT_G8R8_SNORM, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L8A8_SNORM, - fetch_texel_1d_signed_al88, - fetch_texel_2d_signed_al88, - fetch_texel_3d_signed_al88 - }, + FETCH_FUNCS(A8B8G8R8_SNORM), + FETCH_FUNCS(X8B8G8R8_SNORM), + FETCH_FUNCS(R8G8B8A8_SNORM), + FETCH_NULL(R8G8B8X8_SNORM), + FETCH_FUNCS(R16G16_SNORM), + FETCH_NULL(G16R16_SNORM), + FETCH_FUNCS(R8G8_SNORM), + FETCH_NULL(G8R8_SNORM), + FETCH_FUNCS(L8A8_SNORM), /* Array signed/normalized formats */ - { - MESA_FORMAT_A_SNORM8, - fetch_texel_1d_signed_a8, - fetch_texel_2d_signed_a8, - fetch_texel_3d_signed_a8 - }, - { - MESA_FORMAT_A_SNORM16, - fetch_texel_1d_signed_a16, - fetch_texel_2d_signed_a16, - fetch_texel_3d_signed_a16 - }, - { - MESA_FORMAT_L_SNORM8, - fetch_texel_1d_signed_l8, - fetch_texel_2d_signed_l8, - fetch_texel_3d_signed_l8 - }, - { - MESA_FORMAT_L_SNORM16, - fetch_texel_1d_signed_l16, - fetch_texel_2d_signed_l16, - fetch_texel_3d_signed_l16 - }, - { - MESA_FORMAT_I_SNORM8, - fetch_texel_1d_signed_i8, - fetch_texel_2d_signed_i8, - fetch_texel_3d_signed_i8 - }, - { - MESA_FORMAT_I_SNORM16, - fetch_texel_1d_signed_i16, - fetch_texel_2d_signed_i16, - fetch_texel_3d_signed_i16 - }, - { - MESA_FORMAT_R_SNORM8, - fetch_texel_1d_signed_r8, - fetch_texel_2d_signed_r8, - fetch_texel_3d_signed_r8 - }, - { - MESA_FORMAT_R_SNORM16, - fetch_texel_1d_signed_r16, - fetch_texel_2d_signed_r16, - fetch_texel_3d_signed_r16 - }, - { - MESA_FORMAT_LA_SNORM16, - fetch_texel_1d_signed_al1616, - fetch_texel_2d_signed_al1616, - fetch_texel_3d_signed_al1616 - }, - { - MESA_FORMAT_RGB_SNORM16, - fetch_texel_1d_signed_rgb_16, - fetch_texel_2d_signed_rgb_16, - fetch_texel_3d_signed_rgb_16 - }, - { - MESA_FORMAT_RGBA_SNORM16, - fetch_texel_1d_signed_rgba_16, - fetch_texel_2d_signed_rgba_16, - fetch_texel_3d_signed_rgba_16 - }, - { - MESA_FORMAT_RGBX_SNORM16, - NULL, - NULL, - NULL - }, + FETCH_FUNCS(A_SNORM8), + FETCH_FUNCS(A_SNORM16), + FETCH_FUNCS(L_SNORM8), + FETCH_FUNCS(L_SNORM16), + FETCH_FUNCS(I_SNORM8), + FETCH_FUNCS(I_SNORM16), + FETCH_FUNCS(R_SNORM8), + FETCH_FUNCS(R_SNORM16), + FETCH_FUNCS(LA_SNORM16), + FETCH_FUNCS(RGB_SNORM16), + FETCH_FUNCS(RGBA_SNORM16), + FETCH_NULL(RGBX_SNORM16), /* Packed sRGB formats */ - { - MESA_FORMAT_A8B8G8R8_SRGB, - fetch_texel_1d_srgba8, - fetch_texel_2d_srgba8, - fetch_texel_3d_srgba8 - }, - { - MESA_FORMAT_B8G8R8A8_SRGB, - fetch_texel_1d_sargb8, - fetch_texel_2d_sargb8, - fetch_texel_3d_sargb8 - }, - { - MESA_FORMAT_B8G8R8X8_SRGB, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R8G8B8A8_SRGB, - fetch_texel_1d_sabgr8, - fetch_texel_2d_sabgr8, - fetch_texel_3d_sabgr8 - }, - { - MESA_FORMAT_R8G8B8X8_SRGB, - fetch_texel_1d_sxbgr8, - fetch_texel_2d_sxbgr8, - fetch_texel_3d_sxbgr8 - }, - { - MESA_FORMAT_L8A8_SRGB, - fetch_texel_1d_sla8, - fetch_texel_2d_sla8, - fetch_texel_3d_sla8 - }, + FETCH_FUNCS(A8B8G8R8_SRGB), + FETCH_FUNCS(B8G8R8A8_SRGB), + FETCH_NULL(B8G8R8X8_SRGB), + FETCH_FUNCS(R8G8B8A8_SRGB), + FETCH_FUNCS(R8G8B8X8_SRGB), + FETCH_FUNCS(L8A8_SRGB), /* Array sRGB formats */ - { - MESA_FORMAT_L_SRGB8, - fetch_texel_1d_sl8, - fetch_texel_2d_sl8, - fetch_texel_3d_sl8 - }, - { - MESA_FORMAT_BGR_SRGB8, - fetch_texel_1d_srgb8, - fetch_texel_2d_srgb8, - fetch_texel_3d_srgb8 - }, + FETCH_FUNCS(L_SRGB8), + FETCH_FUNCS(BGR_SRGB8), /* Packed float formats */ - { - MESA_FORMAT_R9G9B9E5_FLOAT, - fetch_texel_1d_rgb9_e5, - fetch_texel_2d_rgb9_e5, - fetch_texel_3d_rgb9_e5 - }, - { - MESA_FORMAT_R11G11B10_FLOAT, - fetch_texel_1d_r11_g11_b10f, - fetch_texel_2d_r11_g11_b10f, - fetch_texel_3d_r11_g11_b10f - }, - { - MESA_FORMAT_Z32_FLOAT_S8X24_UINT, - fetch_texel_1d_z32f_x24s8, - fetch_texel_2d_z32f_x24s8, - fetch_texel_3d_z32f_x24s8 - }, + FETCH_FUNCS(R9G9B9E5_FLOAT), + FETCH_FUNCS(R11G11B10_FLOAT), + FETCH_FUNCS(Z32_FLOAT_S8X24_UINT), /* Array float formats */ - { - MESA_FORMAT_A_FLOAT16, - fetch_texel_1d_f_alpha_f16, - fetch_texel_2d_f_alpha_f16, - fetch_texel_3d_f_alpha_f16 - }, - { - MESA_FORMAT_A_FLOAT32, - fetch_texel_1d_f_alpha_f32, - fetch_texel_2d_f_alpha_f32, - fetch_texel_3d_f_alpha_f32 - }, - { - MESA_FORMAT_L_FLOAT16, - fetch_texel_1d_f_luminance_f16, - fetch_texel_2d_f_luminance_f16, - fetch_texel_3d_f_luminance_f16 - }, - { - MESA_FORMAT_L_FLOAT32, - fetch_texel_1d_f_luminance_f32, - fetch_texel_2d_f_luminance_f32, - fetch_texel_3d_f_luminance_f32 - }, - { - MESA_FORMAT_LA_FLOAT16, - fetch_texel_1d_f_luminance_alpha_f16, - fetch_texel_2d_f_luminance_alpha_f16, - fetch_texel_3d_f_luminance_alpha_f16 - }, - { - MESA_FORMAT_LA_FLOAT32, - fetch_texel_1d_f_luminance_alpha_f32, - fetch_texel_2d_f_luminance_alpha_f32, - fetch_texel_3d_f_luminance_alpha_f32 - }, - { - MESA_FORMAT_I_FLOAT16, - fetch_texel_1d_f_intensity_f16, - fetch_texel_2d_f_intensity_f16, - fetch_texel_3d_f_intensity_f16 - }, - { - MESA_FORMAT_I_FLOAT32, - fetch_texel_1d_f_intensity_f32, - fetch_texel_2d_f_intensity_f32, - fetch_texel_3d_f_intensity_f32 - }, - { - MESA_FORMAT_R_FLOAT16, - fetch_texel_1d_f_r_f16, - fetch_texel_2d_f_r_f16, - fetch_texel_3d_f_r_f16 - }, - { - MESA_FORMAT_R_FLOAT32, - fetch_texel_1d_f_r_f32, - fetch_texel_2d_f_r_f32, - fetch_texel_3d_f_r_f32 - }, - { - MESA_FORMAT_RG_FLOAT16, - fetch_texel_1d_f_rg_f16, - fetch_texel_2d_f_rg_f16, - fetch_texel_3d_f_rg_f16 - }, - { - MESA_FORMAT_RG_FLOAT32, - fetch_texel_1d_f_rg_f32, - fetch_texel_2d_f_rg_f32, - fetch_texel_3d_f_rg_f32 - }, - { - MESA_FORMAT_RGB_FLOAT16, - fetch_texel_1d_f_rgb_f16, - fetch_texel_2d_f_rgb_f16, - fetch_texel_3d_f_rgb_f16 - }, - { - MESA_FORMAT_RGB_FLOAT32, - fetch_texel_1d_f_rgb_f32, - fetch_texel_2d_f_rgb_f32, - fetch_texel_3d_f_rgb_f32 - }, - { - MESA_FORMAT_RGBA_FLOAT16, - fetch_texel_1d_f_rgba_f16, - fetch_texel_2d_f_rgba_f16, - fetch_texel_3d_f_rgba_f16 - }, - { - MESA_FORMAT_RGBA_FLOAT32, - fetch_texel_1d_f_rgba_f32, - fetch_texel_2d_f_rgba_f32, - fetch_texel_3d_f_rgba_f32 - }, - { - MESA_FORMAT_RGBX_FLOAT16, - fetch_texel_1d_xbgr16161616_float, - fetch_texel_2d_xbgr16161616_float, - fetch_texel_3d_xbgr16161616_float - }, - { - MESA_FORMAT_RGBX_FLOAT32, - fetch_texel_1d_xbgr32323232_float, - fetch_texel_2d_xbgr32323232_float, - fetch_texel_3d_xbgr32323232_float - }, + FETCH_FUNCS(A_FLOAT16), + FETCH_FUNCS(A_FLOAT32), + FETCH_FUNCS(L_FLOAT16), + FETCH_FUNCS(L_FLOAT32), + FETCH_FUNCS(LA_FLOAT16), + FETCH_FUNCS(LA_FLOAT32), + FETCH_FUNCS(I_FLOAT16), + FETCH_FUNCS(I_FLOAT32), + FETCH_FUNCS(R_FLOAT16), + FETCH_FUNCS(R_FLOAT32), + FETCH_FUNCS(RG_FLOAT16), + FETCH_FUNCS(RG_FLOAT32), + FETCH_FUNCS(RGB_FLOAT16), + FETCH_FUNCS(RGB_FLOAT32), + FETCH_FUNCS(RGBA_FLOAT16), + FETCH_FUNCS(RGBA_FLOAT32), + FETCH_FUNCS(RGBX_FLOAT16), + FETCH_FUNCS(RGBX_FLOAT32), { MESA_FORMAT_Z_FLOAT32, - fetch_texel_1d_f_r_f32, /* Reuse the R32F functions. */ - fetch_texel_2d_f_r_f32, - fetch_texel_3d_f_r_f32 + fetch_texel_1d_R_FLOAT32, /* Reuse the R32F functions. */ + fetch_texel_2d_R_FLOAT32, + fetch_texel_3d_R_FLOAT32 }, /* Packed signed/unsigned non-normalized integer formats */ - { - MESA_FORMAT_B10G10R10A2_UINT, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R10G10B10A2_UINT, - NULL, - NULL, - NULL - }, + FETCH_NULL(B10G10R10A2_UINT), + FETCH_NULL(R10G10B10A2_UINT), /* Array signed/unsigned non-normalized integer formats */ - { - MESA_FORMAT_A_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_A_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_I_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_I_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_I_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_I_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_I_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_I_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_L_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_LA_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_LA_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_LA_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_LA_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_LA_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_LA_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_R_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RG_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RG_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RG_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RG_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RG_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RG_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGB_SINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBA_UINT8, - fetch_texel_1d_rgba_uint8, - fetch_texel_2d_rgba_uint8, - fetch_texel_3d_rgba_uint8 - }, - { - MESA_FORMAT_RGBA_UINT16, - fetch_texel_1d_rgba_uint16, - fetch_texel_2d_rgba_uint16, - fetch_texel_3d_rgba_uint16 - }, - { - MESA_FORMAT_RGBA_UINT32, - fetch_texel_1d_rgba_uint32, - fetch_texel_2d_rgba_uint32, - fetch_texel_3d_rgba_uint32 - }, - { - MESA_FORMAT_RGBA_SINT8, - fetch_texel_1d_rgba_int8, - fetch_texel_2d_rgba_int8, - fetch_texel_3d_rgba_int8 - }, - { - MESA_FORMAT_RGBA_SINT16, - fetch_texel_1d_rgba_int16, - fetch_texel_2d_rgba_int16, - fetch_texel_3d_rgba_int16 - }, - { - MESA_FORMAT_RGBA_SINT32, - fetch_texel_1d_rgba_int32, - fetch_texel_2d_rgba_int32, - fetch_texel_3d_rgba_int32 - }, - { - MESA_FORMAT_RGBX_UINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBX_UINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBX_UINT32, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBX_SINT8, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBX_SINT16, - NULL, - NULL, - NULL - }, - { - MESA_FORMAT_RGBX_SINT32, - NULL, - NULL, - NULL - }, + FETCH_NULL(A_UINT8), + FETCH_NULL(A_UINT16), + FETCH_NULL(A_UINT32), + FETCH_NULL(A_SINT8), + FETCH_NULL(A_SINT16), + FETCH_NULL(A_SINT32), + FETCH_NULL(I_UINT8), + FETCH_NULL(I_UINT16), + FETCH_NULL(I_UINT32), + FETCH_NULL(I_SINT8), + FETCH_NULL(I_SINT16), + FETCH_NULL(I_SINT32), + FETCH_NULL(L_UINT8), + FETCH_NULL(L_UINT16), + FETCH_NULL(L_UINT32), + FETCH_NULL(L_SINT8), + FETCH_NULL(L_SINT16), + FETCH_NULL(L_SINT32), + FETCH_NULL(LA_UINT8), + FETCH_NULL(LA_UINT16), + FETCH_NULL(LA_UINT32), + FETCH_NULL(LA_SINT8), + FETCH_NULL(LA_SINT16), + FETCH_NULL(LA_SINT32), + FETCH_NULL(R_UINT8), + FETCH_NULL(R_UINT16), + FETCH_NULL(R_UINT32), + FETCH_NULL(R_SINT8), + FETCH_NULL(R_SINT16), + FETCH_NULL(R_SINT32), + FETCH_NULL(RG_UINT8), + FETCH_NULL(RG_UINT16), + FETCH_NULL(RG_UINT32), + FETCH_NULL(RG_SINT8), + FETCH_NULL(RG_SINT16), + FETCH_NULL(RG_SINT32), + FETCH_NULL(RGB_UINT8), + FETCH_NULL(RGB_UINT16), + FETCH_NULL(RGB_UINT32), + FETCH_NULL(RGB_SINT8), + FETCH_NULL(RGB_SINT16), + FETCH_NULL(RGB_SINT32), + FETCH_FUNCS(RGBA_UINT8), + FETCH_FUNCS(RGBA_UINT16), + FETCH_FUNCS(RGBA_UINT32), + FETCH_FUNCS(RGBA_SINT8), + FETCH_FUNCS(RGBA_SINT16), + FETCH_FUNCS(RGBA_SINT32), + FETCH_NULL(RGBX_UINT8), + FETCH_NULL(RGBX_UINT16), + FETCH_NULL(RGBX_UINT32), + FETCH_NULL(RGBX_SINT8), + FETCH_NULL(RGBX_SINT16), + FETCH_NULL(RGBX_SINT32), /* DXT compressed formats */ { diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h index f749b491f..d48e39bfd 100644 --- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h +++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h @@ -27,14 +27,14 @@ /** * \file texfetch_tmp.h * Texel fetch functions template. - * + * * This template file is used by texfetch.c to generate texel fetch functions - * for 1-D, 2-D and 3-D texture images. + * for 1-D, 2-D and 3-D texture images. * * It should be expanded by defining \p DIM as the number texture dimensions * (1, 2 or 3). According to the value of \p DIM a series of macros is defined * for the texel lookup in the gl_texture_image::Data. - * + * * \author Gareth Hughes * \author Brian Paul */ @@ -69,41 +69,27 @@ #endif -/* MESA_FORMAT_Z_UNORM32 ***********************************************************/ - -/* Fetch depth texel from 1D, 2D or 3D 32-bit depth texture, - * returning 1 GLfloat. - * Note: no GLchan version of this function. - */ -static void FETCH(f_z32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(Z_UNORM32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); texel[0] = src[0] * (1.0F / 0xffffffff); } -/* MESA_FORMAT_Z_UNORM16 ***********************************************************/ - -/* Fetch depth texel from 1D, 2D or 3D 16-bit depth texture, - * returning 1 GLfloat. - * Note: no GLchan version of this function. - */ -static void FETCH(f_z16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(Z_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[0] = src[0] * (1.0F / 65535.0F); } - -/* MESA_FORMAT_RGBA_F32 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats. - */ -static void FETCH(f_rgba_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RGBA_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); texel[RCOMP] = src[0]; @@ -113,15 +99,9 @@ static void FETCH(f_rgba_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_F16 ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rgba_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RGBA_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); texel[RCOMP] = _mesa_half_to_float(src[0]); @@ -131,14 +111,9 @@ static void FETCH(f_rgba_f16)( const struct swrast_texture_image *texImage, } - -/* MESA_FORMAT_RGB_F32 *******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rgb_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RGB_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3); texel[RCOMP] = src[0]; @@ -148,15 +123,9 @@ static void FETCH(f_rgb_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGB_F16 *******************************************************/ - -/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rgb_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RGB_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3); texel[RCOMP] = _mesa_half_to_float(src[0]); @@ -166,15 +135,9 @@ static void FETCH(f_rgb_f16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_ALPHA_F32 *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_alpha_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); texel[RCOMP] = @@ -184,15 +147,9 @@ static void FETCH(f_alpha_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_ALPHA_F32 *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_alpha_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); texel[RCOMP] = @@ -202,15 +159,9 @@ static void FETCH(f_alpha_f16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_LUMINANCE_F32 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); texel[RCOMP] = @@ -220,15 +171,9 @@ static void FETCH(f_luminance_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_LUMINANCE_F16 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); texel[RCOMP] = @@ -238,15 +183,9 @@ static void FETCH(f_luminance_f16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_alpha_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(LA_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); texel[RCOMP] = @@ -256,15 +195,9 @@ static void FETCH(f_luminance_alpha_f32)( const struct swrast_texture_image *tex } - - -/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/ - -/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_luminance_alpha_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(LA_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); texel[RCOMP] = @@ -274,15 +207,9 @@ static void FETCH(f_luminance_alpha_f16)( const struct swrast_texture_image *tex } - - -/* MESA_FORMAT_INTENSITY_F32 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_intensity_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(I_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); texel[RCOMP] = @@ -292,15 +219,9 @@ static void FETCH(f_intensity_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_INTENSITY_F16 *************************************************/ - -/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_intensity_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(I_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); texel[RCOMP] = @@ -310,15 +231,9 @@ static void FETCH(f_intensity_f16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_R_FLOAT32 *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D R_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_r_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1); texel[RCOMP] = src[0]; @@ -328,15 +243,9 @@ static void FETCH(f_r_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_R_FLOAT16 *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D R_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_r_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1); texel[RCOMP] = _mesa_half_to_float(src[0]); @@ -346,15 +255,9 @@ static void FETCH(f_r_f16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RG_FLOAT32 ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D RG_FLOAT32 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rg_f32)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RG_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); texel[RCOMP] = src[0]; @@ -364,15 +267,9 @@ static void FETCH(f_rg_f32)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RG_FLOAT16 ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D RG_FLOAT16 texture, - * returning 4 GLfloats. - */ -static void FETCH(f_rg_f16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RG_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2); texel[RCOMP] = _mesa_half_to_float(src[0]); @@ -382,17 +279,9 @@ static void FETCH(f_rg_f16)( const struct swrast_texture_image *texImage, } - - -/* - * Begin Hardware formats - */ - -/* MESA_FORMAT_A8B8G8R8_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ -static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A8B8G8R8_UNORM)(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] = UBYTE_TO_FLOAT( (s >> 24) ); @@ -402,15 +291,9 @@ static void FETCH(f_rgba8888)( const struct swrast_texture_image *texImage, } - - - - -/* MESA_FORMAT_RGBA888_REV ***************************************************/ - -/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ -static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8B8A8_UNORM)(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] = UBYTE_TO_FLOAT( (s ) & 0xff ); @@ -420,13 +303,9 @@ static void FETCH(f_rgba8888_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_B8G8R8A8_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ -static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B8G8R8A8_UNORM)(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] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); @@ -436,13 +315,9 @@ static void FETCH(f_argb8888)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A8R8G8B8_UNORM **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */ -static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A8R8G8B8_UNORM)(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] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); @@ -452,13 +327,9 @@ static void FETCH(f_argb8888_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_X8B8G8R8_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgbx8888 texture, return 4 GLfloats */ -static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(X8B8G8R8_UNORM)(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] = UBYTE_TO_FLOAT( (s >> 24) ); @@ -468,13 +339,9 @@ static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBX888_REV ***************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgbx8888_rev texture, return 4 GLchans */ -static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8B8X8_UNORM)(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] = UBYTE_TO_FLOAT( (s ) & 0xff ); @@ -484,13 +351,9 @@ static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_B8G8R8X8_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */ -static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B8G8R8X8_UNORM)(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] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); @@ -500,13 +363,9 @@ static void FETCH(f_xrgb8888)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_X8R8G8B8_UNORM **************************************************/ - -/* Fetch texel from 1D, 2D or 3D xrgb8888_rev texture, return 4 GLfloats */ -static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(X8R8G8B8_UNORM)(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] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); @@ -516,13 +375,9 @@ static void FETCH(f_xrgb8888_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_BGR_UNORM8 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ -static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(BGR_UNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); @@ -532,13 +387,9 @@ static void FETCH(f_rgb888)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGB_UNORM8 ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ -static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(RGB_UNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); texel[RCOMP] = UBYTE_TO_FLOAT( src[0] ); @@ -548,16 +399,9 @@ static void FETCH(f_bgr888)( const struct swrast_texture_image *texImage, } - - -/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding) - instead of slow (g << 2) * 255 / 252 (always rounds down) */ - -/* MESA_FORMAT_B5G6R5_UNORM ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ -static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B5G6R5_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); const GLushort s = *src; @@ -568,13 +412,9 @@ static void FETCH(f_rgb565)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_R5G6B5_UNORM ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */ -static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R5G6B5_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ @@ -585,13 +425,9 @@ static void FETCH(f_rgb565_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_B4G4R4A4_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ -static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B4G4R4A4_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); const GLushort s = *src; @@ -602,13 +438,9 @@ static void FETCH(f_argb4444)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A4R4G4B4_UNORM **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */ -static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A4R4G4B4_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); @@ -618,12 +450,9 @@ static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage, } - -/* MESA_FORMAT_A1B5G5R5_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ -static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A1B5G5R5_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); const GLushort s = *src; @@ -634,12 +463,9 @@ static void FETCH(f_rgba5551)( const struct swrast_texture_image *texImage, } - -/* MESA_FORMAT_B5G5R5A1_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ -static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B5G5R5A1_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); const GLushort s = *src; @@ -650,13 +476,9 @@ static void FETCH(f_argb1555)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A1R5G5B5_UNORM **************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */ -static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A1R5G5B5_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ @@ -667,13 +489,9 @@ static void FETCH(f_argb1555_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_B10G10R10A2_UNORM ***************************************************/ - -/* Fetch texel from 1D, 2D or 3D argb2101010 texture, return 4 GLchans */ -static void FETCH(f_argb2101010)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B10G10R10A2_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); const GLuint s = *src; @@ -684,13 +502,22 @@ static void FETCH(f_argb2101010)( const struct swrast_texture_image *texImage, } +static void +FETCH(R10G10B10A2_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) +{ + const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); + const GLuint s = *src; + texel[RCOMP] = ((s >> 0) & 0x3ff) * (1.0F / 1023.0F); + texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F); + texel[BCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F); + texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F); +} -/* MESA_FORMAT_R8G8_UNORM **********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */ -static void FETCH(f_gr88)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff ); @@ -700,13 +527,9 @@ static void FETCH(f_gr88)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_G8R8_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D rg88_rev texture, return 4 GLchans */ -static void FETCH(f_rg88)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(G8R8_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = UBYTE_TO_FLOAT( s >> 8 ); @@ -716,13 +539,9 @@ static void FETCH(f_rg88)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L4A4_UNORM **********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al44 texture, return 4 GLchans */ -static void FETCH(f_al44)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L4A4_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); texel[RCOMP] = @@ -732,29 +551,21 @@ static void FETCH(f_al44)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L8A8_UNORM **********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ -static void FETCH(f_al88)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L8A8_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = + texel[RCOMP] = + texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff ); texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 ); } - - -/* MESA_FORMAT_R_UNORM8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D rg88 texture, return 4 GLchans */ -static void FETCH(f_r8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +static void +FETCH(R_UNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); texel[RCOMP] = UBYTE_TO_FLOAT(s); @@ -764,13 +575,9 @@ static void FETCH(f_r8)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_R_UNORM16 ***********************************************************/ - -/* Fetch texel from 1D, 2D or 3D r16 texture, return 4 GLchans */ -static void FETCH(f_r16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +static void +FETCH(R_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = USHORT_TO_FLOAT(s); @@ -780,29 +587,21 @@ static void FETCH(f_r16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A8L8_UNORM ******************************************************/ - -/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */ -static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A8L8_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = + texel[RCOMP] = + texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 ); texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); } - - -/* MESA_FORMAT_R16G16_UNORM ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */ -static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R16G16_UNORM)(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] = USHORT_TO_FLOAT( s & 0xffff ); @@ -812,13 +611,9 @@ static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_G16R16_UNORM ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */ -static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(G16R16_UNORM)(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] = USHORT_TO_FLOAT( s >> 16 ); @@ -828,13 +623,9 @@ static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L16A16_UNORM ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */ -static void FETCH(f_al1616)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L16A16_UNORM)(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] = @@ -844,13 +635,9 @@ static void FETCH(f_al1616)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A16L16_UNORM ****************************************************/ - -/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */ -static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A16L16_UNORM)(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] = @@ -860,13 +647,9 @@ static void FETCH(f_al1616_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_B2G3R3_UNORM ********************************************************/ - -/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ -static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B2G3R3_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); const GLubyte s = *src; @@ -877,13 +660,9 @@ static void FETCH(f_rgb332)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A_UNORM8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ -static void FETCH(f_a8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A_UNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); texel[RCOMP] = @@ -893,13 +672,9 @@ static void FETCH(f_a8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A_UNORM16 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ -static void FETCH(f_a16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = @@ -909,13 +684,9 @@ static void FETCH(f_a16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L_UNORM8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ -static void FETCH(f_l8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L_UNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); texel[RCOMP] = @@ -925,13 +696,9 @@ static void FETCH(f_l8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L_UNORM16 ***********************************************************/ - -/* Fetch texel from 1D, 2D or 3D l16 texture, return 4 GLchans */ -static void FETCH(f_l16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = @@ -941,13 +708,9 @@ static void FETCH(f_l16)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_I_UNORM8 ************************************************************/ - -/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ -static void FETCH(f_i8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(I_UNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); texel[RCOMP] = @@ -957,13 +720,9 @@ static void FETCH(f_i8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_I_UNORM16 ***********************************************************/ - -/* Fetch texel from 1D, 2D or 3D i16 texture, return 4 GLchans */ -static void FETCH(f_i16)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(I_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1); texel[RCOMP] = @@ -973,12 +732,9 @@ static void FETCH(f_i16)( const struct swrast_texture_image *texImage, } - - -/* Fetch texel from 1D, 2D or 3D srgb8 texture, return 4 GLfloats */ -/* Note: component order is same as for MESA_FORMAT_BGR_UNORM8 */ -static void FETCH(srgb8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(BGR_SRGB8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3); texel[RCOMP] = nonlinear_to_linear(src[2]); @@ -988,10 +744,9 @@ static void FETCH(srgb8)(const struct swrast_texture_image *texImage, } - -/* Fetch texel from 1D, 2D or 3D srgba8 texture, return 4 GLfloats */ -static void FETCH(srgba8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A8B8G8R8_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] = nonlinear_to_linear( (s >> 24) ); @@ -1001,10 +756,9 @@ static void FETCH(srgba8)(const struct swrast_texture_image *texImage, } - -/* Fetch texel from 1D, 2D or 3D sargb8 texture, return 4 GLfloats */ -static void FETCH(sargb8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(B8G8R8A8_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] = nonlinear_to_linear( (s >> 16) & 0xff ); @@ -1014,10 +768,9 @@ static void FETCH(sargb8)(const struct swrast_texture_image *texImage, } - -/* Fetch texel from 1D, 2D or 3D sabgr8 texture, return 4 GLfloats */ -static void FETCH(sabgr8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8B8A8_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] = nonlinear_to_linear( (s ) & 0xff ); @@ -1027,9 +780,9 @@ static void FETCH(sabgr8)(const struct swrast_texture_image *texImage, } -/* Fetch texel from 1D, 2D or 3D sabgr8 texture, return 4 GLfloats */ -static void FETCH(sxbgr8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8B8X8_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] = nonlinear_to_linear( (s ) & 0xff ); @@ -1039,22 +792,21 @@ static void FETCH(sxbgr8)(const struct swrast_texture_image *texImage, } -/* Fetch texel from 1D, 2D or 3D sl8 texture, return 4 GLfloats */ -static void FETCH(sl8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L_SRGB8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1); - texel[RCOMP] = - texel[GCOMP] = + texel[RCOMP] = + texel[GCOMP] = texel[BCOMP] = nonlinear_to_linear(src[0]); texel[ACOMP] = 1.0F; } - -/* Fetch texel from 1D, 2D or 3D sla8 texture, return 4 GLfloats */ -static void FETCH(sla8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +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); texel[RCOMP] = @@ -1064,13 +816,9 @@ static void FETCH(sla8)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_SINT8 **************************************************/ - static void -FETCH(rgba_int8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +FETCH(RGBA_SINT8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4); texel[RCOMP] = (GLfloat) src[0]; @@ -1080,13 +828,9 @@ FETCH(rgba_int8)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_SINT16 **************************************************/ - static void -FETCH(rgba_int16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +FETCH(RGBA_SINT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); texel[RCOMP] = (GLfloat) src[0]; @@ -1096,13 +840,9 @@ FETCH(rgba_int16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_SINT32 **************************************************/ - static void -FETCH(rgba_int32)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +FETCH(RGBA_SINT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4); texel[RCOMP] = (GLfloat) src[0]; @@ -1112,13 +852,9 @@ FETCH(rgba_int32)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_UINT8 **************************************************/ - static void -FETCH(rgba_uint8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +FETCH(RGBA_UINT8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4); texel[RCOMP] = (GLfloat) src[0]; @@ -1128,13 +864,9 @@ FETCH(rgba_uint8)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_UINT16 **************************************************/ - static void -FETCH(rgba_uint16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +FETCH(RGBA_UINT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); texel[RCOMP] = (GLfloat) src[0]; @@ -1144,13 +876,9 @@ FETCH(rgba_uint16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_UINT32 **************************************************/ - static void -FETCH(rgba_uint32)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +FETCH(RGBA_UINT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4); texel[RCOMP] = (GLfloat) src[0]; @@ -1160,14 +888,13 @@ FETCH(rgba_uint32)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_DUDV8 ********************************************************/ - -/* this format by definition produces 0,0,0,1 as rgba values, - however we'll return the dudv values as rg and fix up elsewhere */ -static void FETCH(dudv8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +/** + * This format by definition produces 0,0,0,1 as rgba values, + * however we'll return the dudv values as rg and fix up elsewhere. + */ +static void +FETCH(DUDV8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 2); texel[RCOMP] = BYTE_TO_FLOAT(src[0]); @@ -1177,10 +904,9 @@ static void FETCH(dudv8)(const struct swrast_texture_image *texImage, } -/* MESA_FORMAT_R_SNORM8 ***********************************************/ - -static void FETCH(signed_r8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R_SNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); texel[RCOMP] = BYTE_TO_FLOAT_TEX( s ); @@ -1190,12 +916,9 @@ static void FETCH(signed_r8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A_SNORM8 ***********************************************/ - -static void FETCH(signed_a8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A_SNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); texel[RCOMP] = 0.0F; @@ -1205,12 +928,9 @@ static void FETCH(signed_a8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L_SNORM8 ***********************************************/ - -static void FETCH(signed_l8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L_SNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); texel[RCOMP] = @@ -1220,12 +940,9 @@ static void FETCH(signed_l8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_I_SNORM8 ***********************************************/ - -static void FETCH(signed_i8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(I_SNORM8)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1); texel[RCOMP] = @@ -1235,12 +952,9 @@ static void FETCH(signed_i8)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_R8G8_SNORM ***********************************************/ - -static void FETCH(signed_rg88_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8_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] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) ); @@ -1250,12 +964,9 @@ static void FETCH(signed_rg88_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L8A8_SNORM ***********************************************/ - -static void FETCH(signed_al88)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(L8A8_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] = @@ -1265,12 +976,9 @@ static void FETCH(signed_al88)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_X8B8G8R8_SNORM ***********************************************/ - -static void FETCH(signed_rgbx8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(X8B8G8R8_SNORM)(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] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); @@ -1280,12 +988,9 @@ static void FETCH(signed_rgbx8888)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A8B8G8R8_SNORM ***********************************************/ - -static void FETCH(signed_rgba8888)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(A8B8G8R8_SNORM)(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] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) ); @@ -1295,9 +1000,9 @@ static void FETCH(signed_rgba8888)( const struct swrast_texture_image *texImage, } - -static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R8G8B8A8_SNORM)(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] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) ); @@ -1307,14 +1012,9 @@ static void FETCH(signed_rgba8888_rev)( const struct swrast_texture_image *texIm } - - - -/* MESA_FORMAT_R_SNORM16 ***********************************************/ - static void -FETCH(signed_r16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(R_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); texel[RCOMP] = SHORT_TO_FLOAT_TEX( s ); @@ -1324,13 +1024,9 @@ FETCH(signed_r16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_A_SNORM16 ***********************************************/ - static void -FETCH(signed_a16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(A_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); texel[RCOMP] = 0.0F; @@ -1340,13 +1036,9 @@ FETCH(signed_a16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_L_SNORM16 ***********************************************/ - static void -FETCH(signed_l16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(L_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); texel[RCOMP] = @@ -1356,13 +1048,9 @@ FETCH(signed_l16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_I_SNORM16 ***********************************************/ - static void -FETCH(signed_i16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(I_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1); texel[RCOMP] = @@ -1372,12 +1060,8 @@ FETCH(signed_i16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_G16R16_SNORM ***********************************************/ - static void -FETCH(signed_rg1616)(const struct swrast_texture_image *texImage, +FETCH(R16G16_SNORM)(const struct swrast_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); @@ -1388,13 +1072,9 @@ FETCH(signed_rg1616)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_LA_SNORM16 ***********************************************/ - static void -FETCH(signed_al1616)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(LA_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2); texel[RCOMP] = @@ -1404,13 +1084,10 @@ FETCH(signed_al1616)(const struct swrast_texture_image *texImage, } +static void - -/* MESA_FORMAT_RGB_SNORM16 ***********************************************/ - -static void -FETCH(signed_rgb_16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(RGB_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3); texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); @@ -1420,13 +1097,9 @@ FETCH(signed_rgb_16)(const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGBA_SNORM16 ***********************************************/ - static void -FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(RGBA_SNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4); texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] ); @@ -1436,14 +1109,9 @@ FETCH(signed_rgba_16)(const struct swrast_texture_image *texImage, } - - - -/* MESA_FORMAT_RGBA_UNORM16 ***********************************************/ - static void -FETCH(rgba_16)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(RGBA_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); texel[RCOMP] = USHORT_TO_FLOAT( s[0] ); @@ -1453,12 +1121,9 @@ FETCH(rgba_16)(const struct swrast_texture_image *texImage, } - -/* MESA_FORMAT_XBGR.... **********************************************/ - static void -FETCH(xbgr16161616_unorm)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(RGBX_UNORM16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4); texel[RCOMP] = USHORT_TO_FLOAT(s[0]); @@ -1467,9 +1132,10 @@ FETCH(xbgr16161616_unorm)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } + static void -FETCH(xbgr16161616_float)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(RGBX_FLOAT16)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLhalfARB *s = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4); texel[RCOMP] = _mesa_half_to_float(s[0]); @@ -1478,9 +1144,10 @@ FETCH(xbgr16161616_float)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } + static void -FETCH(xbgr32323232_float)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +FETCH(RGBX_FLOAT32)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *s = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4); texel[RCOMP] = s[0]; @@ -1489,17 +1156,13 @@ FETCH(xbgr32323232_float)(const struct swrast_texture_image *texImage, texel[ACOMP] = 1.0f; } -/* XXX other XBGR formats need to be implemented here */ - - -/* MESA_FORMAT_YCBCR *********************************************************/ - -/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats. - * We convert YCbCr to RGB here. +/** + * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA. */ -static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(YCBCR)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ const GLushort *src1 = src0 + 1; /* odd */ @@ -1521,15 +1184,12 @@ static void FETCH(f_ycbcr)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_YCBCR_REV *****************************************************/ - -/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats. - * We convert YCbCr to RGB here. +/** + * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA. */ -static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(YCBCR_REV)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */ const GLushort *src1 = src0 + 1; /* odd */ @@ -1551,12 +1211,9 @@ static void FETCH(f_ycbcr_rev)( const struct swrast_texture_image *texImage, } - - -/* MESA_TEXFORMAT_Z24_S8 ***************************************************/ - -static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(S8_UINT_Z24_UNORM)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* only return Z, not stencil data */ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); @@ -1569,12 +1226,9 @@ static void FETCH(f_z24_s8)( const struct swrast_texture_image *texImage, } - - -/* MESA_TEXFORMAT_S8_Z24 ***************************************************/ - -static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(Z24_UNORM_S8_UINT)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* only return Z, not stencil data */ const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); @@ -1587,12 +1241,9 @@ static void FETCH(f_s8_z24)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_RGB9_E5 ******************************************************/ - -static void FETCH(rgb9_e5)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R9G9B9E5_FLOAT)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); rgb9e5_to_float3(*src, texel); @@ -1600,12 +1251,9 @@ static void FETCH(rgb9_e5)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_R11G11B10_FLOAT *********************************************/ - -static void FETCH(r11_g11_b10f)( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +static void +FETCH(R11G11B10_FLOAT)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1); r11g11b10f_to_float3(*src, texel); @@ -1613,12 +1261,9 @@ static void FETCH(r11_g11_b10f)( const struct swrast_texture_image *texImage, } - - -/* MESA_FORMAT_Z32_FLOAT_S8X24_UINT ***********************************************/ - -static void FETCH(z32f_x24s8)(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +static void +FETCH(Z32_FLOAT_S8X24_UINT)(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2); texel[RCOMP] = src[0]; diff --git a/mesalib/src/mesa/tnl/t_context.c b/mesalib/src/mesa/tnl/t_context.c index 134f699be..eb5bae41d 100644 --- a/mesalib/src/mesa/tnl/t_context.c +++ b/mesalib/src/mesa/tnl/t_context.c @@ -93,7 +93,7 @@ _tnl_CreateContext( struct gl_context *ctx ) } /* plug in the VBO drawing function */ - vbo_set_draw_func(ctx, _tnl_vbo_draw_prims); + vbo_set_draw_func(ctx, _tnl_draw_prims); _math_init_transformation(); _math_init_translate(); diff --git a/mesalib/src/mesa/tnl/t_draw.c b/mesalib/src/mesa/tnl/t_draw.c index 2755ae62d..be3f059bb 100644 --- a/mesalib/src/mesa/tnl/t_draw.c +++ b/mesalib/src/mesa/tnl/t_draw.c @@ -411,7 +411,11 @@ static void unmap_vbos( struct gl_context *ctx, } -void _tnl_vbo_draw_prims(struct gl_context *ctx, +/* This is the main entrypoint into the slimmed-down software tnl + * module. In a regular swtnl driver, this can be plugged straight + * into the vbo->Driver.DrawPrims() callback. + */ +void _tnl_draw_prims(struct gl_context *ctx, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, @@ -421,32 +425,16 @@ void _tnl_vbo_draw_prims(struct gl_context *ctx, struct gl_transform_feedback_object *tfb_vertcount, struct gl_buffer_object *indirect) { - const struct gl_client_array **arrays = ctx->Array._DrawArrays; - - if (!index_bounds_valid) - vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims); - - _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); -} - -/* This is the main entrypoint into the slimmed-down software tnl - * module. In a regular swtnl driver, this can be plugged straight - * into the vbo->Driver.DrawPrims() callback. - */ -void _tnl_draw_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index) -{ TNLcontext *tnl = TNL_CONTEXT(ctx); + const struct gl_client_array **arrays = ctx->Array._DrawArrays; const GLuint TEST_SPLIT = 0; const GLint max = TEST_SPLIT ? 8 : tnl->vb.Size - MAX_CLIPPED_VERTICES; GLint max_basevertex = prim->basevertex; GLuint i; + if (!index_bounds_valid) + vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims); + /* Mesa core state should have been validated already */ assert(ctx->NewState == 0x0); @@ -471,7 +459,7 @@ void _tnl_draw_prims( struct gl_context *ctx, */ vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, - _tnl_vbo_draw_prims ); + _tnl_draw_prims ); return; } else if ((GLint)max_index + max_basevertex > max) { @@ -489,7 +477,7 @@ void _tnl_draw_prims( struct gl_context *ctx, */ vbo_split_prims( ctx, arrays, prim, nr_prims, ib, 0, max_index + prim->basevertex, - _tnl_vbo_draw_prims, + _tnl_draw_prims, &limits ); } else { diff --git a/mesalib/src/mesa/tnl/tnl.h b/mesalib/src/mesa/tnl/tnl.h index 59a0ac380..8c59ff9e5 100644 --- a/mesalib/src/mesa/tnl/tnl.h +++ b/mesalib/src/mesa/tnl/tnl.h @@ -77,15 +77,6 @@ struct _mesa_index_buffer; void _tnl_draw_prims( struct gl_context *ctx, - const struct gl_client_array *arrays[], - const struct _mesa_prim *prim, - GLuint nr_prims, - const struct _mesa_index_buffer *ib, - GLuint min_index, - GLuint max_index); - -void -_tnl_vbo_draw_prims( struct gl_context *ctx, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, |