[Mesa-dev] [PATCH 1/3] meta: Refactor the code to prepare for msaa color resolve fix
Anuj Phogat
anuj.phogat at gmail.com
Thu Aug 28 16:48:15 PDT 2014
Patch contains no functional changes.
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/drivers/common/meta.h | 1 +
src/mesa/drivers/common/meta_blit.c | 17 ++++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 56ba9bc..75a869c 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -265,6 +265,7 @@ struct blit_state
{
GLuint VAO;
GLuint VBO;
+ GLuint samples;
struct blit_shader_table shaders;
GLuint msaa_shaders[BLIT_MSAA_SHADER_COUNT];
struct temp_texture depthTex;
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 955e73f..0785ddd 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -65,11 +65,13 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
void *mem_ctx;
enum blit_msaa_shader shader_index;
bool dst_is_msaa = false;
+ bool is_shader_msaa_depth_resolve_or_copy = false;
GLenum src_datatype;
const char *vec4_prefix;
const char *sampler_array_suffix = "";
char *name;
const char *texcoord_type = "vec2";
+ const int samples = MAX2(src_rb->NumSamples, 1);
if (src_rb) {
src_datatype = _mesa_get_format_datatype(src_rb->Format);
@@ -139,6 +141,12 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
vec4_prefix = "";
}
+ is_shader_msaa_depth_resolve_or_copy =
+ shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_RESOLVE ||
+ shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_RESOLVE ||
+ shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_COPY ||
+ shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY;
+
if (blit->msaa_shaders[shader_index]) {
_mesa_UseProgram(blit->msaa_shaders[shader_index]);
return;
@@ -146,10 +154,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
mem_ctx = ralloc_context(NULL);
- if (shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_RESOLVE ||
- shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_RESOLVE ||
- shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_COPY ||
- shader_index == BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY) {
+ if (is_shader_msaa_depth_resolve_or_copy) {
char *sample_index;
const char *arb_sample_shading_extension_string;
@@ -209,7 +214,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
/* You can create 2D_MULTISAMPLE textures with 0 sample count (meaning 1
* sample). Yes, this is ridiculous.
*/
- int samples;
char *sample_resolve;
const char *arb_sample_shading_extension_string;
const char *merge_function;
@@ -217,8 +221,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
vec4_prefix,
dst_is_msaa ? "copy" : "resolve");
- samples = MAX2(src_rb->NumSamples, 1);
-
if (dst_is_msaa) {
arb_sample_shading_extension_string = "#extension GL_ARB_sample_shading : enable";
sample_resolve = ralloc_asprintf(mem_ctx, " out_color = texelFetch(texSampler, i%s(texCoords), gl_SampleID);", texcoord_type);
@@ -316,6 +318,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
_mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, name,
&blit->msaa_shaders[shader_index]);
+ blit->samples = samples;
ralloc_free(mem_ctx);
}
--
1.9.3
More information about the mesa-dev
mailing list