v3d: Add support for glSampleMask / glSampleCoverage.

This commit is contained in:
Eric Anholt 2018-05-08 14:28:33 -07:00
parent 9bbc3f8cf1
commit 97894b1267
7 changed files with 36 additions and 5 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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)

View file

@ -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;

View file

@ -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:

View file

@ -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
}

View file

@ -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