[Mesa-dev] [PATCH 4/4] mesa: add OES_texture_buffer and EXT_texture_buffer support
Rob Clark
robdclark at gmail.com
Tue Mar 29 19:49:50 UTC 2016
hmm, appears to break $piglit/bin/arb_texture_buffer_object-get -auto
-fbo for me..
I get:
line 92: GL_TEXTURE_BUFFER_FORMAT_ARB was GL_R8, expected GL_RGBA8
(haven't dug in yet but figured I should mention it in case you had
some hints/ideas)
BR,
-R
On Sat, Feb 27, 2016 at 4:30 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Allow ES 3.1 contexts to access the texture buffer functionality.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> docs/GL3.txt | 2 +-
> src/mapi/glapi/gen/apiexec.py | 4 ++--
> src/mapi/glapi/gen/es_EXT.xml | 36 ++++++++++++++++++++++++++++++
> src/mesa/main/bufferobj.c | 4 ++--
> src/mesa/main/get.c | 4 ++--
> src/mesa/main/get_hash_params.py | 20 ++++++++---------
> src/mesa/main/tests/dispatch_sanity.cpp | 4 ++++
> src/mesa/main/teximage.c | 20 +++++++++++------
> src/mesa/main/texobj.c | 8 +++----
> src/mesa/main/texparam.c | 39 +++++++++++++++++----------------
> 10 files changed, 94 insertions(+), 47 deletions(-)
>
> diff --git a/docs/GL3.txt b/docs/GL3.txt
> index b9d9713..2f81cba 100644
> --- a/docs/GL3.txt
> +++ b/docs/GL3.txt
> @@ -254,7 +254,7 @@ GLES3.2, GLSL ES 3.2
> GL_OES_shader_multisample_interpolation DONE (nvc0, r600, radeonsi)
> 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 ()
> 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)
> diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py
> index 2a80432..b4f4cf6 100644
> --- a/src/mapi/glapi/gen/apiexec.py
> +++ b/src/mapi/glapi/gen/apiexec.py
> @@ -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.
> diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
> index 2b83a97..ee8e9e5 100644
> --- a/src/mapi/glapi/gen/es_EXT.xml
> +++ b/src/mapi/glapi/gen/es_EXT.xml
> @@ -853,6 +853,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"
> @@ -919,6 +937,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"
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 9aec425..731b62e 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -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;
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index 1cbd692..6e04083 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -1903,8 +1903,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
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index 0142285..d91e241 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -538,6 +538,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
> @@ -807,13 +817,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" ],
>
> @@ -874,9 +877,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" ],
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
> index c323766..1a43a66 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -2452,6 +2452,10 @@ const struct function gles3_functions_possible[] = {
> /* GL_OES_sample_shading */
> { "glMinSampleShadingOES", 30, -1 },
>
> + /* GL_OES_texture_buffer */
> + { "glTexBufferOES", 31, -1 },
> + { "glTexBufferRangeOES", 31, -1 },
> +
> { NULL, 0, -1 }
> };
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 8a4c628..e0ede22 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -481,8 +481,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:
> @@ -4671,7 +4671,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;
> @@ -4758,8 +4758,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;
> @@ -4776,6 +4776,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;
> @@ -4797,6 +4799,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;
> @@ -4818,6 +4822,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;
> @@ -4895,8 +4901,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);
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index d8407f0..c9502bd 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -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
> diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
> index 9d94636..0c3429f 100644
> --- a/src/mesa/main/texparam.c
> +++ b/src/mesa/main/texparam.c
> @@ -1223,6 +1223,26 @@ 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 _mesa_has_ARB_texture_buffer_object(ctx) ||
> + _mesa_has_OES_texture_buffer(ctx);
> }
>
> if (!_mesa_is_desktop_gl(ctx))
> @@ -1247,25 +1267,6 @@ 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;
> --
> 2.4.10
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list