[Mesa-dev] [PATCH 1/7] mesa: add support for immutable textures to teximagemultisample()

Chris Forbes chrisf at ijw.co.nz
Fri Mar 15 22:53:32 PDT 2013


The new entrypoints will come later, but this adds the actual logic for
supporting immutable multisample textures:

- The immutability flag is set as desired.
- Attempting to modify an immutable multisample texture produces
  INVALID_OPERATION.

Note: The extension spec does not mention adding this behavior to
TexImage*Multisample, but it seems like the reasonable thing to do.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/main/teximage.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index bc755ae..0cd4beb 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4194,7 +4194,8 @@ check_multisample_target(GLuint dims, GLenum target)
 static void
 teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
                     GLint internalformat, GLsizei width, GLsizei height,
-                    GLsizei depth, GLboolean fixedsamplelocations)
+                    GLsizei depth, GLboolean fixedsamplelocations,
+                    GLboolean immutable)
 {
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
@@ -4278,6 +4279,13 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
          return;
       }
 
+      /* Check if texObj->Immutable is set */
+      if (texObj->Immutable) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glTexImage%uDMultisample(immutable)",
+                     dims);
+         return;
+      }
+
       ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
 
       _mesa_init_teximage_fields(ctx, texImage,
@@ -4299,6 +4307,7 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
          }
       }
 
+      texObj->Immutable = immutable;
       _mesa_update_fbo_texture(ctx, texObj, 0, 0);
    }
 }
@@ -4309,7 +4318,7 @@ _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
                             GLsizei height, GLboolean fixedsamplelocations)
 {
    teximagemultisample(2, target, samples, internalformat,
-         width, height, 1, fixedsamplelocations);
+         width, height, 1, fixedsamplelocations, GL_FALSE);
 }
 
 void GLAPIENTRY
@@ -4319,5 +4328,5 @@ _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
                             GLboolean fixedsamplelocations)
 {
    teximagemultisample(3, target, samples, internalformat,
-         width, height, depth, fixedsamplelocations);
+         width, height, depth, fixedsamplelocations, GL_FALSE);
 }
-- 
1.8.2



More information about the mesa-dev mailing list