Allow ES 3.1 contexts to access the texture buffer functionality. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>tags/12.0-branchpoint
@@ -269,7 +269,7 @@ GLES3.2, GLSL ES 3.2 | |||
GL_OES_shader_multisample_interpolation not started (based on parts of GL_ARB_gpu_shader5, which is done) | |||
GL_OES_tessellation_shader not started (based on GL_ARB_tessellation_shader, which is done for some drivers) | |||
GL_OES_texture_border_clamp DONE (all drivers) | |||
GL_OES_texture_buffer not started (based on GL_ARB_texture_buffer_object, GL_ARB_texture_buffer_range, and GL_ARB_texture_buffer_object_rgb32 that are all done) | |||
GL_OES_texture_buffer DONE (core only) | |||
GL_OES_texture_cube_map_array not started (based on GL_ARB_texture_cube_map_array, which is done for all drivers) | |||
GL_OES_texture_stencil8 DONE (all drivers that support GL_ARB_texture_stencil8) | |||
GL_OES_texture_storage_multisample_2d_array DONE (all drivers that support GL_ARB_texture_multisample) |
@@ -68,7 +68,7 @@ class exec_info(): | |||
functions = { | |||
# OpenGL 3.1 / GL_ARB_texture_buffer_object. Mesa only exposes this | |||
# extension with core profile. | |||
"TexBuffer": exec_info(core=31), | |||
"TexBuffer": exec_info(core=31, es2=31), | |||
# OpenGL 3.2 / GL_OES_geometry_shader. | |||
"FramebufferTexture": exec_info(core=32, es2=31), | |||
@@ -146,7 +146,7 @@ functions = { | |||
# OpenGL 4.3 / GL_ARB_texture_buffer_range. Mesa can expose the extension | |||
# with OpenGL 3.1. | |||
"TexBufferRange": exec_info(core=31), | |||
"TexBufferRange": exec_info(core=31, es2=31), | |||
# OpenGL 4.3 / GL_ARB_framebuffer_no_attachments. Mesa can expose the | |||
# extension with OpenGL 3.0. |
@@ -847,6 +847,24 @@ | |||
</category> | |||
<category name="GL_EXT_texture_buffer" number="183"> | |||
<function name="TexBufferEXT" es2="3.1" alias="TexBuffer"> | |||
<param name="target" type="GLenum"/> | |||
<param name="internalFormat" type="GLenum"/> | |||
<param name="buffer" type="GLuint"/> | |||
</function> | |||
<function name="TexBufferRangeEXT" es2="3.1" alias="TexBufferRange"> | |||
<param name="target" type="GLenum"/> | |||
<param name="internalformat" type="GLenum"/> | |||
<param name="buffer" type="GLuint"/> | |||
<param name="offset" type="GLintptr"/> | |||
<param name="size" type="GLsizeiptr"/> | |||
</function> | |||
</category> | |||
<category name="GL_EXT_draw_elements_base_vertex" number="204"> | |||
<function name="DrawElementsBaseVertexEXT" alias="DrawElementsBaseVertex" | |||
@@ -891,6 +909,24 @@ | |||
</category> | |||
<category name="GL_OES_texture_buffer" number="216"> | |||
<function name="TexBufferOES" es2="3.1" alias="TexBuffer"> | |||
<param name="target" type="GLenum"/> | |||
<param name="internalFormat" type="GLenum"/> | |||
<param name="buffer" type="GLuint"/> | |||
</function> | |||
<function name="TexBufferRangeOES" es2="3.1" alias="TexBufferRange"> | |||
<param name="target" type="GLenum"/> | |||
<param name="internalformat" type="GLenum"/> | |||
<param name="buffer" type="GLuint"/> | |||
<param name="offset" type="GLintptr"/> | |||
<param name="size" type="GLsizeiptr"/> | |||
</function> | |||
</category> | |||
<category name="GL_OES_draw_elements_base_vertex" number="219"> | |||
<function name="DrawElementsBaseVertexOES" alias="DrawElementsBaseVertex" |
@@ -148,8 +148,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target) | |||
} | |||
break; | |||
case GL_TEXTURE_BUFFER: | |||
if (ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object) { | |||
if (_mesa_has_ARB_texture_buffer_object(ctx) || | |||
_mesa_has_OES_texture_buffer(ctx)) { | |||
return &ctx->Texture.BufferObject; | |||
} | |||
break; |
@@ -1907,8 +1907,8 @@ tex_binding_to_index(const struct gl_context *ctx, GLenum binding) | |||
|| _mesa_is_gles3(ctx) | |||
? TEXTURE_2D_ARRAY_INDEX : -1; | |||
case GL_TEXTURE_BINDING_BUFFER: | |||
return ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object ? | |||
return (_mesa_has_ARB_texture_buffer_object(ctx) || | |||
_mesa_has_OES_texture_buffer(ctx)) ? | |||
TEXTURE_BUFFER_INDEX : -1; | |||
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY: | |||
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_cube_map_array |
@@ -535,6 +535,16 @@ descriptor=[ | |||
# GL_ARB_gpu_shader5 / GL_OES_geometry_shader | |||
[ "MAX_GEOMETRY_SHADER_INVOCATIONS", "CONST(MAX_GEOMETRY_SHADER_INVOCATIONS), extra_ARB_gpu_shader5_or_oes_geometry_shader" ], | |||
# GL_ARB_texture_buffer_object / GL_OES_texture_buffer | |||
[ "MAX_TEXTURE_BUFFER_SIZE_ARB", "CONTEXT_INT(Const.MaxTextureBufferSize), extra_texture_buffer_object" ], | |||
[ "TEXTURE_BINDING_BUFFER_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_texture_buffer_object" ], | |||
[ "TEXTURE_BUFFER_DATA_STORE_BINDING_ARB", "LOC_CUSTOM, TYPE_INT, TEXTURE_BUFFER_INDEX, extra_texture_buffer_object" ], | |||
[ "TEXTURE_BUFFER_FORMAT_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_texture_buffer_object" ], | |||
[ "TEXTURE_BUFFER_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_texture_buffer_object" ], | |||
# GL_ARB_texture_buffer_range | |||
[ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ], | |||
]}, | |||
# Remaining enums are only in OpenGL | |||
@@ -805,13 +815,6 @@ descriptor=[ | |||
# GL_ARB_color_buffer_float | |||
[ "RGBA_FLOAT_MODE_ARB", "BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), extra_core_ARB_color_buffer_float_and_new_buffers" ], | |||
# GL_ARB_texture_buffer_object | |||
[ "MAX_TEXTURE_BUFFER_SIZE_ARB", "CONTEXT_INT(Const.MaxTextureBufferSize), extra_texture_buffer_object" ], | |||
[ "TEXTURE_BINDING_BUFFER_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_texture_buffer_object" ], | |||
[ "TEXTURE_BUFFER_DATA_STORE_BINDING_ARB", "LOC_CUSTOM, TYPE_INT, TEXTURE_BUFFER_INDEX, extra_texture_buffer_object" ], | |||
[ "TEXTURE_BUFFER_FORMAT_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_texture_buffer_object" ], | |||
[ "TEXTURE_BUFFER_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_texture_buffer_object" ], | |||
# GL 3.0 | |||
[ "CONTEXT_FLAGS", "CONTEXT_INT(Const.ContextFlags), extra_version_30" ], | |||
@@ -871,9 +874,6 @@ descriptor=[ | |||
# Enums restricted to OpenGL Core profile | |||
{ "apis": ["GL_CORE"], "params": [ | |||
# GL_ARB_texture_buffer_range | |||
[ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ], | |||
# GL_ARB_viewport_array | |||
[ "MAX_VIEWPORTS", "CONTEXT_INT(Const.MaxViewports), extra_ARB_viewport_array" ], | |||
[ "VIEWPORT_SUBPIXEL_BITS", "CONTEXT_INT(Const.ViewportSubpixelBits), extra_ARB_viewport_array" ], |
@@ -2450,6 +2450,10 @@ const struct function gles3_functions_possible[] = { | |||
{ "glGetSamplerParameterIivOES", 30, -1 }, | |||
{ "glGetSamplerParameterIuivOES", 30, -1 }, | |||
/* GL_OES_texture_buffer */ | |||
{ "glTexBufferOES", 31, -1 }, | |||
{ "glTexBufferRangeOES", 31, -1 }, | |||
{ NULL, 0, -1 } | |||
}; | |||
@@ -499,8 +499,8 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target) | |||
return ctx->Extensions.ARB_texture_cube_map_array | |||
? ctx->Const.MaxCubeTextureLevels : 0; | |||
case GL_TEXTURE_BUFFER: | |||
return ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object ? 1 : 0; | |||
return (_mesa_has_ARB_texture_buffer_object(ctx) || | |||
_mesa_has_OES_texture_buffer(ctx)) ? 1 : 0; | |||
case GL_TEXTURE_2D_MULTISAMPLE: | |||
case GL_PROXY_TEXTURE_2D_MULTISAMPLE: | |||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: | |||
@@ -4717,7 +4717,7 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, | |||
static mesa_format | |||
get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) | |||
{ | |||
if (ctx->API != API_OPENGL_CORE) { | |||
if (ctx->API == API_OPENGL_COMPAT) { | |||
switch (internalFormat) { | |||
case GL_ALPHA8: | |||
return MESA_FORMAT_A_UNORM8; | |||
@@ -4804,8 +4804,8 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) | |||
} | |||
} | |||
if (ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object_rgb32) { | |||
if (_mesa_has_ARB_texture_buffer_object_rgb32(ctx) || | |||
_mesa_has_OES_texture_buffer(ctx)) { | |||
switch (internalFormat) { | |||
case GL_RGB32F: | |||
return MESA_FORMAT_RGB_FLOAT32; | |||
@@ -4822,6 +4822,8 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) | |||
case GL_RGBA8: | |||
return MESA_FORMAT_R8G8B8A8_UNORM; | |||
case GL_RGBA16: | |||
if (_mesa_is_gles(ctx)) | |||
return MESA_FORMAT_NONE; | |||
return MESA_FORMAT_RGBA_UNORM16; | |||
case GL_RGBA16F_ARB: | |||
return MESA_FORMAT_RGBA_FLOAT16; | |||
@@ -4843,6 +4845,8 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) | |||
case GL_RG8: | |||
return MESA_FORMAT_R8G8_UNORM; | |||
case GL_RG16: | |||
if (_mesa_is_gles(ctx)) | |||
return MESA_FORMAT_NONE; | |||
return MESA_FORMAT_R16G16_UNORM; | |||
case GL_RG16F: | |||
return MESA_FORMAT_RG_FLOAT16; | |||
@@ -4864,6 +4868,8 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) | |||
case GL_R8: | |||
return MESA_FORMAT_R_UNORM8; | |||
case GL_R16: | |||
if (_mesa_is_gles(ctx)) | |||
return MESA_FORMAT_NONE; | |||
return MESA_FORMAT_R_UNORM16; | |||
case GL_R16F: | |||
return MESA_FORMAT_R_FLOAT16; | |||
@@ -4941,8 +4947,8 @@ _mesa_texture_buffer_range(struct gl_context *ctx, | |||
/* NOTE: ARB_texture_buffer_object has interactions with | |||
* the compatibility profile that are not implemented. | |||
*/ | |||
if (!(ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object)) { | |||
if (!_mesa_has_ARB_texture_buffer_object(ctx) && | |||
!_mesa_has_OES_texture_buffer(ctx)) { | |||
_mesa_error(ctx, GL_INVALID_OPERATION, | |||
"%s(ARB_texture_buffer_object is not" | |||
" implemented for the compatibility profile)", caller); |
@@ -204,8 +204,8 @@ _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target) | |||
case GL_PROXY_TEXTURE_2D_ARRAY_EXT: | |||
return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; | |||
case GL_TEXTURE_BUFFER: | |||
return ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object ? | |||
return (_mesa_has_ARB_texture_buffer_object(ctx) || | |||
_mesa_has_OES_texture_buffer(ctx)) ? | |||
texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL; | |||
case GL_TEXTURE_EXTERNAL_OES: | |||
return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external | |||
@@ -1574,8 +1574,8 @@ _mesa_tex_target_to_index(const struct gl_context *ctx, GLenum target) | |||
|| _mesa_is_gles3(ctx) | |||
? TEXTURE_2D_ARRAY_INDEX : -1; | |||
case GL_TEXTURE_BUFFER: | |||
return ctx->API == API_OPENGL_CORE && | |||
ctx->Extensions.ARB_texture_buffer_object ? | |||
return (_mesa_has_ARB_texture_buffer_object(ctx) || | |||
_mesa_has_OES_texture_buffer(ctx)) ? | |||
TEXTURE_BUFFER_INDEX : -1; | |||
case GL_TEXTURE_EXTERNAL_OES: | |||
return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external |
@@ -1223,6 +1223,26 @@ _mesa_legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target | |||
case GL_TEXTURE_2D_MULTISAMPLE: | |||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: | |||
return ctx->Extensions.ARB_texture_multisample; | |||
case GL_TEXTURE_BUFFER: | |||
/* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts, | |||
* but not in earlier versions that expose ARB_texture_buffer_object. | |||
* | |||
* From the ARB_texture_buffer_object spec: | |||
* "(7) Do buffer textures support texture parameters (TexParameter) or | |||
* queries (GetTexParameter, GetTexLevelParameter, GetTexImage)? | |||
* | |||
* RESOLVED: No. [...] Note that the spec edits above don't add | |||
* explicit error language for any of these cases. That is because | |||
* each of the functions enumerate the set of valid <target> | |||
* parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in | |||
* these cases means that target is not legal, and an INVALID_ENUM | |||
* error should be generated." | |||
* | |||
* From the OpenGL 3.1 spec: | |||
* "target may also be TEXTURE_BUFFER, indicating the texture buffer." | |||
*/ | |||
return (ctx->API == API_OPENGL_CORE && ctx->Version >= 31) || | |||
_mesa_has_OES_texture_buffer(ctx); | |||
} | |||
if (!_mesa_is_desktop_gl(ctx)) | |||
@@ -1247,25 +1267,6 @@ _mesa_legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target | |||
case GL_PROXY_TEXTURE_1D_ARRAY_EXT: | |||
case GL_PROXY_TEXTURE_2D_ARRAY_EXT: | |||
return ctx->Extensions.EXT_texture_array; | |||
case GL_TEXTURE_BUFFER: | |||
/* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts, | |||
* but not in earlier versions that expose ARB_texture_buffer_object. | |||
* | |||
* From the ARB_texture_buffer_object spec: | |||
* "(7) Do buffer textures support texture parameters (TexParameter) or | |||
* queries (GetTexParameter, GetTexLevelParameter, GetTexImage)? | |||
* | |||
* RESOLVED: No. [...] Note that the spec edits above don't add | |||
* explicit error language for any of these cases. That is because | |||
* each of the functions enumerate the set of valid <target> | |||
* parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in | |||
* these cases means that target is not legal, and an INVALID_ENUM | |||
* error should be generated." | |||
* | |||
* From the OpenGL 3.1 spec: | |||
* "target may also be TEXTURE_BUFFER, indicating the texture buffer." | |||
*/ | |||
return ctx->API == API_OPENGL_CORE && ctx->Version >= 31; | |||
case GL_PROXY_TEXTURE_2D_MULTISAMPLE: | |||
case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY: | |||
return ctx->Extensions.ARB_texture_multisample; |