[Mesa-dev] [PATCH 03/11] ddebug: extract dd_dump_shader
Nicolai Hähnle
nhaehnle at gmail.com
Mon May 8 15:35:53 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
Will be re-used for compute shaders.
---
src/gallium/drivers/ddebug/dd_draw.c | 156 ++++++++++++++++++-----------------
1 file changed, 82 insertions(+), 74 deletions(-)
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index 6e96c72..291ce89 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -190,32 +190,111 @@ dd_dump_render_condition(struct dd_draw_state *dstate, FILE *f)
if (dstate->render_cond.query) {
fprintf(f, "render condition:\n");
DUMP_M(query, &dstate->render_cond, query);
DUMP_M(uint, &dstate->render_cond, condition);
DUMP_M(uint, &dstate->render_cond, mode);
fprintf(f, "\n");
}
}
static void
-dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE *f)
+dd_dump_shader(struct dd_draw_state *dstate, enum pipe_shader_type sh, FILE *f)
{
- int sh, i;
+ int i;
const char *shader_str[PIPE_SHADER_TYPES];
shader_str[PIPE_SHADER_VERTEX] = "VERTEX";
shader_str[PIPE_SHADER_TESS_CTRL] = "TESS_CTRL";
shader_str[PIPE_SHADER_TESS_EVAL] = "TESS_EVAL";
shader_str[PIPE_SHADER_GEOMETRY] = "GEOMETRY";
shader_str[PIPE_SHADER_FRAGMENT] = "FRAGMENT";
shader_str[PIPE_SHADER_COMPUTE] = "COMPUTE";
+ if (sh == PIPE_SHADER_TESS_CTRL &&
+ !dstate->shaders[PIPE_SHADER_TESS_CTRL] &&
+ dstate->shaders[PIPE_SHADER_TESS_EVAL])
+ fprintf(f, "tess_state: {default_outer_level = {%f, %f, %f, %f}, "
+ "default_inner_level = {%f, %f}}\n",
+ dstate->tess_default_levels[0],
+ dstate->tess_default_levels[1],
+ dstate->tess_default_levels[2],
+ dstate->tess_default_levels[3],
+ dstate->tess_default_levels[4],
+ dstate->tess_default_levels[5]);
+
+ if (sh == PIPE_SHADER_FRAGMENT)
+ if (dstate->rs) {
+ unsigned num_viewports = dd_num_active_viewports(dstate);
+
+ if (dstate->rs->state.rs.clip_plane_enable)
+ DUMP(clip_state, &dstate->clip_state);
+
+ for (i = 0; i < num_viewports; i++)
+ DUMP_I(viewport_state, &dstate->viewports[i], i);
+
+ if (dstate->rs->state.rs.scissor)
+ for (i = 0; i < num_viewports; i++)
+ DUMP_I(scissor_state, &dstate->scissors[i], i);
+
+ DUMP(rasterizer_state, &dstate->rs->state.rs);
+
+ if (dstate->rs->state.rs.poly_stipple_enable)
+ DUMP(poly_stipple, &dstate->polygon_stipple);
+ fprintf(f, "\n");
+ }
+
+ if (!dstate->shaders[sh])
+ return;
+
+ fprintf(f, COLOR_SHADER "begin shader: %s" COLOR_RESET "\n", shader_str[sh]);
+ DUMP(shader_state, &dstate->shaders[sh]->state.shader);
+
+ for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++)
+ if (dstate->constant_buffers[sh][i].buffer ||
+ dstate->constant_buffers[sh][i].user_buffer) {
+ DUMP_I(constant_buffer, &dstate->constant_buffers[sh][i], i);
+ if (dstate->constant_buffers[sh][i].buffer)
+ DUMP_M(resource, &dstate->constant_buffers[sh][i], buffer);
+ }
+
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
+ if (dstate->sampler_states[sh][i])
+ DUMP_I(sampler_state, &dstate->sampler_states[sh][i]->state.sampler, i);
+
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
+ if (dstate->sampler_views[sh][i]) {
+ DUMP_I(sampler_view, dstate->sampler_views[sh][i], i);
+ DUMP_M(resource, dstate->sampler_views[sh][i], texture);
+ }
+
+ for (i = 0; i < PIPE_MAX_SHADER_IMAGES; i++)
+ if (dstate->shader_images[sh][i].resource) {
+ DUMP_I(image_view, &dstate->shader_images[sh][i], i);
+ if (dstate->shader_images[sh][i].resource)
+ DUMP_M(resource, &dstate->shader_images[sh][i], resource);
+ }
+
+ for (i = 0; i < PIPE_MAX_SHADER_BUFFERS; i++)
+ if (dstate->shader_buffers[sh][i].buffer) {
+ DUMP_I(shader_buffer, &dstate->shader_buffers[sh][i], i);
+ if (dstate->shader_buffers[sh][i].buffer)
+ DUMP_M(resource, &dstate->shader_buffers[sh][i], buffer);
+ }
+
+ fprintf(f, COLOR_SHADER "end shader: %s" COLOR_RESET "\n\n", shader_str[sh]);
+}
+
+static void
+dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE *f)
+{
+ int sh, i;
+
DUMP(draw_info, info);
if (info->indexed) {
DUMP(index_buffer, &dstate->index_buffer);
if (dstate->index_buffer.buffer)
DUMP_M(resource, &dstate->index_buffer, buffer);
}
if (info->count_from_stream_output)
DUMP_M(stream_output_target, info,
count_from_stream_output);
if (info->indirect)
@@ -251,92 +330,21 @@ dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE
DUMP_I(stream_output_target, dstate->so_targets[i], i);
DUMP_M(resource, dstate->so_targets[i], buffer);
fprintf(f, " offset = %i\n", dstate->so_offsets[i]);
}
fprintf(f, "\n");
for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
if (sh == PIPE_SHADER_COMPUTE)
continue;
- if (sh == PIPE_SHADER_TESS_CTRL &&
- !dstate->shaders[PIPE_SHADER_TESS_CTRL] &&
- dstate->shaders[PIPE_SHADER_TESS_EVAL])
- fprintf(f, "tess_state: {default_outer_level = {%f, %f, %f, %f}, "
- "default_inner_level = {%f, %f}}\n",
- dstate->tess_default_levels[0],
- dstate->tess_default_levels[1],
- dstate->tess_default_levels[2],
- dstate->tess_default_levels[3],
- dstate->tess_default_levels[4],
- dstate->tess_default_levels[5]);
-
- if (sh == PIPE_SHADER_FRAGMENT)
- if (dstate->rs) {
- unsigned num_viewports = dd_num_active_viewports(dstate);
-
- if (dstate->rs->state.rs.clip_plane_enable)
- DUMP(clip_state, &dstate->clip_state);
-
- for (i = 0; i < num_viewports; i++)
- DUMP_I(viewport_state, &dstate->viewports[i], i);
-
- if (dstate->rs->state.rs.scissor)
- for (i = 0; i < num_viewports; i++)
- DUMP_I(scissor_state, &dstate->scissors[i], i);
-
- DUMP(rasterizer_state, &dstate->rs->state.rs);
-
- if (dstate->rs->state.rs.poly_stipple_enable)
- DUMP(poly_stipple, &dstate->polygon_stipple);
- fprintf(f, "\n");
- }
-
- if (!dstate->shaders[sh])
- continue;
-
- fprintf(f, COLOR_SHADER "begin shader: %s" COLOR_RESET "\n", shader_str[sh]);
- DUMP(shader_state, &dstate->shaders[sh]->state.shader);
-
- for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++)
- if (dstate->constant_buffers[sh][i].buffer ||
- dstate->constant_buffers[sh][i].user_buffer) {
- DUMP_I(constant_buffer, &dstate->constant_buffers[sh][i], i);
- if (dstate->constant_buffers[sh][i].buffer)
- DUMP_M(resource, &dstate->constant_buffers[sh][i], buffer);
- }
-
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
- if (dstate->sampler_states[sh][i])
- DUMP_I(sampler_state, &dstate->sampler_states[sh][i]->state.sampler, i);
-
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
- if (dstate->sampler_views[sh][i]) {
- DUMP_I(sampler_view, dstate->sampler_views[sh][i], i);
- DUMP_M(resource, dstate->sampler_views[sh][i], texture);
- }
-
- for (i = 0; i < PIPE_MAX_SHADER_IMAGES; i++)
- if (dstate->shader_images[sh][i].resource) {
- DUMP_I(image_view, &dstate->shader_images[sh][i], i);
- if (dstate->shader_images[sh][i].resource)
- DUMP_M(resource, &dstate->shader_images[sh][i], resource);
- }
-
- for (i = 0; i < PIPE_MAX_SHADER_BUFFERS; i++)
- if (dstate->shader_buffers[sh][i].buffer) {
- DUMP_I(shader_buffer, &dstate->shader_buffers[sh][i], i);
- if (dstate->shader_buffers[sh][i].buffer)
- DUMP_M(resource, &dstate->shader_buffers[sh][i], buffer);
- }
-
- fprintf(f, COLOR_SHADER "end shader: %s" COLOR_RESET "\n\n", shader_str[sh]);
+ dd_dump_shader(dstate, sh, f);
}
if (dstate->dsa)
DUMP(depth_stencil_alpha_state, &dstate->dsa->state.dsa);
DUMP(stencil_ref, &dstate->stencil_ref);
if (dstate->blend)
DUMP(blend_state, &dstate->blend->state.blend);
DUMP(blend_color, &dstate->blend_color);
--
2.9.3
More information about the mesa-dev
mailing list