[Mesa-dev] [PATCH 07/25] dri/nouveau: add GLX_MESA_query_renderer support
Emil Velikov
emil.l.velikov at gmail.com
Fri Feb 21 19:03:57 PST 2014
v2: nv04-2x cards support upto opengl 1.3.
v3: Include correct headers.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/mesa/drivers/dri/nouveau/nouveau_screen.c | 83 ++++++++++++++++++++++++++-
1 file changed, 82 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index a381064..fb92161 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"
@@ -118,13 +120,17 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
/* Compat version validation will occur at context init after
* _mesa_compute_version().
*/
- dri_screen->max_gl_compat_version = 15;
+ dri_screen->max_gl_compat_version = 13;
+ dri_screen->max_gl_core_version = 0;
/* 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;
+ else
+ dri_screen->max_gl_es1_version = 0;
+ dri_screen->max_gl_es2_version = 0;
dri_screen->driverPrivate = screen;
dri_screen->extensions = nouveau_screen_extensions;
@@ -141,6 +147,80 @@ 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: {
+ struct drm_nouveau_getparam gp;
+ int *chip_id = 0, ret;
+
+ memset(&gp, 0, sizeof(gp));
+ gp.param = NOUVEAU_GETPARAM_PCI_DEVICE;
+ gp.value = (unsigned long) chip_id;
+
+ ret = drmCommandWriteRead(psp->fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp));
+ if (ret) {
+ nouveau_error("Error retrieving NOUVEAU_GETPARAM_PCI_DEVICE.\n");
+ *chip_id = -1;
+ }
+ value[0] = *chip_id;
+ return 0;
+ }
+ case __DRI2_RENDERER_ACCELERATED:
+ value[0] = 1;
+ return 0;
+ case __DRI2_RENDERER_VIDEO_MEMORY:
+ /* XXX: return vram_size, vram_limit, gart_size or gart_limit ? */
+ value[0] = screen->device->vram_size >> 20;
+ return 0;
+ case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
+ value[0] = 0;
+ return 0;
+ case __DRI2_RENDERER_PREFERRED_PROFILE:
+ value[0] = (1U << __DRI_API_OPENGL);
+ return 0;
+ default:
+ return driQueryRendererIntegerCommon(psp, param, value);
+ }
+
+ return -1;
+}
+
+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:
+ break;
+ }
+
+ 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)
{
@@ -241,6 +321,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
};
--
1.9.0
More information about the mesa-dev
mailing list