diff options
author | marha <marha@users.sourceforge.net> | 2012-08-16 14:48:54 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-08-16 14:48:54 +0200 |
commit | 4aac32998c2b173b84aec0b020aa086fef4b1423 (patch) | |
tree | 3ffcb971bcc2f01929f60f8f704996544b69b2e1 /mesalib/src/mesa/main | |
parent | 9ddf44af81782451cee798e06749ce3067a14a41 (diff) | |
download | vcxsrv-4aac32998c2b173b84aec0b020aa086fef4b1423.tar.gz vcxsrv-4aac32998c2b173b84aec0b020aa086fef4b1423.tar.bz2 vcxsrv-4aac32998c2b173b84aec0b020aa086fef4b1423.zip |
libxcb xserver mesa git update 16 Aug 2012
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r-- | mesalib/src/mesa/main/api_exec.c | 217 | ||||
-rw-r--r-- | mesalib/src/mesa/main/attrib.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.c | 106 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.h | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/main/context.h | 10 | ||||
-rw-r--r-- | mesalib/src/mesa/main/extensions.c | 163 | ||||
-rw-r--r-- | mesalib/src/mesa/main/fbobject.c | 144 | ||||
-rw-r--r-- | mesalib/src/mesa/main/fbobject.h | 9 | ||||
-rw-r--r-- | mesalib/src/mesa/main/format_unpack.c | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/pack.c | 725 | ||||
-rw-r--r-- | mesalib/src/mesa/main/pack.h | 12 | ||||
-rw-r--r-- | mesalib/src/mesa/main/readpix.c | 13 | ||||
-rw-r--r-- | mesalib/src/mesa/main/samplerobj.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texgetimage.c | 16 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texobj.c | 213 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texobj.h | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texparam.c | 24 | ||||
-rw-r--r-- | mesalib/src/mesa/main/texstore.c | 95 |
19 files changed, 1519 insertions, 251 deletions
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; } |