summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2014-02-14 23:34:47 +0000
committerEmil Velikov <[email protected]>2014-08-15 17:35:37 +0100
commit76f07362ea411fd6ef29b34df3885def5137bcba (patch)
treee88e92db3db79fe6b4417d236507783111564b22 /src/mesa
parent87d3ae0b45b6b6bb50b583dafa55eb109449a005 (diff)
dri/nouveau: add GLX_MESA_query_renderer support
- Create nouveau_{vendor,get_renderer}_string helpers. - Set correct max_gl*version. - Query the device PCIID via libdrm_nouveau/nouveau_getparam. Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_driver.c24
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_driver.h5
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.c82
3 files changed, 92 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
index b2887f83e6c..c1f86724161 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
@@ -34,21 +34,29 @@
#include "drivers/common/meta.h"
-static const GLubyte *
-nouveau_get_string(struct gl_context *ctx, GLenum name)
+const char const *nouveau_vendor_string = "Nouveau";
+
+const char *
+nouveau_get_renderer_string(unsigned chipset)
{
- static char buffer[128];
char hardware_name[32];
+ static char buffer[128];
+
+ snprintf(hardware_name, sizeof(hardware_name), "nv%02X", chipset);
+ driGetRendererString(buffer, hardware_name, 0);
+ return buffer;
+}
+
+static const GLubyte *
+nouveau_get_string(struct gl_context *ctx, GLenum name)
+{
switch (name) {
case GL_VENDOR:
- return (GLubyte *)"Nouveau";
+ return (GLubyte *)nouveau_vendor_string;
case GL_RENDERER:
- sprintf(hardware_name, "nv%02X", context_chipset(ctx));
- driGetRendererString(buffer, hardware_name, 0);
-
- return (GLubyte *)buffer;
+ return (GLubyte *)nouveau_get_renderer_string(context_chipset(ctx));
default:
return NULL;
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.h b/src/mesa/drivers/dri/nouveau/nouveau_driver.h
index 8b46e51cbaf..a4273a554bd 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_driver.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.h
@@ -69,6 +69,11 @@ struct nouveau_driver {
#define nouveau_error(format, ...) \
fprintf(stderr, "%s: " format, __func__, ## __VA_ARGS__)
+extern const char const *nouveau_vendor_string;
+
+const char *
+nouveau_get_renderer_string(unsigned chipset);
+
void
nouveau_clear(struct gl_context *ctx, GLbitfield buffers);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index aec2f729d69..766ae6f2f79 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -24,6 +24,8 @@
*
*/
+#include <xf86drm.h>
+#include <nouveau_drm.h>
#include "nouveau_driver.h"
#include "nouveau_context.h"
#include "nouveau_fbo.h"
@@ -104,28 +106,22 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
switch (screen->device->chipset & 0xf0) {
case 0x00:
screen->driver = &nv04_driver;
+ dri_screen->max_gl_compat_version = 12;
break;
case 0x10:
screen->driver = &nv10_driver;
+ dri_screen->max_gl_compat_version = 12;
+ dri_screen->max_gl_es1_version = 10;
break;
case 0x20:
screen->driver = &nv20_driver;
+ dri_screen->max_gl_compat_version = 13;
+ dri_screen->max_gl_es1_version = 10;
break;
default:
assert(0);
}
- /* Compat version validation will occur at context init after
- * _mesa_compute_version().
- */
- dri_screen->max_gl_compat_version = 15;
-
- /* NV10 and NV20 can support OpenGL ES 1.0 only. Older chips
- * cannot do even that.
- */
- if ((screen->device->chipset & 0xf0) != 0x00)
- dri_screen->max_gl_es1_version = 10;
-
dri_screen->driverPrivate = screen;
dri_screen->extensions = nouveau_screen_extensions;
screen->dri_screen = dri_screen;
@@ -141,6 +137,69 @@ fail:
}
+static int
+nouveau_query_renderer_integer(__DRIscreen *psp, int param,
+ unsigned int *value)
+{
+ const struct nouveau_screen *const screen =
+ (struct nouveau_screen *) psp->driverPrivate;
+
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] = 0x10de;
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID: {
+ uint64_t device_id;
+
+ if (nouveau_getparam(screen->device,
+ NOUVEAU_GETPARAM_PCI_DEVICE,
+ &device_id)) {
+ nouveau_error("Error retrieving the device PCIID.\n");
+ device_id = -1;
+ }
+ value[0] = (unsigned int) device_id;
+ return 0;
+ }
+ case __DRI2_RENDERER_ACCELERATED:
+ value[0] = 1;
+ return 0;
+ case __DRI2_RENDERER_VIDEO_MEMORY:
+ /* XXX: return vram_size or vram_limit ? */
+ value[0] = screen->device->vram_size >> 20;
+ return 0;
+ case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
+ value[0] = 0;
+ return 0;
+ default:
+ return driQueryRendererIntegerCommon(psp, param, value);
+ }
+}
+
+static int
+nouveau_query_renderer_string(__DRIscreen *psp, int param, const char **value)
+{
+ const struct nouveau_screen *const screen =
+ (struct nouveau_screen *) psp->driverPrivate;
+
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] = nouveau_vendor_string;
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID:
+ value[0] = nouveau_get_renderer_string(screen->device->chipset);
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+static const __DRI2rendererQueryExtension nouveau_renderer_query_extension = {
+ .base = { __DRI2_RENDERER_QUERY, 1 },
+
+ .queryInteger = nouveau_query_renderer_integer,
+ .queryString = nouveau_query_renderer_string
+};
+
static void
nouveau_destroy_screen(__DRIscreen *dri_screen)
{
@@ -244,6 +303,7 @@ static const struct __DRItexBufferExtensionRec nouveau_texbuffer_extension = {
static const __DRIextension *nouveau_screen_extensions[] = {
&nouveau_flush_extension.base,
&nouveau_texbuffer_extension.base,
+ &nouveau_renderer_query_extension.base,
&dri2ConfigQueryExtension.base,
NULL
};