[Mesa-dev] [RFC 3/3] u_vbuf: use single vertex buffer if needed

Christian Gmeiner christian.gmeiner at gmail.com
Tue Jun 14 10:16:03 UTC 2016


Hi Nicolai

2016-06-13 11:59 GMT+02:00 Nicolai Hähnle <nhaehnle at gmail.com>:
> On 11.06.2016 21:21, Christian Gmeiner wrote:
>>
>> From: "Wladimir J. van der Laan" <laanwj at gmail.com>
>>
>> CONST, VERTEX and INSTANCE attributes into one vertex buffer if
>> necessary due to hardware constraints.
>>
>> Signed-off-by: Wladimir J. van der Laan <laanwj at gmail.com>
>> ---
>>   src/gallium/auxiliary/util/u_vbuf.c | 28 ++++++++++++++++++++++++----
>>   1 file changed, 24 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/util/u_vbuf.c
>> b/src/gallium/auxiliary/util/u_vbuf.c
>> index 464c279..d35f3b0 100644
>> --- a/src/gallium/auxiliary/util/u_vbuf.c
>> +++ b/src/gallium/auxiliary/util/u_vbuf.c
>> @@ -539,25 +539,45 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf
>> *mgr,
>>      uint32_t unused_vb_mask =
>>         (mgr->ve->incompatible_vb_mask_all | mgr->incompatible_vb_mask |
>>         ~mgr->enabled_vb_mask | extra_free_vb_mask) &
>> mgr->allowed_vb_mask;
>> +   uint32_t unused_vb_mask_temp;
>> +   boolean insufficient_buffers = false;
>> +
>> +   /* No vertex buffers available at all */
>> +   if(!unused_vb_mask)
>> +      return FALSE;
>>
>>      memset(fallback_vbs, ~0, sizeof(fallback_vbs));
>>
>>      /* Find free slots for each type if needed. */
>> +   unused_vb_mask_temp = unused_vb_mask;
>>      for (type = 0; type < VB_NUM; type++) {
>>         if (mask[type]) {
>>            uint32_t index;
>>
>> -         if (!unused_vb_mask) {
>> -            return FALSE;
>> +         if (!unused_vb_mask_temp) {
>> +            insufficient_buffers = TRUE;
>> +            break;
>>            }
>>
>> -         index = ffs(unused_vb_mask) - 1;
>> +         index = ffs(unused_vb_mask_temp) - 1;
>>            fallback_vbs[type] = index;
>> -         unused_vb_mask &= ~(1 << index);
>> +         unused_vb_mask_temp &= ~(1 << index);
>>            /*printf("found slot=%i for type=%i\n", index, type);*/
>>         }
>>      }
>>
>> +   if (insufficient_buffers) {
>> +      /* not enough vbs for all types supported by the hardware, they
>> will have to
>> +       * share one buffer */
>> +      uint32_t index = ffs(unused_vb_mask) - 1;
>> +
>> +      /* When sharing one vertex buffer use per-vertex frequency for
>> everything. */
>> +      fallback_vbs[VB_VERTEX] = index;
>> +      mask[VB_VERTEX] = mask[VB_VERTEX] | mask[VB_CONST] |
>> mask[VB_INSTANCE];
>> +      mask[VB_CONST] = 0;
>> +      mask[VB_INSTANCE] = 0;
>> +   }
>> +
>>      for (type = 0; type < VB_NUM; type++) {
>>         if (mask[type]) {
>>            mgr->dirty_real_vb_mask |= 1 << fallback_vbs[type];
>>
>
> I have a slight preference to make an unused_vb_mask_orig copy that is used
> in the insufficient_buffers fallback case rather than change everything to
> unused_vb_mask_temp.
>

I am fine with that change.

Thanks for review.

greets
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner


More information about the mesa-dev mailing list