mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-17 22:10:21 +01:00
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 <emil.l.velikov@gmail.com>
This commit is contained in:
parent
87d3ae0b45
commit
76f07362ea
3 changed files with 92 additions and 19 deletions
|
|
@ -34,21 +34,29 @@
|
|||
|
||||
#include "drivers/common/meta.h"
|
||||
|
||||
const char const *nouveau_vendor_string = "Nouveau";
|
||||
|
||||
const char *
|
||||
nouveau_get_renderer_string(unsigned chipset)
|
||||
{
|
||||
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)
|
||||
{
|
||||
static char buffer[128];
|
||||
char hardware_name[32];
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue