meta/blit: Add stencil texturing mode save and restore
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Wed, 21 May 2014 08:43:56 +0000 (11:43 +0300)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Tue, 27 May 2014 06:31:07 +0000 (09:31 +0300)
v2 (Ken): Only restore the mode if it has changed.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/common/meta.h
src/mesa/drivers/common/meta_blit.c

index 007f1040bdb371eed0a1ed82348e7d22a4b3c34d..765f8dfe4a213199eb31f4456acd22da4f1f58d3 100644 (file)
@@ -270,7 +270,7 @@ struct blit_state
 struct fb_tex_blit_state
 {
    GLint baseLevelSave, maxLevelSave;
-   GLuint sampler, samplerSave;
+   GLuint sampler, samplerSave, stencilSamplingSave;
    GLuint tempTex;
 };
 
@@ -407,7 +407,7 @@ _mesa_meta_fb_tex_blit_begin(const struct gl_context *ctx,
                              struct fb_tex_blit_state *blit);
 
 extern void
-_mesa_meta_fb_tex_blit_end(const struct gl_context *ctx, GLenum target,
+_mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
                            struct fb_tex_blit_state *blit);
 
 extern GLboolean
index 707269dd687073bad3dcc1c0307f70e38d2e99ab..84594d1d72b579e9a491ee1c3e9a252742879ca0 100644 (file)
@@ -446,6 +446,7 @@ blitframebuffer_texture(struct gl_context *ctx,
 
    fb_tex_blit.baseLevelSave = texObj->BaseLevel;
    fb_tex_blit.maxLevelSave = texObj->MaxLevel;
+   fb_tex_blit.stencilSamplingSave = texObj->StencilSampling;
 
    if (glsl_version) {
       setup_glsl_blit_framebuffer(ctx, blit, rb, target);
@@ -576,7 +577,7 @@ _mesa_meta_fb_tex_blit_begin(const struct gl_context *ctx,
 }
 
 void
-_mesa_meta_fb_tex_blit_end(const struct gl_context *ctx, GLenum target,
+_mesa_meta_fb_tex_blit_end(struct gl_context *ctx, GLenum target,
                            struct fb_tex_blit_state *blit)
 {
    /* Restore texture object state, the texture binding will
@@ -585,6 +586,16 @@ _mesa_meta_fb_tex_blit_end(const struct gl_context *ctx, GLenum target,
    if (target != GL_TEXTURE_RECTANGLE_ARB) {
       _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, blit->baseLevelSave);
       _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, blit->maxLevelSave);
+
+      if (ctx->Extensions.ARB_stencil_texturing) {
+         const struct gl_texture_object *texObj =
+            _mesa_get_current_tex_object(ctx, target);
+
+         if (texObj->StencilSampling != blit->stencilSamplingSave)
+            _mesa_TexParameteri(target, GL_DEPTH_STENCIL_TEXTURE_MODE,
+                                blit->stencilSamplingSave ?
+                                   GL_STENCIL_INDEX : GL_DEPTH_COMPONENT);
+      }
    }
 
    _mesa_BindSampler(ctx->Texture.CurrentUnit, blit->samplerSave);