[Mesa-dev] [PATCH 25/25] st/dri/drm: Add __DRI2rendererQueryExtension support
Emil Velikov
emil.l.velikov at gmail.com
Fri Feb 21 19:04:15 PST 2014
From: Dave Airlie <airlied at redhat.com>
The final step to get GLX_MESA_query_renderer working with hardware
gallium drivers.
v2: (Emil)
- Split out the nouveau changes
- Move code to common/dri_query_renderer, so that we can reuse it
for both dri2 and sw based drivers.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
.../state_trackers/dri/common/dri_query_renderer.c | 81 ++++++++++++++++++++++
.../state_trackers/dri/common/dri_query_renderer.h | 9 +++
.../state_trackers/dri/drm/Makefile.sources | 1 +
src/gallium/state_trackers/dri/drm/dri2.c | 2 +
.../state_trackers/dri/drm/dri_query_renderer.c | 1 +
src/gallium/state_trackers/dri/sw/Makefile.sources | 1 +
.../state_trackers/dri/sw/dri_query_renderer.c | 1 +
src/gallium/state_trackers/dri/sw/drisw.c | 2 +
8 files changed, 98 insertions(+)
create mode 100644 src/gallium/state_trackers/dri/common/dri_query_renderer.c
create mode 100644 src/gallium/state_trackers/dri/common/dri_query_renderer.h
create mode 120000 src/gallium/state_trackers/dri/drm/dri_query_renderer.c
create mode 120000 src/gallium/state_trackers/dri/sw/dri_query_renderer.c
diff --git a/src/gallium/state_trackers/dri/common/dri_query_renderer.c b/src/gallium/state_trackers/dri/common/dri_query_renderer.c
new file mode 100644
index 0000000..3a8d077
--- /dev/null
+++ b/src/gallium/state_trackers/dri/common/dri_query_renderer.c
@@ -0,0 +1,81 @@
+#include "dri_query_renderer.h"
+
+#include "util/u_inlines.h"
+#include "state_tracker/drm_driver.h"
+
+#include "utils.h"
+#include "dri_screen.h"
+#include "dri_query_renderer.h"
+
+static int
+dri2_query_renderer_integer(__DRIscreen *_screen, int param,
+ unsigned int *value)
+{
+ struct dri_screen *screen = dri_screen(_screen);
+
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] =
+ (unsigned int)screen->base.screen->get_param(screen->base.screen,
+ PIPE_CAP_VENDOR_ID);
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID:
+ value[0] =
+ (unsigned int)screen->base.screen->get_param(screen->base.screen,
+ PIPE_CAP_DEVICE_ID);
+ return 0;
+ case __DRI2_RENDERER_ACCELERATED:
+ value[0] =
+ (unsigned int)screen->base.screen->get_param(screen->base.screen,
+ PIPE_CAP_ACCELERATED);
+ return 0;
+
+ case __DRI2_RENDERER_VIDEO_MEMORY:
+ value[0] =
+ (unsigned int)screen->base.screen->get_param(screen->base.screen,
+ PIPE_CAP_VIDEO_MEMORY);
+ return 0;
+
+ case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
+ value[0] =
+ (unsigned int)screen->base.screen->get_param(screen->base.screen,
+ PIPE_CAP_UMA);
+ return 0;
+
+ case __DRI2_RENDERER_PREFERRED_PROFILE:
+ value[0] = (_screen->max_gl_core_version != 0)
+ ? (1U << __DRI_API_OPENGL_CORE) : (1U << __DRI_API_OPENGL);
+
+ return 0;
+ default:
+ return driQueryRendererIntegerCommon(_screen, param, value);
+ }
+
+ return -1;
+}
+
+static int
+dri2_query_renderer_string(__DRIscreen *_screen, int param,
+ const char **value)
+{
+ struct dri_screen *screen = dri_screen(_screen);
+
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] = screen->base.screen->get_vendor(screen->base.screen);
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID:
+ value[0] = screen->base.screen->get_name(screen->base.screen);
+ return 0;
+ default:
+ break;
+ }
+ return -1;
+}
+
+const __DRI2rendererQueryExtension dri2RendererQueryExtension = {
+ .base = { __DRI2_RENDERER_QUERY, 1 },
+
+ .queryInteger = dri2_query_renderer_integer,
+ .queryString = dri2_query_renderer_string
+};
diff --git a/src/gallium/state_trackers/dri/common/dri_query_renderer.h b/src/gallium/state_trackers/dri/common/dri_query_renderer.h
new file mode 100644
index 0000000..59b3ff8
--- /dev/null
+++ b/src/gallium/state_trackers/dri/common/dri_query_renderer.h
@@ -0,0 +1,9 @@
+#ifndef DRI_QUERY_RENDERER_H
+#define DRI_QUERY_RENDERER_H
+
+#include "dri_util.h"
+
+extern const
+__DRI2rendererQueryExtension dri2RendererQueryExtension;
+
+#endif
diff --git a/src/gallium/state_trackers/dri/drm/Makefile.sources b/src/gallium/state_trackers/dri/drm/Makefile.sources
index b9b93a2..7f0c892 100644
--- a/src/gallium/state_trackers/dri/drm/Makefile.sources
+++ b/src/gallium/state_trackers/dri/drm/Makefile.sources
@@ -2,4 +2,5 @@ C_SOURCES := \
dri_context.c \
dri_screen.c \
dri_drawable.c \
+ dri_query_renderer.c \
dri2.c
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index 973773c..c6a61bc 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -41,6 +41,7 @@
#include "dri_screen.h"
#include "dri_context.h"
#include "dri_drawable.h"
+#include "dri_query_renderer.h"
#include "dri2_buffer.h"
/**
@@ -1014,6 +1015,7 @@ static const __DRIextension *dri_screen_extensions[] = {
&driTexBufferExtension.base,
&dri2FlushExtension.base,
&dri2ImageExtension.base,
+ &dri2RendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
&dri2ThrottleExtension.base,
NULL
diff --git a/src/gallium/state_trackers/dri/drm/dri_query_renderer.c b/src/gallium/state_trackers/dri/drm/dri_query_renderer.c
new file mode 120000
index 0000000..3e6a0d2
--- /dev/null
+++ b/src/gallium/state_trackers/dri/drm/dri_query_renderer.c
@@ -0,0 +1 @@
+../common/dri_query_renderer.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/Makefile.sources b/src/gallium/state_trackers/dri/sw/Makefile.sources
index 1255934..ccbfe94 100644
--- a/src/gallium/state_trackers/dri/sw/Makefile.sources
+++ b/src/gallium/state_trackers/dri/sw/Makefile.sources
@@ -2,4 +2,5 @@ C_SOURCES := \
dri_context.c \
dri_screen.c \
dri_drawable.c \
+ dri_query_renderer.c \
drisw.c
diff --git a/src/gallium/state_trackers/dri/sw/dri_query_renderer.c b/src/gallium/state_trackers/dri/sw/dri_query_renderer.c
new file mode 120000
index 0000000..3e6a0d2
--- /dev/null
+++ b/src/gallium/state_trackers/dri/sw/dri_query_renderer.c
@@ -0,0 +1 @@
+../common/dri_query_renderer.c
\ No newline at end of file
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index 6f50b05..4754caf 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -45,6 +45,7 @@
#include "dri_screen.h"
#include "dri_context.h"
#include "dri_drawable.h"
+#include "dri_query_renderer.h"
DEBUG_GET_ONCE_BOOL_OPTION(swrast_no_present, "SWRAST_NO_PRESENT", FALSE);
static boolean swrast_no_present = FALSE;
@@ -331,6 +332,7 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
static const __DRIextension *drisw_screen_extensions[] = {
&driTexBufferExtension.base,
+ &dri2RendererQueryExtension.base,
NULL
};
--
1.9.0
More information about the mesa-dev
mailing list