summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2016-02-29 17:27:11 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2016-03-01 08:46:32 -0800
commit38f4c11c2f5c00a1d2addddcd0508ad89a7cead4 (patch)
treed51cda3f95bcb195a8fff59dfbd954f2ea746b83
parent3f8df795c145113de32a0c5a30607a67f1d94839 (diff)
downloadexternal_mesa3d-38f4c11c2f5c00a1d2addddcd0508ad89a7cead4.zip
external_mesa3d-38f4c11c2f5c00a1d2addddcd0508ad89a7cead4.tar.gz
external_mesa3d-38f4c11c2f5c00a1d2addddcd0508ad89a7cead4.tar.bz2
anv/pipeline: Pull 3DSTATE_SBE into a shared helper
-rw-r--r--src/intel/vulkan/gen7_pipeline.c14
-rw-r--r--src/intel/vulkan/gen8_pipeline.c99
-rw-r--r--src/intel/vulkan/genX_pipeline_util.h109
3 files changed, 111 insertions, 111 deletions
diff --git a/src/intel/vulkan/gen7_pipeline.c b/src/intel/vulkan/gen7_pipeline.c
index 7151e36..c356fed 100644
--- a/src/intel/vulkan/gen7_pipeline.c
+++ b/src/intel/vulkan/gen7_pipeline.c
@@ -245,10 +245,6 @@ genX(graphics_pipeline_create)(
.SampleMask = 0xff);
const struct brw_vue_prog_data *vue_prog_data = &pipeline->vs_prog_data.base;
- /* The last geometry producing stage will set urb_offset and urb_length,
- * which we use in 3DSTATE_SBE. Skip the VUE header and position slots. */
- uint32_t urb_offset = 1;
- uint32_t urb_length = (vue_prog_data->vue_map.num_slots + 1) / 2 - urb_offset;
#if 0
/* From gen7_vs_state.c */
@@ -291,9 +287,6 @@ genX(graphics_pipeline_create)(
if (pipeline->gs_kernel == NO_KERNEL || (extra && extra->disable_vs)) {
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), .GSEnable = false);
} else {
- urb_offset = 1;
- urb_length = (gs_prog_data->base.vue_map.num_slots + 1) / 2 - urb_offset;
-
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS),
.KernelStartPointer = pipeline->gs_kernel,
.ScratchSpaceBasePointer = pipeline->scratch_start[MESA_SHADER_GEOMETRY],
@@ -346,12 +339,7 @@ genX(graphics_pipeline_create)(
if (wm_prog_data->urb_setup[VARYING_SLOT_PRIMITIVE_ID] != -1)
anv_finishme("primitive_id needs sbe swizzling setup");
- /* FIXME: generated header doesn't emit attr swizzle fields */
- anv_batch_emit(&pipeline->batch, GENX(3DSTATE_SBE),
- .NumberofSFOutputAttributes = pipeline->wm_prog_data.num_varying_inputs,
- .VertexURBEntryReadLength = urb_length,
- .VertexURBEntryReadOffset = urb_offset,
- .PointSpriteTextureCoordinateOrigin = UPPERLEFT);
+ emit_3dstate_sbe(pipeline);
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS),
.KernelStartPointer0 = pipeline->ps_ksp0,
diff --git a/src/intel/vulkan/gen8_pipeline.c b/src/intel/vulkan/gen8_pipeline.c
index c9545c8..494a649 100644
--- a/src/intel/vulkan/gen8_pipeline.c
+++ b/src/intel/vulkan/gen8_pipeline.c
@@ -443,104 +443,7 @@ genX(graphics_pipeline_create)(
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS_EXTRA),
.PixelShaderValid = false);
} else {
- /* 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_kernel == NO_KERNEL)
- fs_input_map = &vue_prog_data->vue_map;
- else
- fs_input_map = &gs_prog_data->base.vue_map;
-
- struct GENX(3DSTATE_SBE_SWIZ) swiz = {
- GENX(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;
-
- int source_attr = fs_input_map->varying_to_slot[attr];
- max_source_attr = MAX2(max_source_attr, source_attr);
-
- if (input_index >= 16)
- continue;
-
- if (source_attr == -1) {
- /* This attribute does not exist in the VUE--that means that the
- * vertex shader did not write to it. It could be that it's a
- * regular varying read by the fragment shader but not written by
- * the vertex shader or it's gl_PrimitiveID. In the first case the
- * value is undefined, in the second it needs to be
- * gl_PrimitiveID.
- */
- swiz.Attribute[input_index].ConstantSource = PRIM_ID;
- swiz.Attribute[input_index].ComponentOverrideX = true;
- swiz.Attribute[input_index].ComponentOverrideY = true;
- swiz.Attribute[input_index].ComponentOverrideZ = true;
- swiz.Attribute[input_index].ComponentOverrideW = true;
- } else {
- /* We have to subtract two slots to accout for the URB entry output
- * read offset in the VS and GS stages.
- */
- swiz.Attribute[input_index].SourceAttribute = source_attr - 2;
- }
- }
-
- anv_batch_emit(&pipeline->batch, GENX(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,
-
-#if GEN_GEN >= 9
- .Attribute0ActiveComponentFormat = ACF_XYZW,
- .Attribute1ActiveComponentFormat = ACF_XYZW,
- .Attribute2ActiveComponentFormat = ACF_XYZW,
- .Attribute3ActiveComponentFormat = ACF_XYZW,
- .Attribute4ActiveComponentFormat = ACF_XYZW,
- .Attribute5ActiveComponentFormat = ACF_XYZW,
- .Attribute6ActiveComponentFormat = ACF_XYZW,
- .Attribute7ActiveComponentFormat = ACF_XYZW,
- .Attribute8ActiveComponentFormat = ACF_XYZW,
- .Attribute9ActiveComponentFormat = ACF_XYZW,
- .Attribute10ActiveComponentFormat = ACF_XYZW,
- .Attribute11ActiveComponentFormat = ACF_XYZW,
- .Attribute12ActiveComponentFormat = ACF_XYZW,
- .Attribute13ActiveComponentFormat = ACF_XYZW,
- .Attribute14ActiveComponentFormat = ACF_XYZW,
- .Attribute15ActiveComponentFormat = ACF_XYZW,
- /* wow, much field, very attribute */
- .Attribute16ActiveComponentFormat = ACF_XYZW,
- .Attribute17ActiveComponentFormat = ACF_XYZW,
- .Attribute18ActiveComponentFormat = ACF_XYZW,
- .Attribute19ActiveComponentFormat = ACF_XYZW,
- .Attribute20ActiveComponentFormat = ACF_XYZW,
- .Attribute21ActiveComponentFormat = ACF_XYZW,
- .Attribute22ActiveComponentFormat = ACF_XYZW,
- .Attribute23ActiveComponentFormat = ACF_XYZW,
- .Attribute24ActiveComponentFormat = ACF_XYZW,
- .Attribute25ActiveComponentFormat = ACF_XYZW,
- .Attribute26ActiveComponentFormat = ACF_XYZW,
- .Attribute27ActiveComponentFormat = ACF_XYZW,
- .Attribute28ActiveComponentFormat = ACF_XYZW,
- .Attribute29ActiveComponentFormat = ACF_XYZW,
- .Attribute28ActiveComponentFormat = ACF_XYZW,
- .Attribute29ActiveComponentFormat = ACF_XYZW,
- .Attribute30ActiveComponentFormat = ACF_XYZW,
-#endif
- );
-
- uint32_t *dw = anv_batch_emit_dwords(&pipeline->batch,
- GENX(3DSTATE_SBE_SWIZ_length));
- GENX(3DSTATE_SBE_SWIZ_pack)(&pipeline->batch, dw, &swiz);
+ emit_3dstate_sbe(pipeline);
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS),
.KernelStartPointer0 = pipeline->ps_ksp0,
diff --git a/src/intel/vulkan/genX_pipeline_util.h b/src/intel/vulkan/genX_pipeline_util.h
index d940aba..66250e5 100644
--- a/src/intel/vulkan/genX_pipeline_util.h
+++ b/src/intel/vulkan/genX_pipeline_util.h
@@ -219,6 +219,115 @@ emit_urb_setup(struct anv_pipeline *pipeline)
}
}
+static void
+emit_3dstate_sbe(struct anv_pipeline *pipeline)
+{
+ const struct brw_vue_map *fs_input_map;
+ if (pipeline->gs_kernel == NO_KERNEL)
+ fs_input_map = &pipeline->vs_prog_data.base.vue_map;
+ else
+ fs_input_map = &pipeline->gs_prog_data.base.vue_map;
+
+ struct GENX(3DSTATE_SBE) sbe = {
+ GENX(3DSTATE_SBE_header),
+ .AttributeSwizzleEnable = true,
+ .PointSpriteTextureCoordinateOrigin = UPPERLEFT,
+ .NumberofSFOutputAttributes = pipeline->wm_prog_data.num_varying_inputs,
+
+#if GEN_GEN >= 9
+ .Attribute0ActiveComponentFormat = ACF_XYZW,
+ .Attribute1ActiveComponentFormat = ACF_XYZW,
+ .Attribute2ActiveComponentFormat = ACF_XYZW,
+ .Attribute3ActiveComponentFormat = ACF_XYZW,
+ .Attribute4ActiveComponentFormat = ACF_XYZW,
+ .Attribute5ActiveComponentFormat = ACF_XYZW,
+ .Attribute6ActiveComponentFormat = ACF_XYZW,
+ .Attribute7ActiveComponentFormat = ACF_XYZW,
+ .Attribute8ActiveComponentFormat = ACF_XYZW,
+ .Attribute9ActiveComponentFormat = ACF_XYZW,
+ .Attribute10ActiveComponentFormat = ACF_XYZW,
+ .Attribute11ActiveComponentFormat = ACF_XYZW,
+ .Attribute12ActiveComponentFormat = ACF_XYZW,
+ .Attribute13ActiveComponentFormat = ACF_XYZW,
+ .Attribute14ActiveComponentFormat = ACF_XYZW,
+ .Attribute15ActiveComponentFormat = ACF_XYZW,
+ /* wow, much field, very attribute */
+ .Attribute16ActiveComponentFormat = ACF_XYZW,
+ .Attribute17ActiveComponentFormat = ACF_XYZW,
+ .Attribute18ActiveComponentFormat = ACF_XYZW,
+ .Attribute19ActiveComponentFormat = ACF_XYZW,
+ .Attribute20ActiveComponentFormat = ACF_XYZW,
+ .Attribute21ActiveComponentFormat = ACF_XYZW,
+ .Attribute22ActiveComponentFormat = ACF_XYZW,
+ .Attribute23ActiveComponentFormat = ACF_XYZW,
+ .Attribute24ActiveComponentFormat = ACF_XYZW,
+ .Attribute25ActiveComponentFormat = ACF_XYZW,
+ .Attribute26ActiveComponentFormat = ACF_XYZW,
+ .Attribute27ActiveComponentFormat = ACF_XYZW,
+ .Attribute28ActiveComponentFormat = ACF_XYZW,
+ .Attribute29ActiveComponentFormat = ACF_XYZW,
+ .Attribute28ActiveComponentFormat = ACF_XYZW,
+ .Attribute29ActiveComponentFormat = ACF_XYZW,
+ .Attribute30ActiveComponentFormat = ACF_XYZW,
+#endif
+ };
+
+#if GEN_GEN >= 8
+ /* On Broadwell, they broke 3DSTATE_SBE into two packets */
+ struct GENX(3DSTATE_SBE_SWIZ) swiz = {
+ GENX(3DSTATE_SBE_SWIZ_header),
+ };
+#else
+# define swiz sbe
+#endif
+
+ int max_source_attr = 0;
+ for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) {
+ int input_index = pipeline->wm_prog_data.urb_setup[attr];
+
+ if (input_index < 0)
+ continue;
+
+ int source_attr = fs_input_map->varying_to_slot[attr];
+ max_source_attr = MAX2(max_source_attr, source_attr);
+
+ if (input_index >= 16)
+ continue;
+
+ if (source_attr == -1) {
+ /* This attribute does not exist in the VUE--that means that the
+ * vertex shader did not write to it. It could be that it's a
+ * regular varying read by the fragment shader but not written by
+ * the vertex shader or it's gl_PrimitiveID. In the first case the
+ * value is undefined, in the second it needs to be
+ * gl_PrimitiveID.
+ */
+ swiz.Attribute[input_index].ConstantSource = PRIM_ID;
+ swiz.Attribute[input_index].ComponentOverrideX = true;
+ swiz.Attribute[input_index].ComponentOverrideY = true;
+ swiz.Attribute[input_index].ComponentOverrideZ = true;
+ swiz.Attribute[input_index].ComponentOverrideW = true;
+ } else {
+ /* We have to subtract two slots to accout for the URB entry output
+ * read offset in the VS and GS stages.
+ */
+ swiz.Attribute[input_index].SourceAttribute = source_attr - 2;
+ }
+ }
+
+ sbe.VertexURBEntryReadOffset = 1; /* Skip the VUE header and position slots */
+ sbe.VertexURBEntryReadLength = DIV_ROUND_UP(max_source_attr + 1, 2);
+
+ uint32_t *dw = anv_batch_emit_dwords(&pipeline->batch,
+ GENX(3DSTATE_SBE_length));
+ GENX(3DSTATE_SBE_pack)(&pipeline->batch, dw, &sbe);
+
+#if GEN_GEN >= 8
+ dw = anv_batch_emit_dwords(&pipeline->batch, GENX(3DSTATE_SBE_SWIZ_length));
+ GENX(3DSTATE_SBE_SWIZ_pack)(&pipeline->batch, dw, &swiz);
+#endif
+}
+
static inline uint32_t
scratch_space(const struct brw_stage_prog_data *prog_data)
{