[Mesa-dev] [PATCH 22/25] gallium/nouveau: handle query_renderer caps

Emil Velikov emil.l.velikov at gmail.com
Sat Feb 22 05:25:16 PST 2014


On 22/02/14 05:54, Ilia Mirkin wrote:
> On Fri, Feb 21, 2014 at 10:04 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>>
>> IMHO we could easily rip out all the common stuff wrt PIPE_CAPs
>> handling and move it to nouveau, rather than duplicating it in
>> each driver.
>>
>> I believe that can be done as a follow up patch.
> 
> Easy enough to do it instead of this patch -- add a "fallback" handler
> to nouveau_screen.c, and call it from the default case of each of the
> nvXX_screen.c's get_param handler.
> 
If you can confirm that there are no unhandled caps for the nv30 driver
I would love to go with your suggestion.

-Emil

>>
>> -Emil
>>
>>  src/gallium/drivers/nouveau/nv30/nv30_screen.c | 25 ++++++++++++++++++++++++
>>  src/gallium/drivers/nouveau/nv50/nv50_screen.c | 27 +++++++++++++++++++++++++-
>>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 25 ++++++++++++++++++++++++
>>  3 files changed, 76 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> index abbc3b6..564a6c3 100644
>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> @@ -23,6 +23,8 @@
>>   *
>>   */
>>
>> +#include <xf86drm.h>
> 
> Why is this needed?
> 
>> +#include <nouveau_drm.h>
> 
> This works? Should be <libdrm/nouveau_drm.h> I thought. It also
> happens to already be included in nouveau_screen.c -- another argument
> for moving this stuff there straight away :)
> 
>>  #include "util/u_format.h"
>>  #include "util/u_format_s3tc.h"
>>
>> @@ -44,11 +46,16 @@
>>  #define CURIE_4497_CHIPSET   0x00005450
>>  #define CURIE_4497_CHIPSET6X 0x00000088
>>
>> +#ifndef NOUVEAU_GETPARAM_PCI_DEVICE
>> +# define NOUVEAU_GETPARAM_PCI_DEVICE 4
>> +#endif
>> +
>>  static int
>>  nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>  {
>>     struct nv30_screen *screen = nv30_screen(pscreen);
>>     struct nouveau_object *eng3d = screen->eng3d;
>> +   struct nouveau_device *dev = nouveau_screen(pscreen)->device;
>>
>>     switch (param) {
>>     /* non-boolean capabilities */
>> @@ -146,6 +153,24 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_MAX_GL_ES2_VERSION:
>>        return 20;
>>
>> +   case PIPE_CAP_VENDOR_ID:
>> +      return 0x10de;
>> +   case PIPE_CAP_DEVICE_ID: {
>> +      uint64_t device_id;
>> +      if (!nouveau_getparam(dev, NOUVEAU_GETPARAM_PCI_DEVICE, &device_id)) {
>> +         NOUVEAU_ERR("NOUVEAU_GETPARAM_PCI_DEVICE failed.\n");
>> +         return -1;
>> +      }
>> +      return device_id;
>> +   }
>> +   case PIPE_CAP_ACCELERATED:
>> +      return 1;
>> +   case PIPE_CAP_VIDEO_MEMORY:
>> +      /* XXX: expose vram_size, vram_limit, gart_size or gart_limit ? */
>> +      return dev->vram_size >> 20;
>> +   case PIPE_CAP_UMA:
>> +      return 0;
>> +
>>     default:
>>        debug_printf("unknown param %d\n", param);
>>        return 0;
>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> index 5090b7f..e6a9781 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> @@ -20,6 +20,9 @@
>>   * OTHER DEALINGS IN THE SOFTWARE.
>>   */
>>
>> +#include <errno.h>
>> +#include <xf86drm.h>
>> +#include <nouveau_drm.h>
>>  #include "util/u_format.h"
>>  #include "util/u_format_s3tc.h"
>>  #include "pipe/p_screen.h"
>> @@ -30,7 +33,10 @@
>>  #include "nouveau_vp3_video.h"
>>
>>  #include "nv_object.xml.h"
>> -#include <errno.h>
>> +
>> +#ifndef NOUVEAU_GETPARAM_PCI_DEVICE
>> +# define NOUVEAU_GETPARAM_PCI_DEVICE 4
>> +#endif
>>
>>  #ifndef NOUVEAU_GETPARAM_GRAPH_UNITS
>>  # define NOUVEAU_GETPARAM_GRAPH_UNITS 13
>> @@ -83,6 +89,7 @@ static int
>>  nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>  {
>>     const uint16_t class_3d = nouveau_screen(pscreen)->class_3d;
>> +   struct nouveau_device *dev = nouveau_screen(pscreen)->device;
>>
>>     switch (param) {
>>     case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
>> @@ -209,6 +216,24 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_MAX_GL_ES2_VERSION:
>>        return 30;
>>
>> +   case PIPE_CAP_VENDOR_ID:
>> +      return 0x10de;
>> +   case PIPE_CAP_DEVICE_ID: {
>> +      uint64_t device_id;
>> +      if (!nouveau_getparam(dev, NOUVEAU_GETPARAM_PCI_DEVICE, &device_id)) {
>> +         NOUVEAU_ERR("NOUVEAU_GETPARAM_PCI_DEVICE failed.\n");
>> +         return -1;
>> +      }
>> +      return device_id;
>> +   }
>> +   case PIPE_CAP_ACCELERATED:
>> +      return 1;
>> +   case PIPE_CAP_VIDEO_MEMORY:
>> +      /* XXX: expose vram_size, vram_limit, gart_size or gart_limit ? */
>> +      return dev->vram_size >> 20;
>> +   case PIPE_CAP_UMA:
>> +      return 0;
>> +
>>     default:
>>        NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
>>        return 0;
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> index b96dced..a263ce3 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -20,6 +20,8 @@
>>   * OTHER DEALINGS IN THE SOFTWARE.
>>   */
>>
>> +#include <xf86drm.h>
>> +#include <nouveau_drm.h>
>>  #include "util/u_format.h"
>>  #include "util/u_format_s3tc.h"
>>  #include "pipe/p_screen.h"
>> @@ -34,6 +36,10 @@
>>
>>  #include "nvc0/nvc0_graph_macros.h"
>>
>> +#ifndef NOUVEAU_GETPARAM_PCI_DEVICE
>> +# define NOUVEAU_GETPARAM_PCI_DEVICE 4
>> +#endif
>> +
>>  #ifndef NOUVEAU_GETPARAM_GRAPH_UNITS
>>  # define NOUVEAU_GETPARAM_GRAPH_UNITS 13
>>  #endif
>> @@ -69,6 +75,7 @@ static int
>>  nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>  {
>>     const uint16_t class_3d = nouveau_screen(pscreen)->class_3d;
>> +   struct nouveau_device *dev = nouveau_screen(pscreen)->device;
>>
>>     switch (param) {
>>     case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
>> @@ -187,6 +194,24 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_MAX_GL_ES2_VERSION:
>>        return 30;
>>
>> +   case PIPE_CAP_VENDOR_ID:
>> +      return 0x10de;
>> +   case PIPE_CAP_DEVICE_ID: {
>> +      uint64_t device_id;
>> +      if (!nouveau_getparam(dev, NOUVEAU_GETPARAM_PCI_DEVICE, &device_id)) {
>> +         NOUVEAU_ERR("NOUVEAU_GETPARAM_PCI_DEVICE failed.\n");
>> +         return -1;
>> +      }
>> +      return device_id;
>> +   }
>> +   case PIPE_CAP_ACCELERATED:
>> +      return 1;
>> +   case PIPE_CAP_VIDEO_MEMORY:
>> +      /* XXX: expose vram_size, vram_limit, gart_size or gart_limit ? */
>> +      return dev->vram_size >> 20;
>> +   case PIPE_CAP_UMA:
>> +      return 0;
>> +
>>     default:
>>        NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
>>        return 0;
>> --
>> 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