From ab6ed2e1ac98745c62a10a82e414eb17e4e4ba44 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 23 Oct 2015 21:30:21 -0700 Subject: [PATCH] anv/gen8_pipeline: Emit a real 3DSTATE_SBE_SWIZ packet --- src/vulkan/gen8_pipeline.c | 39 +++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c index 3468ce02154..a51cf4924ae 100644 --- a/src/vulkan/gen8_pipeline.c +++ b/src/vulkan/gen8_pipeline.c @@ -351,7 +351,6 @@ gen8_graphics_pipeline_create( anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_WM_CHROMAKEY, .ChromaKeyKillEnable = false); - anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_SBE_SWIZ); anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_AA_LINE_PARAMETERS); anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_CLIP, @@ -496,13 +495,51 @@ gen8_graphics_pipeline_create( const struct brw_wm_prog_data *wm_prog_data = &pipeline->wm_prog_data; + /* TODO: We should clean this up. Among other things, this is mostly + * shared with other gens. + */ + const struct brw_vue_map *fs_input_map; + if (pipeline->gs_vec4 == NO_KERNEL) + fs_input_map = &vue_prog_data->vue_map; + else + fs_input_map = &gs_prog_data->base.vue_map; + + struct GEN8_3DSTATE_SBE_SWIZ swiz = { + GEN8_3DSTATE_SBE_SWIZ_header, + }; + + int max_source_attr = 0; + for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) { + int input_index = wm_prog_data->urb_setup[attr]; + + if (input_index < 0) + continue; + + /* We have to subtract two slots to accout for the URB entry output + * read offset in the VS and GS stages. + */ + int source_attr = fs_input_map->varying_to_slot[attr] - 2; + max_source_attr = MAX2(max_source_attr, source_attr); + + if (input_index >= 16) + continue; + + swiz.Attribute[input_index].SourceAttribute = source_attr; + } + anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_SBE, + .AttributeSwizzleEnable = true, .ForceVertexURBEntryReadLength = false, .ForceVertexURBEntryReadOffset = false, + .VertexURBEntryReadLength = DIV_ROUND_UP(max_source_attr + 1, 2), .PointSpriteTextureCoordinateOrigin = UPPERLEFT, .NumberofSFOutputAttributes = wm_prog_data->num_varying_inputs); + uint32_t *dw = anv_batch_emit_dwords(&pipeline->batch, + GEN8_3DSTATE_SBE_SWIZ_length); + GEN8_3DSTATE_SBE_SWIZ_pack(&pipeline->batch, dw, &swiz); + anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_PS, .KernelStartPointer0 = pipeline->ps_ksp0, -- 2.30.2