[Mesa-dev] [PATCH 24/25] gallium/softpipe/llvmpipe: handle query_renderer caps

Emil Velikov emil.l.velikov at gmail.com
Sat Feb 22 07:33:55 PST 2014


On 22/02/14 13:52, Brian Paul wrote:
> On Fri, Feb 21, 2014 at 8:04 PM, Emil Velikov <emil.l.velikov at gmail.com>wrote:
> 
>> Both drivers report 0xffffffff as vendor/device id, and the maximum
>> amount of system memory as video memory. We might want to reconsider
>> the latter.
>>
>> Cc: Brian Paul <brianp at vmware.com>
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>>  src/gallium/drivers/llvmpipe/lp_screen.c | 25 +++++++++++++++++++++++++
>>  src/gallium/drivers/softpipe/sp_screen.c | 25 +++++++++++++++++++++++++
>>  2 files changed, 50 insertions(+)
>>
>> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c
>> b/src/gallium/drivers/llvmpipe/lp_screen.c
>> index 604f853..c28f9a7 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
>> @@ -245,6 +245,31 @@ llvmpipe_get_param(struct pipe_screen *screen, enum
>> pipe_cap param)
>>        return 11;
>>     case PIPE_CAP_MAX_GL_ES2_VERSION:
>>        return 20;
>> +
>> +   case PIPE_CAP_VENDOR_ID:
>> +      return 0xFFFFFFFF;
>> +   case PIPE_CAP_DEVICE_ID:
>> +      return 0xFFFFFFFF;
>>
> 
> Maybe just return zero since that's probably the default value returned by
> a driver when it doesn't support a particular cap.
> 
As device id of 0 is a valid value, the spec says that one should return
0xffffffff if the renderer does not have(cannot retrieve) the pci device
id. I've chose the same value for the vendor for consistency.
Will need to duplicated return statement but other than that I would
prefer to keep it as is. Otherwise we'll need to do something messy
within the dri state-tracker like the following

int value = get_params(PIPE_CAP_DEVICE_ID)
if (!value)
  return 0xffffffff;
else
  return value;


> 
> 
>> +   case PIPE_CAP_ACCELERATED:
>> +      return 0;
>> +   case PIPE_CAP_VIDEO_MEMORY: {
>> +      /* XXX: Do we want to return the full amount fo system memory ? */
>> +      const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
>> +      const long system_page_size = sysconf(_SC_PAGE_SIZE);
>>
> 
> I'd bet sysconf() won't work on Windows or other non-Linux systems.
> 
> We should probably have a gallium utility function for doing memory size
> queries.  It would wrap whatever OS calls are needed.
> 
Is there any other platforms to consider apart from Windows, Linux, *BSD
and Haiku ?

> 
> 
>> +
>> +      if (system_memory_pages <= 0 || system_page_size <= 0)
>> +         return 0;
>> +
>> +      const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
>> +         * (uint64_t) system_page_size;
>>
> 
> Declarations cannot follow code (MSVC).
> 
Speaking of MSVC, does it support designated initialisers like the
following ?

const __DRItexBufferExtension driTexBufferExtension = {
  .base = { __DRI_TEX_BUFFER, 2 },

  .setTexBuffer       = dri_set_tex_buffer,
  .setTexBuffer2      = dri_set_tex_buffer2,
  .releaseTexBuffer   = NULL,
};


-Emil
> 
> 
>> +
>> +      const unsigned system_memory_megabytes =
>> +          (unsigned) (system_memory_bytes / (1024 * 1024));
>> +
>> +      return system_memory_megabytes;
>> +   }
>> +   case PIPE_CAP_UMA:
>> +      return 0;
>>     }
>>     /* should only get here on unhandled cases */
>>     debug_printf("Unexpected PIPE_CAP %d query\n", param);
>> diff --git a/src/gallium/drivers/softpipe/sp_screen.c
>> b/src/gallium/drivers/softpipe/sp_screen.c
>> index 3a6d31a..bf91274 100644
>> --- a/src/gallium/drivers/softpipe/sp_screen.c
>> +++ b/src/gallium/drivers/softpipe/sp_screen.c
>> @@ -195,6 +195,31 @@ softpipe_get_param(struct pipe_screen *screen, enum
>> pipe_cap param)
>>        return 11;
>>     case PIPE_CAP_MAX_GL_ES2_VERSION:
>>        return 20;
>> +
>> +   case PIPE_CAP_VENDOR_ID:
>> +      return 0xFFFFFFFF;
>> +   case PIPE_CAP_DEVICE_ID:
>> +      return 0xFFFFFFFF;
>> +   case PIPE_CAP_ACCELERATED:
>> +      return 0;
>> +   case PIPE_CAP_VIDEO_MEMORY: {
>> +      /* XXX: Do we want to return the full amount fo system memory ? */
>> +      const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
>> +      const long system_page_size = sysconf(_SC_PAGE_SIZE);
>> +
>> +      if (system_memory_pages <= 0 || system_page_size <= 0)
>> +         return 0;
>> +
>> +      const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
>> +         * (uint64_t) system_page_size;
>> +
>> +      const unsigned system_memory_megabytes =
>> +          (unsigned) (system_memory_bytes / (1024 * 1024));
>> +
>> +      return system_memory_megabytes;
>> +   }
>> +   case PIPE_CAP_UMA:
>> +      return 0;
>>     }
>>     /* should only get here on unhandled cases */
>>     debug_printf("Unexpected PIPE_CAP %d query\n", param);
>> --
>> 1.9.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
> 



More information about the mesa-dev mailing list