[Mesa-dev] [PATCH v2 2/3] nvc0: use NV_VRAM_DOMAIN() macro

Alexandre Courbot acourbot at nvidia.com
Tue Nov 18 21:59:42 PST 2014


On 11/19/2014 02:49 PM, Ilia Mirkin wrote:
> On Wed, Nov 19, 2014 at 12:41 AM, Alexandre Courbot <acourbot at nvidia.com> wrote:
>> Use the newly-introduced NV_VRAM_DOMAIN() macro to support alternative
>> VRAM domains for chips that do not use dedicated video memory.
>>
>> Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>
>> ---
>>   src/gallium/drivers/nouveau/nouveau_buffer.c           |  6 ++----
>>   src/gallium/drivers/nouveau/nv50/nv50_miptree.c        |  4 ++--
>>   src/gallium/drivers/nouveau/nvc0/nvc0_compute.c        |  2 +-
>>   src/gallium/drivers/nouveau/nvc0/nvc0_context.c        |  4 ++--
>>   src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c        |  2 +-
>>   src/gallium/drivers/nouveau/nvc0/nvc0_program.c        |  8 ++++----
>>   src/gallium/drivers/nouveau/nvc0/nvc0_screen.c         | 12 ++++++------
>>   src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c   |  2 +-
>>   src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c |  2 +-
>>   src/gallium/drivers/nouveau/nvc0/nvc0_tex.c            |  2 +-
>>   src/gallium/drivers/nouveau/nvc0/nve4_compute.c        |  2 +-
>>   11 files changed, 22 insertions(+), 24 deletions(-)
>>
>> diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
>> index 49ff100c4ece..4c21691ee671 100644
>> --- a/src/gallium/drivers/nouveau/nouveau_buffer.c
>> +++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
>> @@ -658,13 +658,11 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
>>         switch (buffer->base.usage) {
>>         case PIPE_USAGE_DEFAULT:
>>         case PIPE_USAGE_IMMUTABLE:
>> -         buffer->domain = NOUVEAU_BO_VRAM;
>> -         break;
>>         case PIPE_USAGE_DYNAMIC:
>>            /* For most apps, we'd have to do staging transfers to avoid sync
>>             * with this usage, and GART -> GART copies would be suboptimal.
>>             */
>> -         buffer->domain = NOUVEAU_BO_VRAM;
>> +         buffer->domain = NV_VRAM_DOMAIN(screen);
>>            break;
>>         case PIPE_USAGE_STAGING:
>>         case PIPE_USAGE_STREAM:
>> @@ -676,7 +674,7 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
>>         }
>>      } else {
>>         if (buffer->base.bind & screen->vidmem_bindings)
>> -         buffer->domain = NOUVEAU_BO_VRAM;
>> +         buffer->domain = NV_VRAM_DOMAIN(screen);
>>         else
>>         if (buffer->base.bind & screen->sysmem_bindings)
>>            buffer->domain = NOUVEAU_BO_GART;
>
> Both of these changes should be unnecessary if vidmem_bindings is
> cleared out, right?

For our particular case (vram_domain == NOUVEAU_BO_GART), that's 
correct. However NV_VRAM_DOMAIN could be a any combination of 
NOUVEAU_BO_*, so we can imagine a future scenario where 
(buffer->base.bind & screen->vidmem_bindings) == 1 but NV_VRAM_DOMAIN() 
will return something different from NOUVEAU_BO_VRAM. For this reason it 
seems consistent to use this macro here as well.


More information about the mesa-dev mailing list