diff options
author | Eric Anholt <[email protected]> | 2018-04-26 09:24:32 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-04-26 11:30:22 -0700 |
commit | 76ee9edcb4f5be8699cfb9a6c4aa231c4e7d4183 (patch) | |
tree | 27556d81315aa8bf857050be0c86dec24a15306b /src/gallium/drivers | |
parent | e2f33178010a9612d8d89bf128e3a01a69e1dd82 (diff) |
broadcom/vc5: Add support for centroid varyings.
It would be nice to share the flags packet emit logic with flat shade
flags, but I couldn't come up with a good way while still using our pack
macros. We need to refactor this to shader record setup at compile time,
anyway.
Fixes ext_framebuffer_multisample-interpolation * centroid-*
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/vc5/vc5_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/vc5/vc5_draw.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/vc5/vc5_emit.c | 39 | ||||
-rw-r--r-- | src/gallium/drivers/vc5/vc5_program.c | 14 |
4 files changed, 53 insertions, 4 deletions
diff --git a/src/gallium/drivers/vc5/vc5_context.h b/src/gallium/drivers/vc5/vc5_context.h index e08a2a59909..9e55f80f947 100644 --- a/src/gallium/drivers/vc5/vc5_context.h +++ b/src/gallium/drivers/vc5/vc5_context.h @@ -82,6 +82,7 @@ void vc5_job_add_bo(struct vc5_job *job, struct vc5_bo *bo); #define VC5_DIRTY_FS_INPUTS (1 << 26) #define VC5_DIRTY_STREAMOUT (1 << 27) #define VC5_DIRTY_OQ (1 << 28) +#define VC5_DIRTY_CENTROID_FLAGS (1 << 29) #define VC5_MAX_FS_INPUTS 64 diff --git a/src/gallium/drivers/vc5/vc5_draw.c b/src/gallium/drivers/vc5/vc5_draw.c index ff14d1c1358..ecb1aa37831 100644 --- a/src/gallium/drivers/vc5/vc5_draw.c +++ b/src/gallium/drivers/vc5/vc5_draw.c @@ -177,6 +177,9 @@ vc5_emit_gl_shader_state(struct vc5_context *vc5, (vc5->prog.fs->prog_data.fs->writes_z || vc5->prog.fs->prog_data.fs->discard); + shader.fragment_shader_uses_real_pixel_centre_w_in_addition_to_centroid_w2 = + vc5->prog.fs->prog_data.fs->uses_centroid_and_center_w; + shader.number_of_varyings_in_fragment_shader = vc5->prog.fs->prog_data.base->num_inputs; diff --git a/src/gallium/drivers/vc5/vc5_emit.c b/src/gallium/drivers/vc5/vc5_emit.c index 0d11d7e1ad1..cb8af953300 100644 --- a/src/gallium/drivers/vc5/vc5_emit.c +++ b/src/gallium/drivers/vc5/vc5_emit.c @@ -589,6 +589,45 @@ v3dX(emit_state)(struct pipe_context *pctx) } } +#if V3D_VERSION >= 40 + if (vc5->dirty & VC5_DIRTY_CENTROID_FLAGS) { + bool emitted_any = false; + + for (int i = 0; i < ARRAY_SIZE(vc5->prog.fs->prog_data.fs->centroid_flags); i++) { + if (!vc5->prog.fs->prog_data.fs->centroid_flags[i]) + continue; + + cl_emit(&job->bcl, CENTROID_FLAGS, flags) { + flags.varying_offset_v0 = i; + + if (emitted_any) { + flags.action_for_centroid_flags_of_lower_numbered_varyings = + V3D_VARYING_FLAGS_ACTION_UNCHANGED; + flags.action_for_centroid_flags_of_higher_numbered_varyings = + V3D_VARYING_FLAGS_ACTION_UNCHANGED; + } else { + flags.action_for_centroid_flags_of_lower_numbered_varyings = + ((i == 0) ? + V3D_VARYING_FLAGS_ACTION_UNCHANGED : + V3D_VARYING_FLAGS_ACTION_ZEROED); + + flags.action_for_centroid_flags_of_higher_numbered_varyings = + V3D_VARYING_FLAGS_ACTION_ZEROED; + } + + flags.centroid_flags_for_varyings_v024 = + vc5->prog.fs->prog_data.fs->centroid_flags[i]; + } + + emitted_any = true; + } + + if (!emitted_any) { + cl_emit(&job->bcl, ZERO_ALL_CENTROID_FLAGS, flags); + } + } +#endif + /* Set up the transform feedback data specs (which VPM entries to * output to which buffers). */ diff --git a/src/gallium/drivers/vc5/vc5_program.c b/src/gallium/drivers/vc5/vc5_program.c index d885cdf2975..23d2d73a2dc 100644 --- a/src/gallium/drivers/vc5/vc5_program.c +++ b/src/gallium/drivers/vc5/vc5_program.c @@ -477,10 +477,16 @@ vc5_update_compiled_fs(struct vc5_context *vc5, uint8_t prim_mode) vc5->dirty |= VC5_DIRTY_COMPILED_FS; - if (old_fs && - vc5->prog.fs->prog_data.fs->flat_shade_flags != - old_fs->prog_data.fs->flat_shade_flags) { - vc5->dirty |= VC5_DIRTY_FLAT_SHADE_FLAGS; + if (old_fs) { + if (vc5->prog.fs->prog_data.fs->flat_shade_flags != + old_fs->prog_data.fs->flat_shade_flags) { + vc5->dirty |= VC5_DIRTY_FLAT_SHADE_FLAGS; + } + + if (vc5->prog.fs->prog_data.fs->centroid_flags != + old_fs->prog_data.fs->centroid_flags) { + vc5->dirty |= VC5_DIRTY_CENTROID_FLAGS; + } } if (old_fs && memcmp(vc5->prog.fs->prog_data.fs->input_slots, |