[Mesa-dev] [PATCH 09/92] ddebug: handle some cases of non-TGSI shaders
Nicolai Hähnle
nhaehnle at gmail.com
Mon Jun 26 14:09:48 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/gallium/drivers/ddebug/dd_context.c | 6 ++++--
src/gallium/drivers/ddebug/dd_draw.c | 9 +++++++--
src/gallium/drivers/ddebug/dd_screen.c | 11 +++++++++++
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c
index 1ace9e5..6b1ddc9 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -307,37 +307,39 @@ DD_CSO_DELETE(vertex_elements)
} \
\
static void \
dd_context_delete_##name##_state(struct pipe_context *_pipe, void *state) \
{ \
struct dd_context *dctx = dd_context(_pipe); \
struct pipe_context *pipe = dctx->pipe; \
struct dd_state *hstate = state; \
\
pipe->delete_##name##_state(pipe, hstate->cso); \
- tgsi_free_tokens(hstate->state.shader.tokens); \
+ if (hstate->state.shader.type == PIPE_SHADER_IR_TGSI) \
+ tgsi_free_tokens(hstate->state.shader.tokens); \
FREE(hstate); \
}
#define DD_SHADER(NAME, name) \
static void * \
dd_context_create_##name##_state(struct pipe_context *_pipe, \
const struct pipe_shader_state *state) \
{ \
struct pipe_context *pipe = dd_context(_pipe)->pipe; \
struct dd_state *hstate = CALLOC_STRUCT(dd_state); \
\
if (!hstate) \
return NULL; \
hstate->cso = pipe->create_##name##_state(pipe, state); \
hstate->state.shader = *state; \
- hstate->state.shader.tokens = tgsi_dup_tokens(state->tokens); \
+ if (hstate->state.shader.type == PIPE_SHADER_IR_TGSI) \
+ hstate->state.shader.tokens = tgsi_dup_tokens(state->tokens); \
return hstate; \
} \
\
DD_SHADER_NOCREATE(NAME, name)
DD_SHADER(FRAGMENT, fs)
DD_SHADER(VERTEX, vs)
DD_SHADER(GEOMETRY, gs)
DD_SHADER(TESS_CTRL, tcs)
DD_SHADER(TESS_EVAL, tes)
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index 7edf6af..c9d3a62 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -91,22 +91,27 @@ dd_num_active_viewports(struct dd_draw_state *dstate)
if (dstate->shaders[PIPE_SHADER_GEOMETRY])
tokens = dstate->shaders[PIPE_SHADER_GEOMETRY]->state.shader.tokens;
else if (dstate->shaders[PIPE_SHADER_TESS_EVAL])
tokens = dstate->shaders[PIPE_SHADER_TESS_EVAL]->state.shader.tokens;
else if (dstate->shaders[PIPE_SHADER_VERTEX])
tokens = dstate->shaders[PIPE_SHADER_VERTEX]->state.shader.tokens;
else
return 1;
- tgsi_scan_shader(tokens, &info);
- return info.writes_viewport_index ? PIPE_MAX_VIEWPORTS : 1;
+ if (tokens) {
+ tgsi_scan_shader(tokens, &info);
+ if (info.writes_viewport_index)
+ return PIPE_MAX_VIEWPORTS;
+ }
+
+ return 1;
}
#define COLOR_RESET "\033[0m"
#define COLOR_SHADER "\033[1;32m"
#define COLOR_STATE "\033[1;33m"
#define DUMP(name, var) do { \
fprintf(f, COLOR_STATE #name ": " COLOR_RESET); \
util_dump_##name(f, var); \
fprintf(f, "\n"); \
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index 9642532..a5d2be1 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -48,20 +48,30 @@ dd_screen_get_vendor(struct pipe_screen *_screen)
}
static const char *
dd_screen_get_device_vendor(struct pipe_screen *_screen)
{
struct pipe_screen *screen = dd_screen(_screen)->screen;
return screen->get_device_vendor(screen);
}
+static const void *
+dd_screen_get_compiler_options(struct pipe_screen *_screen,
+ enum pipe_shader_ir ir,
+ enum pipe_shader_type shader)
+{
+ struct pipe_screen *screen = dd_screen(_screen)->screen;
+
+ return screen->get_compiler_options(screen, ir, shader);
+}
+
static struct disk_cache *
dd_screen_get_disk_shader_cache(struct pipe_screen *_screen)
{
struct pipe_screen *screen = dd_screen(_screen)->screen;
return screen->get_disk_shader_cache(screen);
}
static int
dd_screen_get_param(struct pipe_screen *_screen,
@@ -404,20 +414,21 @@ ddebug_screen_create(struct pipe_screen *screen)
dscreen->base.resource_from_handle = dd_screen_resource_from_handle;
SCR_INIT(resource_from_user_memory);
dscreen->base.resource_get_handle = dd_screen_resource_get_handle;
SCR_INIT(resource_changed);
dscreen->base.resource_destroy = dd_screen_resource_destroy;
SCR_INIT(flush_frontbuffer);
SCR_INIT(fence_reference);
SCR_INIT(fence_finish);
SCR_INIT(get_driver_query_info);
SCR_INIT(get_driver_query_group_info);
+ SCR_INIT(get_compiler_options);
#undef SCR_INIT
dscreen->screen = screen;
dscreen->timeout_ms = timeout;
dscreen->mode = mode;
dscreen->no_flush = no_flush;
dscreen->verbose = strstr(option, "verbose") != NULL;
dscreen->apitrace_dump_call = apitrace_dump_call;
--
2.9.3
More information about the mesa-dev
mailing list