From a664233042e1ad343184a0c237c3bd7ac5010779 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 20 Nov 2015 17:11:18 -0800 Subject: [PATCH] vc4: Add support for loading sample mask. --- src/gallium/drivers/vc4/kernel/vc4_packet.h | 3 +++ src/gallium/drivers/vc4/vc4_context.c | 2 ++ src/gallium/drivers/vc4/vc4_program.c | 4 ++++ src/gallium/drivers/vc4/vc4_qir.h | 1 + src/gallium/drivers/vc4/vc4_state.c | 2 +- src/gallium/drivers/vc4/vc4_uniforms.c | 8 ++++++++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/vc4/kernel/vc4_packet.h b/src/gallium/drivers/vc4/kernel/vc4_packet.h index 771e2b78761..9c12d331f61 100644 --- a/src/gallium/drivers/vc4/kernel/vc4_packet.h +++ b/src/gallium/drivers/vc4/kernel/vc4_packet.h @@ -121,6 +121,9 @@ enum vc4_packet { #define VC4_PACKET_TILE_COORDINATES_SIZE 3 #define VC4_PACKET_GEM_HANDLES_SIZE 9 +/* Number of multisamples supported. */ +#define VC4_MAX_SAMPLES 4 + #define VC4_MASK(high, low) (((1 << ((high) - (low) + 1)) - 1) << (low)) /* Using the GNU statement expression extension */ #define VC4_SET_FIELD(value, field) \ diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c index d490fad5167..4f3e2263f56 100644 --- a/src/gallium/drivers/vc4/vc4_context.c +++ b/src/gallium/drivers/vc4/vc4_context.c @@ -245,6 +245,8 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) vc4_debug |= saved_shaderdb_flag; + vc4->sample_mask = (1 << VC4_MAX_SAMPLES) - 1; + return &vc4->base; fail: diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 197577b6c20..9c6e8647256 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1462,6 +1462,10 @@ ntq_emit_intrinsic(struct vc4_compile *c, nir_intrinsic_instr *instr) instr->const_index[0]); break; + case nir_intrinsic_load_sample_mask_in: + *dest = qir_uniform(c, QUNIFORM_SAMPLE_MASK, 0); + break; + case nir_intrinsic_load_input: assert(instr->num_components == 1); if (instr->const_index[0] == VC4_NIR_TLB_COLOR_READ_INPUT) { diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index ddb35e41fcf..ad243ec1113 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -247,6 +247,7 @@ enum quniform_contents { QUNIFORM_STENCIL, QUNIFORM_ALPHA_REF, + QUNIFORM_SAMPLE_MASK, }; struct vc4_varying_slot { diff --git a/src/gallium/drivers/vc4/vc4_state.c b/src/gallium/drivers/vc4/vc4_state.c index a234ce53b20..2a88188a959 100644 --- a/src/gallium/drivers/vc4/vc4_state.c +++ b/src/gallium/drivers/vc4/vc4_state.c @@ -79,7 +79,7 @@ static void vc4_set_sample_mask(struct pipe_context *pctx, unsigned sample_mask) { struct vc4_context *vc4 = vc4_context(pctx); - vc4->sample_mask = (uint16_t)sample_mask; + vc4->sample_mask = sample_mask & ((1 << VC4_MAX_SAMPLES) - 1); vc4->dirty |= VC4_DIRTY_SAMPLE_MASK; } diff --git a/src/gallium/drivers/vc4/vc4_uniforms.c b/src/gallium/drivers/vc4/vc4_uniforms.c index f5ad481f186..5dfdd73f7bd 100644 --- a/src/gallium/drivers/vc4/vc4_uniforms.c +++ b/src/gallium/drivers/vc4/vc4_uniforms.c @@ -303,6 +303,10 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader, cl_aligned_f(&uniforms, vc4->zsa->base.alpha.ref_value); break; + + case QUNIFORM_SAMPLE_MASK: + cl_aligned_u32(&uniforms, vc4->sample_mask); + break; } #if 0 uint32_t written_val = *((uint32_t *)uniforms - 1); @@ -363,6 +367,10 @@ vc4_set_shader_uniform_dirty_flags(struct vc4_compiled_shader *shader) case QUNIFORM_ALPHA_REF: dirty |= VC4_DIRTY_ZSA; break; + + case QUNIFORM_SAMPLE_MASK: + dirty |= VC4_DIRTY_SAMPLE_MASK; + break; } } -- 2.30.2