[Mesa-dev] [PATCH 3/3] broadcom/vc5: Use the new glFragColor lowering pass.
Eric Anholt
eric at anholt.net
Fri Dec 29 01:56:20 UTC 2017
This fixes dEQP-GLES3.functional.fbo.color.clear.r16i and friends, by
making sure we do an integer TLB store instead of float.
---
src/broadcom/compiler/nir_to_vir.c | 5 +----
src/broadcom/compiler/v3d_compiler.h | 6 ++++++
src/broadcom/compiler/vir.c | 13 +++++++++++++
src/gallium/drivers/vc5/vc5_program.c | 5 +++++
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 1cf8865bf0e1..4bd9ae2e9a74 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1493,10 +1493,7 @@ ntq_setup_outputs(struct v3d_compile *c)
if (c->s->info.stage == MESA_SHADER_FRAGMENT) {
switch (var->data.location) {
case FRAG_RESULT_COLOR:
- c->output_color_var[0] = var;
- c->output_color_var[1] = var;
- c->output_color_var[2] = var;
- c->output_color_var[3] = var;
+ unreachable("Should have been lowered");
break;
case FRAG_RESULT_DATA0:
case FRAG_RESULT_DATA1:
diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h
index bbe7a57fa10e..d060af3c4169 100644
--- a/src/broadcom/compiler/v3d_compiler.h
+++ b/src/broadcom/compiler/v3d_compiler.h
@@ -322,6 +322,12 @@ struct v3d_fs_key {
uint8_t swap_color_rb;
/* Mask of which render targets need to be written as 32-bit floats */
uint8_t f32_color_rb;
+
+ /* Mask of which render targets need gl_FragColor output as a vec4. */
+ uint8_t gl_fragcolor_lower_vec4;
+ /* Mask of which render targets need gl_FragColor output as a uvec4. */
+ uint8_t gl_fragcolor_lower_uvec4;
+
uint8_t alpha_test_func;
uint8_t logicop_func;
uint32_t point_sprite_mask;
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 4e78a477bd7d..abcb430c6e3b 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -750,6 +750,19 @@ uint64_t *v3d_compile_fs(const struct v3d_compiler *compiler,
if (key->base.ucp_enables)
NIR_PASS_V(c->s, nir_lower_clip_fs, key->base.ucp_enables);
+ const struct glsl_type *gl_fragcolor_types[4] = {NULL, NULL, NULL, NULL};
+ for (int i = 0; i < ARRAY_SIZE(gl_fragcolor_types); i++) {
+ if (key->gl_fragcolor_lower_vec4 & (1 << i))
+ gl_fragcolor_types[i] = glsl_vec4_type();
+ else if (key->gl_fragcolor_lower_uvec4 & (1 << i))
+ gl_fragcolor_types[i] = glsl_uvec4_type();
+ }
+
+ NIR_PASS_V(c->s, nir_lower_gl_fragcolor,
+ key->gl_fragcolor_lower_vec4 |
+ key->gl_fragcolor_lower_uvec4,
+ gl_fragcolor_types);
+
/* Note: FS input scalarizing must happen after
* nir_lower_two_sided_color, which only handles a vec4 at a time.
*/
diff --git a/src/gallium/drivers/vc5/vc5_program.c b/src/gallium/drivers/vc5/vc5_program.c
index 4f902fd4c65d..2fb50897730d 100644
--- a/src/gallium/drivers/vc5/vc5_program.c
+++ b/src/gallium/drivers/vc5/vc5_program.c
@@ -378,6 +378,11 @@ vc5_update_compiled_fs(struct vc5_context *vc5, uint8_t prim_mode)
desc->channel[0].size == 32) {
key->f32_color_rb |= 1 << i;
}
+
+ if (desc->channel[0].pure_integer)
+ key->gl_fragcolor_lower_uvec4 |= 1 << i;
+ else
+ key->gl_fragcolor_lower_vec4 |= 1 << i;
}
if (key->is_points) {
--
2.15.0
More information about the mesa-dev
mailing list