From 768c8dd71894fb3f57a758814946d745a426d7e5 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 21 Oct 2016 14:32:03 -0700 Subject: intel/blorp: Use an actual chunk of vertex buffer for the VUE header We're about to start passing other things in as a sort of "VS header" for vertex shaders and we need a place to put them. Since we want the instance id to be one of them, it makes sense to have one vec4 that's either VUE header or VS header. Always uploading some handy zeros makes the code a bit simpler. Signed-off-by: Jason Ekstrand Reviewed-by: Topi Pohjolainen --- src/intel/blorp/blorp_genX_exec.h | 67 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'src/intel/blorp') diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h index 121f05de43e..78fb3ffe4ca 100644 --- a/src/intel/blorp/blorp_genX_exec.h +++ b/src/intel/blorp/blorp_genX_exec.h @@ -193,27 +193,34 @@ blorp_emit_input_varying_data(struct blorp_batch *batch, const unsigned vec4_size_in_bytes = 4 * sizeof(float); const unsigned max_num_varyings = DIV_ROUND_UP(sizeof(params->wm_inputs), vec4_size_in_bytes); - const unsigned num_varyings = params->wm_prog_data->num_varying_inputs; + const unsigned num_varyings = + params->wm_prog_data ? params->wm_prog_data->num_varying_inputs : 0; - *size = num_varyings * vec4_size_in_bytes; + *size = 16 + num_varyings * vec4_size_in_bytes; const uint32_t *const inputs_src = (const uint32_t *)¶ms->wm_inputs; uint32_t *inputs = blorp_alloc_vertex_buffer(batch, *size, addr); - /* Walk over the attribute slots, determine if the attribute is used by - * the program and when necessary copy the values from the input storage to - * the vertex data buffer. - */ - for (unsigned i = 0; i < max_num_varyings; i++) { - const gl_varying_slot attr = VARYING_SLOT_VAR0 + i; + /* Zero data for the VUE header */ + memset(inputs, 0, 4 * sizeof(uint32_t)); + inputs += 4; + + if (params->wm_prog_data) { + /* Walk over the attribute slots, determine if the attribute is used by + * the program and when necessary copy the values from the input storage + * to the vertex data buffer. + */ + for (unsigned i = 0; i < max_num_varyings; i++) { + const gl_varying_slot attr = VARYING_SLOT_VAR0 + i; - const int input_index = params->wm_prog_data->urb_setup[attr]; - if (input_index < 0) - continue; + const int input_index = params->wm_prog_data->urb_setup[attr]; + if (input_index < 0) + continue; - memcpy(inputs, inputs_src + i * 4, vec4_size_in_bytes); + memcpy(inputs, inputs_src + i * 4, vec4_size_in_bytes); - inputs += 4; + inputs += 4; + } } } @@ -224,8 +231,6 @@ blorp_emit_vertex_buffers(struct blorp_batch *batch, struct GENX(VERTEX_BUFFER_STATE) vb[2]; memset(vb, 0, sizeof(vb)); - unsigned num_buffers = 1; - uint32_t size; blorp_emit_vertex_data(batch, params, &vb[0].BufferStartingAddress, &size); vb[0].VertexBufferIndex = 0; @@ -242,30 +247,26 @@ blorp_emit_vertex_buffers(struct blorp_batch *batch, vb[0].EndAddress.offset += size - 1; #endif - if (params->wm_prog_data && params->wm_prog_data->num_varying_inputs) { - blorp_emit_input_varying_data(batch, params, - &vb[1].BufferStartingAddress, &size); - vb[1].VertexBufferIndex = 1; - vb[1].BufferPitch = 0; - vb[1].VertexBufferMOCS = batch->blorp->mocs.vb; + blorp_emit_input_varying_data(batch, params, + &vb[1].BufferStartingAddress, &size); + vb[1].VertexBufferIndex = 1; + vb[1].BufferPitch = 0; + vb[1].VertexBufferMOCS = batch->blorp->mocs.vb; #if GEN_GEN >= 7 - vb[1].AddressModifyEnable = true; + vb[1].AddressModifyEnable = true; #endif #if GEN_GEN >= 8 - vb[1].BufferSize = size; + vb[1].BufferSize = size; #else - vb[1].BufferAccessType = INSTANCEDATA; - vb[1].EndAddress = vb[1].BufferStartingAddress; - vb[1].EndAddress.offset += size - 1; + vb[1].BufferAccessType = INSTANCEDATA; + vb[1].EndAddress = vb[1].BufferStartingAddress; + vb[1].EndAddress.offset += size - 1; #endif - num_buffers++; - } - const unsigned num_dwords = - 1 + GENX(VERTEX_BUFFER_STATE_length) * num_buffers; + const unsigned num_dwords = 1 + GENX(VERTEX_BUFFER_STATE_length) * 2; uint32_t *dw = blorp_emitn(batch, GENX(3DSTATE_VERTEX_BUFFERS), num_dwords); - for (unsigned i = 0; i < num_buffers; i++) { + for (unsigned i = 0; i < 2; i++) { GENX(VERTEX_BUFFER_STATE_pack)(batch, dw, &vb[i]); dw += GENX(VERTEX_BUFFER_STATE_length); } @@ -328,7 +329,7 @@ blorp_emit_vertex_elements(struct blorp_batch *batch, * * See the vertex element setup below. */ - ve[0].VertexBufferIndex = 0; + ve[0].VertexBufferIndex = 1; ve[0].Valid = true; ve[0].SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT; ve[0].SourceElementOffset = 0; @@ -359,7 +360,7 @@ blorp_emit_vertex_elements(struct blorp_batch *batch, ve[i + 2].VertexBufferIndex = 1; ve[i + 2].Valid = true; ve[i + 2].SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT; - ve[i + 2].SourceElementOffset = i * 4 * sizeof(float); + ve[i + 2].SourceElementOffset = 16 + i * 4 * sizeof(float); ve[i + 2].Component0Control = VFCOMP_STORE_SRC; ve[i + 2].Component1Control = VFCOMP_STORE_SRC; ve[i + 2].Component2Control = VFCOMP_STORE_SRC; -- cgit v1.2.3