diff options
Diffstat (limited to 'mesalib/src/mesa/main')
33 files changed, 1392 insertions, 1689 deletions
diff --git a/mesalib/src/mesa/main/APIspec.xml b/mesalib/src/mesa/main/APIspec.xml index c26caf6ad..3121226ca 100644 --- a/mesalib/src/mesa/main/APIspec.xml +++ b/mesalib/src/mesa/main/APIspec.xml @@ -226,47 +226,6 @@ <param name="param" type="GLtype"/> </vector> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> - <value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/> - </desc> - - <desc name="pname"> - <value name="GL_TEXTURE_WRAP_S"/> - <value name="GL_TEXTURE_WRAP_T"/> - <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/> - - <desc name="param"> - <value name="GL_CLAMP_TO_EDGE"/> - <value name="GL_REPEAT"/> - <value name="GL_MIRRORED_REPEAT" category="GLES2.0"/> - <value name="GL_MIRRORED_REPEAT_OES" category="OES_texture_mirrored_repeat"/> - </desc> - </desc> - - <desc name="pname"> - <value name="GL_TEXTURE_MIN_FILTER"/> - <value name="GL_TEXTURE_MAG_FILTER"/> - <value name="GL_TEXTURE_MAX_ANISOTROPY_EXT" category="EXT_texture_filter_anisotropic"/> - </desc> - - <desc name="pname" category="GLES1.1"> - <value name="GL_GENERATE_MIPMAP"/> - - <desc name="param"> - <value name="GL_TRUE"/> - <value name="GL_FALSE"/> - </desc> - </desc> - - <desc name="pname" category="OES_draw_texture"> - <value name="GL_TEXTURE_CROP_RECT_OES"/> - <desc name="params" vector_size="4"/> - </desc> </template> <template name="TexImage2D"> @@ -282,168 +241,6 @@ <param name="type" type="GLenum"/> <param name="pixels" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> - </desc> - - <desc name="internalFormat"> - <value name="GL_ALPHA"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_ALPHA"/> - </desc> - </desc> - - <desc name="internalFormat"> - <value name="GL_RGB"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_RGB"/> - </desc> - </desc> - - <desc name="internalFormat"> - <value name="GL_RGBA"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_RGBA"/> - </desc> - </desc> - - <desc name="internalFormat"> - <value name="GL_LUMINANCE"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_LUMINANCE"/> - </desc> - </desc> - - <desc name="internalFormat"> - <value name="GL_LUMINANCE_ALPHA"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_LUMINANCE_ALPHA"/> - </desc> - </desc> - - <desc name="internalFormat" category="OES_depth_texture"> - <value name="GL_DEPTH_COMPONENT"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_DEPTH_COMPONENT"/> - </desc> - </desc> - - <desc name="internalFormat" category="OES_packed_depth_stencil"> - <value name="GL_DEPTH_STENCIL_OES"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_DEPTH_STENCIL_OES"/> - </desc> - </desc> - - <desc name="internalFormat" category="EXT_texture_format_BGRA8888"> - <value name="GL_BGRA_EXT"/> - - <desc name="format" error="GL_INVALID_VALUE"> - <value name="GL_BGRA_EXT"/> - </desc> - </desc> - - <desc name="border" error="GL_INVALID_VALUE"> - <value name="0"/> - </desc> - - <desc name="format"> - <value name="GL_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGB"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_5_6_5"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGBA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> - <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format" category="OES_depth_texture"> - <value name="GL_DEPTH_COMPONENT"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_SHORT"/> - <value name="GL_UNSIGNED_INT"/> - </desc> - </desc> - - <desc name="format" category="OES_packed_depth_stencil"> - <value name="GL_DEPTH_STENCIL_OES"/> - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_INT_24_8_OES"/> - </desc> - </desc> - - <desc name="format" category="EXT_texture_format_BGRA8888"> - <value name="GL_BGRA_EXT"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - </desc> - </desc> </template> <template name="TexEnv"> @@ -1231,30 +1028,6 @@ <param name="pname" type="GLenum"/> <vector name="params" type="GLtype *" size="dynamic"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> - <value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/> - </desc> - - <desc name="pname"> - <value name="GL_TEXTURE_WRAP_S"/> - <value name="GL_TEXTURE_WRAP_T"/> - <value name="GL_TEXTURE_WRAP_R_OES" category="OES_texture_3D"/> - <value name="GL_TEXTURE_MIN_FILTER"/> - <value name="GL_TEXTURE_MAG_FILTER"/> - <value name="GL_GENERATE_MIPMAP" category="GLES1.1"/> - - <desc name="params" vector_size="1" convert="false"/> - </desc> - - <desc name="pname" category="OES_draw_texture"> - <value name="GL_TEXTURE_CROP_RECT_OES"/> - <desc name="params" vector_size="4"/> - </desc> </template> <template name="IsEnabled" direction="get"> @@ -1445,17 +1218,6 @@ <param name="stride" type="GLsizei"/> <param name="pointer" type="const GLvoid *"/> </proto> - - <desc name="size" error="GL_INVALID_VALUE"> - <value name="4"/> - </desc> - - <desc name="type"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT"/> - <value name="GL_FIXED"/> - <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> - </desc> </template> <template name="DisableClientState"> @@ -1567,14 +1329,6 @@ <param name="stride" type="GLsizei"/> <param name="pointer" type="const GLvoid *"/> </proto> - - <desc name="type"> - <value name="GL_BYTE"/> - <value name="GL_SHORT"/> - <value name="GL_FLOAT"/> - <value name="GL_FIXED"/> - <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> - </desc> </template> <template name="TexCoordPointer"> @@ -1585,20 +1339,6 @@ <param name="stride" type="GLsizei"/> <param name="pointer" type="const GLvoid *"/> </proto> - - <desc name="size" error="GL_INVALID_VALUE"> - <value name="2"/> - <value name="3"/> - <value name="4"/> - </desc> - - <desc name="type"> - <value name="GL_BYTE"/> - <value name="GL_SHORT"/> - <value name="GL_FLOAT"/> - <value name="GL_FIXED"/> - <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> - </desc> </template> <template name="VertexPointer"> @@ -1609,20 +1349,6 @@ <param name="stride" type="GLsizei"/> <param name="pointer" type="const GLvoid *"/> </proto> - - <desc name="size" error="GL_INVALID_VALUE"> - <value name="2"/> - <value name="3"/> - <value name="4"/> - </desc> - - <desc name="type"> - <value name="GL_BYTE"/> - <value name="GL_SHORT"/> - <value name="GL_FLOAT"/> - <value name="GL_FIXED"/> - <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> - </desc> </template> <template name="PolygonOffset"> @@ -1645,34 +1371,6 @@ <param name="height" type="GLsizei"/> <param name="border" type="GLint"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> - </desc> - - <desc name="internalFormat" error="GL_INVALID_VALUE"> - <value name="GL_ALPHA"/> - <value name="GL_RGB"/> - <value name="GL_RGBA"/> - <value name="GL_LUMINANCE"/> - <value name="GL_LUMINANCE_ALPHA"/> - </desc> - - <desc name="border" error="GL_INVALID_VALUE"> - <value name="0"/> - </desc> </template> <template name="CopyTexSubImage2D"> @@ -1687,22 +1385,6 @@ <param name="width" type="GLsizei"/> <param name="height" type="GLsizei"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> - </desc> </template> <template name="TexSubImage2D"> @@ -1718,101 +1400,6 @@ <param name="type" type="GLenum"/> <param name="pixels" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> - </desc> - - <desc name="format"> - <value name="GL_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGB"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_5_6_5"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGBA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> - <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format" category="OES_depth_texture"> - <value name="GL_DEPTH_COMPONENT"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_SHORT"/> - <value name="GL_UNSIGNED_INT"/> - </desc> - </desc> - - <desc name="format" category="OES_packed_depth_stencil"> - <value name="GL_DEPTH_STENCIL_OES"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_INT_24_8_OES"/> - </desc> - </desc> - - <desc name="format" category="EXT_texture_format_BGRA8888"> - <value name="GL_BGRA_EXT"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - </desc> - </desc> </template> <template name="BindTexture"> @@ -1821,14 +1408,6 @@ <param name="target" type="GLenum"/> <param name="texture" type="GLuint"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/> - <value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/> - </desc> </template> <template name="DeleteTextures"> @@ -1894,71 +1473,6 @@ <param name="pixels" type="const GLvoid *"/> </proto> - <desc name="target"> - <value name="GL_TEXTURE_3D_OES"/> - </desc> - - <desc name="internalFormat"> - <value name="GL_ALPHA"/> - <value name="GL_RGB"/> - <value name="GL_RGBA"/> - <value name="GL_LUMINANCE"/> - <value name="GL_LUMINANCE_ALPHA"/> - </desc> - - <desc name="format"> - <value name="GL_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGB"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_5_6_5"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGBA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> - <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> </template> <template name="TexSubImage3D"> @@ -1976,64 +1490,6 @@ <param name="type" type="GLenum"/> <param name="pixels" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_3D_OES"/> - </desc> - - <desc name="format"> - <value name="GL_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGB"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_5_6_5"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_RGBA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_UNSIGNED_SHORT_4_4_4_4"/> - <value name="GL_UNSIGNED_SHORT_5_5_5_1"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - <value name="GL_UNSIGNED_INT_2_10_10_10_REV_EXT" category="EXT_texture_type_2_10_10_10_REV"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> - - <desc name="format"> - <value name="GL_LUMINANCE_ALPHA"/> - - <desc name="type" error="GL_INVALID_OPERATION"> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_FLOAT" category="OES_texture_float"/> - <value name="GL_HALF_FLOAT_OES" category="OES_texture_half_float"/> - </desc> - </desc> </template> <template name="CopyTexSubImage3D"> @@ -2049,10 +1505,6 @@ <param name="width" type="GLsizei"/> <param name="height" type="GLsizei"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_3D_OES"/> - </desc> </template> <template name="MultiTexCoord"> @@ -2081,10 +1533,6 @@ <param name="imagesize" type="GLsizei"/> <param name="data" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_3D_OES"/> - </desc> </template> <template name="CompressedTexSubImage3D"> @@ -2102,10 +1550,6 @@ <param name="imagesize" type="GLsizei"/> <param name="data" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_3D_OES"/> - </desc> </template> <template name="ActiveTexture"> @@ -2142,40 +1586,6 @@ <param name="imageSize" type="GLsizei"/> <param name="data" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> - </desc> - - <desc name="internalFormat"> - <value name="GL_ETC1_RGB8_OES" category="OES_compressed_ETC1_RGB8_texture"/> - - <value name="GL_PALETTE4_RGB8_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE4_RGBA8_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE4_R5_G6_B5_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE4_RGBA4_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE4_RGB5_A1_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE8_RGB8_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE8_RGBA8_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE8_R5_G6_B5_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE8_RGBA4_OES" category="OES_compressed_paletted_texture"/> - <value name="GL_PALETTE8_RGB5_A1_OES" category="OES_compressed_paletted_texture"/> - - <value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> - <value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> - </desc> </template> <template name="CompressedTexSubImage2D"> @@ -2191,27 +1601,6 @@ <param name="imageSize" type="GLsizei"/> <param name="data" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" category="GLES2.0"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES" category="OES_texture_cube_map"/> - <value name="GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES" category="OES_texture_cube_map"/> - </desc> - - <desc name="format"> - <value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> - <value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/> - </desc> </template> <template name="BlendFuncSeparate"> @@ -2344,35 +1733,6 @@ <param name="stride" type="GLsizei"/> <param name="pointer" type="const GLvoid *"/> </proto> - - <desc name="size" error="GL_INVALID_VALUE"> - <value name="1"/> - <value name="2"/> - <value name="3"/> - <value name="4"/> - </desc> - - <desc name="type" error="GL_INVALID_VALUE"> - <value name="GL_BYTE"/> - <value name="GL_UNSIGNED_BYTE"/> - <value name="GL_SHORT"/> - <value name="GL_UNSIGNED_SHORT"/> - <value name="GL_FLOAT"/> - <value name="GL_FIXED"/> - <value name="GL_HALF_FLOAT_OES" category="OES_vertex_half_float"/> - <value name="GL_UNSIGNED_INT_10_10_10_2_OES" category="OES_vertex_type_10_10_10_2"/> - <value name="GL_INT_10_10_10_2_OES" category="OES_vertex_type_10_10_10_2"/> - </desc> - - <desc name="type" category="OES_vertex_type_10_10_10_2"> - <value name="GL_UNSIGNED_INT_10_10_10_2_OES"/> - <value name="GL_INT_10_10_10_2_OES"/> - - <desc name="size"> - <value name="3"/> - <value name="4"/> - </desc> - </desc> </template> <template name="EnableVertexAttribArray"> @@ -2403,21 +1763,6 @@ <param name="pname" type="GLenum"/> <vector name="params" type="GLtype *" size="dynamic"/> </proto> - - <desc name="pname"> - <value name="GL_DELETE_STATUS"/> - <value name="GL_LINK_STATUS"/> - <value name="GL_VALIDATE_STATUS"/> - <value name="GL_INFO_LOG_LENGTH"/> - <value name="GL_ATTACHED_SHADERS"/> - <value name="GL_ACTIVE_ATTRIBUTES"/> - <value name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/> - <value name="GL_ACTIVE_UNIFORMS"/> - <value name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/> - <value name="GL_PROGRAM_BINARY_LENGTH_OES" category="OES_get_program_binary"/> - - <desc name="params" convert="false"/> - </desc> </template> <template name="GetVertexAttrib" direction="get"> @@ -2461,11 +1806,6 @@ <param name="pname" type="GLenum"/> <vector name="params" type="GLvoid **" size="dynamic"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> </template> <template name="MapBuffer" direction="get"> @@ -2474,15 +1814,6 @@ <param name="target" type="GLenum"/> <param name="access" type="GLenum"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> - - <desc name="access"> - <value name="GL_WRITE_ONLY_OES"/> - </desc> </template> <template name="UnmapBuffer" direction="get"> @@ -2490,11 +1821,6 @@ <return type="GLboolean"/> <param name="target" type="GLenum"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> </template> <template name="BindBuffer"> @@ -2503,11 +1829,6 @@ <param name="target" type="GLenum"/> <param name="buffer" type="GLuint"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> </template> <template name="BufferData"> @@ -2518,17 +1839,6 @@ <param name="data" type="const GLvoid *"/> <param name="usage" type="GLenum"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> - - <desc name="usage"> - <value name="GL_STATIC_DRAW"/> - <value name="GL_DYNAMIC_DRAW"/> - <value name="GL_STREAM_DRAW" category="GLES2.0"/> - </desc> </template> <template name="BufferSubData"> @@ -2539,11 +1849,6 @@ <param name="size" type="GLsizeiptr"/> <param name="data" type="const GLvoid *"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> </template> <template name="DeleteBuffers"> @@ -2569,18 +1874,6 @@ <param name="pname" type="GLenum"/> <vector name="params" type="GLtype *" size="dynamic"/> </proto> - - <desc name="target"> - <value name="GL_ARRAY_BUFFER"/> - <value name="GL_ELEMENT_ARRAY_BUFFER"/> - </desc> - - <desc name="pname"> - <value name="GL_BUFFER_SIZE"/> - <value name="GL_BUFFER_USAGE"/> - <value name="GL_BUFFER_ACCESS_OES" category="OES_mapbuffer"/> - <value name="GL_BUFFER_MAPPED_OES" category="OES_mapbuffer"/> - </desc> </template> <template name="IsBuffer" direction="get"> @@ -2595,11 +1888,6 @@ <return type="GLuint"/> <param name="type" type="GLenum"/> </proto> - - <desc name="type"> - <value name="GL_VERTEX_SHADER"/> - <value name="GL_FRAGMENT_SHADER"/> - </desc> </template> <template name="ShaderSource"> @@ -3140,11 +2428,6 @@ <param name="target" type="GLenum"/> <param name="image" type="GLeglImageOES"/> </proto> - - <desc name="target"> - <value name="GL_TEXTURE_2D"/> - <value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/> - </desc> </template> <template name="EGLImageTargetRenderbufferStorage"> diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c index eaf614bdc..b15dfba73 100644 --- a/mesalib/src/mesa/main/api_validate.c +++ b/mesalib/src/mesa/main/api_validate.c @@ -31,6 +31,7 @@ #include "mtypes.h" #include "enums.h" #include "vbo/vbo.h" +#include <stdbool.h> /** @@ -262,6 +263,26 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name) return GL_TRUE; } +/** + * Verify that the element type is valid. + * + * Generates \c GL_INVALID_ENUM and returns \c false if it is not. + */ +static bool +valid_elements_type(struct gl_context *ctx, GLenum type, const char *name) +{ + switch (type) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + return true; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", name, + _mesa_lookup_enum_by_nr(type)); + return false; + } +} /** * Error checking for glDrawElements(). Includes parameter checking @@ -286,13 +307,8 @@ _mesa_validate_DrawElements(struct gl_context *ctx, return GL_FALSE; } - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) - { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); + if (!valid_elements_type(ctx, type, "glDrawElements")) return GL_FALSE; - } if (!check_valid_to_render(ctx, "glDrawElements")) return GL_FALSE; @@ -348,13 +364,8 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx, return GL_FALSE; } - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) - { - _mesa_error(ctx, GL_INVALID_ENUM, "glMultiDrawElements(type)" ); + if (!valid_elements_type(ctx, type, "glMultiDrawElements")) return GL_FALSE; - } if (!check_valid_to_render(ctx, "glMultiDrawElements")) return GL_FALSE; @@ -419,12 +430,8 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, GLenum mode, return GL_FALSE; } - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) { - _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(type)" ); + if (!valid_elements_type(ctx, type, "glDrawRangeElements")) return GL_FALSE; - } if (!check_valid_to_render(ctx, "glDrawRangeElements")) return GL_FALSE; @@ -548,13 +555,8 @@ _mesa_validate_DrawElementsInstanced(struct gl_context *ctx, return GL_FALSE; } - if (type != GL_UNSIGNED_INT && - type != GL_UNSIGNED_BYTE && - type != GL_UNSIGNED_SHORT) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glDrawElementsInstanced(type=0x%x)", type); + if (!valid_elements_type(ctx, type, "glDrawElementsInstanced")) return GL_FALSE; - } if (numInstances <= 0) { if (numInstances < 0) diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index 90f8b8bf2..2d406f9bb 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -30,7 +30,7 @@ * \author Brian Paul, Ian Romanick */ - +#include <stdbool.h> #include "glheader.h" #include "enums.h" #include "hash.h" @@ -68,6 +68,12 @@ static struct gl_buffer_object DummyBufferObject; static inline struct gl_buffer_object ** get_buffer_target(struct gl_context *ctx, GLenum target) { + /* Other targets are only supported in desktop OpenGL and OpenGL ES 3.0. + */ + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx) + && target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) + return NULL; + switch (target) { case GL_ARRAY_BUFFER_ARB: return &ctx->Array.ArrayBufferObj; @@ -89,7 +95,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target) break; #endif case GL_TEXTURE_BUFFER: - if (ctx->Extensions.ARB_texture_buffer_object) { + if (_mesa_is_desktop_gl(ctx) + && ctx->Extensions.ARB_texture_buffer_object) { return &ctx->Texture.BufferObject; } break; @@ -1002,6 +1009,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, { GET_CURRENT_CONTEXT(ctx); struct gl_buffer_object *bufObj; + bool valid_usage; ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & VERBOSE_API) @@ -1017,18 +1025,30 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, switch (usage) { case GL_STREAM_DRAW_ARB: + valid_usage = (ctx->API != API_OPENGLES); + break; + + case GL_STATIC_DRAW_ARB: + case GL_DYNAMIC_DRAW_ARB: + valid_usage = true; + break; + case GL_STREAM_READ_ARB: case GL_STREAM_COPY_ARB: - case GL_STATIC_DRAW_ARB: case GL_STATIC_READ_ARB: case GL_STATIC_COPY_ARB: - case GL_DYNAMIC_DRAW_ARB: case GL_DYNAMIC_READ_ARB: case GL_DYNAMIC_COPY_ARB: - /* OK */ + valid_usage = _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx); break; + default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)"); + valid_usage = false; + break; + } + + if (!valid_usage) { + _mesa_error(ctx, GL_INVALID_ENUM, "glBufferData(usage)"); return; } @@ -1115,20 +1135,29 @@ _mesa_MapBufferARB(GLenum target, GLenum access) struct gl_buffer_object * bufObj; GLbitfield accessFlags; void *map; + bool valid_access; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); switch (access) { case GL_READ_ONLY_ARB: accessFlags = GL_MAP_READ_BIT; + valid_access = _mesa_is_desktop_gl(ctx); break; case GL_WRITE_ONLY_ARB: accessFlags = GL_MAP_WRITE_BIT; + valid_access = true; break; case GL_READ_WRITE_ARB: accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; + valid_access = _mesa_is_desktop_gl(ctx); break; default: + valid_access = false; + break; + } + + if (!valid_access) { _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)"); return NULL; } @@ -1282,17 +1311,20 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) *params = _mesa_bufferobj_mapped(bufObj); return; case GL_BUFFER_ACCESS_FLAGS: - if (!ctx->Extensions.ARB_map_buffer_range) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = bufObj->AccessFlags; return; case GL_BUFFER_MAP_OFFSET: - if (!ctx->Extensions.ARB_map_buffer_range) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLint) bufObj->Offset; return; case GL_BUFFER_MAP_LENGTH: - if (!ctx->Extensions.ARB_map_buffer_range) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_map_buffer_range) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLint) bufObj->Length; return; diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index 226897b19..e6a1e68cb 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -189,12 +189,15 @@ struct dd_function_table { /*@{*/ /** - * Choose actual hardware texture format given the user-provided source - * image format and type and the desired internal format. In some - * cases, srcFormat and srcType can be GL_NONE. + * Choose actual hardware texture format given the texture target, the + * user-provided source image format and type and the desired internal + * format. In some cases, srcFormat and srcType can be GL_NONE. + * Note: target may be GL_TEXTURE_CUBE_MAP, but never + * GL_TEXTURE_CUBE_MAP_[POSITIVE/NEGATIVE]_[XYZ]. * Called by glTexImage(), etc. */ - gl_format (*ChooseTextureFormat)( struct gl_context *ctx, GLint internalFormat, + gl_format (*ChooseTextureFormat)( struct gl_context *ctx, + GLenum target, GLint internalFormat, GLenum srcFormat, GLenum srcType ); /** @@ -396,6 +399,13 @@ struct dd_function_table { GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target, struct gl_program *prog); + /** + * Notify driver that the sampler uniforms for the current program have + * changed. On some drivers, this may require shader recompiles. + */ + void (*SamplerUniformChange)(struct gl_context *ctx, GLenum target, + struct gl_program *prog); + /** Query if program can be loaded onto hardware */ GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, struct gl_program *prog); diff --git a/mesalib/src/mesa/main/dlopen.c b/mesalib/src/mesa/main/dlopen.c deleted file mode 100644 index 62d9023a9..000000000 --- a/mesalib/src/mesa/main/dlopen.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * Wrapper functions for dlopen(), dlsym(), dlclose(). - * Note that the #ifdef tests for various environments should be expanded. - */ - - -#include "compiler.h" -#include "dlopen.h" - -#if defined(_GNU_SOURCE) && !defined(__MINGW32__) && !defined(__blrts) -#include <dlfcn.h> -#endif -#if defined(_WIN32) -#include <windows.h> -#endif - - -/** - * Wrapper for dlopen(). - * Note that 'flags' isn't used at this time. - */ -void * -_mesa_dlopen(const char *libname, int flags) -{ -#if defined(__blrts) - return NULL; -#elif defined(_GNU_SOURCE) - flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */ - return dlopen(libname, flags); -#elif defined(__MINGW32__) | defined(_MSC_VER) - return LoadLibraryA(libname); -#else - return NULL; -#endif -} - - -/** - * Wrapper for dlsym() that does a cast to a generic function type, - * rather than a void *. This reduces the number of warnings that are - * generated. - */ -GenericFunc -_mesa_dlsym(void *handle, const char *fname) -{ - union { - void *v; - GenericFunc f; - } u; -#if defined(__blrts) - u.v = NULL; -#elif defined(__DJGPP__) - /* need '_' prefix on symbol names */ - char fname2[1000]; - fname2[0] = '_'; - strncpy(fname2 + 1, fname, 998); - fname2[999] = 0; - u.v = dlsym(handle, fname2); -#elif defined(_GNU_SOURCE) - u.v = dlsym(handle, fname); -#elif defined(__MINGW32__) | defined(_MSC_VER) - u.v = (void *) GetProcAddress(handle, fname); -#else - u.v = NULL; -#endif - return u.f; -} - - -/** - * Wrapper for dlclose(). - */ -void -_mesa_dlclose(void *handle) -{ -#if defined(__blrts) - (void) handle; -#elif defined(_GNU_SOURCE) - dlclose(handle); -#elif defined(__MINGW32__) | defined(_MSC_VER) - FreeLibrary(handle); -#else - (void) handle; -#endif -} - - - diff --git a/mesalib/src/mesa/main/dlopen.h b/mesalib/src/mesa/main/dlopen.h index 9895a2254..a5366a14e 100644 --- a/mesalib/src/mesa/main/dlopen.h +++ b/mesalib/src/mesa/main/dlopen.h @@ -25,18 +25,85 @@ #ifndef DLOPEN_H #define DLOPEN_H +/** + * Wrapper functions for dlopen(), dlsym(), dlclose(). + * Note that the #ifdef tests for various environments should be expanded. + */ -typedef void (*GenericFunc)(void); - +#if defined(HAVE_DLOPEN) +#include <dlfcn.h> +#endif +#if defined(_WIN32) +#include <windows.h> +#endif -extern void * -_mesa_dlopen(const char *libname, int flags); +typedef void (*GenericFunc)(void); -extern GenericFunc -_mesa_dlsym(void *handle, const char *fname); +/** + * Wrapper for dlopen(). + * Note that 'flags' isn't used at this time. + */ +static inline void * +_mesa_dlopen(const char *libname, int flags) +{ +#if defined(__blrts) + return NULL; +#elif defined(HAVE_DLOPEN) + flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */ + return dlopen(libname, flags); +#elif defined(__MINGW32__) + return LoadLibraryA(libname); +#else + return NULL; +#endif +} -extern void -_mesa_dlclose(void *handle); +/** + * Wrapper for dlsym() that does a cast to a generic function type, + * rather than a void *. This reduces the number of warnings that are + * generated. + */ +static inline GenericFunc +_mesa_dlsym(void *handle, const char *fname) +{ + union { + void *v; + GenericFunc f; + } u; +#if defined(__blrts) + u.v = NULL; +#elif defined(__DJGPP__) + /* need '_' prefix on symbol names */ + char fname2[1000]; + fname2[0] = '_'; + strncpy(fname2 + 1, fname, 998); + fname2[999] = 0; + u.v = dlsym(handle, fname2); +#elif defined(HAVE_DLOPEN) + u.v = dlsym(handle, fname); +#elif defined(__MINGW32__) + u.v = (void *) GetProcAddress(handle, fname); +#else + u.v = NULL; +#endif + return u.f; +} +/** + * Wrapper for dlclose(). + */ +static inline void +_mesa_dlclose(void *handle) +{ +#if defined(__blrts) + (void) handle; +#elif defined(HAVE_DLOPEN) + dlclose(handle); +#elif defined(__MINGW32__) + FreeLibrary(handle); +#else + (void) handle; +#endif +} #endif diff --git a/mesalib/src/mesa/main/es1_conversion.c b/mesalib/src/mesa/main/es1_conversion.c index ebd1e889f..75cdfc887 100644 --- a/mesalib/src/mesa/main/es1_conversion.c +++ b/mesalib/src/mesa/main/es1_conversion.c @@ -1237,56 +1237,11 @@ _check_TexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params) void GL_APIENTRY _es_TexParameterx(GLenum target, GLenum pname, GLfixed param) { - GLfloat converted_param; - bool convert_param_value = true; - - switch(target) { - case GL_TEXTURE_2D: - case GL_TEXTURE_CUBE_MAP: - case GL_TEXTURE_EXTERNAL_OES: - break; - default: - _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, - "glTexParameterx(target=0x%x)", target); - return; - } - switch(pname) { - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - if (param != GL_CLAMP_TO_EDGE && param != GL_REPEAT && param != GL_MIRRORED_REPEAT) { - _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, - "glTexParameterx(pname=0x%x)", pname); - return; - } - convert_param_value = false; - break; - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - convert_param_value = false; - break; - case GL_GENERATE_MIPMAP: - if (param != GL_TRUE && param != GL_FALSE) { - _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, - "glTexParameterx(pname=0x%x)", pname); - return; - } - convert_param_value = false; - break; - case GL_TEXTURE_MAX_ANISOTROPY_EXT: - break; - default: - _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, - "glTexParameterx(pname=0x%x)", pname); - return; - } - - if (convert_param_value) { - converted_param = (GLfloat) (param / 65536.0f); + if (pname == GL_TEXTURE_MAX_ANISOTROPY_EXT) { + _mesa_TexParameterf(target, pname, (GLfloat) (param / 65536.0f)); } else { - converted_param = (GLfloat) param; + _mesa_TexParameterf(target, pname, (GLfloat) param); } - - _mesa_TexParameterf(target, pname, converted_param); } void GL_APIENTRY @@ -1310,25 +1265,12 @@ _es_TexParameterxv(GLenum target, GLenum pname, const GLfixed *params) switch(pname) { case GL_TEXTURE_WRAP_S: case GL_TEXTURE_WRAP_T: - if (params[0] != GL_CLAMP_TO_EDGE && params[0] != GL_REPEAT && params[0] != GL_MIRRORED_REPEAT) { - _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, - "glTexParameterxv(pname=0x%x)", pname); - return; - } convert_params_value = false; n_params = 1; break; case GL_TEXTURE_MIN_FILTER: case GL_TEXTURE_MAG_FILTER: - convert_params_value = false; - n_params = 1; - break; case GL_GENERATE_MIPMAP: - if (params[0] != GL_TRUE && params[0] != GL_FALSE) { - _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, - "glTexParameterxv(pname=0x%x)", pname); - return; - } convert_params_value = false; n_params = 1; break; diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 9e357cd09..ab33ac565 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -275,6 +275,7 @@ static const struct extension extension_table[] = { { "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), GLL, 2002 }, + { "GL_APPLE_texture_max_level", o(dummy_true), ES1 | ES2, 2009 }, { "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), GLL, 2002 }, diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index f743ce109..e850d47dd 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -1363,7 +1363,8 @@ create_new_program(struct gl_context *ctx, struct state_key *key) _mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters); _mesa_update_shader_textures_used(p.shader_program, fp); - (void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp); + if (ctx->Driver.SamplerUniformChange) + ctx->Driver.SamplerUniformChange(ctx, fp->Target, fp); if (!p.shader_program->LinkStatus) _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n", diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c index daf1b7667..2d06cb715 100644 --- a/mesalib/src/mesa/main/glformats.c +++ b/mesalib/src/mesa/main/glformats.c @@ -790,37 +790,45 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) switch (format) { case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return ctx->Extensions.EXT_texture_compression_s3tc; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return ctx->Extensions.EXT_texture_compression_s3tc; + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.EXT_texture_compression_s3tc; case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_RGBA_S3TC: case GL_RGBA4_S3TC: - return ctx->Extensions.S3_s3tc; + return _mesa_is_desktop_gl(ctx) && ctx->Extensions.S3_s3tc; case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - return ctx->Extensions.EXT_texture_sRGB + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.EXT_texture_sRGB && ctx->Extensions.EXT_texture_compression_s3tc; case GL_COMPRESSED_RGB_FXT1_3DFX: case GL_COMPRESSED_RGBA_FXT1_3DFX: - return ctx->Extensions.TDFX_texture_compression_FXT1; + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.TDFX_texture_compression_FXT1; case GL_COMPRESSED_RED_RGTC1: case GL_COMPRESSED_SIGNED_RED_RGTC1: case GL_COMPRESSED_RG_RGTC2: case GL_COMPRESSED_SIGNED_RG_RGTC2: - return ctx->Extensions.ARB_texture_compression_rgtc; + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.ARB_texture_compression_rgtc; case GL_COMPRESSED_LUMINANCE_LATC1_EXT: case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: - return ctx->Extensions.EXT_texture_compression_latc; + return ctx->API == API_OPENGL + && ctx->Extensions.EXT_texture_compression_latc; case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI: - return ctx->Extensions.ATI_texture_compression_3dc; + return ctx->API == API_OPENGL + && ctx->Extensions.ATI_texture_compression_3dc; case GL_ETC1_RGB8_OES: - return ctx->Extensions.OES_compressed_ETC1_RGB8_texture; + return _mesa_is_gles(ctx) + && ctx->Extensions.OES_compressed_ETC1_RGB8_texture; #if FEATURE_ES case GL_PALETTE4_RGB8_OES: case GL_PALETTE4_RGBA8_OES: @@ -963,6 +971,45 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname) /** + * If format is a generic compressed format, return the corresponding + * non-compressed format. For other formats, return the format as-is. + */ +GLenum +_mesa_generic_compressed_format_to_uncompressed_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RED: + return GL_RED; + case GL_COMPRESSED_RG: + return GL_RG; + case GL_COMPRESSED_RGB: + return GL_RGB; + case GL_COMPRESSED_RGBA: + return GL_RGBA; + case GL_COMPRESSED_ALPHA: + return GL_ALPHA; + case GL_COMPRESSED_LUMINANCE: + return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA: + return GL_LUMINANCE_ALPHA; + case GL_COMPRESSED_INTENSITY: + return GL_INTENSITY; + /* sRGB formats */ + case GL_COMPRESSED_SRGB: + return GL_SRGB; + case GL_COMPRESSED_SRGB_ALPHA: + return GL_SRGB_ALPHA; + case GL_COMPRESSED_SLUMINANCE: + return GL_SLUMINANCE; + case GL_COMPRESSED_SLUMINANCE_ALPHA: + return GL_SLUMINANCE_ALPHA; + default: + return format; + } +} + + +/** * Do error checking of format/type combinations for glReadPixels, * glDrawPixels and glTex[Sub]Image. Note that depending on the format * and type values, we may either generate GL_INVALID_OPERATION or diff --git a/mesalib/src/mesa/main/glformats.h b/mesalib/src/mesa/main/glformats.h index d553eae0a..24fbda991 100644 --- a/mesalib/src/mesa/main/glformats.h +++ b/mesalib/src/mesa/main/glformats.h @@ -92,6 +92,9 @@ extern GLboolean _mesa_base_format_has_channel(GLenum base_format, GLenum pname); extern GLenum +_mesa_generic_compressed_format_to_uncompressed_format(GLenum format); + +extern GLenum _mesa_error_check_format_and_type(const struct gl_context *ctx, GLenum format, GLenum type); diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c index 00d3e8f9e..15373ba69 100644 --- a/mesalib/src/mesa/main/mipmap.c +++ b/mesalib/src/mesa/main/mipmap.c @@ -33,6 +33,7 @@ #include "mipmap.h" #include "mtypes.h" #include "teximage.h" +#include "texobj.h" #include "texstore.h" #include "image.h" #include "macros.h" @@ -1817,7 +1818,7 @@ _mesa_prepare_mipmap_level(struct gl_context *ctx, GLsizei width, GLsizei height, GLsizei depth, GLsizei border, GLenum intFormat, gl_format format) { - const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + const GLuint numFaces = _mesa_num_tex_faces(texObj->Target); GLuint face; if (texObj->Immutable) { diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 552c1cf69..58111a737 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2820,6 +2820,14 @@ struct gl_constants GLuint MaxProgramMatrices; GLuint MaxProgramMatrixStackDepth; + struct { + GLuint SamplesPassed; + GLuint TimeElapsed; + GLuint Timestamp; + GLuint PrimitivesGenerated; + GLuint PrimitivesWritten; + } QueryCounterBits; + /** vertex array / buffer object bounds checking */ GLboolean CheckArrayBounds; diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c index a578aa594..d5e2453e6 100644 --- a/mesalib/src/mesa/main/queryobj.c +++ b/mesalib/src/mesa/main/queryobj.c @@ -482,7 +482,36 @@ _mesa_GetQueryIndexediv(GLenum target, GLuint index, GLenum pname, switch (pname) { case GL_QUERY_COUNTER_BITS_ARB: - *params = 8 * sizeof(q->Result); + switch (target) { + case GL_SAMPLES_PASSED: + *params = ctx->Const.QueryCounterBits.SamplesPassed; + break; + case GL_ANY_SAMPLES_PASSED: + /* The minimum value of this is 1 if it's nonzero, and the value + * is only ever GL_TRUE or GL_FALSE, so no sense in reporting more + * bits. + */ + *params = 1; + break; + case GL_TIME_ELAPSED: + *params = ctx->Const.QueryCounterBits.TimeElapsed; + break; + case GL_TIMESTAMP: + *params = ctx->Const.QueryCounterBits.Timestamp; + break; + case GL_PRIMITIVES_GENERATED: + *params = ctx->Const.QueryCounterBits.PrimitivesGenerated; + break; + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + *params = ctx->Const.QueryCounterBits.PrimitivesWritten; + break; + default: + _mesa_problem(ctx, + "Unknown target in glGetQueryIndexediv(target = %s)", + _mesa_lookup_enum_by_nr(target)); + *params = 0; + break; + } break; case GL_CURRENT_QUERY_ARB: *params = q ? q->Id : 0; @@ -716,6 +745,12 @@ _mesa_init_queryobj(struct gl_context *ctx) { ctx->Query.QueryObjects = _mesa_NewHashTable(); ctx->Query.CurrentOcclusionObject = NULL; + + ctx->Const.QueryCounterBits.SamplesPassed = 64; + ctx->Const.QueryCounterBits.TimeElapsed = 64; + ctx->Const.QueryCounterBits.Timestamp = 64; + ctx->Const.QueryCounterBits.PrimitivesGenerated = 64; + ctx->Const.QueryCounterBits.PrimitivesWritten = 64; } diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index caeb9657e..d6acade3d 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -177,7 +177,7 @@ validate_shader_target(const struct gl_context *ctx, GLenum type) #endif #if FEATURE_ARB_geometry_shader4 case GL_GEOMETRY_SHADER_ARB: - return ctx->Extensions.ARB_geometry_shader4; + return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_geometry_shader4; #endif default: return false; @@ -473,6 +473,29 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program); +#if FEATURE_EXT_transform_feedback + /* Is transform feedback available in this context? + */ + const bool has_xfb = + (ctx->API == API_OPENGL && ctx->Extensions.EXT_transform_feedback) + || ctx->API == API_OPENGL_CORE + || _mesa_is_gles3(ctx); +#endif + +#if FEATURE_ARB_geometry_shader4 + /* Are geometry shaders available in this context? + */ + const bool has_gs = + _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_geometry_shader4; +#endif + + /* Are uniform buffer objects available in this context? + */ + const bool has_ubo = + (ctx->API == API_OPENGL && ctx->Extensions.ARB_uniform_buffer_object) + || ctx->API == API_OPENGL_CORE + || _mesa_is_gles3(ctx); + if (!shProg) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)"); return; @@ -481,28 +504,28 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param switch (pname) { case GL_DELETE_STATUS: *params = shProg->DeletePending; - break; + return; case GL_LINK_STATUS: *params = shProg->LinkStatus; - break; + return; case GL_VALIDATE_STATUS: *params = shProg->Validated; - break; + return; case GL_INFO_LOG_LENGTH: *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; - break; + return; case GL_ATTACHED_SHADERS: *params = shProg->NumShaders; - break; + return; case GL_ACTIVE_ATTRIBUTES: *params = _mesa_count_active_attribs(shProg); - break; + return; case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: *params = _mesa_longest_attribute_name_length(shProg); - break; + return; case GL_ACTIVE_UNIFORMS: *params = shProg->NumUserUniformStorage; - break; + return; case GL_ACTIVE_UNIFORM_MAX_LENGTH: { unsigned i; GLint max_len = 0; @@ -517,41 +540,48 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param } *params = max_len; - break; + return; } - case GL_PROGRAM_BINARY_LENGTH_OES: - *params = 0; - break; #if FEATURE_EXT_transform_feedback case GL_TRANSFORM_FEEDBACK_VARYINGS: + if (!has_xfb) + break; *params = shProg->TransformFeedback.NumVarying; - break; + return; case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: + if (!has_xfb) + break; *params = longest_feedback_varying_name(shProg) + 1; - break; + return; case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: + if (!has_xfb) + break; *params = shProg->TransformFeedback.BufferMode; - break; + return; #endif #if FEATURE_ARB_geometry_shader4 case GL_GEOMETRY_VERTICES_OUT_ARB: + if (!has_gs) + break; *params = shProg->Geom.VerticesOut; - break; + return; case GL_GEOMETRY_INPUT_TYPE_ARB: + if (!has_gs) + break; *params = shProg->Geom.InputType; - break; + return; case GL_GEOMETRY_OUTPUT_TYPE_ARB: + if (!has_gs) + break; *params = shProg->Geom.OutputType; - break; + return; #endif case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: { unsigned i; GLint max_len = 0; - if (!ctx->Extensions.ARB_uniform_buffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); - return; - } + if (!has_ubo) + break; for (i = 0; i < shProg->NumUniformBlocks; i++) { /* Add one for the terminating NUL character. @@ -563,20 +593,20 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param } *params = max_len; - break; + return; } case GL_ACTIVE_UNIFORM_BLOCKS: - if (!ctx->Extensions.ARB_uniform_buffer_object) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); - return; - } + if (!has_ubo) + break; *params = shProg->NumUniformBlocks; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); return; + default: + break; } + + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); } diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c index c376b970e..846d4bb63 100644 --- a/mesalib/src/mesa/main/texcompress.c +++ b/mesalib/src/mesa/main/texcompress.c @@ -372,7 +372,7 @@ _mesa_glenum_to_compressed_format(GLenum format) * internal format unchanged. */ GLenum -_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat) +_mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat) { switch (mesaFormat) { #if FEATURE_texture_fxt1 @@ -494,16 +494,16 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height, switch (format) { /* DXT formats */ case MESA_FORMAT_RGB_DXT1: - fetch = _mesa_fetch_texel_2d_f_rgb_dxt1; + fetch = _mesa_fetch_texel_rgb_dxt1; break; case MESA_FORMAT_RGBA_DXT1: - fetch = _mesa_fetch_texel_2d_f_rgba_dxt1; + fetch = _mesa_fetch_texel_rgba_dxt1; break; case MESA_FORMAT_RGBA_DXT3: - fetch = _mesa_fetch_texel_2d_f_rgba_dxt3; + fetch = _mesa_fetch_texel_rgba_dxt3; break; case MESA_FORMAT_RGBA_DXT5: - fetch = _mesa_fetch_texel_2d_f_rgba_dxt5; + fetch = _mesa_fetch_texel_rgba_dxt5; break; /* FXT1 formats */ @@ -516,30 +516,30 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height, /* Red/RG formats */ case MESA_FORMAT_RED_RGTC1: - fetch = _mesa_fetch_texel_2d_f_red_rgtc1; + fetch = _mesa_fetch_texel_red_rgtc1; break; case MESA_FORMAT_SIGNED_RED_RGTC1: - fetch = _mesa_fetch_texel_2d_f_signed_red_rgtc1; + fetch = _mesa_fetch_texel_signed_red_rgtc1; break; case MESA_FORMAT_RG_RGTC2: - fetch = _mesa_fetch_texel_2d_f_rg_rgtc2; + fetch = _mesa_fetch_texel_rg_rgtc2; break; case MESA_FORMAT_SIGNED_RG_RGTC2: - fetch = _mesa_fetch_texel_2d_f_signed_rg_rgtc2; + fetch = _mesa_fetch_texel_signed_rg_rgtc2; break; /* L/LA formats */ case MESA_FORMAT_L_LATC1: - fetch = _mesa_fetch_texel_2d_f_l_latc1; + fetch = _mesa_fetch_texel_l_latc1; break; case MESA_FORMAT_SIGNED_L_LATC1: - fetch = _mesa_fetch_texel_2d_f_signed_l_latc1; + fetch = _mesa_fetch_texel_signed_l_latc1; break; case MESA_FORMAT_LA_LATC2: - fetch = _mesa_fetch_texel_2d_f_la_latc2; + fetch = _mesa_fetch_texel_la_latc2; break; case MESA_FORMAT_SIGNED_LA_LATC2: - fetch = _mesa_fetch_texel_2d_f_signed_la_latc2; + fetch = _mesa_fetch_texel_signed_la_latc2; break; /* ETC1 formats */ diff --git a/mesalib/src/mesa/main/texcompress.h b/mesalib/src/mesa/main/texcompress.h index 2c357068c..34f4fae7a 100644 --- a/mesalib/src/mesa/main/texcompress.h +++ b/mesalib/src/mesa/main/texcompress.h @@ -43,7 +43,7 @@ extern gl_format _mesa_glenum_to_compressed_format(GLenum format); extern GLenum -_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat); +_mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat); extern GLubyte * _mesa_compressed_image_address(GLint col, GLint row, GLint img, diff --git a/mesalib/src/mesa/main/texpal.c b/mesalib/src/mesa/main/texcompress_cpal.c index ed2261b01..2398ded69 100644 --- a/mesalib/src/mesa/main/texpal.c +++ b/mesalib/src/mesa/main/texcompress_cpal.c @@ -1,10 +1,25 @@ -/************************************************************************** +/* + * Mesa 3-D graphics library * * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. * - **************************************************************************/ - + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ /** * Code to convert compressed/paletted texture images to ordinary images. @@ -22,8 +37,8 @@ #include "mtypes.h" #include "imports.h" #include "pixelstore.h" +#include "texcompress_cpal.h" #include "teximage.h" -#include "texpal.h" #if FEATURE_ES diff --git a/mesalib/src/mesa/main/texpal.h b/mesalib/src/mesa/main/texcompress_cpal.h index acfaa313e..7507d5c1b 100644 --- a/mesalib/src/mesa/main/texpal.h +++ b/mesalib/src/mesa/main/texcompress_cpal.h @@ -23,8 +23,8 @@ */ -#ifndef TEXPAL_H -#define TEXPAL_H +#ifndef TEXCOMPRESS_CPAL_H +#define TEXCOMPRESS_CPAL_H #include "main/glheader.h" @@ -42,4 +42,4 @@ extern void _mesa_cpal_compressed_format_type(GLenum internalFormat, GLenum *format, GLenum *type); -#endif /* TEXPAL_H */ +#endif /* TEXCOMPRESS_CPAL_H */ diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c index f707a0994..84d8fc7fc 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.c +++ b/mesalib/src/mesa/main/texcompress_rgtc.c @@ -292,12 +292,14 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) } void -_mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_red_rgtc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, - i, j, &red, 1); + GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0; + unsigned_fetch_texel_rgtc(texImage->RowStride, + texImage->Map + sliceOffset, + i, j, &red, 1); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = 0.0; texel[BCOMP] = 0.0; @@ -305,12 +307,14 @@ _mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_signed_red_rgtc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), - i, j, &red, 1); + GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0; + signed_fetch_texel_rgtc(texImage->RowStride, + (GLbyte *)(texImage->Map) + sliceOffset, + i, j, &red, 1); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = 0.0; texel[BCOMP] = 0.0; @@ -318,14 +322,17 @@ _mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texIm } void -_mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_rg_rgtc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red, green; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, - i, j, &red, 2); - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map + 8, - i, j, &green, 2); + GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0; + unsigned_fetch_texel_rgtc(texImage->RowStride, + texImage->Map + sliceOffset, + i, j, &red, 2); + unsigned_fetch_texel_rgtc(texImage->RowStride, + texImage->Map + sliceOffset + 8, + i, j, &green, 2); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = UBYTE_TO_FLOAT(green); texel[BCOMP] = 0.0; @@ -333,14 +340,17 @@ _mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_signed_rg_rgtc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red, green; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), - i, j, &red, 2); - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map) + 8, - i, j, &green, 2); + GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0; + signed_fetch_texel_rgtc(texImage->RowStride, + (GLbyte *)(texImage->Map) + sliceOffset, + i, j, &red, 2); + signed_fetch_texel_rgtc(texImage->RowStride, + (GLbyte *)(texImage->Map) + sliceOffset + 8, + i, j, &green, 2); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = BYTE_TO_FLOAT_TEX(green); texel[BCOMP] = 0.0; @@ -348,12 +358,14 @@ _mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texIma } void -_mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_l_latc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, - i, j, &red, 1); + GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0; + unsigned_fetch_texel_rgtc(texImage->RowStride, + texImage->Map + sliceOffset, + i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT(red); @@ -361,12 +373,14 @@ _mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_signed_l_latc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), - i, j, &red, 1); + GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0; + signed_fetch_texel_rgtc(texImage->RowStride, + (GLbyte *)(texImage->Map) + sliceOffset, + i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = BYTE_TO_FLOAT_TEX(red); @@ -374,14 +388,17 @@ _mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImag } void -_mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_la_latc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLubyte red, green; - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map, - i, j, &red, 2); - unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map + 8, - i, j, &green, 2); + GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0; + unsigned_fetch_texel_rgtc(texImage->RowStride, + texImage->Map + sliceOffset, + i, j, &red, 2); + unsigned_fetch_texel_rgtc(texImage->RowStride, + texImage->Map + sliceOffset + 8, + i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT(red); @@ -389,14 +406,17 @@ _mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_signed_la_latc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { GLbyte red, green; - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map), - i, j, &red, 2); - signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map) + 8, - i, j, &green, 2); + GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0; + signed_fetch_texel_rgtc(texImage->RowStride, + (GLbyte *)(texImage->Map) + sliceOffset, + i, j, &red, 2); + signed_fetch_texel_rgtc(texImage->RowStride, + (GLbyte *)(texImage->Map) + sliceOffset + 8, + i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = BYTE_TO_FLOAT_TEX(red); diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h index 6be6ad9be..91fda882d 100644 --- a/mesalib/src/mesa/main/texcompress_rgtc.h +++ b/mesalib/src/mesa/main/texcompress_rgtc.h @@ -43,35 +43,35 @@ extern GLboolean _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS); extern void -_mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_red_rgtc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_signed_red_rgtc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_rg_rgtc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_signed_rg_rgtc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_l_latc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_signed_l_latc1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_la_latc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_signed_la_latc2(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); #endif diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c index 632c05873..c1984da66 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.c +++ b/mesalib/src/mesa/main/texcompress_s3tc.c @@ -372,13 +372,14 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) static void -fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLubyte *texel ) +fetch_texel_2d_rgb_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLubyte *texel) { (void) k; if (fetch_ext_rgb_dxt1) { + GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0; fetch_ext_rgb_dxt1(texImage->RowStride, - texImage->Map, i, j, texel); + texImage->Map + sliceOffset, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1"); @@ -386,8 +387,8 @@ fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage, void -_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_rgb_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -400,13 +401,14 @@ _mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage, static void -fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLubyte *texel ) +fetch_texel_2d_rgba_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLubyte *texel) { (void) k; if (fetch_ext_rgba_dxt1) { + GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0; fetch_ext_rgba_dxt1(texImage->RowStride, - texImage->Map, i, j, texel); + texImage->Map + sliceOffset, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n"); @@ -414,8 +416,8 @@ fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage, void -_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_rgba_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -428,13 +430,14 @@ _mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage, static void -fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLubyte *texel ) +fetch_texel_2d_rgba_dxt3(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLubyte *texel) { (void) k; if (fetch_ext_rgba_dxt3) { + GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0; fetch_ext_rgba_dxt3(texImage->RowStride, - texImage->Map, i, j, texel); + texImage->Map + sliceOffset, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n"); @@ -442,8 +445,8 @@ fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage, void -_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_rgba_dxt3(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -456,13 +459,14 @@ _mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage, static void -fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLubyte *texel ) +fetch_texel_2d_rgba_dxt5(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLubyte *texel) { (void) k; if (fetch_ext_rgba_dxt5) { + GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0; fetch_ext_rgba_dxt5(texImage->RowStride, - texImage->Map, i, j, texel); + texImage->Map + sliceOffset, i, j, texel); } else _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n"); @@ -470,8 +474,8 @@ fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage, void -_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_rgba_dxt5(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -484,8 +488,8 @@ _mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage, #if FEATURE_EXT_texture_sRGB void -_mesa_fetch_texel_2d_f_srgb_dxt1( const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +_mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -497,8 +501,8 @@ _mesa_fetch_texel_2d_f_srgb_dxt1( const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -510,8 +514,8 @@ _mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; @@ -523,8 +527,8 @@ _mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage, } void -_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel) +_mesa_fetch_texel_srgba_dxt5(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel) { /* just sample as GLubyte and convert to float here */ GLubyte rgba[4]; diff --git a/mesalib/src/mesa/main/texcompress_s3tc.h b/mesalib/src/mesa/main/texcompress_s3tc.h index 23793d167..2c06e50ce 100644 --- a/mesalib/src/mesa/main/texcompress_s3tc.h +++ b/mesalib/src/mesa/main/texcompress_s3tc.h @@ -48,36 +48,36 @@ extern GLboolean _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS); extern void -_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_rgb_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_rgba_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_rgba_dxt3(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_rgba_dxt5(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_srgb_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void -_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel); +_mesa_fetch_texel_srgba_dxt5(const struct swrast_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel); extern void _mesa_init_texture_s3tc(struct gl_context *ctx); diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 275e69e31..1a318abe4 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -61,8 +61,8 @@ * will typically override this function with a specialized version. */ gl_format -_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ) +_mesa_choose_tex_format(struct gl_context *ctx, GLenum target, + GLint internalFormat, GLenum format, GLenum type) { (void) format; (void) type; @@ -236,21 +236,33 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, RETURN_IF_SUPPORTED(MESA_FORMAT_I8); break; case GL_COMPRESSED_RGB_ARB: - if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); - if (ctx->Extensions.TDFX_texture_compression_FXT1) - RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1); + /* We don't use texture compression for 1D and 1D array textures. + * For 1D textures, compressions doesn't buy us much. + * For 1D ARRAY textures, there's complicated issues with updating + * sub-regions on non-block boundaries with glCopyTexSubImage, among + * other issues. FWIW, the GL_EXT_texture_array extension prohibits + * 1D ARRAY textures in S3TC format. + */ + if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) { + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); + if (ctx->Extensions.TDFX_texture_compression_FXT1) + RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1); + } RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888); RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888); RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); break; case GL_COMPRESSED_RGBA_ARB: - if (ctx->Extensions.EXT_texture_compression_s3tc || - ctx->Extensions.S3_s3tc) - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */ - if (ctx->Extensions.TDFX_texture_compression_FXT1) - RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1); + /* We don't use texture compression for 1D and 1D array textures. */ + if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) { + if (ctx->Extensions.EXT_texture_compression_s3tc || + ctx->Extensions.S3_s3tc) + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */ + if (ctx->Extensions.TDFX_texture_compression_FXT1) + RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1); + } RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888); RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888); break; @@ -775,7 +787,8 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, break; case GL_COMPRESSED_RED: - RETURN_IF_SUPPORTED(MESA_FORMAT_RED_RGTC1); + if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) + RETURN_IF_SUPPORTED(MESA_FORMAT_RED_RGTC1); RETURN_IF_SUPPORTED(MESA_FORMAT_R8); break; @@ -789,7 +802,8 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, break; case GL_COMPRESSED_RG: - RETURN_IF_SUPPORTED(MESA_FORMAT_RG_RGTC2); + if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) + RETURN_IF_SUPPORTED(MESA_FORMAT_RG_RGTC2); RETURN_IF_SUPPORTED(MESA_FORMAT_GR88); break; diff --git a/mesalib/src/mesa/main/texformat.h b/mesalib/src/mesa/main/texformat.h index 3cf09213a..71af9ca22 100644 --- a/mesalib/src/mesa/main/texformat.h +++ b/mesalib/src/mesa/main/texformat.h @@ -32,8 +32,8 @@ struct gl_context; extern gl_format -_mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat, - GLenum format, GLenum type ); +_mesa_choose_tex_format(struct gl_context *ctx, GLenum target, + GLint internalFormat, GLenum format, GLenum type); #endif diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index 27294ba80..59b38dee4 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -28,7 +28,7 @@ * Texture image-related functions. */ - +#include <stdbool.h> #include "glheader.h" #include "bufferobj.h" #include "context.h" @@ -42,14 +42,20 @@ #include "mfeatures.h" #include "state.h" #include "texcompress.h" +#include "texcompress_cpal.h" #include "teximage.h" #include "texobj.h" #include "texstate.h" -#include "texpal.h" #include "mtypes.h" #include "glformats.h" +/* Inexplicably, GL_HALF_FLOAT_OES has a different value than GL_HALF_FLOAT. + */ +#ifndef GL_HALF_FLOAT_OES +#define GL_HALF_FLOAT_OES 0x8D61 +#endif + /** * State changes which we care about for glCopyTex[Sub]Image() calls. * In particular, we care about pixel transfer state and buffer state @@ -833,8 +839,8 @@ _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, * \return pointer to texture image or NULL if invalid target, invalid * level, or out of memory. */ -struct gl_texture_image * -_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) +static struct gl_texture_image * +get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level) { struct gl_texture_image *texImage; GLuint texIndex; @@ -1375,6 +1381,16 @@ compressedteximage_only_format(const struct gl_context *ctx, GLenum format) { switch (format) { case GL_ETC1_RGB8_OES: + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: return GL_TRUE; default: return GL_FALSE; @@ -1426,16 +1442,19 @@ legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) switch (target) { case GL_TEXTURE_1D: case GL_PROXY_TEXTURE_1D: - return GL_TRUE; + return _mesa_is_desktop_gl(ctx); default: return GL_FALSE; } case 2: switch (target) { case GL_TEXTURE_2D: - case GL_PROXY_TEXTURE_2D: return GL_TRUE; + case GL_PROXY_TEXTURE_2D: + return _mesa_is_desktop_gl(ctx); case GL_PROXY_TEXTURE_CUBE_MAP: + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.ARB_texture_cube_map; case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: @@ -1445,23 +1464,31 @@ legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target) return ctx->Extensions.ARB_texture_cube_map; case GL_TEXTURE_RECTANGLE_NV: case GL_PROXY_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle; + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.NV_texture_rectangle; case GL_TEXTURE_1D_ARRAY_EXT: case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); + return _mesa_is_desktop_gl(ctx) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); default: return GL_FALSE; } case 3: switch (target) { case GL_TEXTURE_3D: - case GL_PROXY_TEXTURE_3D: return GL_TRUE; + case GL_PROXY_TEXTURE_3D: + return _mesa_is_desktop_gl(ctx); case GL_TEXTURE_2D_ARRAY_EXT: + return (_mesa_is_desktop_gl(ctx) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array)) + || _mesa_is_gles3(ctx); case GL_PROXY_TEXTURE_2D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); + return _mesa_is_desktop_gl(ctx) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); default: return GL_FALSE; } @@ -1483,7 +1510,7 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) { switch (dims) { case 1: - return target == GL_TEXTURE_1D; + return _mesa_is_desktop_gl(ctx) && target == GL_TEXTURE_1D; case 2: switch (target) { case GL_TEXTURE_2D: @@ -1496,10 +1523,12 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: return ctx->Extensions.ARB_texture_cube_map; case GL_TEXTURE_RECTANGLE_NV: - return ctx->Extensions.NV_texture_rectangle; + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.NV_texture_rectangle; case GL_TEXTURE_1D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); + return _mesa_is_desktop_gl(ctx) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array); default: return GL_FALSE; } @@ -1508,8 +1537,10 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target) case GL_TEXTURE_3D: return GL_TRUE; case GL_TEXTURE_2D_ARRAY_EXT: - return (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array); + return (_mesa_is_desktop_gl(ctx) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array)) + || _mesa_is_gles3(ctx); default: return GL_FALSE; } @@ -1537,6 +1568,101 @@ mutable_tex_object(struct gl_context *ctx, GLenum target) } +GLenum +_mesa_es_error_check_format_and_type(GLenum format, GLenum type, + unsigned dimensions) +{ + bool type_valid = true; + + switch (format) { + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + type_valid = (type == GL_UNSIGNED_BYTE + || type == GL_FLOAT + || type == GL_HALF_FLOAT_OES); + break; + + case GL_RGB: + type_valid = (type == GL_UNSIGNED_BYTE + || type == GL_UNSIGNED_SHORT_5_6_5 + || type == GL_FLOAT + || type == GL_HALF_FLOAT_OES); + break; + + case GL_RGBA: + type_valid = (type == GL_UNSIGNED_BYTE + || type == GL_UNSIGNED_SHORT_4_4_4_4 + || type == GL_UNSIGNED_SHORT_5_5_5_1 + || type == GL_FLOAT + || type == GL_HALF_FLOAT_OES + || type == GL_UNSIGNED_INT_2_10_10_10_REV); + break; + + case GL_DEPTH_COMPONENT: + /* This format is filtered against invalid dimensionalities elsewhere. + */ + type_valid = (type == GL_UNSIGNED_SHORT + || type == GL_UNSIGNED_INT); + break; + + case GL_DEPTH_STENCIL: + /* This format is filtered against invalid dimensionalities elsewhere. + */ + type_valid = (type == GL_UNSIGNED_INT_24_8); + break; + + case GL_BGRA_EXT: + type_valid = (type == GL_UNSIGNED_BYTE); + + /* This feels like a bug in the EXT_texture_format_BGRA8888 spec, but + * the format does not appear to be allowed for 3D textures in OpenGL + * ES. + */ + if (dimensions != 2) + return GL_INVALID_VALUE; + + break; + + default: + return GL_INVALID_VALUE; + } + + return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION; +} + + + +/** + * Return expected size of a compressed texture. + */ +static GLuint +compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, + GLenum glformat) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + return _mesa_format_image_size(mesaFormat, width, height, depth); +} + + +/* + * Return compressed texture block size, in pixels. + */ +static void +get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) +{ + gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); + _mesa_get_format_block_size(mesaFormat, bw, bh); +} + + +/** + * Special value returned by error some texture error checking functions when + * an error is detected and the proxy texture image's width/height/depth/format + * fields should be zeroed-out. + */ +#define PROXY_ERROR 2 + /** * Test the glTexImage[123]D() parameters for errors. @@ -1553,13 +1679,14 @@ mutable_tex_object(struct gl_context *ctx, GLenum target) * \param depth image depth given by the user. * \param border image border given by the user. * - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors. + * \return PROXY_ERROR if there's an error that should zero-out the proxy image, + * GL_TRUE if a regular GL error is found, or GL_FALSE if no error, * * Verifies each of the parameters against the constants specified in * __struct gl_contextRec::Const and the supported extensions, and according * to the OpenGL specification. */ -static GLboolean +static GLenum texture_error_check( struct gl_context *ctx, GLuint dimensions, GLenum target, GLint level, GLint internalFormat, @@ -1579,34 +1706,62 @@ texture_error_check( struct gl_context *ctx, */ const GLboolean indexFormat = (format == GL_COLOR_INDEX); + /* Note: for proxy textures, some error conditions immediately generate + * a GL error in the usual way. But others do not generate a GL error. + * Instead, they cause the width, height, depth, format fields of the + * texture image to be zeroed-out. The GL spec seems to indicate that the + * zero-out behaviour is only used in cases related to memory allocation. + */ + /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */ if (level < 0 || level >= MAX_TEXTURE_LEVELS) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(level=%d)", dimensions, level); - } + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(level=%d)", dimensions, level); return GL_TRUE; } /* Check border */ if (border < 0 || border > 1 || - ((target == GL_TEXTURE_RECTANGLE_NV || + ((ctx->API != API_OPENGL || + target == GL_TEXTURE_RECTANGLE_NV || target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(border=%d)", dimensions, border); - } + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(border=%d)", dimensions, border); return GL_TRUE; } if (width < 0 || height < 0 || depth < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(width, height or depth < 0)", dimensions); - } + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(width, height or depth < 0)", dimensions); return GL_TRUE; } + /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the + * combinations of format, internalFormat, and type that can be used. + * Formats and types that require additional extensions (e.g., GL_FLOAT + * requires GL_OES_texture_float) are filtered elsewhere. + */ + if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) { + if (format != internalFormat) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(format = %s, internalFormat = %s)", + dimensions, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(internalFormat)); + return GL_TRUE; + } + + err = _mesa_es_error_check_format_and_type(format, type, dimensions); + if (err != GL_NO_ERROR) { + _mesa_error(ctx, err, + "glTexImage%dD(format = %s, type = %s)", + dimensions, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type)); + return GL_TRUE; + } + } + /* Do this simple check before calling the TestProxyTexImage() function */ if (proxyTarget == GL_PROXY_TEXTURE_CUBE_MAP_ARB) { sizeOK = (width == height); @@ -1621,32 +1776,32 @@ texture_error_check( struct gl_context *ctx, type, width, height, depth, border); if (!sizeOK) { - if (!isProxy) { + if (isProxy) { + /* No GL error is recorded, but we need to zero-out the image dims */ + return PROXY_ERROR; + } + else { _mesa_error(ctx, GL_INVALID_VALUE, "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)", dimensions, level, width, height, depth); + return GL_TRUE; } - return GL_TRUE; } /* Check internalFormat */ if (_mesa_base_tex_format(ctx, internalFormat) < 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_VALUE, - "glTexImage%dD(internalFormat=%s)", - dimensions, _mesa_lookup_enum_by_nr(internalFormat)); - } + _mesa_error(ctx, GL_INVALID_VALUE, + "glTexImage%dD(internalFormat=%s)", + dimensions, _mesa_lookup_enum_by_nr(internalFormat)); return GL_TRUE; } /* Check incoming image format and type */ err = _mesa_error_check_format_and_type(ctx, format, type); if (err != GL_NO_ERROR) { - if (!isProxy) { - _mesa_error(ctx, err, - "glTexImage%dD(incompatible format 0x%x, type 0x%x)", - dimensions, format, type); - } + _mesa_error(ctx, err, + "glTexImage%dD(incompatible format 0x%x, type 0x%x)", + dimensions, format, type); return GL_TRUE; } @@ -1657,10 +1812,9 @@ texture_error_check( struct gl_context *ctx, (_mesa_is_ycbcr_format(internalFormat) != _mesa_is_ycbcr_format(format)) || (_mesa_is_depthstencil_format(internalFormat) != _mesa_is_depthstencil_format(format)) || (_mesa_is_dudv_format(internalFormat) != _mesa_is_dudv_format(format))) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", - dimensions, internalFormat, format); + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(incompatible internalFormat 0x%x, format 0x%x)", + dimensions, internalFormat, format); return GL_TRUE; } @@ -1671,7 +1825,8 @@ texture_error_check( struct gl_context *ctx, type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { char message[100]; _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format/type YCBCR mismatch", dimensions); + "glTexImage%dD(format/type YCBCR mismatch)", + dimensions); _mesa_error(ctx, GL_INVALID_ENUM, "%s", message); return GL_TRUE; /* error */ } @@ -1679,18 +1834,17 @@ texture_error_check( struct gl_context *ctx, target != GL_PROXY_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV && target != GL_PROXY_TEXTURE_RECTANGLE_NV) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)"); + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage%dD(bad target for YCbCr texture)", + dimensions); return GL_TRUE; } if (border != 0) { - if (!isProxy) { - char message[100]; - _mesa_snprintf(message, sizeof(message), - "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", - dimensions, border); - _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); - } + char message[100]; + _mesa_snprintf(message, sizeof(message), + "glTexImage%dD(format=GL_YCBCR_MESA and border=%d)", + dimensions, border); + _mesa_error(ctx, GL_INVALID_VALUE, "%s", message); return GL_TRUE; } } @@ -1711,9 +1865,9 @@ texture_error_check( struct gl_context *ctx, target != GL_PROXY_TEXTURE_RECTANGLE_ARB && !((_mesa_is_cube_face(target) || target == GL_PROXY_TEXTURE_CUBE_MAP) && (ctx->Version >= 30 || ctx->Extensions.EXT_gpu_shader4))) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage(target/internalFormat)"); + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage%dD(bad target for depth texture)", + dimensions); return GL_TRUE; } } @@ -1721,21 +1875,18 @@ texture_error_check( struct gl_context *ctx, /* additional checks for compressed textures */ if (_mesa_is_compressed_format(ctx, internalFormat)) { if (!target_can_be_compressed(ctx, target, internalFormat)) { - if (!isProxy) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexImage%dD(target)", dimensions); + _mesa_error(ctx, GL_INVALID_ENUM, + "glTexImage%dD(target can't be compressed)", dimensions); return GL_TRUE; } if (compressedteximage_only_format(ctx, internalFormat)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(no compression for format)", dimensions); + "glTexImage%dD(no compression for format)", dimensions); return GL_TRUE; } if (border != 0) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(border!=0)", dimensions); - } + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(border!=0)", dimensions); return GL_TRUE; } } @@ -1744,11 +1895,9 @@ texture_error_check( struct gl_context *ctx, if ((ctx->Version >= 30 || ctx->Extensions.EXT_texture_integer) && (_mesa_is_enum_format_integer(format) != _mesa_is_enum_format_integer(internalFormat))) { - if (!isProxy) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glTexImage%dD(integer/non-integer format mismatch)", - dimensions); - } + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(integer/non-integer format mismatch)", + dimensions); return GL_TRUE; } @@ -1764,6 +1913,187 @@ texture_error_check( struct gl_context *ctx, /** + * Error checking for glCompressedTexImage[123]D(). + * \param reason returns reason for error, if any + * \return error code or GL_NO_ERROR or PROXY_ERROR. + */ +static GLenum +compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, + GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize) +{ + const GLenum proxyTarget = get_proxy_target(target); + const GLint maxLevels = _mesa_max_texture_levels(ctx, target); + GLint expectedSize; + GLenum choose_format; + GLenum choose_type; + GLenum proxy_format; + GLenum error = GL_NO_ERROR; + char *reason = ""; /* no error */ + + if (!target_can_be_compressed(ctx, target, internalFormat)) { + reason = "target"; + error = GL_INVALID_ENUM; + goto error; + } + + /* This will detect any invalid internalFormat value */ + if (!_mesa_is_compressed_format(ctx, internalFormat)) { + reason = "internalFormat"; + error = GL_INVALID_ENUM; + goto error; + } + + switch (internalFormat) { +#if FEATURE_ES + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + _mesa_cpal_compressed_format_type(internalFormat, &choose_format, + &choose_type); + proxy_format = choose_format; + + /* check level (note that level should be zero or less!) */ + if (level > 0 || level < -maxLevels) { + reason = "level"; + error = GL_INVALID_VALUE; + goto error; + } + + if (dimensions != 2) { + reason = "compressed paletted textures must be 2D"; + error = GL_INVALID_OPERATION; + goto error; + } + + /* Figure out the expected texture size (in bytes). This will be + * checked against the actual size later. + */ + expectedSize = _mesa_cpal_compressed_size(level, internalFormat, + width, height); + + /* This is for the benefit of the TestProxyTexImage below. It expects + * level to be non-negative. OES_compressed_paletted_texture uses a + * weird mechanism where the level specified to glCompressedTexImage2D + * is -(n-1) number of levels in the texture, and the data specifies the + * complete mipmap stack. This is done to ensure the palette is the + * same for all levels. + */ + level = -level; + break; +#endif + + default: + choose_format = GL_NONE; + choose_type = GL_NONE; + proxy_format = internalFormat; + + /* check level */ + if (level < 0 || level >= maxLevels) { + reason = "level"; + error = GL_INVALID_VALUE; + goto error; + } + + /* Figure out the expected texture size (in bytes). This will be + * checked against the actual size later. + */ + expectedSize = compressed_tex_size(width, height, depth, internalFormat); + break; + } + + /* This should really never fail */ + if (_mesa_base_tex_format(ctx, internalFormat) < 0) { + reason = "internalFormat"; + error = GL_INVALID_ENUM; + goto error; + } + + /* No compressed formats support borders at this time */ + if (border != 0) { + reason = "border != 0"; + error = GL_INVALID_VALUE; + goto error; + } + + /* For cube map, width must equal height */ + if (_mesa_is_cube_face(target) && width != height) { + reason = "width != height"; + error = GL_INVALID_VALUE; + goto error; + } + + /* check image size against compression block size */ + { + gl_format texFormat = + ctx->Driver.ChooseTextureFormat(ctx, target, proxy_format, + choose_format, choose_type); + GLuint bw, bh; + + _mesa_get_format_block_size(texFormat, &bw, &bh); + if ((width > bw && width % bw > 0) || + (height > bh && height % bh > 0)) { + /* + * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is + * generated [...] if any parameter combinations are not + * supported by the specific compressed internal format. + */ + reason = "invalid width or height for compression format"; + error = GL_INVALID_OPERATION; + goto error; + } + } + + /* check image sizes */ + if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, + proxy_format, choose_format, + choose_type, + width, height, depth, border)) { + /* See error comment above */ + if (target == proxyTarget) { + return PROXY_ERROR; + } + reason = "invalid width, height or format"; + error = GL_INVALID_OPERATION; + goto error; + } + + /* check image size in bytes */ + if (expectedSize != imageSize) { + /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] + * if <imageSize> is not consistent with the format, dimensions, and + * contents of the specified image. + */ + reason = "imageSize inconsistant with width/height/format"; + error = GL_INVALID_VALUE; + goto error; + } + + if (!mutable_tex_object(ctx, target)) { + reason = "immutable texture"; + error = GL_INVALID_OPERATION; + goto error; + } + + return GL_NO_ERROR; + +error: + _mesa_error(ctx, error, "glCompressedTexImage%dD(%s)", dimensions, reason); + return error; +} + + + +/** * Test glTexSubImage[123]D() parameters for errors. * * \param ctx GL context. @@ -1817,6 +2147,23 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } + /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the + * combinations of format and type that can be used. Formats and types + * that require additional extensions (e.g., GL_FLOAT requires + * GL_OES_texture_float) are filtered elsewhere. + */ + if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) { + err = _mesa_es_error_check_format_and_type(format, type, dimensions); + if (err != GL_NO_ERROR) { + _mesa_error(ctx, err, + "glTexSubImage%dD(format = %s, type = %s)", + dimensions, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type)); + return GL_TRUE; + } + } + err = _mesa_error_check_format_and_type(ctx, format, type); if (err != GL_NO_ERROR) { _mesa_error(ctx, err, @@ -1992,11 +2339,32 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, /* Check border */ if (border < 0 || border > 1 || - ((target == GL_TEXTURE_RECTANGLE_NV || + ((ctx->API != API_OPENGL || + target == GL_TEXTURE_RECTANGLE_NV || target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(border=%d)", dimensions, border); return GL_TRUE; } + /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the + * internalFormat. + */ + if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) { + switch (internalFormat) { + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyTexImage%dD(internalFormat)", dimensions); + return GL_TRUE; + } + } + baseFormat = _mesa_base_tex_format(ctx, internalFormat); if (baseFormat < 0) { _mesa_error(ctx, GL_INVALID_VALUE, @@ -2429,7 +2797,8 @@ _mesa_choose_texture_format(struct gl_context *ctx, } /* choose format from scratch */ - f = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type); + f = ctx->Driver.ChooseTextureFormat(ctx, texObj->Target, internalFormat, + format, type); ASSERT(f != MESA_FORMAT_NONE); return f; } @@ -2477,71 +2846,125 @@ strip_texture_border(GLenum target, } } + /** - * Common code to implement all the glTexImage1D/2D/3D functions. + * Common code to implement all the glTexImage1D/2D/3D functions + * as well as glCompressedTexImage1D/2D/3D. + * \param compressed only GL_TRUE for glCompressedTexImage1D/2D/3D calls. + * \param format the user's image format (only used if !compressed) + * \param type the user's image type (only used if !compressed) + * \param imageSize only used for glCompressedTexImage1D/2D/3D calls. */ static void -teximage(struct gl_context *ctx, GLuint dims, +teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, - const GLvoid *pixels) + GLsizei imageSize, const GLvoid *pixels) { - GLboolean error; + const char *func = compressed ? "glCompressedTexImage" : "glTexImage"; + GLenum error; struct gl_pixelstore_attrib unpack_no_border; const struct gl_pixelstore_attrib *unpack = &ctx->Unpack; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, depth, border, - _mesa_lookup_enum_by_nr(format), - _mesa_lookup_enum_by_nr(type), pixels); + if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) { + if (compressed) + _mesa_debug(ctx, + "glCompressedTexImage%uD %s %d %s %d %d %d %d %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, pixels); + else + _mesa_debug(ctx, + "glTexImage%uD %s %d %s %d %d %d %d %s %s %p\n", + dims, + _mesa_lookup_enum_by_nr(target), level, + _mesa_lookup_enum_by_nr(internalFormat), + width, height, depth, border, + _mesa_lookup_enum_by_nr(format), + _mesa_lookup_enum_by_nr(type), pixels); + } internalFormat = override_internal_format(internalFormat, width, height); /* target error checking */ if (!legal_teximage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); + _mesa_error(ctx, GL_INVALID_ENUM, "%s%uD(target=%s)", + func, dims, _mesa_lookup_enum_by_nr(target)); return; } /* general error checking */ - error = texture_error_check(ctx, dims, target, level, internalFormat, - format, type, width, height, depth, border); + if (compressed) { + error = compressed_texture_error_check(ctx, dims, target, level, + internalFormat, + width, height, depth, + border, imageSize); + } + else { + error = texture_error_check(ctx, dims, target, level, internalFormat, + format, type, width, height, depth, border); + } + +#if FEATURE_ES + /* Here we convert a cpal compressed image into a regular glTexImage2D + * call by decompressing the texture. If we really want to support cpal + * textures in any driver this would have to be changed. + */ + if (compressed && !error && dims == 2) { + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + _mesa_cpal_compressed_teximage2d(target, level, internalFormat, + width, height, imageSize, pixels); + return; + } + } +#endif if (_mesa_is_proxy_texture(target)) { /* Proxy texture: just clear or set state depending on error checking */ struct gl_texture_image *texImage = - _mesa_get_proxy_tex_image(ctx, target, level); + get_proxy_tex_image(ctx, target, level); + gl_format texFormat = MESA_FORMAT_NONE; - if (error) { - /* when error, clear all proxy texture image parameters */ - if (texImage) - clear_teximage_fields(texImage); - } - else { - /* no error, set the tex image parameters */ + if (!error) { + /* No parameter errors. Choose a texture format and see if we + * can really allocate the texture. + */ struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target); - gl_format texFormat = _mesa_choose_texture_format(ctx, texObj, - target, level, - internalFormat, - format, type); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, texImage, width, height, - depth, border, internalFormat, - texFormat); + texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, + internalFormat, format, type); + if (!legal_texture_size(ctx, texFormat, width, height, depth)) { + error = PROXY_ERROR; } - else if (texImage) { + } + + if (error == PROXY_ERROR) { + /* image too large, etc. Clear all proxy texture image parameters. */ + if (texImage) clear_teximage_fields(texImage); - } + } + else if (error == GL_FALSE) { + /* no error: store the teximage parameters */ + if (texImage) + _mesa_init_teximage_fields(ctx, texImage, width, height, depth, + border, internalFormat, texFormat); + } + else { + /* other, regular error (was already recorded) */ } } else { @@ -2575,7 +2998,7 @@ teximage(struct gl_context *ctx, GLuint dims, texImage = _mesa_get_tex_image(ctx, texObj, target, level); if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s%uD", func, dims); } else { gl_format texFormat; @@ -2592,8 +3015,14 @@ teximage(struct gl_context *ctx, GLuint dims, border, internalFormat, texFormat); /* Give the texture to the driver. <pixels> may be null. */ - ctx->Driver.TexImage(ctx, dims, texImage, format, - type, pixels, unpack); + if (compressed) { + ctx->Driver.CompressedTexImage(ctx, dims, texImage, + imageSize, pixels); + } + else { + ctx->Driver.TexImage(ctx, dims, texImage, format, + type, pixels, unpack); + } check_gen_mipmap(ctx, target, texObj, level); @@ -2602,7 +3031,7 @@ teximage(struct gl_context *ctx, GLuint dims, _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage%uD", dims); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s%uD", func, dims); } } } @@ -2620,8 +3049,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, GLenum type, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 1, target, level, internalFormat, width, 1, 1, - border, format, type, pixels); + teximage(ctx, GL_FALSE, 1, target, level, internalFormat, width, 1, 1, + border, format, type, 0, pixels); } @@ -2632,8 +3061,8 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 2, target, level, internalFormat, width, height, 1, - border, format, type, pixels); + teximage(ctx, GL_FALSE, 2, target, level, internalFormat, width, height, 1, + border, format, type, 0, pixels); } @@ -2648,8 +3077,9 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - teximage(ctx, 3, target, level, internalFormat, width, height, depth, - border, format, type, pixels); + teximage(ctx, GL_FALSE, 3, target, level, internalFormat, + width, height, depth, + border, format, type, 0, pixels); } @@ -2670,13 +3100,23 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) { struct gl_texture_object *texObj; struct gl_texture_image *texImage; + bool valid_target; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if ((target == GL_TEXTURE_2D && - !ctx->Extensions.OES_EGL_image) || - (target == GL_TEXTURE_EXTERNAL_OES && - !ctx->Extensions.OES_EGL_image_external)) { + switch (target) { + case GL_TEXTURE_2D: + valid_target = ctx->Extensions.OES_EGL_image; + break; + case GL_TEXTURE_EXTERNAL_OES: + valid_target = ctx->Extensions.OES_EGL_image_external; + break; + default: + valid_target = false; + break; + } + + if (!valid_target) { _mesa_error(ctx, GL_INVALID_ENUM, "glEGLImageTargetTexture2D(target=%d)", target); return; @@ -3084,190 +3524,6 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, /** - * Return expected size of a compressed texture. - */ -static GLuint -compressed_tex_size(GLsizei width, GLsizei height, GLsizei depth, - GLenum glformat) -{ - gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); - return _mesa_format_image_size(mesaFormat, width, height, depth); -} - - -/* - * Return compressed texture block size, in pixels. - */ -static void -get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh) -{ - gl_format mesaFormat = _mesa_glenum_to_compressed_format(glformat); - _mesa_get_format_block_size(mesaFormat, bw, bh); -} - - -/** - * Error checking for glCompressedTexImage[123]D(). - * \param reason returns reason for error, if any - * \return error code or GL_NO_ERROR. - */ -static GLenum -compressed_texture_error_check(struct gl_context *ctx, GLint dimensions, - GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, char **reason) -{ - const GLenum proxyTarget = get_proxy_target(target); - const GLint maxLevels = _mesa_max_texture_levels(ctx, target); - GLint expectedSize; - GLenum choose_format; - GLenum choose_type; - GLenum proxy_format; - - *reason = ""; /* no error */ - - if (!target_can_be_compressed(ctx, target, internalFormat)) { - *reason = "target"; - return GL_INVALID_ENUM; - } - - /* This will detect any invalid internalFormat value */ - if (!_mesa_is_compressed_format(ctx, internalFormat)) { - *reason = "internalFormat"; - return GL_INVALID_ENUM; - } - - switch (internalFormat) { -#if FEATURE_ES - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB8_OES: - case GL_PALETTE8_RGBA8_OES: - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - _mesa_cpal_compressed_format_type(internalFormat, &choose_format, - &choose_type); - proxy_format = choose_format; - - /* check level */ - if (level > 0 || level < -maxLevels) { - *reason = "level"; - return GL_INVALID_VALUE; - } - - if (dimensions != 2) { - *reason = "compressed paletted textures must be 2D"; - return GL_INVALID_OPERATION; - } - - /* Figure out the expected texture size (in bytes). This will be - * checked against the actual size later. - */ - expectedSize = _mesa_cpal_compressed_size(level, internalFormat, - width, height); - - /* This is for the benefit of the TestProxyTexImage below. It expects - * level to be non-negative. OES_compressed_paletted_texture uses a - * weird mechanism where the level specified to glCompressedTexImage2D - * is -(n-1) number of levels in the texture, and the data specifies the - * complete mipmap stack. This is done to ensure the palette is the - * same for all levels. - */ - level = -level; - break; -#endif - - default: - choose_format = GL_NONE; - choose_type = GL_NONE; - proxy_format = internalFormat; - - /* check level */ - if (level < 0 || level >= maxLevels) { - *reason = "level"; - return GL_INVALID_VALUE; - } - - /* Figure out the expected texture size (in bytes). This will be - * checked against the actual size later. - */ - expectedSize = compressed_tex_size(width, height, depth, internalFormat); - break; - } - - /* This should really never fail */ - if (_mesa_base_tex_format(ctx, internalFormat) < 0) { - *reason = "internalFormat"; - return GL_INVALID_ENUM; - } - - /* No compressed formats support borders at this time */ - if (border != 0) { - *reason = "border != 0"; - return GL_INVALID_VALUE; - } - - /* For cube map, width must equal height */ - if (_mesa_is_cube_face(target) && width != height) { - *reason = "width != height"; - return GL_INVALID_VALUE; - } - - /* check image size against compression block size */ - { - gl_format texFormat = - ctx->Driver.ChooseTextureFormat(ctx, proxy_format, - choose_format, choose_type); - GLuint bw, bh; - - _mesa_get_format_block_size(texFormat, &bw, &bh); - if ((width > bw && width % bw > 0) || - (height > bh && height % bh > 0)) { - /* - * Per GL_ARB_texture_compression: GL_INVALID_OPERATION is - * generated [...] if any parameter combinations are not - * supported by the specific compressed internal format. - */ - *reason = "invalid width or height for compression format"; - return GL_INVALID_OPERATION; - } - } - - /* check image sizes */ - if (!ctx->Driver.TestProxyTexImage(ctx, proxyTarget, level, - proxy_format, choose_format, - choose_type, - width, height, depth, border)) { - /* See error comment above */ - *reason = "invalid width, height or format"; - return GL_INVALID_OPERATION; - } - - /* check image size in bytes */ - if (expectedSize != imageSize) { - /* Per GL_ARB_texture_compression: GL_INVALID_VALUE is generated [...] - * if <imageSize> is not consistent with the format, dimensions, and - * contents of the specified image. - */ - *reason = "imageSize inconsistant with width/height/format"; - return GL_INVALID_VALUE; - } - - if (!mutable_tex_object(ctx, target)) { - *reason = "immutable texture"; - return GL_INVALID_OPERATION; - } - - return GL_NO_ERROR; -} - - -/** * Error checking for glCompressedTexSubImage[123]D(). * \warning There are some bad assumptions here about the size of compressed * texture tiles (multiple of 4) used to test the validity of the @@ -3409,141 +3665,6 @@ compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims, } -/** - * Implementation of the glCompressedTexImage1/2/3D() functions. - */ -static void -compressedteximage(struct gl_context *ctx, GLuint dims, - GLenum target, GLint level, - GLenum internalFormat, GLsizei width, - GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid *data) -{ - GLenum error; - char *reason = ""; - - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - - if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) - _mesa_debug(ctx, - "glCompressedTexImage%uDARB %s %d %s %d %d %d %d %d %p\n", - dims, - _mesa_lookup_enum_by_nr(target), level, - _mesa_lookup_enum_by_nr(internalFormat), - width, height, depth, border, imageSize, data); - - /* check target */ - if (!legal_teximage_target(ctx, dims, target)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage%uD(target=%s)", - dims, _mesa_lookup_enum_by_nr(target)); - return; - } - - error = compressed_texture_error_check(ctx, dims, target, level, - internalFormat, width, height, depth, - border, imageSize, &reason); - -#if FEATURE_ES - /* XXX this is kind of a hack */ - if (!error && dims == 2) { - switch (internalFormat) { - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB8_OES: - case GL_PALETTE8_RGBA8_OES: - case GL_PALETTE8_R5_G6_B5_OES: - case GL_PALETTE8_RGBA4_OES: - case GL_PALETTE8_RGB5_A1_OES: - _mesa_cpal_compressed_teximage2d(target, level, internalFormat, - width, height, imageSize, data); - return; - } - } -#endif - - if (_mesa_is_proxy_texture(target)) { - /* Proxy texture: just check for errors and update proxy state */ - struct gl_texture_image *texImage; - - if (!error) { - struct gl_texture_object *texObj = - _mesa_get_current_tex_object(ctx, target); - gl_format texFormat = - _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, GL_NONE, GL_NONE); - if (!legal_texture_size(ctx, texFormat, width, height, depth)) { - error = GL_OUT_OF_MEMORY; - } - } - - texImage = _mesa_get_proxy_tex_image(ctx, target, level); - if (texImage) { - if (error) { - /* if error, clear all proxy texture image parameters */ - clear_teximage_fields(texImage); - } - else { - /* no error: store the teximage parameters */ - _mesa_init_teximage_fields(ctx, texImage, width, height, - depth, border, internalFormat, - MESA_FORMAT_NONE); - } - } - } - else { - /* non-proxy target */ - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - if (error) { - _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason); - return; - } - - texObj = _mesa_get_current_tex_object(ctx, target); - - _mesa_lock_texture(ctx, texObj); - { - texImage = _mesa_get_tex_image(ctx, texObj, target, level); - if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glCompressedTexImage%uD", dims); - } - else { - gl_format texFormat; - - ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - - texFormat = _mesa_choose_texture_format(ctx, texObj, target, level, - internalFormat, GL_NONE, - GL_NONE); - - if (legal_texture_size(ctx, texFormat, width, height, depth)) { - _mesa_init_teximage_fields(ctx, texImage, - width, height, depth, - border, internalFormat, texFormat); - - ctx->Driver.CompressedTexImage(ctx, dims, texImage, imageSize, - data); - - check_gen_mipmap(ctx, target, texObj, level); - - _mesa_dirty_texobj(ctx, texObj, GL_TRUE); - } - else { - _mesa_error(ctx, GL_OUT_OF_MEMORY, - "glCompressedTexImage%uD", dims); - } - } - } - _mesa_unlock_texture(ctx, texObj); - } -} - - void GLAPIENTRY _mesa_CompressedTexImage1DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, @@ -3551,8 +3672,8 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level, const GLvoid *data) { GET_CURRENT_CONTEXT(ctx); - compressedteximage(ctx, 1, target, level, internalFormat, - width, 1, 1, border, imageSize, data); + teximage(ctx, GL_TRUE, 1, target, level, internalFormat, + width, 1, 1, border, GL_NONE, GL_NONE, imageSize, data); } @@ -3563,8 +3684,8 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level, const GLvoid *data) { GET_CURRENT_CONTEXT(ctx); - compressedteximage(ctx, 2, target, level, internalFormat, - width, height, 1, border, imageSize, data); + teximage(ctx, GL_TRUE, 2, target, level, internalFormat, + width, height, 1, border, GL_NONE, GL_NONE, imageSize, data); } @@ -3575,8 +3696,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level, GLsizei imageSize, const GLvoid *data) { GET_CURRENT_CONTEXT(ctx); - compressedteximage(ctx, 3, target, level, internalFormat, - width, height, depth, border, imageSize, data); + teximage(ctx, GL_TRUE, 3, target, level, internalFormat, + width, height, depth, border, GL_NONE, GL_NONE, imageSize, data); } diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h index 66a0c8895..feaaf0cba 100644 --- a/mesalib/src/mesa/main/teximage.h +++ b/mesalib/src/mesa/main/teximage.h @@ -120,10 +120,6 @@ _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, GLenum target, GLint level); -extern struct gl_texture_image * -_mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level); - - extern GLint _mesa_max_texture_levels(struct gl_context *ctx, GLenum target); @@ -140,6 +136,10 @@ _mesa_tex_target_to_face(GLenum target); extern GLint _mesa_get_texture_dimensions(GLenum target); +extern GLenum +_mesa_es_error_check_format_and_type(GLenum format, GLenum type, + unsigned dimensions); + /** * Lock a texture for updating. See also _mesa_lock_context_textures(). */ diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c index 1d905b608..638e418da 100644 --- a/mesalib/src/mesa/main/texobj.c +++ b/mesalib/src/mesa/main/texobj.c @@ -577,7 +577,7 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx, GLint i; const GLint minLevel = baseLevel; const GLint maxLevel = t->_MaxLevel; - const GLuint numFaces = t->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + const GLuint numFaces = _mesa_num_tex_faces(t->Target); GLuint width, height, depth, face; if (minLevel > maxLevel) { @@ -783,7 +783,8 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) texObj->Sampler.MinFilter = GL_NEAREST; texObj->Sampler.MagFilter = GL_NEAREST; - texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA, + texFormat = ctx->Driver.ChooseTextureFormat(ctx, target, + GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE); /* need a loop here just for cube maps */ @@ -826,7 +827,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) static GLuint texture_size(const struct gl_texture_object *texObj) { - const GLuint numFaces = texObj->Target == GL_TEXTURE_CUBE_MAP ? 6 : 1; + const GLuint numFaces = _mesa_num_tex_faces(texObj->Target); GLuint face, level, size = 0; for (face = 0; face < numFaces; face++) { @@ -1118,27 +1119,39 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) * \return TEXTURE_x_INDEX or -1 if target is invalid */ static GLint -target_enum_to_index(GLenum target) +target_enum_to_index(struct gl_context *ctx, GLenum target) { switch (target) { case GL_TEXTURE_1D: - return TEXTURE_1D_INDEX; + return _mesa_is_desktop_gl(ctx) ? TEXTURE_1D_INDEX : -1; case GL_TEXTURE_2D: return TEXTURE_2D_INDEX; case GL_TEXTURE_3D: return TEXTURE_3D_INDEX; case GL_TEXTURE_CUBE_MAP_ARB: - return TEXTURE_CUBE_INDEX; + return ctx->Extensions.ARB_texture_cube_map + ? TEXTURE_CUBE_INDEX : -1; case GL_TEXTURE_RECTANGLE_NV: - return TEXTURE_RECT_INDEX; + return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle + ? TEXTURE_RECT_INDEX : -1; case GL_TEXTURE_1D_ARRAY_EXT: - return TEXTURE_1D_ARRAY_INDEX; + return _mesa_is_desktop_gl(ctx) + && (ctx->Extensions.EXT_texture_array + || ctx->Extensions.MESA_texture_array) + ? TEXTURE_1D_ARRAY_INDEX : -1; case GL_TEXTURE_2D_ARRAY_EXT: - return TEXTURE_2D_ARRAY_INDEX; + return (_mesa_is_desktop_gl(ctx) + && (ctx->Extensions.EXT_texture_array + || ctx->Extensions.MESA_texture_array)) + || _mesa_is_gles3(ctx) + ? TEXTURE_2D_ARRAY_INDEX : -1; case GL_TEXTURE_BUFFER_ARB: - return TEXTURE_BUFFER_INDEX; + return _mesa_is_desktop_gl(ctx) + && ctx->Extensions.ARB_texture_buffer_object + ? TEXTURE_BUFFER_INDEX : -1; case GL_TEXTURE_EXTERNAL_OES: - return TEXTURE_EXTERNAL_INDEX; + return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external + ? TEXTURE_EXTERNAL_INDEX : -1; default: return -1; } @@ -1173,7 +1186,7 @@ _mesa_BindTexture( GLenum target, GLuint texName ) _mesa_debug(ctx, "glBindTexture %s %d\n", _mesa_lookup_enum_by_nr(target), (GLint) texName); - targetIndex = target_enum_to_index(target); + targetIndex = target_enum_to_index(ctx, target); if (targetIndex < 0) { _mesa_error(ctx, GL_INVALID_ENUM, "glBindTexture(target)"); return; diff --git a/mesalib/src/mesa/main/texobj.h b/mesalib/src/mesa/main/texobj.h index 93e0d7738..a6f1d3a14 100644 --- a/mesalib/src/mesa/main/texobj.h +++ b/mesalib/src/mesa/main/texobj.h @@ -78,6 +78,17 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, } +/** + * Return number of faces for a texture target. This will be 6 for + * cube maps (and cube map arrays) and 1 otherwise. + */ +static inline GLuint +_mesa_num_tex_faces(GLenum target) +{ + return target == GL_TEXTURE_CUBE_MAP ? 6 : 1; +} + + /** Is the texture "complete" with respect to the given sampler state? */ static inline GLboolean _mesa_is_texture_complete(const struct gl_texture_object *texObj, diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index 41b9f97bf..e6140eb65 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -29,7 +29,7 @@ * glTexParameter-related functions */ - +#include <stdbool.h> #include "main/glheader.h" #include "main/colormac.h" #include "main/context.h" @@ -56,43 +56,56 @@ static GLboolean validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap) { const struct gl_extensions * const e = & ctx->Extensions; + const bool is_desktop_gl = _mesa_is_desktop_gl(ctx); + bool supported; - if (target == GL_TEXTURE_RECTANGLE_NV) { - if (wrap == GL_CLAMP || wrap == GL_CLAMP_TO_EDGE || - (wrap == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) - return GL_TRUE; - } - else if (target == GL_TEXTURE_EXTERNAL_OES) { - if (wrap == GL_CLAMP_TO_EDGE) - return GL_TRUE; - } - else { - switch (wrap) { - case GL_CLAMP: - case GL_REPEAT: - case GL_CLAMP_TO_EDGE: - case GL_MIRRORED_REPEAT: - return GL_TRUE; - case GL_CLAMP_TO_BORDER: - if (e->ARB_texture_border_clamp) - return GL_TRUE; - break; - case GL_MIRROR_CLAMP_EXT: - case GL_MIRROR_CLAMP_TO_EDGE_EXT: - if (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp) - return GL_TRUE; - break; - case GL_MIRROR_CLAMP_TO_BORDER_EXT: - if (e->EXT_texture_mirror_clamp) - return GL_TRUE; - break; - default: - break; - } + switch (wrap) { + case GL_CLAMP: + /* GL_CLAMP was removed in the core profile, and it has never existed in + * OpenGL ES. + */ + supported = (ctx->API == API_OPENGL) + && (target != GL_TEXTURE_EXTERNAL_OES); + break; + + case GL_CLAMP_TO_EDGE: + supported = true; + break; + + case GL_CLAMP_TO_BORDER: + supported = is_desktop_gl && e->ARB_texture_border_clamp + && (target != GL_TEXTURE_EXTERNAL_OES); + break; + + case GL_REPEAT: + case GL_MIRRORED_REPEAT: + supported = (target != GL_TEXTURE_RECTANGLE_NV) + && (target != GL_TEXTURE_EXTERNAL_OES); + break; + + case GL_MIRROR_CLAMP_EXT: + case GL_MIRROR_CLAMP_TO_EDGE_EXT: + supported = is_desktop_gl + && (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp) + && (target != GL_TEXTURE_RECTANGLE_NV) + && (target != GL_TEXTURE_EXTERNAL_OES); + break; + + case GL_MIRROR_CLAMP_TO_BORDER_EXT: + supported = is_desktop_gl && e->EXT_texture_mirror_clamp + && (target != GL_TEXTURE_RECTANGLE_NV) + && (target != GL_TEXTURE_EXTERNAL_OES); + break; + + default: + supported = false; + break; } - _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); - return GL_FALSE; + if (!supported) + _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)", wrap ); + + return supported; } @@ -118,35 +131,42 @@ get_texobj(struct gl_context *ctx, GLenum target, GLboolean get) switch (target) { case GL_TEXTURE_1D: - return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + if (_mesa_is_desktop_gl(ctx)) + return texUnit->CurrentTex[TEXTURE_1D_INDEX]; + break; case GL_TEXTURE_2D: return texUnit->CurrentTex[TEXTURE_2D_INDEX]; case GL_TEXTURE_3D: - return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + if (ctx->API != API_OPENGLES) + return texUnit->CurrentTex[TEXTURE_3D_INDEX]; + break; case GL_TEXTURE_CUBE_MAP: if (ctx->Extensions.ARB_texture_cube_map) { return texUnit->CurrentTex[TEXTURE_CUBE_INDEX]; } break; case GL_TEXTURE_RECTANGLE_NV: - if (ctx->Extensions.NV_texture_rectangle) { + if (_mesa_is_desktop_gl(ctx) + && ctx->Extensions.NV_texture_rectangle) { return texUnit->CurrentTex[TEXTURE_RECT_INDEX]; } break; case GL_TEXTURE_1D_ARRAY_EXT: - if (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array) { + if (_mesa_is_desktop_gl(ctx) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array)) { return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX]; } break; case GL_TEXTURE_2D_ARRAY_EXT: - if (ctx->Extensions.MESA_texture_array || - ctx->Extensions.EXT_texture_array) { + if ((_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx)) + && (ctx->Extensions.MESA_texture_array || + ctx->Extensions.EXT_texture_array)) { return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX]; } break; case GL_TEXTURE_EXTERNAL_OES: - if (ctx->Extensions.OES_EGL_image_external) { + if (_mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external) { return texUnit->CurrentTex[TEXTURE_EXTERNAL_INDEX]; } break; @@ -305,6 +325,9 @@ set_tex_parameteri(struct gl_context *ctx, return GL_FALSE; case GL_TEXTURE_BASE_LEVEL: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + if (texObj->BaseLevel == params[0]) return GL_FALSE; if (params[0] < 0 || @@ -330,6 +353,9 @@ set_tex_parameteri(struct gl_context *ctx, return GL_TRUE; case GL_GENERATE_MIPMAP_SGIS: + if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + goto invalid_pname; + if (params[0] && texObj->Target == GL_TEXTURE_EXTERNAL_OES) goto invalid_param; if (texObj->GenerateMipmap != params[0]) { @@ -340,7 +366,8 @@ set_tex_parameteri(struct gl_context *ctx, return GL_FALSE; case GL_TEXTURE_COMPARE_MODE_ARB: - if (ctx->Extensions.ARB_shadow) { + if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_shadow) + || _mesa_is_gles3(ctx)) { if (texObj->Sampler.CompareMode == params[0]) return GL_FALSE; if (params[0] == GL_NONE || @@ -354,7 +381,8 @@ set_tex_parameteri(struct gl_context *ctx, goto invalid_pname; case GL_TEXTURE_COMPARE_FUNC_ARB: - if (ctx->Extensions.ARB_shadow) { + if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_shadow) + || _mesa_is_gles3(ctx)) { if (texObj->Sampler.CompareFunc == params[0]) return GL_FALSE; switch (params[0]) { @@ -382,7 +410,10 @@ set_tex_parameteri(struct gl_context *ctx, goto invalid_pname; case GL_DEPTH_TEXTURE_MODE_ARB: - if (ctx->Extensions.ARB_depth_texture) { + /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has never + * existed in OpenGL ES. + */ + if (ctx->API == API_OPENGL && ctx->Extensions.ARB_depth_texture) { if (texObj->DepthMode == params[0]) return GL_FALSE; if (params[0] == GL_LUMINANCE || @@ -399,6 +430,9 @@ set_tex_parameteri(struct gl_context *ctx, #if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: + if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture) + goto invalid_pname; + texObj->CropRect[0] = params[0]; texObj->CropRect[1] = params[1]; texObj->CropRect[2] = params[2]; @@ -410,7 +444,8 @@ set_tex_parameteri(struct gl_context *ctx, case GL_TEXTURE_SWIZZLE_G_EXT: case GL_TEXTURE_SWIZZLE_B_EXT: case GL_TEXTURE_SWIZZLE_A_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { + if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_swizzle) + || _mesa_is_gles3(ctx)) { const GLuint comp = pname - GL_TEXTURE_SWIZZLE_R_EXT; const GLint swz = comp_to_swizzle(params[0]); if (swz < 0) { @@ -428,7 +463,8 @@ set_tex_parameteri(struct gl_context *ctx, goto invalid_pname; case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (ctx->Extensions.EXT_texture_swizzle) { + if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_swizzle) + || _mesa_is_gles3(ctx)) { GLuint comp; flush(ctx); for (comp = 0; comp < 4; comp++) { @@ -448,7 +484,8 @@ set_tex_parameteri(struct gl_context *ctx, goto invalid_pname; case GL_TEXTURE_SRGB_DECODE_EXT: - if (ctx->Extensions.EXT_texture_sRGB_decode) { + if (_mesa_is_desktop_gl(ctx) + && ctx->Extensions.EXT_texture_sRGB_decode) { GLenum decode = params[0]; if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) { if (texObj->Sampler.sRGBDecode != decode) { @@ -461,7 +498,8 @@ set_tex_parameteri(struct gl_context *ctx, goto invalid_pname; case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (ctx->Extensions.AMD_seamless_cubemap_per_texture) { + if (_mesa_is_desktop_gl(ctx) + && ctx->Extensions.AMD_seamless_cubemap_per_texture) { GLenum param = params[0]; if (param != GL_TRUE && param != GL_FALSE) { goto invalid_param; @@ -501,6 +539,9 @@ set_tex_parameterf(struct gl_context *ctx, { switch (pname) { case GL_TEXTURE_MIN_LOD: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + if (texObj->Sampler.MinLod == params[0]) return GL_FALSE; flush(ctx); @@ -508,6 +549,9 @@ set_tex_parameterf(struct gl_context *ctx, return GL_TRUE; case GL_TEXTURE_MAX_LOD: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + if (texObj->Sampler.MaxLod == params[0]) return GL_FALSE; flush(ctx); @@ -515,6 +559,9 @@ set_tex_parameterf(struct gl_context *ctx, return GL_TRUE; case GL_TEXTURE_PRIORITY: + if (ctx->API != API_OPENGL) + goto invalid_pname; + flush(ctx); texObj->Priority = CLAMP(params[0], 0.0F, 1.0F); return GL_TRUE; @@ -536,13 +583,18 @@ set_tex_parameterf(struct gl_context *ctx, else { static GLuint count = 0; if (count++ < 10) - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)"); + goto invalid_pname; } return GL_FALSE; case GL_TEXTURE_LOD_BIAS: - /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */ + /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias. + * It was removed in core-profile, and it has never existed in OpenGL + * ES. + */ + if (ctx->API != API_OPENGL) + goto invalid_pname; + if (texObj->Sampler.LodBias != params[0]) { flush(ctx); texObj->Sampler.LodBias = params[0]; @@ -551,6 +603,9 @@ set_tex_parameterf(struct gl_context *ctx, break; case GL_TEXTURE_BORDER_COLOR: + if (!_mesa_is_desktop_gl(ctx)) + goto invalid_pname; + flush(ctx); /* ARB_texture_float disables clamping */ if (ctx->Extensions.ARB_texture_float) { @@ -567,9 +622,14 @@ set_tex_parameterf(struct gl_context *ctx, return GL_TRUE; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname); + goto invalid_pname; } return GL_FALSE; + +invalid_pname: + _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)", + _mesa_lookup_enum_by_nr(pname)); + return GL_FALSE; } @@ -1250,6 +1310,9 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) *params = ENUM_TO_FLOAT(obj->Sampler.WrapR); break; case GL_TEXTURE_BORDER_COLOR: + if (!_mesa_is_desktop_gl(ctx)) + goto invalid_pname; + if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) _mesa_update_state_locked(ctx); if (ctx->Color._ClampFragmentColor) { @@ -1266,18 +1329,33 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) } break; case GL_TEXTURE_RESIDENT: + if (ctx->API != API_OPENGL) + goto invalid_pname; + *params = 1.0F; break; case GL_TEXTURE_PRIORITY: + if (ctx->API != API_OPENGL) + goto invalid_pname; + *params = obj->Priority; break; case GL_TEXTURE_MIN_LOD: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + *params = obj->Sampler.MinLod; break; case GL_TEXTURE_MAX_LOD: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + *params = obj->Sampler.MaxLod; break; case GL_TEXTURE_BASE_LEVEL: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + *params = (GLfloat) obj->BaseLevel; break; case GL_TEXTURE_MAX_LEVEL: @@ -1289,28 +1367,42 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) *params = obj->Sampler.MaxAnisotropy; break; case GL_GENERATE_MIPMAP_SGIS: + if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + goto invalid_pname; + *params = (GLfloat) obj->GenerateMipmap; break; case GL_TEXTURE_COMPARE_MODE_ARB: - if (!ctx->Extensions.ARB_shadow) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLfloat) obj->Sampler.CompareMode; break; case GL_TEXTURE_COMPARE_FUNC_ARB: - if (!ctx->Extensions.ARB_shadow) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLfloat) obj->Sampler.CompareFunc; break; case GL_DEPTH_TEXTURE_MODE_ARB: - if (!ctx->Extensions.ARB_depth_texture) + /* GL_DEPTH_TEXTURE_MODE_ARB is removed in core-profile and it has + * never existed in OpenGL ES. + */ + if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_depth_texture) goto invalid_pname; *params = (GLfloat) obj->DepthMode; break; case GL_TEXTURE_LOD_BIAS: + if (ctx->API != API_OPENGL) + goto invalid_pname; + *params = obj->Sampler.LodBias; break; #if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: + if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture) + goto invalid_pname; + params[0] = obj->CropRect[0]; params[1] = obj->CropRect[1]; params[2] = obj->CropRect[2]; @@ -1322,13 +1414,17 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) case GL_TEXTURE_SWIZZLE_G_EXT: case GL_TEXTURE_SWIZZLE_B_EXT: case GL_TEXTURE_SWIZZLE_A_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) + if ((!_mesa_is_desktop_gl(ctx) + || !ctx->Extensions.EXT_texture_swizzle) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLfloat) obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT]; break; case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) { + if ((!_mesa_is_desktop_gl(ctx) + || !ctx->Extensions.EXT_texture_swizzle) + && !_mesa_is_gles3(ctx)) { goto invalid_pname; } else { @@ -1340,7 +1436,8 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) break; case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + if (!_mesa_is_desktop_gl(ctx) + || !ctx->Extensions.AMD_seamless_cubemap_per_texture) goto invalid_pname; *params = (GLfloat) obj->Sampler.CubeMapSeamless; break; @@ -1394,6 +1491,9 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) *params = (GLint) obj->Sampler.WrapR; break; case GL_TEXTURE_BORDER_COLOR: + if (!_mesa_is_desktop_gl(ctx)) + goto invalid_pname; + { GLfloat b[4]; b[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); @@ -1407,18 +1507,33 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) } break; case GL_TEXTURE_RESIDENT: + if (ctx->API != API_OPENGL) + goto invalid_pname; + *params = 1; break; case GL_TEXTURE_PRIORITY: + if (ctx->API != API_OPENGL) + goto invalid_pname; + *params = FLOAT_TO_INT(obj->Priority); break; case GL_TEXTURE_MIN_LOD: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + *params = (GLint) obj->Sampler.MinLod; break; case GL_TEXTURE_MAX_LOD: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + *params = (GLint) obj->Sampler.MaxLod; break; case GL_TEXTURE_BASE_LEVEL: + if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + goto invalid_pname; + *params = obj->BaseLevel; break; case GL_TEXTURE_MAX_LEVEL: @@ -1430,28 +1545,39 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) *params = (GLint) obj->Sampler.MaxAnisotropy; break; case GL_GENERATE_MIPMAP_SGIS: + if (ctx->API != API_OPENGL && ctx->API != API_OPENGLES) + goto invalid_pname; + *params = (GLint) obj->GenerateMipmap; break; case GL_TEXTURE_COMPARE_MODE_ARB: - if (!ctx->Extensions.ARB_shadow) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLint) obj->Sampler.CompareMode; break; case GL_TEXTURE_COMPARE_FUNC_ARB: - if (!ctx->Extensions.ARB_shadow) + if ((!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_shadow) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = (GLint) obj->Sampler.CompareFunc; break; case GL_DEPTH_TEXTURE_MODE_ARB: - if (!ctx->Extensions.ARB_depth_texture) + if (ctx->API != API_OPENGL || !ctx->Extensions.ARB_depth_texture) goto invalid_pname; *params = (GLint) obj->DepthMode; break; case GL_TEXTURE_LOD_BIAS: + if (ctx->API != API_OPENGL) + goto invalid_pname; + *params = (GLint) obj->Sampler.LodBias; break; #if FEATURE_OES_draw_texture case GL_TEXTURE_CROP_RECT_OES: + if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture) + goto invalid_pname; + params[0] = obj->CropRect[0]; params[1] = obj->CropRect[1]; params[2] = obj->CropRect[2]; @@ -1462,19 +1588,24 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) case GL_TEXTURE_SWIZZLE_G_EXT: case GL_TEXTURE_SWIZZLE_B_EXT: case GL_TEXTURE_SWIZZLE_A_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) + if ((!_mesa_is_desktop_gl(ctx) + || !ctx->Extensions.EXT_texture_swizzle) + && !_mesa_is_gles3(ctx)) goto invalid_pname; *params = obj->Swizzle[pname - GL_TEXTURE_SWIZZLE_R_EXT]; break; case GL_TEXTURE_SWIZZLE_RGBA_EXT: - if (!ctx->Extensions.EXT_texture_swizzle) + if ((!_mesa_is_desktop_gl(ctx) + || !ctx->Extensions.EXT_texture_swizzle) + && !_mesa_is_gles3(ctx)) goto invalid_pname; COPY_4V(params, obj->Swizzle); break; case GL_TEXTURE_CUBE_MAP_SEAMLESS: - if (!ctx->Extensions.AMD_seamless_cubemap_per_texture) + if (!_mesa_is_desktop_gl(ctx) + || !ctx->Extensions.AMD_seamless_cubemap_per_texture) goto invalid_pname; *params = (GLint) obj->Sampler.CubeMapSeamless; break; @@ -1486,7 +1617,7 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) break; case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: - if (!ctx->Extensions.OES_EGL_image_external) + if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external) goto invalid_pname; *params = obj->RequiredTextureImageUnits; break; diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c index 5e1f31a93..f8af8bf01 100644 --- a/mesalib/src/mesa/main/texstorage.c +++ b/mesalib/src/mesa/main/texstorage.c @@ -36,6 +36,7 @@ #include "macros.h" #include "mfeatures.h" #include "teximage.h" +#include "texobj.h" #include "texstorage.h" #include "mtypes.h" @@ -128,7 +129,7 @@ setup_texstorage(struct gl_context *ctx, GLsizei width, GLsizei height, GLsizei depth) { const GLenum target = texObj->Target; - const GLuint numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; + const GLuint numFaces = _mesa_num_tex_faces(target); gl_format texFormat; GLint level, levelWidth = width, levelHeight = height, levelDepth = depth; GLuint face; @@ -206,7 +207,7 @@ clear_image_fields(struct gl_context *ctx, struct gl_texture_object *texObj) { const GLenum target = texObj->Target; - const GLuint numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; + const GLuint numFaces = _mesa_num_tex_faces(target); GLint level; GLuint face; diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index 816c2779c..bddb8f95e 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -809,7 +809,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg, sizeof(shProg->SamplerUnits)); _mesa_update_shader_textures_used(shProg, prog); - (void) ctx->Driver.ProgramStringNotify(ctx, prog->Target, prog); + if (ctx->Driver.SamplerUniformChange) + ctx->Driver.SamplerUniformChange(ctx, prog->Target, prog); } } } diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c index 327fabbc1..8c3ddc524 100644 --- a/mesalib/src/mesa/main/varray.c +++ b/mesalib/src/mesa/main/varray.c @@ -133,16 +133,37 @@ update_array(struct gl_context *ctx, GLsizei elementSize; GLenum format = GL_RGBA; - if (ctx->API != API_OPENGLES && ctx->API != API_OPENGLES2) { - /* fixed point arrays / data is only allowed with OpenGL ES 1.x/2.0 */ + if (_mesa_is_gles(ctx)) { + /* Once Mesa gets support for GL_OES_vertex_half_float this mask will + * change. Adding support for this extension isn't quite as trivial as + * we'd like because ES uses a different enum value for GL_HALF_FLOAT. + */ + legalTypesMask &= ~(FIXED_GL_BIT | HALF_BIT | DOUBLE_BIT); + + /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until + * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or + * GL_OES_vertex_type_10_10_10_2. + */ + if (ctx->Version < 30) { + legalTypesMask &= ~(UNSIGNED_INT_BIT + | INT_BIT + | UNSIGNED_INT_2_10_10_10_REV_BIT + | INT_2_10_10_10_REV_BIT); + } + + /* BGRA ordering is not supported in ES contexts. + */ + if (sizeMax == BGRA_OR_4) + sizeMax = 4; + } else { legalTypesMask &= ~FIXED_ES_BIT; - } - if (!ctx->Extensions.ARB_ES2_compatibility) { - legalTypesMask &= ~FIXED_GL_BIT; - } - if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) { - legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); + + if (!ctx->Extensions.ARB_ES2_compatibility) + legalTypesMask &= ~FIXED_GL_BIT; + + if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) + legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); } typeBit = type_to_bit(ctx, type); @@ -228,16 +249,15 @@ update_array(struct gl_context *ctx, void GLAPIENTRY _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { - GLbitfield legalTypes = (SHORT_BIT | INT_BIT | FLOAT_BIT | - DOUBLE_BIT | HALF_BIT | FIXED_ES_BIT | - UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); + GLbitfield legalTypes = (ctx->API == API_OPENGLES) + ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT) + : (SHORT_BIT | INT_BIT | FLOAT_BIT | + DOUBLE_BIT | HALF_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (ctx->API == API_OPENGLES) - legalTypes |= BYTE_BIT; - update_array(ctx, "glVertexPointer", VERT_ATTRIB_POS, legalTypes, 2, 4, size, type, stride, GL_FALSE, GL_FALSE, ptr); @@ -247,12 +267,13 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) void GLAPIENTRY _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) { - const GLbitfield legalTypes = (BYTE_BIT | SHORT_BIT | INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT | - UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); + const GLbitfield legalTypes = (ctx->API == API_OPENGLES) + ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT) + : (BYTE_BIT | SHORT_BIT | INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); update_array(ctx, "glNormalPointer", VERT_ATTRIB_NORMAL, @@ -264,18 +285,20 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) void GLAPIENTRY _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { - const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT | - SHORT_BIT | UNSIGNED_SHORT_BIT | - INT_BIT | UNSIGNED_INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT | - UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); + const GLbitfield legalTypes = (ctx->API == API_OPENGLES) + ? (UNSIGNED_BYTE_BIT | HALF_BIT | FLOAT_BIT | FIXED_ES_BIT) + : (BYTE_BIT | UNSIGNED_BYTE_BIT | + SHORT_BIT | UNSIGNED_SHORT_BIT | + INT_BIT | UNSIGNED_INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); + const GLint sizeMin = (ctx->API == API_OPENGLES) ? 4 : 3; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); update_array(ctx, "glColorPointer", VERT_ATTRIB_COLOR0, - legalTypes, 3, BGRA_OR_4, + legalTypes, sizeMin, BGRA_OR_4, size, type, stride, GL_TRUE, GL_FALSE, ptr); } @@ -330,20 +353,19 @@ void GLAPIENTRY _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { - GLbitfield legalTypes = (SHORT_BIT | INT_BIT | - HALF_BIT | FLOAT_BIT | DOUBLE_BIT | - FIXED_ES_BIT | - UNSIGNED_INT_2_10_10_10_REV_BIT | - INT_2_10_10_10_REV_BIT); GET_CURRENT_CONTEXT(ctx); + GLbitfield legalTypes = (ctx->API == API_OPENGLES) + ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT) + : (SHORT_BIT | INT_BIT | + HALF_BIT | FLOAT_BIT | DOUBLE_BIT | + UNSIGNED_INT_2_10_10_10_REV_BIT | + INT_2_10_10_10_REV_BIT); + const GLint sizeMin = (ctx->API == API_OPENGLES) ? 2 : 1; const GLuint unit = ctx->Array.ActiveTexture; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - if (ctx->API == API_OPENGLES) - legalTypes |= BYTE_BIT; - update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX(unit), - legalTypes, 1, 4, + legalTypes, sizeMin, 4, size, type, stride, GL_FALSE, GL_FALSE, ptr); } |