diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index ebfbbf4770d..b4b80d8ad89 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -509,6 +509,22 @@ emit_3dstate_sbe(struct anv_graphics_pipeline *pipeline) sbe_mesh.PerVertexURBEntryOutputReadOffset = mue->per_vertex_header_size_dw / 8; sbe_mesh.PerVertexURBEntryOutputReadLength = DIV_ROUND_UP(mue->per_vertex_data_size_dw, 8); + /* Clip distance array is passed in the per-vertex header so that + * it can be consumed by the HW. If user wants to read it in the FS, + * adjust the offset and length to cover it. Conveniently it is at + * the end of the per-vertex header, right before per-vertex + * attributes. + * + * Note that FS attribute reading must be aware that the clip + * distances have fixed position. + */ + if (mue->per_vertex_header_size_dw > 8 && + (wm_prog_data->urb_setup[VARYING_SLOT_CLIP_DIST0] >= 0 || + wm_prog_data->urb_setup[VARYING_SLOT_CLIP_DIST1] >= 0)) { + sbe_mesh.PerVertexURBEntryOutputReadOffset -= 1; + sbe_mesh.PerVertexURBEntryOutputReadLength += 1; + } + assert(mue->per_primitive_header_size_dw % 8 == 0); sbe_mesh.PerPrimitiveURBEntryOutputReadOffset = mue->per_primitive_header_size_dw / 8; sbe_mesh.PerPrimitiveURBEntryOutputReadLength = DIV_ROUND_UP(mue->per_primitive_data_size_dw, 8);