[Mesa-dev] [PATCH 27/35] meta: Use GLSL to decompress 2D-array textures
Ian Romanick
idr at freedesktop.org
Wed Jan 29 13:53:18 PST 2014
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72582
---
src/mesa/drivers/common/meta.c | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 363b1ac..9b54d3a 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -324,6 +324,8 @@ struct decompress_state
GLuint ArrayObj;
GLuint VBO, FBO, RBO, Sampler;
GLint Width, Height;
+
+ struct sampler_table samplers;
};
/**
@@ -3858,6 +3860,10 @@ decompress_texture_image(struct gl_context *ctx,
GLuint fboDrawSave, fboReadSave;
GLuint rbSave;
GLuint samplerSave;
+ const bool use_glsl_version = ctx->Extensions.ARB_vertex_shader &&
+ ctx->Extensions.ARB_fragment_shader &&
+ (ctx->API != API_OPENGLES);
+ GLuint shaderProg = 0;
if (slice > 0) {
assert(target == GL_TEXTURE_3D ||
@@ -3874,9 +3880,8 @@ decompress_texture_image(struct gl_context *ctx,
assert(!"No compressed 3D textures.");
return;
- case GL_TEXTURE_2D_ARRAY:
case GL_TEXTURE_CUBE_MAP_ARRAY:
- /* These targets are just broken currently. */
+ /* This target is just broken currently. */
return;
case GL_TEXTURE_CUBE_MAP:
@@ -3922,7 +3927,20 @@ decompress_texture_image(struct gl_context *ctx,
decompress->Height = height;
}
- setup_ff_TNL_for_blit(&decompress->ArrayObj, &decompress->VBO, 3);
+ if (use_glsl_version) {
+ struct glsl_sampler *sampler;
+
+ setup_vertex_objects(&decompress->ArrayObj, &decompress->VBO, true,
+ 2, 3, 0);
+
+ /* Generate a relevant fragment shader program for the texture target */
+ sampler = setup_texture_sampler(target, &decompress->samplers);
+ assert(sampler != NULL);
+
+ shaderProg = setup_shader_for_sampler(ctx, sampler);
+ } else {
+ setup_ff_TNL_for_blit(&decompress->ArrayObj, &decompress->VBO, 3);
+ }
if (!decompress->Sampler) {
_mesa_GenSamplers(1, &decompress->Sampler);
@@ -3966,7 +3984,13 @@ decompress_texture_image(struct gl_context *ctx,
/* setup texture state */
_mesa_BindTexture(target, texObj->Name);
- _mesa_set_enable(ctx, target, GL_TRUE);
+
+ if (!use_glsl_version)
+ _mesa_set_enable(ctx, target, GL_TRUE);
+ else {
+ assert(shaderProg != 0);
+ _mesa_UseProgram(shaderProg);
+ }
{
/* save texture object state */
@@ -4026,7 +4050,8 @@ decompress_texture_image(struct gl_context *ctx,
}
/* disable texture unit */
- _mesa_set_enable(ctx, target, GL_FALSE);
+ if (!use_glsl_version)
+ _mesa_set_enable(ctx, target, GL_FALSE);
_mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave);
--
1.8.1.4
More information about the mesa-dev
mailing list