diff options
author | Rafael Antognolli <[email protected]> | 2017-03-30 11:33:05 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2017-04-24 15:14:10 -0700 |
commit | 9670124e3157636e5325fc0d3302375709403d0e (patch) | |
tree | 778ca551f408f8e8a5ac4a5ae6925a85b2217baf /src/intel/blorp | |
parent | 4ace73b1f6e8c8d96663a0d8f0f1d61f934e9cb2 (diff) |
genxml: Make BLEND_STATE command support variable length array.
We need to emit BLEND_STATE, which size is 1 + 2 * nr_draw_buffers
dwords (on gen8+), but the BLEND_STATE struct length is always 17. By
marking it size 1, which is actually the size of the struct minus the
BLEND_STATE_ENTRY's, we can emit a BLEND_STATE of variable number of
entries.
For gen6 and gen7 we set length to 0, since it only contains
BLEND_STATE_ENTRY's, and no other data.
With this change, we also change the code for blorp and anv to emit only
the needed BLEND_STATE_ENTRY's, instead of always emitting 16 dwords on
gen6-7 and 17 dwords on gen8+.
v2:
- Use designated initializers on blorp and remove 0 from
initialization (Jason)
- Default entries to disabled on Vulkan (Jason)
- Rebase code.
Signed-off-by: Rafael Antognolli <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/blorp')
-rw-r--r-- | src/intel/blorp/blorp_genX_exec.h | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h index bbc391d9f21..0bde2d2e844 100644 --- a/src/intel/blorp/blorp_genX_exec.h +++ b/src/intel/blorp/blorp_genX_exec.h @@ -858,20 +858,35 @@ static uint32_t blorp_emit_blend_state(struct blorp_batch *batch, const struct blorp_params *params) { + struct GENX(BLEND_STATE) blend; + memset(&blend, 0, sizeof(blend)); + uint32_t offset; - blorp_emit_dynamic(batch, GENX(BLEND_STATE), blend, 64, &offset) { - for (unsigned i = 0; i < params->num_draw_buffers; ++i) { - blend.Entry[i].PreBlendColorClampEnable = true; - blend.Entry[i].PostBlendColorClampEnable = true; - blend.Entry[i].ColorClampRange = COLORCLAMP_RTFORMAT; - - blend.Entry[i].WriteDisableRed = params->color_write_disable[0]; - blend.Entry[i].WriteDisableGreen = params->color_write_disable[1]; - blend.Entry[i].WriteDisableBlue = params->color_write_disable[2]; - blend.Entry[i].WriteDisableAlpha = params->color_write_disable[3]; - } + int size = GENX(BLEND_STATE_length) * 4; + size += GENX(BLEND_STATE_ENTRY_length) * 4 * params->num_draw_buffers; + uint32_t *state = blorp_alloc_dynamic_state(batch, size, 64, &offset); + uint32_t *pos = state; + + GENX(BLEND_STATE_pack)(NULL, pos, &blend); + pos += GENX(BLEND_STATE_length); + + for (unsigned i = 0; i < params->num_draw_buffers; ++i) { + struct GENX(BLEND_STATE_ENTRY) entry = { + .PreBlendColorClampEnable = true, + .PostBlendColorClampEnable = true, + .ColorClampRange = COLORCLAMP_RTFORMAT, + + .WriteDisableRed = params->color_write_disable[0], + .WriteDisableGreen = params->color_write_disable[1], + .WriteDisableBlue = params->color_write_disable[2], + .WriteDisableAlpha = params->color_write_disable[3], + }; + GENX(BLEND_STATE_ENTRY_pack)(NULL, pos, &entry); + pos += GENX(BLEND_STATE_ENTRY_length); } + blorp_flush_range(batch, state, size); + #if GEN_GEN >= 7 blorp_emit(batch, GENX(3DSTATE_BLEND_STATE_POINTERS), sp) { sp.BlendStatePointer = offset; |