[Mesa-dev] [PATCH] RFC: gallium/dri2/st: start adding support for GLX_MESA_query_renderer
Marek Olšák
maraeo at gmail.com
Sat Oct 26 17:24:23 CEST 2013
FYI, the flags psp->max_gl_xxx_version are incorrect for most (all?)
Gallium drivers.
Marek
On Sat, Oct 26, 2013 at 1:55 PM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> + nvc0 support for demo purposes, will split up later.
>
> So I've done this by just adding pipe cap queries for this stuff,
> we might want to add another high level query to say if we are
> bothered exposing this stuff.
>
> nouveau can't get the pci device id as it doesn't seem to use them in
> userspace at all.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 10 +++++
> src/gallium/include/pipe/p_defines.h | 7 ++-
> src/gallium/state_trackers/dri/drm/dri2.c | 61 ++++++++++++++++++++++++++
> 3 files changed, 77 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> index ad20372..a692e2b 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -171,6 +171,16 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
> return PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50;
> case PIPE_CAP_ENDIANNESS:
> return PIPE_ENDIAN_LITTLE;
> + case PIPE_CAP_VENDOR_ID:
> + return 0x10de;
> + case PIPE_CAP_DEVICE_ID:
> + return 0x10de;
> + case PIPE_CAP_UMA:
> + return 0;
> + case PIPE_CAP_ACCELERATED:
> + return 1;
> + case PIPE_CAP_VIDEO_MEMORY:
> + return nouveau_screen(pscreen)->device->vram_size / (1024*1024);
> default:
> NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
> return 0;
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index 63869c9..38d36b7 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -512,7 +512,12 @@ enum pipe_cap {
> PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK = 82,
> PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE = 83,
> PIPE_CAP_MAX_VIEWPORTS = 84,
> - PIPE_CAP_ENDIANNESS = 85
> + PIPE_CAP_ENDIANNESS = 85,
> + PIPE_CAP_VENDOR_ID = 86,
> + PIPE_CAP_DEVICE_ID = 87,
> + PIPE_CAP_ACCELERATED = 88,
> + PIPE_CAP_VIDEO_MEMORY = 89,
> + PIPE_CAP_UMA = 90,
> };
>
> #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
> diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
> index 5647968..87c4756 100644
> --- a/src/gallium/state_trackers/dri/drm/dri2.c
> +++ b/src/gallium/state_trackers/dri/drm/dri2.c
> @@ -39,6 +39,7 @@
> #include "dri_drawable.h"
> #include "dri2_buffer.h"
>
> +#include "utils.h"
> /**
> * DRI2 flush extension.
> */
> @@ -845,6 +846,65 @@ static struct __DRIimageExtensionRec dri2ImageExtension = {
> dri2_from_planar,
> };
>
> +static int
> +dri2_query_renderer_integer(__DRIscreen *_screen, int param, int *value)
> +{
> + struct dri_screen *screen = dri_screen(_screen);
> + switch (param) {
> + case __DRI2_RENDERER_VENDOR_ID:
> + value[0] = screen->base.screen->get_param(screen->base.screen, PIPE_CAP_VENDOR_ID);
> + return 0;
> + case __DRI2_RENDERER_DEVICE_ID:
> + value[0] = screen->base.screen->get_param(screen->base.screen, PIPE_CAP_DEVICE_ID);
> + return 0;
> + case __DRI2_RENDERER_ACCELERATED:
> + value[0] = screen->base.screen->get_param(screen->base.screen, PIPE_CAP_ACCELERATED);
> + return 0;
> +
> + case __DRI2_RENDERER_VIDEO_MEMORY:
> + value[0] = screen->base.screen->get_param(screen->base.screen, PIPE_CAP_VIDEO_MEMORY);
> + return 0;
> +
> + case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
> + value[0] = 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;
> +}
> +
> +static struct __DRI2rendererQueryExtensionRec driRendererQueryExtension = {
> + .base = { __DRI2_RENDERER_QUERY, 1 },
> +
> + .queryInteger = dri2_query_renderer_integer,
> + .queryString = dri2_query_renderer_string
> +};
> +
> /*
> * Backend function init_screen.
> */
> @@ -853,6 +913,7 @@ static const __DRIextension *dri_screen_extensions[] = {
> &driTexBufferExtension.base,
> &dri2FlushExtension.base,
> &dri2ImageExtension.base,
> + &driRendererQueryExtension.base,
> &dri2ConfigQueryExtension.base,
> &dri2ThrottleExtension.base,
> NULL
> --
> 1.8.3.1
>
> _______________________________________________
> 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