[Mesa-dev] [PATCH 11/14] intel/blorp: Add a helper for filling out VERTEX_BUFFER_STATE

Jason Ekstrand jason at jlekstrand.net
Tue Nov 14 21:44:51 UTC 2017


On Tue, Nov 14, 2017 at 10:05 AM, Lionel Landwerlin <
lionel.g.landwerlin at intel.com> wrote:

> On 13/11/17 16:12, Jason Ekstrand wrote:
>
>> There are enough #ifs in there that it's kind-of pointless to duplicate
>> it for each buffer.
>> ---
>>   src/intel/blorp/blorp_genX_exec.h | 69 +++++++++++++++++++-----------
>> ---------
>>   1 file changed, 33 insertions(+), 36 deletions(-)
>>
>> diff --git a/src/intel/blorp/blorp_genX_exec.h
>> b/src/intel/blorp/blorp_genX_exec.h
>> index 4f88650..7548392 100644
>> --- a/src/intel/blorp/blorp_genX_exec.h
>> +++ b/src/intel/blorp/blorp_genX_exec.h
>> @@ -263,53 +263,50 @@ blorp_emit_input_varying_data(struct blorp_batch
>> *batch,
>>   }
>>     static void
>> -blorp_emit_vertex_buffers(struct blorp_batch *batch,
>> -                          const struct blorp_params *params)
>> +blorp_fill_vertex_buffer_state(struct blorp_batch *batch,
>> +                               struct GENX(VERTEX_BUFFER_STATE) *vb,
>> +                               unsigned idx,
>> +                               struct blorp_address addr, uint32_t size,
>> +                               uint32_t stride)
>>   {
>> -   struct GENX(VERTEX_BUFFER_STATE) vb[2];
>> -   memset(vb, 0, sizeof(vb));
>> +   vb[idx].VertexBufferIndex = idx;
>> +   vb[idx].BufferStartingAddress = addr;
>> +   vb[idx].BufferPitch = stride;
>>   -   uint32_t size;
>> -   blorp_emit_vertex_data(batch, params, &vb[0].BufferStartingAddress,
>> &size);
>> -   vb[0].VertexBufferIndex = 0;
>> -   vb[0].BufferPitch = 3 * sizeof(float);
>>   #if GEN_GEN >= 6
>> -   vb[0].VertexBufferMOCS = batch->blorp->mocs.vb;
>> -#endif
>> -#if GEN_GEN >= 7
>> -   vb[0].AddressModifyEnable = true;
>> -#endif
>> -#if GEN_GEN >= 8
>> -   vb[0].BufferSize = size;
>> -#elif GEN_GEN >= 5
>> -   vb[0].BufferAccessType = VERTEXDATA;
>> -   vb[0].EndAddress = vb[0].BufferStartingAddress;
>> -   vb[0].EndAddress.offset += size - 1;
>> -#elif GEN_GEN == 4
>> -   vb[0].BufferAccessType = VERTEXDATA;
>> -   vb[0].MaxIndex = 2;
>> +   vb[idx].VertexBufferMOCS = batch->blorp->mocs.vb;
>>   #endif
>>   -   blorp_emit_input_varying_data(batch, params,
>> -                                 &vb[1].BufferStartingAddress, &size);
>> -   vb[1].VertexBufferIndex = 1;
>> -   vb[1].BufferPitch = 0;
>> -#if GEN_GEN >= 6
>> -   vb[1].VertexBufferMOCS = batch->blorp->mocs.vb;
>> -#endif
>>   #if GEN_GEN >= 7
>> -   vb[1].AddressModifyEnable = true;
>> +   vb[idx].AddressModifyEnable = true;
>>   #endif
>> +
>>   #if GEN_GEN >= 8
>> -   vb[1].BufferSize = size;
>> +   vb[idx].BufferSize = size;
>>   #elif GEN_GEN >= 5
>> -   vb[1].BufferAccessType = INSTANCEDATA;
>> -   vb[1].EndAddress = vb[1].BufferStartingAddress;
>> -   vb[1].EndAddress.offset += size - 1;
>> +   vb[idx].BufferAccessType = stride > 0 ? VERTEXDATA : INSTANCEDATA;
>> +   vb[idx].EndAddress = vb[idx].BufferStartingAddress;
>> +   vb[idx].EndAddress.offset += size - 1;
>>   #elif GEN_GEN == 4
>> -   vb[1].BufferAccessType = INSTANCEDATA;
>> -   vb[1].MaxIndex = 0;
>> +   vb[idx].BufferAccessType = stride > 0 ? VERTEXDATA : INSTANCEDATA;
>> +   vb[idx].MaxIndex = 2;
>>
>
> This MaxIndex used to be 0 for vb[1], now it's always 2 on gen4.
> I can't really tell whether that's going to have an unintended effect :(
>

That exists for gen4's really awkward method of bounds checking.  It may be
better to just set this to "stride > 0 ? size / stride : 0".  I'll do that
and see if it works.  Also, I don't think it really maters so long as it's
large enough since blorp is never going to go OOB.


>   #endif
>> +}
>> +
>> +static void
>> +blorp_emit_vertex_buffers(struct blorp_batch *batch,
>> +                          const struct blorp_params *params)
>> +{
>> +   struct GENX(VERTEX_BUFFER_STATE) vb[2];
>> +   memset(vb, 0, sizeof(vb));
>> +
>> +   struct blorp_address addr;
>> +   uint32_t size;
>> +   blorp_emit_vertex_data(batch, params, &addr, &size);
>> +   blorp_fill_vertex_buffer_state(batch, vb, 0, addr, size, 3 *
>> sizeof(float));
>> +
>> +   blorp_emit_input_varying_data(batch, params, &addr, &size);
>> +   blorp_fill_vertex_buffer_state(batch, vb, 1, addr, size, 0);
>>        const unsigned num_dwords = 1 + GENX(VERTEX_BUFFER_STATE_length)
>> * 2;
>>      uint32_t *dw = blorp_emitn(batch, GENX(3DSTATE_VERTEX_BUFFERS),
>> num_dwords);
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171114/63b137bd/attachment.html>


More information about the mesa-dev mailing list