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

Emil Velikov emil.l.velikov at gmail.com
Fri Feb 21 19:04:12 PST 2014


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.

-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>
+#include <nouveau_drm.h>
 #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



More information about the mesa-dev mailing list