diff options
Diffstat (limited to 'mesalib/src/mesa')
31 files changed, 1623 insertions, 337 deletions
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am index bb70ed6ea..f1cd6d67c 100644 --- a/mesalib/src/mesa/Makefile.am +++ b/mesalib/src/mesa/Makefile.am @@ -42,8 +42,7 @@ main/git_sha1.h: main/git_sha1.h.tmp fi # include glapi_gen.mk for generating glapi headers for GLES -TOP = $(top_srcdir) -GLAPI = $(TOP)/src/mapi/glapi/gen +GLAPI = $(top_srcdir)/src/mapi/glapi/gen include $(GLAPI)/glapi_gen.mk BUILT_SOURCES = \ @@ -78,24 +77,25 @@ main/api_exec_es2_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_d main/api_exec_es2.o: main/api_exec_es2_dispatch.h main/api_exec_es2_remap_helper.h main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py - $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py \ + $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/es_generator.py \ -S $(srcdir)/main/APIspec.xml -V GLES1.1 > $@ main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py - $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py \ + $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/es_generator.py \ -S $(srcdir)/main/APIspec.xml -V GLES2.0 > $@ program/program_parse.tab.c program/program_parse.tab.h: program/program_parse.y - mkdir -p program - $(YACC) -v -d --output=program/program_parse.tab.c $< + $(MKDIR_P) program + $(AM_V_GEN) $(YACC) -v -d --output=program/program_parse.tab.c $< program/lex.yy.c: program/program_lexer.l - mkdir -p program - $(LEX) --never-interactive --outfile=$@ $< + $(MKDIR_P) program + $(AM_V_GEN) $(LEX) --never-interactive --outfile=$@ $< noinst_LTLIBRARIES = libmesa.la libmesagallium.la SRCDIR = $(top_srcdir)/src/mesa/ +BUILDDIR = $(top_builddir)/src/mesa/ include sources.mak AM_CPPFLAGS = $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS) @@ -107,12 +107,21 @@ MESA_ASM_FILES_FOR_ARCH = if HAVE_X86_ASM MESA_ASM_FILES_FOR_ARCH += $(X86_FILES) +AM_CPPFLAGS += \ + -I$(top_builddir)/src/mesa/x86 \ + -I$(top_srcdir)/src/mesa/x86 endif if HAVE_X86_64_ASM MESA_ASM_FILES_FOR_ARCH += $(X86_64_FILES) +AM_CPPFLAGS += \ + -I$(top_builddir)/src/mesa/x86-64 \ + -I$(top_srcdir)/src/mesa/x86-64 endif if HAVE_SPARC_ASM MESA_ASM_FILES_FOR_ARCH += $(SPARC_FILES) +AM_CPPFLAGS += \ + -I$(top_builddir)/src/mesa/sparc \ + -I$(top_srcdir)/src/mesa/sparc endif libmesa_la_SOURCES = \ diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index d36b1a3b8..ca01a3301 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -74,6 +74,8 @@ #include "program/program.h" #include "swrast/swrast.h" #include "drivers/common/meta.h" +#include "main/enums.h" +#include "main/glformats.h" /** Return offset in bytes of the field within a vertex struct */ @@ -3158,8 +3160,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, * ReadPixels() and passed to Tex[Sub]Image(). */ static GLenum -get_temp_image_type(struct gl_context *ctx, GLenum baseFormat) +get_temp_image_type(struct gl_context *ctx, gl_format format) { + GLenum baseFormat, type; + + baseFormat = _mesa_get_format_base_format(format); + switch (baseFormat) { case GL_RGBA: case GL_RGB: @@ -3174,7 +3180,7 @@ get_temp_image_type(struct gl_context *ctx, GLenum baseFormat) else if (ctx->DrawBuffer->Visual.redBits <= 16) return GL_UNSIGNED_SHORT; else - return GL_FLOAT; + return _mesa_get_format_datatype(format); case GL_DEPTH_COMPONENT: return GL_UNSIGNED_INT; case GL_DEPTH_STENCIL: @@ -3216,12 +3222,10 @@ _mesa_meta_CopyTexSubImage(struct gl_context *ctx, GLuint dims, format = GL_RGBA; } + type = get_temp_image_type(ctx, texImage->TexFormat); if (_mesa_is_format_integer_color(texImage->TexFormat)) { - _mesa_problem(ctx, "unsupported integer color copyteximage"); - return; + format = _mesa_base_format_to_integer_format(format); } - - type = get_temp_image_type(ctx, format); bpp = _mesa_bytes_per_pixel(format, type); if (bpp <= 0) { _mesa_problem(ctx, "Bad bpp in _mesa_meta_CopyTexSubImage()"); diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index 91ae186fe..86409dd06 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -192,6 +192,8 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, mesa_api = API_OPENGLES2; break; case __DRI_API_OPENGL_CORE: + mesa_api = API_OPENGL_CORE; + break; default: *error = __DRI_CTX_ERROR_BAD_API; return NULL; @@ -218,6 +220,20 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, } } + /* Mesa does not support the GL_ARB_compatibilty extension or the + * compatibility profile. This means that we treat a API_OPENGL 3.1 as + * API_OPENGL_CORE and reject API_OPENGL 3.2+. + */ + if (mesa_api == API_OPENGL && major_version == 3 && minor_version == 1) + mesa_api = API_OPENGL_CORE; + + if (mesa_api == API_OPENGL + && ((major_version > 3) + || (major_version == 3 && minor_version >= 2))) { + *error = __DRI_CTX_ERROR_BAD_API; + return NULL; + } + /* The EGL_KHR_create_context spec says: * * "Flags are only defined for OpenGL context creation, and specifying @@ -228,8 +244,8 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, * anything specific about this case. However, none of the known flags * have any meaning in an ES context, so this seems safe. */ - if (mesa_api != __DRI_API_OPENGL - && mesa_api != __DRI_API_OPENGL_CORE + if (mesa_api != API_OPENGL + && mesa_api != API_OPENGL_CORE && flags != 0) { *error = __DRI_CTX_ERROR_BAD_FLAG; return NULL; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index ca6bda027..7773fd905 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -719,11 +719,20 @@ dri_create_context(gl_api api, */ (void) flags; - if (api == API_OPENGL - && (major_version > 2 - || (major_version == 2 && minor_version > 1))) { - *error = __DRI_CTX_ERROR_BAD_VERSION; - goto context_fail; + switch (api) { + case API_OPENGL: + if (major_version > 2 + || (major_version == 2 && minor_version > 1)) { + *error = __DRI_CTX_ERROR_BAD_VERSION; + return GL_FALSE; + } + break; + case API_OPENGLES: + case API_OPENGLES2: + break; + case API_OPENGL_CORE: + *error = __DRI_CTX_ERROR_BAD_API; + return GL_FALSE; } ctx = CALLOC_STRUCT(dri_context); diff --git a/mesalib/src/mesa/main/api_exec.c b/mesalib/src/mesa/main/api_exec.c index 81be46d5f..6b1499f4f 100644 --- a/mesalib/src/mesa/main/api_exec.c +++ b/mesalib/src/mesa/main/api_exec.c @@ -158,7 +158,7 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_GetError(exec, _mesa_GetError); SET_GetFloatv(exec, _mesa_GetFloatv); SET_GetString(exec, _mesa_GetString); - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_LineStipple(exec, _mesa_LineStipple); } SET_LineWidth(exec, _mesa_LineWidth); @@ -197,13 +197,13 @@ _mesa_create_exec_table(struct gl_context *ctx) } SET_Viewport(exec, _mesa_Viewport); - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { _mesa_init_accum_dispatch(exec); _mesa_init_dlist_dispatch(exec); } SET_ClearDepth(exec, _mesa_ClearDepth); - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_ClearIndex(exec, _mesa_ClearIndex); SET_ClipPlane(exec, _mesa_ClipPlane); SET_ColorMaterial(exec, _mesa_ColorMaterial); @@ -213,9 +213,11 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_DepthRange(exec, _mesa_DepthRange); _mesa_init_drawpix_dispatch(exec); - _mesa_init_feedback_dispatch(exec); + if (ctx->API == API_OPENGL) { + _mesa_init_feedback_dispatch(exec); + } - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT); SET_Fogf(exec, _mesa_Fogf); SET_Fogfv(exec, _mesa_Fogfv); @@ -241,7 +243,7 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv); SET_GetTexImage(exec, _mesa_GetTexImage); SET_Hint(exec, _mesa_Hint); - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_IndexMask(exec, _mesa_IndexMask); } SET_IsEnabled(exec, _mesa_IsEnabled); @@ -257,24 +259,22 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_LoadMatrixd(exec, _mesa_LoadMatrixd); } - _mesa_init_eval_dispatch(exec); - - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { + _mesa_init_eval_dispatch(exec); SET_MultMatrixd(exec, _mesa_MultMatrixd); + _mesa_init_pixel_dispatch(exec); } - _mesa_init_pixel_dispatch(exec); - SET_PixelStoref(exec, _mesa_PixelStoref); SET_PointSize(exec, _mesa_PointSize); SET_PolygonMode(exec, _mesa_PolygonMode); SET_PolygonOffset(exec, _mesa_PolygonOffset); - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_PolygonStipple(exec, _mesa_PolygonStipple); - } - _mesa_init_attrib_dispatch(exec); - _mesa_init_rastpos_dispatch(exec); + _mesa_init_attrib_dispatch(exec); + _mesa_init_rastpos_dispatch(exec); + } SET_ReadPixels(exec, _mesa_ReadPixels); if (ctx->API != API_OPENGL_CORE) { @@ -285,13 +285,15 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_TexEnviv(exec, _mesa_TexEnviv); } - _mesa_init_texgen_dispatch(exec); + if (ctx->API != API_OPENGL_CORE) { + _mesa_init_texgen_dispatch(exec); + } SET_TexImage1D(exec, _mesa_TexImage1D); SET_TexParameterf(exec, _mesa_TexParameterf); SET_TexParameterfv(exec, _mesa_TexParameterfv); SET_TexParameteriv(exec, _mesa_TexParameteriv); - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_Translated(exec, _mesa_Translated); } @@ -300,7 +302,7 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_DeleteTextures(exec, _mesa_DeleteTextures); SET_GenTextures(exec, _mesa_GenTextures); #if _HAVE_FULL_GL - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_AreTexturesResident(exec, _mesa_AreTexturesResident); SET_ColorPointer(exec, _mesa_ColorPointer); } @@ -341,9 +343,11 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_BlendEquation(exec, _mesa_BlendEquation); SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT); - _mesa_init_colortable_dispatch(exec); - _mesa_init_convolve_dispatch(exec); - _mesa_init_histogram_dispatch(exec); + if (ctx->API == API_OPENGL) { + _mesa_init_colortable_dispatch(exec); + _mesa_init_convolve_dispatch(exec); + _mesa_init_histogram_dispatch(exec); + } /* OpenGL 2.0 */ SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate); @@ -362,7 +366,9 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 3. GL_EXT_polygon_offset */ #if _HAVE_FULL_GL - SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); + if (ctx->API == API_OPENGL) { + SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT); + } #endif /* 6. GL_EXT_texture3d */ @@ -374,7 +380,7 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 11. GL_EXT_histogram */ #if 0 - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_GetHistogramEXT(exec, _mesa_GetHistogram); SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv); SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv); @@ -397,7 +403,7 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 30. GL_EXT_vertex_array */ #if _HAVE_FULL_GL - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT); SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT); SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT); @@ -424,8 +430,10 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 97. GL_EXT_compiled_vertex_array */ #if _HAVE_FULL_GL - SET_LockArraysEXT(exec, _mesa_LockArraysEXT); - SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); + if (ctx->API == API_OPENGL) { + SET_LockArraysEXT(exec, _mesa_LockArraysEXT); + SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT); + } #endif /* 148. GL_EXT_multi_draw_arrays */ @@ -454,54 +462,61 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 233. GL_NV_vertex_program */ #if FEATURE_NV_vertex_program - SET_BindProgramNV(exec, _mesa_BindProgram); - SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); - SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); - SET_GenProgramsNV(exec, _mesa_GenPrograms); - SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); - SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV); - SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); - SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); - SET_GetProgramivNV(exec, _mesa_GetProgramivNV); - SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); - SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); - SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); - SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); - SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); - SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); - SET_IsProgramNV(exec, _mesa_IsProgramARB); - SET_LoadProgramNV(exec, _mesa_LoadProgramNV); - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ - SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); - SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); - SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); - SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); - /* glVertexAttrib*NV functions handled in api_loopback.c */ + if (ctx->API == API_OPENGL) { + SET_BindProgramNV(exec, _mesa_BindProgram); + SET_DeleteProgramsNV(exec, _mesa_DeletePrograms); + SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV); + SET_GenProgramsNV(exec, _mesa_GenPrograms); + SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV); + SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV); + SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV); + SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV); + SET_GetProgramivNV(exec, _mesa_GetProgramivNV); + SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV); + SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV); + SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV); + SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV); + SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV); + SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV); + SET_IsProgramNV(exec, _mesa_IsProgramARB); + SET_LoadProgramNV(exec, _mesa_LoadProgramNV); + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); /* alias to ProgramParameter4dNV */ + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); /* alias to ProgramParameter4dvNV */ + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); /* alias to ProgramParameter4fNV */ + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */ + SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV); + SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV); + SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV); + SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV); + /* glVertexAttrib*NV functions handled in api_loopback.c */ + } #endif /* 273. GL_APPLE_vertex_array_object */ - SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE); + if (ctx->API == API_OPENGL) { + SET_BindVertexArrayAPPLE(exec, _mesa_BindVertexArrayAPPLE); + SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE); + } + /* Reused by ARB_vertex_array_object */ SET_DeleteVertexArraysAPPLE(exec, _mesa_DeleteVertexArraysAPPLE); - SET_GenVertexArraysAPPLE(exec, _mesa_GenVertexArraysAPPLE); SET_IsVertexArrayAPPLE(exec, _mesa_IsVertexArrayAPPLE); /* 282. GL_NV_fragment_program */ #if FEATURE_NV_fragment_program - SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV); - SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV); - SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV); - SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); - SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); - SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); + if (ctx->API == API_OPENGL) { + SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV); + SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV); + SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV); + SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV); + SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV); + SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV); + SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); + SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); + } #endif /* 262. GL_NV_point_sprite */ @@ -512,7 +527,9 @@ _mesa_create_exec_table(struct gl_context *ctx) /* 268. GL_EXT_stencil_two_side */ #if _HAVE_FULL_GL - SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT); + if (ctx->API == API_OPENGL) { + SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT); + } #endif /* 285. GL_NV_primitive_restart */ @@ -536,7 +553,7 @@ _mesa_create_exec_table(struct gl_context *ctx) /* ARB 3. GL_ARB_transpose_matrix */ #if _HAVE_FULL_GL - if (ctx->API != API_OPENGL_CORE) { + if (ctx->API == API_OPENGL) { SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB); SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB); SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB); @@ -617,24 +634,26 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB); SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB); /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */ - SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); - SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); - SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); - SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); - SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); - SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); - SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); - SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); - SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); - SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); - SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); - SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); + if (ctx->API == API_OPENGL) { + SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB); + SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB); + SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); + } SET_GetProgramivARB(exec, _mesa_GetProgramivARB); - SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB); #endif /* ARB 28. GL_ARB_vertex_buffer_object */ - _mesa_init_bufferobj_dispatch(exec); + _mesa_init_bufferobj_dispatch(ctx, exec); /* ARB 29. GL_ARB_occlusion_query */ _mesa_init_queryobj_dispatch(exec); @@ -657,13 +676,17 @@ _mesa_create_exec_table(struct gl_context *ctx) SET_ReadnPixelsARB(exec, _mesa_ReadnPixelsARB); /* GL_ATI_fragment_shader */ - _mesa_init_ati_fragment_shader_dispatch(exec); + if (ctx->API == API_OPENGL) { + _mesa_init_ati_fragment_shader_dispatch(exec); + } /* GL_ATI_envmap_bumpmap */ - SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); - SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); - SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); - SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); + if (ctx->API == API_OPENGL) { + SET_GetTexBumpParameterivATI(exec, _mesa_GetTexBumpParameterivATI); + SET_GetTexBumpParameterfvATI(exec, _mesa_GetTexBumpParameterfvATI); + SET_TexBumpParameterivATI(exec, _mesa_TexBumpParameterivATI); + SET_TexBumpParameterfvATI(exec, _mesa_TexBumpParameterfvATI); + } #if FEATURE_EXT_framebuffer_object SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT); @@ -691,8 +714,10 @@ _mesa_create_exec_table(struct gl_context *ctx) /* GL_EXT_gpu_program_parameters */ #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program - SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); - SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); + if (ctx->API == API_OPENGL) { + SET_ProgramEnvParameters4fvEXT(exec, _mesa_ProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(exec, _mesa_ProgramLocalParameters4fvEXT); + } #endif /* GL_MESA_texture_array / GL_EXT_texture_array */ @@ -701,7 +726,9 @@ _mesa_create_exec_table(struct gl_context *ctx) #endif /* GL_ATI_separate_stencil */ - SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); + if (ctx->API == API_OPENGL) { + SET_StencilFuncSeparateATI(exec, _mesa_StencilFuncSeparateATI); + } #if FEATURE_ARB_framebuffer_object /* The ARB_fbo functions are the union of @@ -800,6 +827,16 @@ _mesa_create_exec_table(struct gl_context *ctx) _mesa_init_sampler_object_dispatch(exec); #endif + if (_mesa_is_desktop_gl(ctx)) { + SET_InvalidateTexSubImage(exec, _mesa_InvalidateTexSubImage); + SET_InvalidateTexImage(exec, _mesa_InvalidateTexImage); + } + + if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) { + SET_InvalidateSubFramebuffer(exec, _mesa_InvalidateSubFramebuffer); + SET_InvalidateFramebuffer(exec, _mesa_InvalidateFramebuffer); + } + return exec; } diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 9cab35b0c..1a04eebdd 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -805,10 +805,6 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate) _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, samp->MaxAnisotropy); } - if (ctx->Extensions.ARB_shadow_ambient) { - _mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, - samp->CompareFailValue); - } if (ctx->Extensions.ARB_shadow) { _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_MODE, samp->CompareMode); diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 22d7927bb..df559821c 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -2200,8 +2200,100 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer) } } +static void GLAPIENTRY +_mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset, + GLsizeiptr length) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + const GLintptr end = offset + length; + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateBufferSubData(name = 0x%x) invalid object", + buffer); + return; + } + + /* The GL_ARB_invalidate_subdata spec says: + * + * "An INVALID_VALUE error is generated if <offset> or <length> is + * negative, or if <offset> + <length> is greater than the value of + * BUFFER_SIZE." + */ + if (end < 0 || end > bufObj->Size) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateBufferSubData(invalid offset or length)"); + return; + } + + /* The GL_ARB_invalidate_subdata spec says: + * + * "An INVALID_OPERATION error is generated if the buffer is currently + * mapped by MapBuffer, or if the invalidate range intersects the range + * currently mapped by MapBufferRange." + */ + if (_mesa_bufferobj_mapped(bufObj)) { + const GLintptr mapEnd = bufObj->Offset + bufObj->Length; + + /* The regions do not overlap if and only if the end of the discard + * region is before the mapped region or the start of the discard region + * is after the mapped region. + * + * Note that 'end' and 'mapEnd' are the first byte *after* the discard + * region and the mapped region, repsectively. It is okay for that byte + * to be mapped (for 'end') or discarded (for 'mapEnd'). + */ + if (!(end <= bufObj->Offset || offset >= mapEnd)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glInvalidateBufferSubData(intersection with mapped " + "range)"); + return; + } + } + + /* We don't actually do anything for this yet. Just return after + * validating the parameters and generating the required errors. + */ + return; +} + +static void GLAPIENTRY +_mesa_InvalidateBufferData(GLuint buffer) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_buffer_object *bufObj; + + bufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!bufObj) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateBufferData(name = 0x%x) invalid object", + buffer); + return; + } + + /* The GL_ARB_invalidate_subdata spec says: + * + * "An INVALID_OPERATION error is generated if the buffer is currently + * mapped by MapBuffer, or if the invalidate range intersects the range + * currently mapped by MapBufferRange." + */ + if (_mesa_bufferobj_mapped(bufObj)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glInvalidateBufferData(intersection with mapped " + "range)"); + return; + } + + /* We don't actually do anything for this yet. Just return after + * validating the parameters and generating the required errors. + */ + return; +} + void -_mesa_init_bufferobj_dispatch(struct _glapi_table *disp) +_mesa_init_bufferobj_dispatch(struct gl_context *ctx, struct _glapi_table *disp) { SET_BindBufferARB(disp, _mesa_BindBufferARB); SET_BufferDataARB(disp, _mesa_BufferDataARB); @@ -2214,6 +2306,14 @@ _mesa_init_bufferobj_dispatch(struct _glapi_table *disp) SET_IsBufferARB(disp, _mesa_IsBufferARB); SET_MapBufferARB(disp, _mesa_MapBufferARB); SET_UnmapBufferARB(disp, _mesa_UnmapBufferARB); - SET_BindBufferRangeEXT(disp, _mesa_BindBufferRange); - SET_BindBufferBaseEXT(disp, _mesa_BindBufferBase); + + if (_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) { + SET_BindBufferRangeEXT(disp, _mesa_BindBufferRange); + SET_BindBufferBaseEXT(disp, _mesa_BindBufferBase); + } + + if (_mesa_is_desktop_gl(ctx)) { + SET_InvalidateBufferData(disp, _mesa_InvalidateBufferData); + SET_InvalidateBufferSubData(disp, _mesa_InvalidateBufferSubData); + } } diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h index e1d0f7a97..15fdb9c30 100644 --- a/mesalib/src/mesa/main/bufferobj.h +++ b/mesalib/src/mesa/main/bufferobj.h @@ -167,6 +167,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); extern void -_mesa_init_bufferobj_dispatch(struct _glapi_table *disp); +_mesa_init_bufferobj_dispatch(struct gl_context *ctx, + struct _glapi_table *disp); #endif diff --git a/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h index 6b7dafa78..e2387521f 100644 --- a/mesalib/src/mesa/main/context.h +++ b/mesalib/src/mesa/main/context.h @@ -310,6 +310,16 @@ _mesa_is_gles(const struct gl_context *ctx) } +/** + * Checks if the context is for GLES 3.x + */ +static inline GLboolean +_mesa_is_gles3(const struct gl_context *ctx) +{ + return ctx->API == API_OPENGLES2 && ctx->Version >= 30; +} + + #ifdef __cplusplus } #endif diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 5e13a9357..9e357cd09 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -88,28 +88,29 @@ static const struct extension extension_table[] = { { "GL_ARB_debug_output", o(dummy_true), GL, 2009 }, { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 }, { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 }, - { "GL_ARB_depth_texture", o(ARB_depth_texture), GL, 2001 }, + { "GL_ARB_depth_texture", o(ARB_depth_texture), GLL, 2001 }, { "GL_ARB_draw_buffers", o(dummy_true), GL, 2002 }, { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 }, { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 }, { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL, 2008 }, { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL, 2009 }, { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL, 2009 }, - { "GL_ARB_fragment_program", o(ARB_fragment_program), GL, 2002 }, - { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GL, 2003 }, + { "GL_ARB_fragment_program", o(ARB_fragment_program), GLL, 2002 }, + { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GLL, 2003 }, { "GL_ARB_fragment_shader", o(ARB_fragment_shader), GL, 2002 }, { "GL_ARB_framebuffer_object", o(ARB_framebuffer_object), GL, 2005 }, { "GL_ARB_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL, 1998 }, { "GL_ARB_half_float_pixel", o(ARB_half_float_pixel), GL, 2003 }, { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), GL, 2008 }, { "GL_ARB_instanced_arrays", o(ARB_instanced_arrays), GL, 2008 }, + { "GL_ARB_invalidate_subdata", o(dummy_true), GL, 2012 }, { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), GL, 2008 }, - { "GL_ARB_multisample", o(dummy_true), GL, 1994 }, - { "GL_ARB_multitexture", o(dummy_true), GL, 1998 }, + { "GL_ARB_multisample", o(dummy_true), GLL, 1994 }, + { "GL_ARB_multitexture", o(dummy_true), GLL, 1998 }, { "GL_ARB_occlusion_query2", o(ARB_occlusion_query2), GL, 2003 }, - { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GL, 2001 }, + { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GLL, 2001 }, { "GL_ARB_pixel_buffer_object", o(EXT_pixel_buffer_object), GL, 2004 }, - { "GL_ARB_point_parameters", o(EXT_point_parameters), GL, 1997 }, + { "GL_ARB_point_parameters", o(EXT_point_parameters), GLL, 1997 }, { "GL_ARB_point_sprite", o(ARB_point_sprite), GL, 2003 }, { "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL, 2009 }, { "GL_ARB_robustness", o(dummy_true), GL, 2010 }, @@ -119,21 +120,20 @@ static const struct extension extension_table[] = { { "GL_ARB_shader_objects", o(ARB_shader_objects), GL, 2002 }, { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 }, { "GL_ARB_shader_texture_lod", o(ARB_shader_texture_lod), GL, 2009 }, - { "GL_ARB_shading_language_100", o(ARB_shading_language_100), GL, 2003 }, - { "GL_ARB_shadow_ambient", o(ARB_shadow_ambient), GL, 2001 }, - { "GL_ARB_shadow", o(ARB_shadow), GL, 2001 }, + { "GL_ARB_shading_language_100", o(ARB_shading_language_100), GLL, 2003 }, + { "GL_ARB_shadow", o(ARB_shadow), GLL, 2001 }, { "GL_ARB_sync", o(ARB_sync), GL, 2003 }, - { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GL, 2000 }, + { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 2000 }, { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GL, 2008 }, - { "GL_ARB_texture_compression", o(dummy_true), GL, 2000 }, + { "GL_ARB_texture_compression", o(dummy_true), GLL, 2000 }, { "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 }, - { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GL, 1999 }, - { "GL_ARB_texture_env_add", o(dummy_true), GL, 1999 }, - { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GL, 2001 }, - { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GL, 2001 }, - { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GL, 2001 }, + { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GLL, 1999 }, + { "GL_ARB_texture_env_add", o(dummy_true), GLL, 1999 }, + { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GLL, 2001 }, + { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GLL, 2001 }, + { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GLL, 2001 }, { "GL_ARB_texture_float", o(ARB_texture_float), GL, 2004 }, - { "GL_ARB_texture_mirrored_repeat", o(dummy_true), GL, 2001 }, + { "GL_ARB_texture_mirrored_repeat", o(dummy_true), GLL, 2001 }, { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL, 2009 }, { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL, 2003 }, { "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL, 2004 }, @@ -145,74 +145,74 @@ static const struct extension extension_table[] = { { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL, 2010 }, { "GL_ARB_transform_feedback3", o(ARB_transform_feedback3), GL, 2010 }, { "GL_ARB_transform_feedback_instanced", o(ARB_transform_feedback_instanced), GL, 2011 }, - { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GL, 1999 }, + { "GL_ARB_transpose_matrix", o(ARB_transpose_matrix), GLL, 1999 }, { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL, 2009 }, { "GL_ARB_vertex_array_bgra", o(EXT_vertex_array_bgra), GL, 2008 }, { "GL_ARB_vertex_array_object", o(ARB_vertex_array_object), GL, 2006 }, - { "GL_ARB_vertex_buffer_object", o(dummy_true), GL, 2003 }, - { "GL_ARB_vertex_program", o(ARB_vertex_program), GL, 2002 }, + { "GL_ARB_vertex_buffer_object", o(dummy_true), GLL, 2003 }, + { "GL_ARB_vertex_program", o(ARB_vertex_program), GLL, 2002 }, { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL, 2002 }, { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL, 2009 }, - { "GL_ARB_window_pos", o(ARB_window_pos), GL, 2001 }, + { "GL_ARB_window_pos", o(ARB_window_pos), GLL, 2001 }, /* EXT extensions */ { "GL_EXT_abgr", o(dummy_true), GL, 1995 }, - { "GL_EXT_bgra", o(dummy_true), GL, 1995 }, - { "GL_EXT_blend_color", o(EXT_blend_color), GL, 1995 }, + { "GL_EXT_bgra", o(dummy_true), GLL, 1995 }, + { "GL_EXT_blend_color", o(EXT_blend_color), GLL, 1995 }, { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 }, - { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GL, 1999 }, - { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GL | ES1 | ES2, 1995 }, - { "GL_EXT_blend_subtract", o(dummy_true), GL, 1995 }, + { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GLL, 1999 }, + { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GLL | ES1 | ES2, 1995 }, + { "GL_EXT_blend_subtract", o(dummy_true), GLL, 1995 }, { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL, 1996 }, - { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), GL, 1996 }, - { "GL_EXT_copy_texture", o(dummy_true), GL, 1995 }, + { "GL_EXT_compiled_vertex_array", o(EXT_compiled_vertex_array), GLL, 1996 }, + { "GL_EXT_copy_texture", o(dummy_true), GLL, 1995 }, { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL, 2002 }, { "GL_EXT_draw_buffers2", o(EXT_draw_buffers2), GL, 2006 }, { "GL_EXT_draw_instanced", o(ARB_draw_instanced), GL, 2006 }, - { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), GL, 1997 }, - { "GL_EXT_fog_coord", o(EXT_fog_coord), GL, 1999 }, + { "GL_EXT_draw_range_elements", o(EXT_draw_range_elements), GLL, 1997 }, + { "GL_EXT_fog_coord", o(EXT_fog_coord), GLL, 1999 }, { "GL_EXT_framebuffer_blit", o(EXT_framebuffer_blit), GL, 2005 }, { "GL_EXT_framebuffer_multisample", o(EXT_framebuffer_multisample), GL, 2005 }, { "GL_EXT_framebuffer_object", o(EXT_framebuffer_object), GL, 2000 }, { "GL_EXT_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL, 1998 }, - { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GL, 2006 }, + { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GLL, 2006 }, { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), GL, 2006 }, - { "GL_EXT_multi_draw_arrays", o(dummy_true), GL | ES1 | ES2, 1999 }, + { "GL_EXT_multi_draw_arrays", o(dummy_true), GLL | ES1 | ES2, 1999 }, { "GL_EXT_packed_depth_stencil", o(EXT_packed_depth_stencil), GL, 2005 }, { "GL_EXT_packed_float", o(EXT_packed_float), GL, 2004 }, - { "GL_EXT_packed_pixels", o(EXT_packed_pixels), GL, 1997 }, + { "GL_EXT_packed_pixels", o(EXT_packed_pixels), GLL, 1997 }, { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL, 2004 }, - { "GL_EXT_point_parameters", o(EXT_point_parameters), GL, 1997 }, - { "GL_EXT_polygon_offset", o(dummy_true), GL, 1995 }, + { "GL_EXT_point_parameters", o(EXT_point_parameters), GLL, 1997 }, + { "GL_EXT_polygon_offset", o(dummy_true), GLL, 1995 }, { "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL, 2009 }, - { "GL_EXT_rescale_normal", o(EXT_rescale_normal), GL, 1997 }, - { "GL_EXT_secondary_color", o(EXT_secondary_color), GL, 1999 }, - { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), GL, 2008 }, - { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), GL, 1997 }, - { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), GL, 2002 }, - { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GL, 2001 }, - { "GL_EXT_stencil_wrap", o(dummy_true), GL, 2002 }, - { "GL_EXT_subtexture", o(dummy_true), GL, 1995 }, - { "GL_EXT_texture3D", o(EXT_texture3D), GL, 1996 }, + { "GL_EXT_rescale_normal", o(EXT_rescale_normal), GLL, 1997 }, + { "GL_EXT_secondary_color", o(EXT_secondary_color), GLL, 1999 }, + { "GL_EXT_separate_shader_objects", o(EXT_separate_shader_objects), GLL, 2008 }, + { "GL_EXT_separate_specular_color", o(EXT_separate_specular_color), GLL, 1997 }, + { "GL_EXT_shadow_funcs", o(EXT_shadow_funcs), GLL, 2002 }, + { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GLL, 2001 }, + { "GL_EXT_stencil_wrap", o(dummy_true), GLL, 2002 }, + { "GL_EXT_subtexture", o(dummy_true), GLL, 1995 }, + { "GL_EXT_texture3D", o(EXT_texture3D), GLL, 1996 }, { "GL_EXT_texture_array", o(EXT_texture_array), GL, 2006 }, { "GL_EXT_texture_compression_dxt1", o(EXT_texture_compression_s3tc), GL | ES1 | ES2, 2004 }, { "GL_EXT_texture_compression_latc", o(EXT_texture_compression_latc), GL, 2006 }, { "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 }, { "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL, 2000 }, - { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GL, 2001 }, - { "GL_EXT_texture_edge_clamp", o(dummy_true), GL, 1997 }, - { "GL_EXT_texture_env_add", o(dummy_true), GL, 1999 }, - { "GL_EXT_texture_env_combine", o(dummy_true), GL, 2000 }, - { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GL, 2000 }, + { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GLL, 2001 }, + { "GL_EXT_texture_edge_clamp", o(dummy_true), GLL, 1997 }, + { "GL_EXT_texture_env_add", o(dummy_true), GLL, 1999 }, + { "GL_EXT_texture_env_combine", o(dummy_true), GLL, 2000 }, + { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GLL, 2000 }, { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), GL | ES1 | ES2, 1999 }, { "GL_EXT_texture_format_BGRA8888", o(dummy_true), ES1 | ES2, 2005 }, { "GL_EXT_texture_rg", o(ARB_texture_rg), ES2, 2011 }, { "GL_EXT_read_format_bgra", o(dummy_true), ES1 | ES2, 2009 }, { "GL_EXT_texture_integer", o(EXT_texture_integer), GL, 2006 }, - { "GL_EXT_texture_lod_bias", o(dummy_true), GL | ES1, 1999 }, + { "GL_EXT_texture_lod_bias", o(dummy_true), GLL | ES1, 1999 }, { "GL_EXT_texture_mirror_clamp", o(EXT_texture_mirror_clamp), GL, 2004 }, - { "GL_EXT_texture_object", o(dummy_true), GL, 1995 }, - { "GL_EXT_texture", o(dummy_true), GL, 1996 }, - { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GL, 2004 }, + { "GL_EXT_texture_object", o(dummy_true), GLL, 1995 }, + { "GL_EXT_texture", o(dummy_true), GLL, 1996 }, + { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GLL, 2004 }, { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL, 2004 }, { "GL_EXT_texture_snorm", o(EXT_texture_snorm), GL, 2009 }, { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL, 2004 }, @@ -223,7 +223,7 @@ static const struct extension extension_table[] = { { "GL_EXT_transform_feedback", o(EXT_transform_feedback), GL, 2011 }, { "GL_EXT_unpack_subimage", o(dummy_true), ES2, 2011 }, { "GL_EXT_vertex_array_bgra", o(EXT_vertex_array_bgra), GL, 2008 }, - { "GL_EXT_vertex_array", o(dummy_true), GL, 1995 }, + { "GL_EXT_vertex_array", o(dummy_true), GLL, 1995 }, /* OES extensions */ { "GL_OES_blend_equation_separate", o(EXT_blend_equation_separate), ES1, 2009 }, @@ -274,52 +274,52 @@ static const struct extension extension_table[] = { { "GL_AMD_seamless_cubemap_per_texture", o(AMD_seamless_cubemap_per_texture), GL, 2009 }, { "GL_AMD_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 }, { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL, 2006 }, - { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GL, 2002 }, - { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GL, 2002 }, + { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GLL, 2002 }, + { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GLL, 2002 }, { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 }, - { "GL_ATI_draw_buffers", o(dummy_true), GL, 2002 }, - { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GL, 2001 }, - { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GL, 2001 }, - { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GL, 2006 }, + { "GL_ATI_draw_buffers", o(dummy_true), GLL, 2002 }, + { "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GLL, 2001 }, + { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GLL, 2001 }, + { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GLL, 2006 }, { "GL_ATI_texture_compression_3dc", o(ATI_texture_compression_3dc), GL, 2004 }, - { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GL, 2002 }, + { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GLL, 2002 }, { "GL_ATI_texture_float", o(ARB_texture_float), GL, 2002 }, { "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL, 2006 }, { "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), GL, 1998 }, { "GL_IBM_rasterpos_clip", o(IBM_rasterpos_clip), GL, 1996 }, - { "GL_IBM_texture_mirrored_repeat", o(dummy_true), GL, 1998 }, - { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GL, 1999 }, + { "GL_IBM_texture_mirrored_repeat", o(dummy_true), GLL, 1998 }, + { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GLL, 1999 }, { "GL_MESA_pack_invert", o(MESA_pack_invert), GL, 2002 }, { "GL_MESA_resize_buffers", o(MESA_resize_buffers), GL, 1999 }, - { "GL_MESA_texture_array", o(MESA_texture_array), GL, 2007 }, + { "GL_MESA_texture_array", o(MESA_texture_array), GLL, 2007 }, { "GL_MESA_texture_signed_rgba", o(EXT_texture_snorm), GL, 2009 }, - { "GL_MESA_window_pos", o(ARB_window_pos), GL, 2000 }, + { "GL_MESA_window_pos", o(ARB_window_pos), GLL, 2000 }, { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL, 2002 }, - { "GL_NV_blend_square", o(NV_blend_square), GL, 1999 }, + { "GL_NV_blend_square", o(NV_blend_square), GLL, 1999 }, { "GL_NV_conditional_render", o(NV_conditional_render), GL, 2008 }, { "GL_NV_depth_clamp", o(ARB_depth_clamp), GL, 2001 }, { "GL_NV_draw_buffers", o(dummy_true), ES2, 2011 }, { "GL_NV_fbo_color_attachments", o(EXT_framebuffer_object), ES2, 2010 }, - { "GL_NV_fog_distance", o(NV_fog_distance), GL, 2001 }, - { "GL_NV_fragment_program", o(NV_fragment_program), GL, 2001 }, - { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GL, 2005 }, - { "GL_NV_light_max_exponent", o(NV_light_max_exponent), GL, 1999 }, + { "GL_NV_fog_distance", o(NV_fog_distance), GLL, 2001 }, + { "GL_NV_fragment_program", o(NV_fragment_program), GLL, 2001 }, + { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GLL, 2005 }, + { "GL_NV_light_max_exponent", o(NV_light_max_exponent), GLL, 1999 }, { "GL_NV_packed_depth_stencil", o(EXT_packed_depth_stencil), GL, 2000 }, { "GL_NV_point_sprite", o(NV_point_sprite), GL, 2001 }, { "GL_NV_primitive_restart", o(NV_primitive_restart), GL, 2002 }, { "GL_NV_read_buffer", o(dummy_true), ES2, 2011 }, - { "GL_NV_texgen_reflection", o(NV_texgen_reflection), GL, 1999 }, + { "GL_NV_texgen_reflection", o(NV_texgen_reflection), GLL, 1999 }, { "GL_NV_texture_barrier", o(NV_texture_barrier), GL, 2009 }, - { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GL, 1999 }, - { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GL, 2000 }, - { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), GL, 2001 }, - { "GL_NV_vertex_program", o(NV_vertex_program), GL, 2000 }, + { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GLL, 1999 }, + { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GLL, 2000 }, + { "GL_NV_vertex_program1_1", o(NV_vertex_program1_1), GLL, 2001 }, + { "GL_NV_vertex_program", o(NV_vertex_program), GLL, 2000 }, { "GL_S3_s3tc", o(S3_s3tc), GL, 1999 }, - { "GL_SGIS_generate_mipmap", o(dummy_true), GL, 1997 }, - { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GL, 1997 }, - { "GL_SGIS_texture_edge_clamp", o(dummy_true), GL, 1997 }, - { "GL_SGIS_texture_lod", o(SGIS_texture_lod), GL, 1997 }, - { "GL_SUN_multi_draw_arrays", o(dummy_true), GL, 1999 }, + { "GL_SGIS_generate_mipmap", o(dummy_true), GLL, 1997 }, + { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 1997 }, + { "GL_SGIS_texture_edge_clamp", o(dummy_true), GLL, 1997 }, + { "GL_SGIS_texture_lod", o(SGIS_texture_lod), GLL, 1997 }, + { "GL_SUN_multi_draw_arrays", o(dummy_true), GLL, 1999 }, { 0, 0, 0, 0 }, }; @@ -427,7 +427,6 @@ _mesa_enable_sw_extensions(struct gl_context *ctx) ctx->Extensions.ARB_shading_language_100 = GL_TRUE; #endif ctx->Extensions.ARB_shadow = GL_TRUE; - ctx->Extensions.ARB_shadow_ambient = GL_TRUE; ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; ctx->Extensions.ARB_texture_cube_map = GL_TRUE; ctx->Extensions.ARB_texture_env_combine = GL_TRUE; diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index d558d7f87..aa8ba1882 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -685,6 +685,9 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, assert(_mesa_is_user_fbo(fb)); + /* we're changing framebuffer fields here */ + FLUSH_VERTICES(ctx, _NEW_BUFFERS); + numImages = 0; fb->Width = 0; fb->Height = 0; @@ -3006,3 +3009,144 @@ _mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, "not implemented!"); } #endif /* FEATURE_ARB_geometry_shader4 */ + +static void +invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments, + const GLenum *attachments, GLint x, GLint y, + GLsizei width, GLsizei height, const char *name) +{ + int i; + struct gl_framebuffer *fb; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + fb = get_framebuffer_target(ctx, target); + if (!fb) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", name); + return; + } + + if (numAttachments < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "%s(numAttachments < 0)", name); + return; + } + + /* The GL_ARB_invalidate_subdata spec says: + * + * "If an attachment is specified that does not exist in the + * framebuffer bound to <target>, it is ignored." + * + * It also says: + * + * "If <attachments> contains COLOR_ATTACHMENTm and m is greater than + * or equal to the value of MAX_COLOR_ATTACHMENTS, then the error + * INVALID_OPERATION is generated." + * + * No mention is made of GL_AUXi being out of range. Therefore, we allow + * any enum that can be allowed by the API (OpenGL ES 3.0 has a different + * set of retrictions). + */ + for (i = 0; i < numAttachments; i++) { + if (_mesa_is_winsys_fbo(fb)) { + switch (attachments[i]) { + case GL_ACCUM: + case GL_AUX0: + case GL_AUX1: + case GL_AUX2: + case GL_AUX3: + /* Accumulation buffers and auxilary buffers were removed in + * OpenGL 3.1, and they never existed in OpenGL ES. + */ + if (ctx->API != API_OPENGL) + goto invalid_enum; + break; + case GL_COLOR: + case GL_DEPTH: + case GL_STENCIL: + break; + case GL_BACK_LEFT: + case GL_BACK_RIGHT: + case GL_FRONT_LEFT: + case GL_FRONT_RIGHT: + if (!_mesa_is_desktop_gl(ctx)) + goto invalid_enum; + break; + default: + goto invalid_enum; + } + } else { + switch (attachments[i]) { + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + case GL_COLOR_ATTACHMENT0: + case GL_COLOR_ATTACHMENT1: + case GL_COLOR_ATTACHMENT2: + case GL_COLOR_ATTACHMENT3: + case GL_COLOR_ATTACHMENT4: + case GL_COLOR_ATTACHMENT5: + case GL_COLOR_ATTACHMENT6: + case GL_COLOR_ATTACHMENT7: + case GL_COLOR_ATTACHMENT8: + case GL_COLOR_ATTACHMENT9: + case GL_COLOR_ATTACHMENT10: + case GL_COLOR_ATTACHMENT11: + case GL_COLOR_ATTACHMENT12: + case GL_COLOR_ATTACHMENT13: + case GL_COLOR_ATTACHMENT14: + case GL_COLOR_ATTACHMENT15: { + const int k = attachments[i] - GL_COLOR_ATTACHMENT0; + if (k >= ctx->Const.MaxColorAttachments) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(attachment >= max. color attachments)", name); + return; + } + } + default: + goto invalid_enum; + } + } + } + + /* We don't actually do anything for this yet. Just return after + * validating the parameters and generating the required errors. + */ + return; + +invalid_enum: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(attachment)", name); + return; +} + +void GLAPIENTRY +_mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, + const GLenum *attachments, GLint x, GLint y, + GLsizei width, GLsizei height) +{ + invalidate_framebuffer_storage(target, numAttachments, attachments, + x, y, width, height, + "glInvalidateSubFramebuffer"); +} + +void GLAPIENTRY +_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, + const GLenum *attachments) +{ + /* The GL_ARB_invalidate_subdata spec says: + * + * "The command + * + * void InvalidateFramebuffer(enum target, + * sizei numAttachments, + * const enum *attachments); + * + * is equivalent to the command InvalidateSubFramebuffer with <x>, <y>, + * <width>, <height> equal to 0, 0, <MAX_VIEWPORT_DIMS[0]>, + * <MAX_VIEWPORT_DIMS[1]> respectively." + */ + invalidate_framebuffer_storage(target, numAttachments, attachments, + 0, 0, MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT, + "glInvalidateFramebuffer"); +} diff --git a/mesalib/src/mesa/main/fbobject.h b/mesalib/src/mesa/main/fbobject.h index 3aee842f5..9cded3cfa 100644 --- a/mesalib/src/mesa/main/fbobject.h +++ b/mesalib/src/mesa/main/fbobject.h @@ -214,4 +214,13 @@ _mesa_FramebufferTextureFaceARB(GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +extern void GLAPIENTRY +_mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, + const GLenum *attachments, GLint x, GLint y, + GLsizei width, GLsizei height); + +extern void GLAPIENTRY +_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, + const GLenum *attachments); + #endif /* FBOBJECT_H */ diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c index 529c416a8..bd218520f 100644 --- a/mesalib/src/mesa/main/format_unpack.c +++ b/mesalib/src/mesa/main/format_unpack.c @@ -1604,6 +1604,11 @@ get_unpack_rgba_function(gl_format format) initialized = GL_TRUE; } + if (table[format] == NULL) { + _mesa_problem(NULL, "unsupported unpack for format %s", + _mesa_get_format_name(format)); + } + return table[format]; } diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 8fcb6b456..552c1cf69 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1250,7 +1250,6 @@ struct gl_sampler_object GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ GLenum CompareMode; /**< GL_ARB_shadow */ GLenum CompareFunc; /**< GL_ARB_shadow */ - GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */ }; @@ -2972,7 +2971,6 @@ struct gl_extensions GLboolean ARB_shader_texture_lod; GLboolean ARB_shading_language_100; GLboolean ARB_shadow; - GLboolean ARB_shadow_ambient; GLboolean ARB_sync; GLboolean ARB_texture_border_clamp; GLboolean ARB_texture_buffer_object; diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c index 83192c157..7aebd45ea 100644 --- a/mesalib/src/mesa/main/pack.c +++ b/mesalib/src/mesa/main/pack.c @@ -462,8 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) } } -/* Customization of integer packing. We always treat src as uint, and can pack dst - * as any integer type/format combo. +/* Customization of unsigned integer packing. */ #define SRC_TYPE GLuint @@ -475,6 +474,14 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef SRC_CONVERT #undef FN_NAME +#define DST_TYPE GLint +#define SRC_CONVERT(x) MIN2(x, 0x7fffffff) +#define FN_NAME pack_int_from_uint_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + #define DST_TYPE GLushort #define SRC_CONVERT(x) MIN2(x, 0xffff) #define FN_NAME pack_ushort_from_uint_rgba @@ -507,18 +514,32 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef SRC_CONVERT #undef FN_NAME +#undef SRC_TYPE + +static void +_pack_rgba_span_from_uints_problem(struct gl_context *ctx, + GLenum dstFormat, GLenum dstType) +{ + _mesa_problem(ctx, + "Unsupported type (%s) / format (%s) " + "in _mesa_pack_rgba_span_from_uints", + _mesa_lookup_enum_by_nr(dstType), + _mesa_lookup_enum_by_nr(dstFormat)); +} + void -_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr) +_mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][4], + GLenum dstFormat, GLenum dstType, + GLvoid *dstAddr) { + GLuint i; + switch(dstType) { case GL_UNSIGNED_INT: pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); break; case GL_INT: - /* No conversion necessary. */ - pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); + pack_int_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); break; case GL_UNSIGNED_SHORT: pack_ushort_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); @@ -532,11 +553,691 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], case GL_BYTE: pack_byte_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); break; + case GL_UNSIGNED_BYTE_3_3_2: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLubyte *dst = (GLubyte *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5) + | (CLAMP(rgba[i][GCOMP], 0, 7) << 2) + | (CLAMP(rgba[i][BCOMP], 0, 3) ); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLubyte *dst = (GLubyte *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) ) + | (CLAMP(rgba[i][GCOMP], 0, 7) << 3) + | (CLAMP(rgba[i][BCOMP], 0, 3) << 6); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) + | (CLAMP(rgba[i][GCOMP], 0, 63) << 5) + | (CLAMP(rgba[i][BCOMP], 0, 31) ); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) ) + | (CLAMP(rgba[i][GCOMP], 0, 63) << 5) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 11); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][ACOMP], 0, 15) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][ACOMP], 0, 15) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][RCOMP], 0, 15) ); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) ) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) ) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][RCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) ) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 15) << 12); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 6) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 1) + | (CLAMP(rgba[i][ACOMP], 0, 1) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 6) + | (CLAMP(rgba[i][RCOMP], 0, 31) << 1) + | (CLAMP(rgba[i][ACOMP], 0, 1) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 6) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 1) + | (CLAMP(rgba[i][RCOMP], 0, 1) ); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) ) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 5) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 10) + | (CLAMP(rgba[i][ACOMP], 0, 1) << 15); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) ) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 5) + | (CLAMP(rgba[i][RCOMP], 0, 31) << 10) + | (CLAMP(rgba[i][ACOMP], 0, 1) << 15); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) ) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 5) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 10) + | (CLAMP(rgba[i][RCOMP], 0, 1) << 15); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 255) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][RCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 255) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 255) ); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) ) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) ) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) ) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][RCOMP], 0, 255) << 24); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 2) + | (CLAMP(rgba[i][ACOMP], 0, 3) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) + | (CLAMP(rgba[i][RCOMP], 0, 1023) << 2) + | (CLAMP(rgba[i][ACOMP], 0, 3) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 2) + | (CLAMP(rgba[i][RCOMP], 0, 3) ); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) ) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20) + | (CLAMP(rgba[i][ACOMP], 0, 3) << 30); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) ) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) + | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20) + | (CLAMP(rgba[i][ACOMP], 0, 3) << 30); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) ) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20) + | (CLAMP(rgba[i][RCOMP], 0, 3) << 30); + } + } else { + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + } + break; + default: + _pack_rgba_span_from_uints_problem(ctx, dstFormat, dstType); + return; + } +} + + +/* Customization of signed integer packing. + */ +#define SRC_TYPE GLint + +#define DST_TYPE GLuint +#define SRC_CONVERT(x) MAX2(x, 0) +#define FN_NAME pack_uint_from_int_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLushort +#define SRC_CONVERT(x) MAX2(x, 0) +#define FN_NAME pack_ushort_from_int_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLshort +#define SRC_CONVERT(x) CLAMP(x, -0x8000, 0x7fff) +#define FN_NAME pack_short_from_int_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLubyte +#define SRC_CONVERT(x) MAX2(x, 0) +#define FN_NAME pack_ubyte_from_int_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#define DST_TYPE GLbyte +#define SRC_CONVERT(x) CLAMP(x, -0x80, 0x7f) +#define FN_NAME pack_byte_from_int_rgba +#include "pack_tmp.h" +#undef DST_TYPE +#undef SRC_CONVERT +#undef FN_NAME + +#undef SRC_TYPE + +static void +_pack_rgba_span_from_ints_problem(struct gl_context *ctx, + GLenum dstFormat, GLenum dstType) +{ + _mesa_problem(ctx, + "Unsupported type (%s) / format (%s) " + "in _mesa_pack_rgba_span_from_ints", + _mesa_lookup_enum_by_nr(dstType), + _mesa_lookup_enum_by_nr(dstFormat)); +} + +void +_mesa_pack_rgba_span_from_ints(struct gl_context *ctx, GLuint n, GLint rgba[][4], + GLenum dstFormat, GLenum dstType, + GLvoid *dstAddr) +{ + GLuint i; + + switch(dstType) { + case GL_UNSIGNED_INT: + pack_uint_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); + break; + case GL_INT: + /* No conversion necessary. */ + pack_uint_from_uint_rgba(ctx, dstAddr, dstFormat, rgba, n); + break; + case GL_UNSIGNED_SHORT: + pack_ushort_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); + break; + case GL_SHORT: + pack_short_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); + break; + case GL_UNSIGNED_BYTE: + pack_ubyte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); + break; + case GL_BYTE: + pack_byte_from_int_rgba(ctx, dstAddr, dstFormat, rgba, n); + break; + case GL_UNSIGNED_BYTE_3_3_2: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLubyte *dst = (GLubyte *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) << 5) + | (CLAMP(rgba[i][GCOMP], 0, 7) << 2) + | (CLAMP(rgba[i][BCOMP], 0, 3) ); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLubyte *dst = (GLubyte *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 7) ) + | (CLAMP(rgba[i][GCOMP], 0, 7) << 3) + | (CLAMP(rgba[i][BCOMP], 0, 3) << 6); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) + | (CLAMP(rgba[i][GCOMP], 0, 63) << 5) + | (CLAMP(rgba[i][BCOMP], 0, 31) ); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + if ((dstFormat == GL_RGB) || (dstFormat == GL_RGB_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) ) + | (CLAMP(rgba[i][GCOMP], 0, 63) << 5) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 11); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) << 12) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][ACOMP], 0, 15) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) << 12) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][ACOMP], 0, 15) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) << 12) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][RCOMP], 0, 15) ); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 15) ) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 15) ) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][RCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 15) << 12); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 15) ) + | (CLAMP(rgba[i][BCOMP], 0, 15) << 4) + | (CLAMP(rgba[i][GCOMP], 0, 15) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 15) << 12); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_5_5_5_1: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) << 11) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 6) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 1) + | (CLAMP(rgba[i][ACOMP], 0, 1) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) << 11) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 6) + | (CLAMP(rgba[i][RCOMP], 0, 31) << 1) + | (CLAMP(rgba[i][ACOMP], 0, 1) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) << 11) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 6) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 1) + | (CLAMP(rgba[i][RCOMP], 0, 1) ); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 31) ) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 5) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 10) + | (CLAMP(rgba[i][ACOMP], 0, 1) << 15); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 31) ) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 5) + | (CLAMP(rgba[i][RCOMP], 0, 31) << 10) + | (CLAMP(rgba[i][ACOMP], 0, 1) << 15); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLushort *dst = (GLushort *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 31) ) + | (CLAMP(rgba[i][BCOMP], 0, 31) << 5) + | (CLAMP(rgba[i][GCOMP], 0, 31) << 10) + | (CLAMP(rgba[i][RCOMP], 0, 1) << 15); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) << 24) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 255) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) << 24) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][RCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][ACOMP], 0, 255) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) << 24) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 255) ); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 255) ) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 255) ) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][RCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][ACOMP], 0, 255) << 24); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 255) ) + | (CLAMP(rgba[i][BCOMP], 0, 255) << 8) + | (CLAMP(rgba[i][GCOMP], 0, 255) << 16) + | (CLAMP(rgba[i][RCOMP], 0, 255) << 24); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) << 22) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 2) + | (CLAMP(rgba[i][ACOMP], 0, 3) ); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) << 22) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 12) + | (CLAMP(rgba[i][RCOMP], 0, 1023) << 2) + | (CLAMP(rgba[i][ACOMP], 0, 3) ); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) << 22) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 12) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 2) + | (CLAMP(rgba[i][RCOMP], 0, 3) ); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + if ((dstFormat == GL_RGBA) || (dstFormat == GL_RGBA_INTEGER_EXT)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][RCOMP], 0, 1023) ) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 20) + | (CLAMP(rgba[i][ACOMP], 0, 3) << 30); + } + } + else if ((dstFormat == GL_BGRA) || (dstFormat == GL_BGRA_INTEGER)) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][BCOMP], 0, 1023) ) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 10) + | (CLAMP(rgba[i][RCOMP], 0, 1023) << 20) + | (CLAMP(rgba[i][ACOMP], 0, 3) << 30); + } + } + else if (dstFormat == GL_ABGR_EXT) { + GLuint *dst = (GLuint *) dstAddr; + for (i=0;i<n;i++) { + dst[i] = (CLAMP(rgba[i][ACOMP], 0, 1023) ) + | (CLAMP(rgba[i][BCOMP], 0, 1023) << 10) + | (CLAMP(rgba[i][GCOMP], 0, 1023) << 20) + | (CLAMP(rgba[i][RCOMP], 0, 3) << 30); + } + } else { + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); + } + break; default: - _mesa_problem(ctx, - "Unsupported type (%s) for format (%s)", - _mesa_lookup_enum_by_nr(dstType), - _mesa_lookup_enum_by_nr(dstFormat)); + _pack_rgba_span_from_ints_problem(ctx, dstFormat, dstType); return; } } @@ -4913,7 +5614,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n, else { /* need to use double precision to prevent overflow problems */ for (i = 0; i < n; i++) { - GLdouble z = depthValues[i] * (GLfloat) depthMax; + GLdouble z = depthValues[i] * (GLdouble) depthMax; if (z >= (GLdouble) 0xffffffff) zValues[i] = 0xffffffff; else diff --git a/mesalib/src/mesa/main/pack.h b/mesalib/src/mesa/main/pack.h index cd49c7495..2fbdf9115 100644 --- a/mesalib/src/mesa/main/pack.h +++ b/mesalib/src/mesa/main/pack.h @@ -145,9 +145,15 @@ _mesa_unpack_image(GLuint dimensions, void -_mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], - GLenum dstFormat, GLenum dstType, - GLvoid *dstAddr); +_mesa_pack_rgba_span_from_uints(struct gl_context *ctx, GLuint n, GLuint rgba[][4], + GLenum dstFormat, GLenum dstType, + GLvoid *dstAddr); + + +void +_mesa_pack_rgba_span_from_ints(struct gl_context *ctx, GLuint n, GLint rgba[][4], + GLenum dstFormat, GLenum dstType, + GLvoid *dstAddr); extern void diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c index 7ac877497..f0bc157d8 100644 --- a/mesalib/src/mesa/main/readpix.c +++ b/mesalib/src/mesa/main/readpix.c @@ -322,6 +322,8 @@ slow_read_rgba_pixels( struct gl_context *ctx, void *rgba; GLubyte *dst, *map; int dstStride, stride, j; + GLboolean dst_is_integer = _mesa_is_enum_format_integer(format); + GLboolean dst_is_uint = _mesa_is_format_unsigned(rbFormat); dstStride = _mesa_image_row_stride(packing, width, format, type); dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, @@ -339,12 +341,17 @@ slow_read_rgba_pixels( struct gl_context *ctx, goto done; for (j = 0; j < height; j++) { - if (_mesa_is_enum_format_integer(format)) { + if (dst_is_integer) { _mesa_unpack_uint_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba); _mesa_rebase_rgba_uint(width, (GLuint (*)[4]) rgba, rb->_BaseFormat); - _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4]) rgba, format, - type, dst); + if (dst_is_uint) { + _mesa_pack_rgba_span_from_uints(ctx, width, (GLuint (*)[4]) rgba, format, + type, dst); + } else { + _mesa_pack_rgba_span_from_ints(ctx, width, (GLint (*)[4]) rgba, format, + type, dst); + } } else { _mesa_unpack_rgba_row(rbFormat, width, map, (GLfloat (*)[4]) rgba); _mesa_rebase_rgba_float(width, (GLfloat (*)[4]) rgba, diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c index dc8adfc3f..8bf5f490a 100644 --- a/mesalib/src/mesa/main/samplerobj.c +++ b/mesalib/src/mesa/main/samplerobj.c @@ -130,7 +130,6 @@ _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name) sampObj->MaxAnisotropy = 1.0F; sampObj->CompareMode = GL_NONE; sampObj->CompareFunc = GL_LEQUAL; - sampObj->CompareFailValue = 0.0; sampObj->sRGBDecode = GL_DECODE_EXT; sampObj->CubeMapSeamless = GL_FALSE; } diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c index 0ba3ff5b3..4cd87c645 100644 --- a/mesalib/src/mesa/main/texgetimage.c +++ b/mesalib/src/mesa/main/texgetimage.c @@ -306,7 +306,8 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, GLuint img, row; GLfloat (*rgba)[4]; GLuint (*rgba_uint)[4]; - GLboolean is_integer = _mesa_is_format_integer_color(texImage->TexFormat); + GLboolean tex_is_integer = _mesa_is_format_integer_color(texImage->TexFormat); + GLboolean tex_is_uint = _mesa_is_format_unsigned(texImage->TexFormat); /* Allocate buffer for one row of texels */ rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat)); @@ -358,12 +359,19 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, width, height, format, type, img, row, 0); - if (is_integer) { + if (tex_is_integer) { _mesa_unpack_uint_rgba_row(texFormat, width, src, rgba_uint); if (rebaseFormat) _mesa_rebase_rgba_uint(width, rgba_uint, rebaseFormat); - _mesa_pack_rgba_span_int(ctx, width, rgba_uint, - format, type, dest); + if (tex_is_uint) { + _mesa_pack_rgba_span_from_uints(ctx, width, + (GLuint (*)[4]) rgba_uint, + format, type, dest); + } else { + _mesa_pack_rgba_span_from_ints(ctx, width, + (GLint (*)[4]) rgba_uint, + format, type, dest); + } } else { _mesa_unpack_rgba_row(texFormat, width, src, rgba); if (rebaseFormat) diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index f70da4fbc..1d905b608 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -144,7 +144,6 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj, obj->Sampler.MaxAnisotropy = 1.0; obj->Sampler.CompareMode = GL_NONE; /* ARB_shadow */ obj->Sampler.CompareFunc = GL_LEQUAL; /* ARB_shadow */ - obj->Sampler.CompareFailValue = 0.0F; /* ARB_shadow_ambient */ obj->DepthMode = GL_LUMINANCE; obj->Sampler.CubeMapSeamless = GL_FALSE; obj->Swizzle[0] = GL_RED; @@ -257,7 +256,6 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, dest->Sampler.MaxAnisotropy = src->Sampler.MaxAnisotropy; dest->Sampler.CompareMode = src->Sampler.CompareMode; dest->Sampler.CompareFunc = src->Sampler.CompareFunc; - dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue; dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless; dest->DepthMode = src->DepthMode; dest->Sampler.sRGBDecode = src->Sampler.sRGBDecode; @@ -879,7 +877,58 @@ _mesa_total_texture_memory(struct gl_context *ctx) return total; } +static struct gl_texture_object * +invalidate_tex_image_error_check(struct gl_context *ctx, GLuint texture, + GLint level, const char *name) +{ + /* The GL_ARB_invalidate_subdata spec says: + * + * "If <texture> is zero or is not the name of a texture, the error + * INVALID_VALUE is generated." + * + * This performs the error check in a different order than listed in the + * spec. We have to get the texture object before we can validate the + * other parameters against values in the texture object. + */ + struct gl_texture_object *const t = _mesa_lookup_texture(ctx, texture); + if (texture == 0 || t == NULL) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(texture)", name); + return NULL; + } + /* The GL_ARB_invalidate_subdata spec says: + * + * "If <level> is less than zero or greater than the base 2 logarithm + * of the maximum texture width, height, or depth, the error + * INVALID_VALUE is generated." + */ + if (level < 0 || level > t->MaxLevel) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", name); + return NULL; + } + + /* The GL_ARB_invalidate_subdata spec says: + * + * "If the target of <texture> is TEXTURE_RECTANGLE, TEXTURE_BUFFER, + * TEXTURE_2D_MULTISAMPLE, or TEXTURE_2D_MULTISAMPLE_ARRAY, and <level> + * is not zero, the error INVALID_VALUE is generated." + */ + if (level != 0) { + switch (t->Target) { + case GL_TEXTURE_RECTANGLE: + case GL_TEXTURE_BUFFER: + case GL_TEXTURE_2D_MULTISAMPLE: + case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: + _mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", name); + return NULL; + + default: + break; + } + } + + return t; +} /*@}*/ @@ -1348,4 +1397,164 @@ _mesa_unlock_context_textures( struct gl_context *ctx ) _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex); } +void GLAPIENTRY +_mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth) +{ + struct gl_texture_object *t; + struct gl_texture_image *image; + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + t = invalidate_tex_image_error_check(ctx, texture, level, + "glInvalidateTexSubImage"); + + /* The GL_ARB_invalidate_subdata spec says: + * + * "...the specified subregion must be between -<b> and <dim>+<b> where + * <dim> is the size of the dimension of the texture image, and <b> is + * the size of the border of that texture image, otherwise + * INVALID_VALUE is generated (border is not applied to dimensions that + * don't exist in a given texture target)." + */ + image = t->Image[0][level]; + if (image) { + int xBorder; + int yBorder; + int zBorder; + int imageWidth; + int imageHeight; + int imageDepth; + + /* The GL_ARB_invalidate_subdata spec says: + * + * "For texture targets that don't have certain dimensions, this + * command treats those dimensions as having a size of 1. For + * example, to invalidate a portion of a two-dimensional texture, + * the application would use <zoffset> equal to zero and <depth> + * equal to one." + */ + switch (t->Target) { + case GL_TEXTURE_BUFFER: + xBorder = 0; + yBorder = 0; + zBorder = 0; + imageWidth = 1; + imageHeight = 1; + imageDepth = 1; + break; + case GL_TEXTURE_1D: + xBorder = image->Border; + yBorder = 0; + zBorder = 0; + imageWidth = image->Width; + imageHeight = 1; + imageDepth = 1; + break; + case GL_TEXTURE_1D_ARRAY: + xBorder = image->Border; + yBorder = 0; + zBorder = 0; + imageWidth = image->Width; + imageHeight = image->Height; + imageDepth = 1; + break; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_RECTANGLE: + case GL_TEXTURE_2D_MULTISAMPLE: + xBorder = image->Border; + yBorder = image->Border; + zBorder = 0; + imageWidth = image->Width; + imageHeight = image->Height; + imageDepth = 1; + break; + case GL_TEXTURE_2D_ARRAY: + case GL_TEXTURE_CUBE_MAP_ARRAY: + xBorder = image->Border; + yBorder = image->Border; + zBorder = 0; + imageWidth = image->Width; + imageHeight = image->Height; + imageDepth = image->Depth; + break; + case GL_TEXTURE_3D: + xBorder = image->Border; + yBorder = image->Border; + zBorder = image->Border; + imageWidth = image->Width; + imageHeight = image->Height; + imageDepth = image->Depth; + break; + default: + assert(!"Should not get here."); + xBorder = 0; + yBorder = 0; + zBorder = 0; + imageWidth = 0; + imageHeight = 0; + imageDepth = 0; + break; + } + + if (xoffset < -xBorder) { + _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateSubTexImage(xoffset)"); + return; + } + + if (xoffset + width > imageWidth + xBorder) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateSubTexImage(xoffset+width)"); + return; + } + + if (yoffset < -yBorder) { + _mesa_error(ctx, GL_INVALID_VALUE, "glInvalidateSubTexImage(yoffset)"); + return; + } + + if (yoffset + height > imageHeight + yBorder) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateSubTexImage(yoffset+height)"); + return; + } + + if (zoffset < -zBorder) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateSubTexImage(zoffset)"); + return; + } + + if (zoffset + depth > imageDepth + zBorder) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glInvalidateSubTexImage(zoffset+depth)"); + return; + } + } + + /* We don't actually do anything for this yet. Just return after + * validating the parameters and generating the required errors. + */ + return; +} + +void GLAPIENTRY +_mesa_InvalidateTexImage(GLuint texture, GLint level) +{ + GET_CURRENT_CONTEXT(ctx); + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + invalidate_tex_image_error_check(ctx, texture, level, + "glInvalidateTexImage"); + + /* We don't actually do anything for this yet. Just return after + * validating the parameters and generating the required errors. + */ + return; +} + /*@}*/ diff --git a/mesalib/src/mesa/main/texobj.h b/mesalib/src/mesa/main/texobj.h index 23e1ade09..93e0d7738 100644 --- a/mesalib/src/mesa/main/texobj.h +++ b/mesalib/src/mesa/main/texobj.h @@ -152,6 +152,14 @@ _mesa_AreTexturesResident( GLsizei n, const GLuint *textures, extern GLboolean GLAPIENTRY _mesa_IsTexture( GLuint texture ); +extern void GLAPIENTRY +_mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth); + +extern void GLAPIENTRY +_mesa_InvalidateTexImage(GLuint texture, GLint level); + /*@}*/ diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index 9e7c3e457..690fd6c25 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -541,20 +541,6 @@ set_tex_parameterf(struct gl_context *ctx, } return GL_FALSE; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (ctx->Extensions.ARB_shadow_ambient) { - if (texObj->Sampler.CompareFailValue != params[0]) { - flush(ctx); - texObj->Sampler.CompareFailValue = CLAMP(params[0], 0.0F, 1.0F); - return GL_TRUE; - } - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)"); - } - return GL_FALSE; - case GL_TEXTURE_LOD_BIAS: /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */ if (texObj->Sampler.LodBias != params[0]) { @@ -1136,11 +1122,6 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) goto invalid_pname; *params = obj->Sampler.MaxAnisotropy; break; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (!ctx->Extensions.ARB_shadow_ambient) - goto invalid_pname; - *params = obj->Sampler.CompareFailValue; - break; case GL_GENERATE_MIPMAP_SGIS: *params = (GLfloat) obj->GenerateMipmap; break; @@ -1282,11 +1263,6 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) goto invalid_pname; *params = (GLint) obj->Sampler.MaxAnisotropy; break; - case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: - if (!ctx->Extensions.ARB_shadow_ambient) - goto invalid_pname; - *params = (GLint) FLOAT_TO_INT(obj->Sampler.CompareFailValue); - break; case GL_GENERATE_MIPMAP_SGIS: *params = (GLint) obj->GenerateMipmap; break; diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 544c08d73..18429f581 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -3200,6 +3200,7 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) srcPacking); const GLuint *src = tempImage; GLint img, row; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { @@ -3207,8 +3208,14 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLbyte *dstTexel = (GLbyte *) dstRow; GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLbyte) src[i]; + if (is_unsigned) { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLbyte) MIN2(src[i], 0x7f); + } + } else { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLbyte) CLAMP((GLint) src[i], -0x80, 0x7f); + } } dstRow += dstRowStride; src += srcWidth * components; @@ -3270,6 +3277,7 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) srcPacking); const GLuint *src = tempImage; GLint img, row; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { @@ -3277,8 +3285,14 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLshort *dstTexel = (GLshort *) dstRow; GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; + if (is_unsigned) { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLshort) MIN2(src[i], 0x7fff); + } + } else { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLshort)CLAMP((GLint) src[i], -0x8000, 0x7fff); + } } dstRow += dstRowStride; src += srcWidth * components; @@ -3340,6 +3354,7 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) srcPacking); const GLuint *src = tempImage; GLint img, row; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { @@ -3347,8 +3362,14 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLint *dstTexel = (GLint *) dstRow; GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLint) src[i]; + if (is_unsigned) { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) MIN2(src[i], 0x7fffffff); + } + } else { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLint) src[i]; + } } dstRow += dstRowStride; src += srcWidth * components; @@ -3407,6 +3428,7 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) srcFormat, srcType, srcAddr, srcPacking); const GLuint *src = tempImage; GLint img, row; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { @@ -3414,8 +3436,14 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLubyte *dstTexel = (GLubyte *) dstRow; GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLubyte) CLAMP(src[i], 0, 0xff); + if (is_unsigned) { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLubyte) MIN2(src[i], 0xff); + } + } else { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLubyte) CLAMP((GLint) src[i], 0, 0xff); + } } dstRow += dstRowStride; src += srcWidth * components; @@ -3474,6 +3502,7 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) srcFormat, srcType, srcAddr, srcPacking); const GLuint *src = tempImage; GLint img, row; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { @@ -3481,8 +3510,14 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLushort *dstTexel = (GLushort *) dstRow; GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = (GLushort) CLAMP(src[i], 0, 0xffff); + if (is_unsigned) { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLushort) MIN2(src[i], 0xffff); + } + } else { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = (GLushort) CLAMP((GLint) src[i], 0, 0xffff); + } } dstRow += dstRowStride; src += srcWidth * components; @@ -3540,6 +3575,7 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); const GLuint *src = tempImage; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); GLint img, row; if (!tempImage) return GL_FALSE; @@ -3548,8 +3584,14 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLuint *dstTexel = (GLuint *) dstRow; GLint i; - for (i = 0; i < srcWidth * components; i++) { - dstTexel[i] = src[i]; + if (is_unsigned) { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = src[i]; + } + } else { + for (i = 0; i < srcWidth * components; i++) { + dstTexel[i] = MAX2((GLint) src[i], 0); + } } dstRow += dstRowStride; src += srcWidth * components; @@ -3867,6 +3909,7 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) srcPacking); const GLuint *src = tempImage; GLint img, row, col; + GLboolean is_unsigned = _mesa_is_type_unsigned(srcType); if (!tempImage) return GL_FALSE; for (img = 0; img < srcDepth; img++) { @@ -3874,14 +3917,26 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; - for (col = 0; col < srcWidth; col++) { - GLushort a,r,g,b; - r = src[RCOMP]; - g = src[GCOMP]; - b = src[BCOMP]; - a = src[ACOMP]; - dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b); - src += 4; + if (is_unsigned) { + for (col = 0; col < srcWidth; col++) { + GLushort a,r,g,b; + r = MIN2(src[RCOMP], 0x3ff); + g = MIN2(src[GCOMP], 0x3ff); + b = MIN2(src[BCOMP], 0x3ff); + a = MIN2(src[ACOMP], 0x003); + dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b); + src += 4; + } + } else { + for (col = 0; col < srcWidth; col++) { + GLushort a,r,g,b; + r = CLAMP((GLint) src[RCOMP], 0, 0x3ff); + g = CLAMP((GLint) src[GCOMP], 0, 0x3ff); + b = CLAMP((GLint) src[BCOMP], 0, 0x3ff); + a = CLAMP((GLint) src[ACOMP], 0, 0x003); + dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b); + src += 4; + } } dstRow += dstRowStride; } diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c index 91212218e..f9c6677b1 100644 --- a/mesalib/src/mesa/program/prog_statevars.c +++ b/mesalib/src/mesa/program/prog_statevars.c @@ -551,22 +551,6 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], value[3] = ctx->Pixel.AlphaBias; return; - case STATE_SHADOW_AMBIENT: - { - const int unit = (int) state[2]; - const struct gl_texture_object *texObj - = ctx->Texture.Unit[unit]._Current; - const struct gl_sampler_object *samp = - _mesa_get_samplerobj(ctx, unit); - if (texObj) { - value[0] = - value[1] = - value[2] = - value[3] = samp->CompareFailValue; - } - } - return; - case STATE_FB_SIZE: value[0] = (GLfloat) (ctx->DrawBuffer->Width - 1); value[1] = (GLfloat) (ctx->DrawBuffer->Height - 1); @@ -702,7 +686,6 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) return _NEW_MODELVIEW; case STATE_TEXRECT_SCALE: - case STATE_SHADOW_AMBIENT: case STATE_ROT_MATRIX_0: case STATE_ROT_MATRIX_1: return _NEW_TEXTURE; @@ -918,9 +901,6 @@ append_token(char *dst, gl_state_index k) case STATE_PT_BIAS: append(dst, "PTbias"); break; - case STATE_SHADOW_AMBIENT: - append(dst, "CompareFailValue"); - break; case STATE_FB_SIZE: append(dst, "FbSize"); break; diff --git a/mesalib/src/mesa/program/prog_statevars.h b/mesalib/src/mesa/program/prog_statevars.h index 65baa7833..efd0e030c 100644 --- a/mesalib/src/mesa/program/prog_statevars.h +++ b/mesalib/src/mesa/program/prog_statevars.h @@ -124,7 +124,6 @@ typedef enum gl_state_index_ { STATE_LIGHT_HALF_VECTOR, /* object vs eye space */ STATE_PT_SCALE, /**< Pixel transfer RGBA scale */ STATE_PT_BIAS, /**< Pixel transfer RGBA bias */ - STATE_SHADOW_AMBIENT, /**< ARB_shadow_ambient fail value; token[2] is texture unit index */ STATE_FB_SIZE, /**< (width-1, height-1, 0, 0) */ STATE_FB_WPOS_Y_TRANSFORM, /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */ STATE_ROT_MATRIX_0, /**< ATI_envmap_bumpmap, rot matrix row 0 */ diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak index ce248dea1..30e2219b0 100644 --- a/mesalib/src/mesa/sources.mak +++ b/mesalib/src/mesa/sources.mak @@ -5,8 +5,8 @@ # this is part of MAIN_FILES MAIN_ES_FILES = \ - $(SRCDIR)main/api_exec_es1.c \ - $(SRCDIR)main/api_exec_es2.c + $(BUILDDIR)main/api_exec_es1.c \ + $(BUILDDIR)main/api_exec_es2.c MAIN_FILES = \ $(SRCDIR)main/api_arrayelt.c \ @@ -35,7 +35,6 @@ MAIN_FILES = \ $(SRCDIR)main/drawpix.c \ $(SRCDIR)main/drawtex.c \ $(SRCDIR)main/enable.c \ - $(SRCDIR)main/enums.c \ $(SRCDIR)main/errors.c \ $(SRCDIR)main/eval.c \ $(SRCDIR)main/execmem.c \ @@ -107,6 +106,7 @@ MAIN_FILES = \ $(SRCDIR)main/version.c \ $(SRCDIR)main/viewport.c \ $(SRCDIR)main/vtxfmt.c \ + $(BUILDDIR)main/enums.c \ $(MAIN_ES_FILES) MAIN_CXX_FILES = \ @@ -251,11 +251,9 @@ STATETRACKER_FILES = \ PROGRAM_FILES = \ $(SRCDIR)program/arbprogparse.c \ $(SRCDIR)program/hash_table.c \ - $(SRCDIR)program/lex.yy.c \ $(SRCDIR)program/nvfragparse.c \ $(SRCDIR)program/nvvertparse.c \ $(SRCDIR)program/program.c \ - $(SRCDIR)program/program_parse.tab.c \ $(SRCDIR)program/program_parse_extra.c \ $(SRCDIR)program/prog_cache.c \ $(SRCDIR)program/prog_execute.c \ @@ -269,7 +267,9 @@ PROGRAM_FILES = \ $(SRCDIR)program/prog_statevars.c \ $(SRCDIR)program/programopt.c \ $(SRCDIR)program/register_allocate.c \ - $(SRCDIR)program/symbol_table.c + $(SRCDIR)program/symbol_table.c \ + $(BUILDDIR)program/lex.yy.c \ + $(BUILDDIR)program/program_parse.tab.c SHADER_CXX_FILES = \ @@ -372,18 +372,18 @@ MESA_GALLIUM_OBJECTS = \ COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_FILES:.c=.o) -### Other archives/libraries - -GLSL_LIBS = \ - $(TOP)/src/glsl/libglsl.a - - ### Include directories INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/glsl \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mapi \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/glsl \ + -I$(top_builddir)/src/glsl \ + -I$(top_srcdir)/src/glsl/glcpp \ + -I$(top_srcdir)/src/mesa \ + -I$(top_builddir)/src/mesa \ + -I$(top_srcdir)/src/mesa/main \ + -I$(top_builddir)/src/mesa/main \ + -I$(top_srcdir)/src/mapi \ + -I$(top_builddir)/src/mapi \ + -I$(top_srcdir)/src/gallium/include \ + -I$(top_srcdir)/src/gallium/auxiliary diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c index 204f505a6..d9e9d21f6 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c @@ -239,7 +239,8 @@ static void update_raster_state( struct st_context *st ) /* _NEW_FRAG_CLAMP */ raster->clamp_fragment_color = !st->clamp_frag_color_in_shader && - ctx->Color._ClampFragmentColor; + ctx->Color._ClampFragmentColor && + !ctx->DrawBuffer->_IntegerColor; raster->gl_rasterization_rules = 1; /* _NEW_RASTERIZER_DISCARD */ diff --git a/mesalib/src/mesa/state_tracker/st_atom_shader.c b/mesalib/src/mesa/state_tracker/st_atom_shader.c index ae3491097..45e7a117f 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_shader.c +++ b/mesalib/src/mesa/state_tracker/st_atom_shader.c @@ -85,7 +85,8 @@ update_fp( struct st_context *st ) /* _NEW_FRAG_CLAMP */ key.clamp_color = st->clamp_frag_color_in_shader && - st->ctx->Color._ClampFragmentColor; + st->ctx->Color._ClampFragmentColor && + !st->ctx->DrawBuffer->_IntegerColor; st->fp_variant = st_get_fp_variant(st, stfp, &key); @@ -106,7 +107,7 @@ update_fp( struct st_context *st ) const struct st_tracked_state st_update_fp = { "st_update_fp", /* name */ { /* dirty */ - 0, /* mesa */ + _NEW_BUFFERS, /* mesa */ ST_NEW_FRAGMENT_PROGRAM /* st */ }, update_fp /* update */ diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c index 3c17bd6c3..7d9ccc1e5 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c @@ -424,7 +424,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, key.st = st; key.bitmap = GL_TRUE; key.clamp_color = st->clamp_frag_color_in_shader && - st->ctx->Color._ClampFragmentColor; + st->ctx->Color._ClampFragmentColor && + !st->ctx->DrawBuffer->_IntegerColor; fpv = st_get_fp_variant(st, st->fp, &key); diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 88068ac60..9f1b427a9 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -697,7 +697,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, struct pipe_rasterizer_state rasterizer; memset(&rasterizer, 0, sizeof(rasterizer)); rasterizer.clamp_fragment_color = !st->clamp_frag_color_in_shader && - ctx->Color._ClampFragmentColor; + ctx->Color._ClampFragmentColor && + !ctx->DrawBuffer->_IntegerColor; rasterizer.gl_rasterization_rules = 1; rasterizer.depth_clip = !ctx->Transform.DepthClamp; rasterizer.scissor = ctx->Scissor.Enabled; @@ -1026,7 +1027,8 @@ get_color_fp_variant(struct st_context *st) ctx->Pixel.AlphaScale != 1.0); key.pixelMaps = ctx->Pixel.MapColorFlag; key.clamp_color = st->clamp_frag_color_in_shader && - st->ctx->Color._ClampFragmentColor; + st->ctx->Color._ClampFragmentColor && + !st->ctx->DrawBuffer->_IntegerColor; fpv = st_get_fp_variant(st, st->fp, &key); diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index 51c899208..3c2aae913 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -3345,34 +3345,33 @@ sample_lambda_1d_array(struct gl_context *ctx, /** - * Compare texcoord against depth sample. Return 1.0 or the ambient value. + * Compare texcoord against depth sample. Return 1.0 or 0.0 value. */ static inline GLfloat -shadow_compare(GLenum function, GLfloat coord, GLfloat depthSample, - GLfloat ambient) +shadow_compare(GLenum function, GLfloat coord, GLfloat depthSample) { switch (function) { case GL_LEQUAL: - return (coord <= depthSample) ? 1.0F : ambient; + return (coord <= depthSample) ? 1.0F : 0.0F; case GL_GEQUAL: - return (coord >= depthSample) ? 1.0F : ambient; + return (coord >= depthSample) ? 1.0F : 0.0F; case GL_LESS: - return (coord < depthSample) ? 1.0F : ambient; + return (coord < depthSample) ? 1.0F : 0.0F; case GL_GREATER: - return (coord > depthSample) ? 1.0F : ambient; + return (coord > depthSample) ? 1.0F : 0.0F; case GL_EQUAL: - return (coord == depthSample) ? 1.0F : ambient; + return (coord == depthSample) ? 1.0F : 0.0F; case GL_NOTEQUAL: - return (coord != depthSample) ? 1.0F : ambient; + return (coord != depthSample) ? 1.0F : 0.0F; case GL_ALWAYS: return 1.0F; case GL_NEVER: - return ambient; + return 0.0F; case GL_NONE: return depthSample; default: _mesa_problem(NULL, "Bad compare func in shadow_compare"); - return ambient; + return 0.0F; } } @@ -3384,9 +3383,9 @@ static inline GLfloat shadow_compare4(GLenum function, GLfloat coord, GLfloat depth00, GLfloat depth01, GLfloat depth10, GLfloat depth11, - GLfloat ambient, GLfloat wi, GLfloat wj) + GLfloat wi, GLfloat wj) { - const GLfloat d = (1.0F - (GLfloat) ambient) * 0.25F; + const GLfloat d = 0.25F; GLfloat luminance = 1.0F; switch (function) { @@ -3429,13 +3428,13 @@ shadow_compare4(GLenum function, GLfloat coord, case GL_ALWAYS: return 1.0F; case GL_NEVER: - return ambient; + return 0.0F; case GL_NONE: /* ordinary bilinear filtering */ return lerp_2d(wi, wj, depth00, depth10, depth01, depth11); default: _mesa_problem(NULL, "Bad compare func in sample_compare4"); - return ambient; + return 0.0F; } } @@ -3483,7 +3482,6 @@ sample_depth_texture( struct gl_context *ctx, const GLint depth = img->Depth; const GLuint compare_coord = (tObj->Target == GL_TEXTURE_2D_ARRAY_EXT) ? 3 : 2; - GLfloat ambient; GLenum function; GLfloat result; @@ -3497,8 +3495,6 @@ sample_depth_texture( struct gl_context *ctx, tObj->Target == GL_TEXTURE_2D_ARRAY_EXT || tObj->Target == GL_TEXTURE_CUBE_MAP); - ambient = samp->CompareFailValue; - /* XXXX if samp->MinFilter != samp->MagFilter, we're ignoring lambda */ function = (samp->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) ? @@ -3522,7 +3518,7 @@ sample_depth_texture( struct gl_context *ctx, depthRef = CLAMP(texcoords[i][compare_coord], 0.0F, 1.0F); - result = shadow_compare(function, depthRef, depthSample, ambient); + result = shadow_compare(function, depthRef, depthSample); switch (tObj->DepthMode) { case GL_LUMINANCE: @@ -3617,7 +3613,7 @@ sample_depth_texture( struct gl_context *ctx, result = shadow_compare4(function, depthRef, depth00, depth01, depth10, depth11, - ambient, wi, wj); + wi, wj); switch (tObj->DepthMode) { case GL_LUMINANCE: |