diff options
author | Eric Anholt <eric@anholt.net> | 2018-05-08 14:28:33 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2018-05-17 15:09:46 +0100 |
commit | 97894b1267923dee25ea5263e547ac8822ef7095 (patch) | |
tree | 1a937b563cad17d3fa0a910d644ab5ad68d31417 | |
parent | 9bbc3f8cf1f116aa17ebcd399c0d3a8fb07b5266 (diff) |
v3d: Add support for glSampleMask / glSampleCoverage.
-rw-r--r-- | src/broadcom/cle/v3d_packet_v41.xml | 5 | ||||
-rw-r--r-- | src/broadcom/cle/v3d_packet_v42.xml | 5 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_program.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3d_uniforms.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_emit.c | 23 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_state.c | 2 |
7 files changed, 36 insertions, 5 deletions
diff --git a/src/broadcom/cle/v3d_packet_v41.xml b/src/broadcom/cle/v3d_packet_v41.xml index 1fb5d5d284..c516561407 100644 --- a/src/broadcom/cle/v3d_packet_v41.xml +++ b/src/broadcom/cle/v3d_packet_v41.xml @@ -475,6 +475,11 @@ <field name="Varying offset V0" size="4" start="0" type="uint"/> </packet> + <packet code="91" name="Sample State"> + <field name="Coverage" size="16" start="16" type="uint"/> <!-- float-1-8-7 --> + <field name="Mask" size="4" start="0" type="uint"/> + </packet> + <packet code="92" name="Occlusion Query Counter"> <field name="address" size="32" start="0" type="address"/> </packet> diff --git a/src/broadcom/cle/v3d_packet_v42.xml b/src/broadcom/cle/v3d_packet_v42.xml index a562d662ff..fb4425968c 100644 --- a/src/broadcom/cle/v3d_packet_v42.xml +++ b/src/broadcom/cle/v3d_packet_v42.xml @@ -476,6 +476,11 @@ <field name="Varying offset V0" size="4" start="0" type="uint"/> </packet> + <packet code="91" name="Sample State"> + <field name="Coverage" size="16" start="16" type="uint"/> <!-- float-1-8-7 --> + <field name="Mask" size="4" start="0" type="uint"/> + </packet> + <packet code="92" name="Occlusion Query Counter"> <field name="address" size="32" start="0" type="address"/> </packet> diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index d110ed5022..47945f9649 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -61,7 +61,7 @@ void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo); #define VC5_DIRTY_BLEND_COLOR (1 << 7) #define VC5_DIRTY_STENCIL_REF (1 << 8) -#define VC5_DIRTY_SAMPLE_MASK (1 << 9) +#define VC5_DIRTY_SAMPLE_STATE (1 << 9) #define VC5_DIRTY_FRAMEBUFFER (1 << 10) #define VC5_DIRTY_STIPPLE (1 << 11) #define VC5_DIRTY_VIEWPORT (1 << 12) diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c index 63e6fda547..036f7c6e67 100644 --- a/src/gallium/drivers/v3d/v3d_program.c +++ b/src/gallium/drivers/v3d/v3d_program.c @@ -399,7 +399,7 @@ v3d_update_compiled_fs(struct v3d_context *v3d, uint8_t prim_mode) VC5_DIRTY_FRAMEBUFFER | VC5_DIRTY_ZSA | VC5_DIRTY_RASTERIZER | - VC5_DIRTY_SAMPLE_MASK | + VC5_DIRTY_SAMPLE_STATE | VC5_DIRTY_FRAGTEX | VC5_DIRTY_UNCOMPILED_FS))) { return; diff --git a/src/gallium/drivers/v3d/v3d_uniforms.c b/src/gallium/drivers/v3d/v3d_uniforms.c index 9dd128ab41..ad46c69121 100644 --- a/src/gallium/drivers/v3d/v3d_uniforms.c +++ b/src/gallium/drivers/v3d/v3d_uniforms.c @@ -475,7 +475,7 @@ v3d_set_shader_uniform_dirty_flags(struct v3d_compiled_shader *shader) break; case QUNIFORM_SAMPLE_MASK: - dirty |= VC5_DIRTY_SAMPLE_MASK; + dirty |= VC5_DIRTY_SAMPLE_STATE; break; default: diff --git a/src/gallium/drivers/v3d/v3dx_emit.c b/src/gallium/drivers/v3d/v3dx_emit.c index 8a65478a16..161ce51b2f 100644 --- a/src/gallium/drivers/v3d/v3dx_emit.c +++ b/src/gallium/drivers/v3d/v3dx_emit.c @@ -387,8 +387,17 @@ v3dX(emit_state)(struct pipe_context *pctx) config.enable_depth_offset = v3d->rasterizer->base.offset_tri; + /* V3D follows GL behavior where the sample mask only + * applies when MSAA is enabled. Gallium has sample + * mask apply anyway, and the MSAA blit shaders will + * set sample mask without explicitly setting + * rasterizer oversample. Just force it on here, + * since the blit shaders are the only way to have + * !multisample && samplemask != 0xf. + */ config.rasterizer_oversample_mode = - v3d->rasterizer->base.multisample; + v3d->rasterizer->base.multisample || + v3d->sample_mask != 0xf; config.direct3d_provoking_vertex = v3d->rasterizer->base.flatshade_first; @@ -719,4 +728,16 @@ v3dX(emit_state)(struct pipe_context *pctx) } } } + +#if V3D_VERSION >= 40 + if (v3d->dirty & VC5_DIRTY_SAMPLE_STATE) { + cl_emit(&job->bcl, SAMPLE_STATE, state) { + /* Note: SampleCoverage was handled at the + * state_tracker level by converting to sample_mask. + */ + state.coverage = fui(1.0) >> 16; + state.mask = job->msaa ? v3d->sample_mask : 0xf; + } + } +#endif } diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c index 1387a22e04..e48e0f3767 100644 --- a/src/gallium/drivers/v3d/v3dx_state.c +++ b/src/gallium/drivers/v3d/v3dx_state.c @@ -88,7 +88,7 @@ v3d_set_sample_mask(struct pipe_context *pctx, unsigned sample_mask) { struct v3d_context *v3d = v3d_context(pctx); v3d->sample_mask = sample_mask & ((1 << VC5_MAX_SAMPLES) - 1); - v3d->dirty |= VC5_DIRTY_SAMPLE_MASK; + v3d->dirty |= VC5_DIRTY_SAMPLE_STATE; } static uint16_t |