[Mesa-dev] [PATCH 2/2] mesa: Expose texture buffer objects when the context is GL 3.1 core.

Eric Anholt eric at anholt.net
Tue Jul 31 15:24:18 PDT 2012


---
 src/mesa/main/bufferobj.c |    3 ++-
 src/mesa/main/get.c       |   16 +++++++++++-----
 src/mesa/main/teximage.c  |    6 ++++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 5fdf52e..7216307 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -89,7 +89,8 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
       break;
 #endif
    case GL_TEXTURE_BUFFER:
-      if (ctx->Extensions.ARB_texture_buffer_object) {
+      if (ctx->Extensions.ARB_texture_buffer_object ||
+          (ctx->API == API_OPENGL && ctx->Version >= 31)) {
          return &ctx->Texture.BufferObject;
       }
       break;
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 7ffa3c1..a1e6879 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -284,6 +284,12 @@ static const int extra_GLSL_130[] = {
    EXTRA_END
 };
 
+static const int extra_texture_buffer_object[] = {
+   EXTRA_VERSION_31,
+   EXT(ARB_texture_buffer_object),
+   EXTRA_END
+};
+
 static const int extra_ARB_sampler_objects[] = {
    EXT(ARB_sampler_objects),
    EXTRA_END
@@ -1292,15 +1298,15 @@ static const struct value_desc values[] = {
 
    /* GL_ARB_texture_buffer_object */
    { GL_MAX_TEXTURE_BUFFER_SIZE_ARB, CONTEXT_INT(Const.MaxTextureBufferSize),
-     extra_ARB_texture_buffer_object },
+     extra_texture_buffer_object },
    { GL_TEXTURE_BINDING_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0,
-     extra_ARB_texture_buffer_object },
+     extra_texture_buffer_object },
    { GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
-     TEXTURE_BUFFER_INDEX, extra_ARB_texture_buffer_object },
+     TEXTURE_BUFFER_INDEX, extra_texture_buffer_object },
    { GL_TEXTURE_BUFFER_FORMAT_ARB, LOC_CUSTOM, TYPE_INT, 0,
-     extra_ARB_texture_buffer_object },
+     extra_texture_buffer_object },
    { GL_TEXTURE_BUFFER_ARB, LOC_CUSTOM, TYPE_INT, 0,
-     extra_ARB_texture_buffer_object },
+     extra_texture_buffer_object },
 
    /* GL_ARB_sampler_objects / GL 3.3 */
    { GL_SAMPLER_BINDING,
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index ef64a79..e70470d 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -774,7 +774,8 @@ _mesa_select_tex_object(struct gl_context *ctx,
       case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
          return arrayTex ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL;
       case GL_TEXTURE_BUFFER:
-         return ctx->Extensions.ARB_texture_buffer_object
+         return (ctx->Extensions.ARB_texture_buffer_object ||
+                 (ctx->API == API_OPENGL && ctx->Version >= 31))
             ? texUnit->CurrentTex[TEXTURE_BUFFER_INDEX] : NULL;
       case GL_TEXTURE_EXTERNAL_OES:
          return ctx->Extensions.OES_EGL_image_external
@@ -3881,7 +3882,8 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   if (!ctx->Extensions.ARB_texture_buffer_object) {
+   if (!(ctx->Extensions.ARB_texture_buffer_object ||
+         (ctx->API == API_OPENGL && ctx->Version >= 31))) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer");
       return;
    }
-- 
1.7.10.4



More information about the mesa-dev mailing list