anv: switch to use brw's prog_data source_hash

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Michael Cheng <michael.cheng@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33643>
This commit is contained in:
Lionel Landwerlin 2025-02-12 13:06:22 +02:00 committed by Marge Bot
parent da098b76a4
commit 84f96a0199
6 changed files with 82 additions and 74 deletions

View file

@ -157,17 +157,21 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer,
if (type == INTEL_SNAPSHOT_COMPUTE && cmd_buffer->state.compute.base.pipeline) {
const struct anv_compute_pipeline *pipeline =
anv_pipeline_to_compute(cmd_buffer->state.compute.base.pipeline);
snapshot->cs = pipeline->source_hash;
snapshot->cs = pipeline->cs->prog_data->source_hash;
} else if (type == INTEL_SNAPSHOT_DRAW && cmd_buffer->state.gfx.base.pipeline) {
const struct anv_graphics_pipeline *pipeline =
anv_pipeline_to_graphics(cmd_buffer->state.gfx.base.pipeline);
snapshot->vs = pipeline->base.source_hashes[MESA_SHADER_VERTEX];
snapshot->tcs = pipeline->base.source_hashes[MESA_SHADER_TESS_CTRL];
snapshot->tes = pipeline->base.source_hashes[MESA_SHADER_TESS_EVAL];
snapshot->gs = pipeline->base.source_hashes[MESA_SHADER_GEOMETRY];
snapshot->fs = pipeline->base.source_hashes[MESA_SHADER_FRAGMENT];
snapshot->ms = pipeline->base.source_hashes[MESA_SHADER_MESH];
snapshot->ts = pipeline->base.source_hashes[MESA_SHADER_TASK];
#define SHADER_SOURCE_HASH(_name) \
(pipeline->base.shaders[MESA_SHADER_##VERTEX] ? \
pipeline->base.shaders[MESA_SHADER_##VERTEX]->prog_data->source_hash : 0)
snapshot->vs = SHADER_SOURCE_HASH(VERTEX);
snapshot->tcs = SHADER_SOURCE_HASH(TESS_CTRL);
snapshot->tes = SHADER_SOURCE_HASH(TESS_EVAL);
snapshot->gs = SHADER_SOURCE_HASH(GEOMETRY);
snapshot->fs = SHADER_SOURCE_HASH(FRAGMENT);
snapshot->ms = SHADER_SOURCE_HASH(MESH);
snapshot->ts = SHADER_SOURCE_HASH(TASK);
#undef SHADER_SOURCE_HASH
}
}
@ -219,18 +223,22 @@ state_changed(struct anv_cmd_buffer *cmd_buffer,
const struct anv_compute_pipeline *cs_pipe =
anv_pipeline_to_compute(cmd_buffer->state.compute.base.pipeline);
assert(cs_pipe);
cs = cs_pipe->source_hash;
cs = cs_pipe->cs->prog_data->source_hash;
} else if (type == INTEL_SNAPSHOT_DRAW) {
const struct anv_graphics_pipeline *gfx =
anv_pipeline_to_graphics(cmd_buffer->state.gfx.base.pipeline);
assert(gfx);
vs = gfx->base.source_hashes[MESA_SHADER_VERTEX];
tcs = gfx->base.source_hashes[MESA_SHADER_TESS_CTRL];
tes = gfx->base.source_hashes[MESA_SHADER_TESS_EVAL];
gs = gfx->base.source_hashes[MESA_SHADER_GEOMETRY];
fs = gfx->base.source_hashes[MESA_SHADER_FRAGMENT];
ms = gfx->base.source_hashes[MESA_SHADER_MESH];
ts = gfx->base.source_hashes[MESA_SHADER_TASK];
#define SHADER_SOURCE_HASH(_name) \
(gfx->base.shaders[MESA_SHADER_##VERTEX] ? \
gfx->base.shaders[MESA_SHADER_##VERTEX]->prog_data->source_hash : 0)
vs = SHADER_SOURCE_HASH(VERTEX);
tcs = SHADER_SOURCE_HASH(TESS_CTRL);
tes = SHADER_SOURCE_HASH(TESS_EVAL);
gs = SHADER_SOURCE_HASH(GEOMETRY);
fs = SHADER_SOURCE_HASH(FRAGMENT);
ms = SHADER_SOURCE_HASH(MESH);
ts = SHADER_SOURCE_HASH(TASK);
#undef SHADER_SOURCE_HASH
}
/* else blorp, all programs NULL */

View file

@ -1871,7 +1871,6 @@ anv_graphics_pipeline_load_cached_shaders(struct anv_graphics_base_pipeline *pip
stages[s].bin = stages[s].imported.bin;
pipeline->shaders[s] = anv_shader_bin_ref(stages[s].imported.bin);
pipeline->source_hashes[s] = stages[s].source_hash;
imported++;
}
}
@ -1892,7 +1891,6 @@ anv_graphics_pipeline_load_cached_shaders(struct anv_graphics_base_pipeline *pip
*/
if (stages[s].imported.bin == NULL || link_optimize)
anv_pipeline_add_executables(&pipeline->base, &stages[s]);
pipeline->source_hashes[s] = stages[s].source_hash;
}
return true;
} else if (found > 0) {
@ -2446,7 +2444,6 @@ anv_graphics_pipeline_compile(struct anv_graphics_base_pipeline *pipeline,
}
anv_pipeline_add_executables(&pipeline->base, stage);
pipeline->source_hashes[s] = stage->source_hash;
pipeline->shaders[s] = stage->bin;
ralloc_free(stage_ctx);
@ -2471,7 +2468,6 @@ anv_graphics_pipeline_compile(struct anv_graphics_base_pipeline *pipeline,
struct anv_pipeline_stage *stage = &stages[s];
pipeline->source_hashes[s] = stage->source_hash;
pipeline->shaders[s] = anv_shader_bin_ref(stage->imported.bin);
}
@ -2638,7 +2634,6 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
anv_pipeline_account_shader(&pipeline->base, stage.bin);
anv_pipeline_add_executables(&pipeline->base, &stage);
pipeline->source_hash = stage.source_hash;
ralloc_free(mem_ctx);
@ -2795,6 +2790,7 @@ anv_graphics_pipeline_emit(struct anv_graphics_pipeline *pipeline,
if (anv_pipeline_is_primitive(pipeline)) {
const struct brw_vs_prog_data *vs_prog_data = get_vs_prog_data(pipeline);
const struct brw_wm_prog_data *wm_prog_data = get_wm_prog_data(pipeline);
/* The total number of vertex elements we need to program. We might need
* a couple more to implement some of the draw parameters.
@ -2823,6 +2819,9 @@ anv_graphics_pipeline_emit(struct anv_graphics_pipeline *pipeline,
pipeline->instance_multiplier = 1;
if (pipeline->view_mask && !uses_primitive_replication)
pipeline->instance_multiplier = util_bitcount(pipeline->view_mask);
pipeline->vs_source_hash = vs_prog_data->base.base.source_hash;
pipeline->fs_source_hash = wm_prog_data ? wm_prog_data->base.source_hash : 0;
} else {
assert(anv_pipeline_is_mesh(pipeline));
/* TODO(mesh): Mesh vs. Multiview with Instancing. */
@ -2951,7 +2950,7 @@ anv_graphics_pipeline_import_lib(struct anv_graphics_base_pipeline *pipeline,
/* Always import the shader sha1, this will be used for cache lookup. */
memcpy(stages[s].shader_sha1, lib->retained_shaders[s].shader_sha1,
sizeof(stages[s].shader_sha1));
stages[s].source_hash = lib->base.source_hashes[s];
stages[s].source_hash = lib->base.shaders[s]->prog_data->source_hash;
stages[s].subgroup_size_type = lib->retained_shaders[s].subgroup_size_type;
stages[s].imported.nir = lib->retained_shaders[s].nir;
@ -4359,10 +4358,11 @@ VkResult anv_GetPipelineExecutableStatisticsKHR(
vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) {
uint32_t hash = pipeline->type == ANV_PIPELINE_COMPUTE ?
anv_pipeline_to_compute(pipeline)->source_hash :
anv_pipeline_to_compute(pipeline)->cs->prog_data->source_hash :
(pipeline->type == ANV_PIPELINE_GRAPHICS_LIB ||
pipeline->type == ANV_PIPELINE_GRAPHICS) ?
anv_pipeline_to_graphics_base(pipeline)->source_hashes[exe->stage] :
anv_pipeline_to_graphics_base(pipeline)->shaders[
exe->stage]->prog_data->source_hash:
0 /* No source hash for ray tracing */;
WRITE_STR(stat->name, "Source hash");
WRITE_STR(stat->description,

View file

@ -4819,11 +4819,6 @@ struct anv_graphics_base_pipeline {
/* Shaders */
struct anv_shader_bin * shaders[ANV_GRAPHICS_SHADER_STAGE_COUNT];
/* A small hash based of shader_info::source_sha1 for identifying
* shaders in renderdoc/shader-db.
*/
uint32_t source_hashes[ANV_GRAPHICS_SHADER_STAGE_COUNT];
/* Feedback index in
* VkPipelineCreationFeedbackCreateInfo::pPipelineStageCreationFeedbacks
*
@ -4891,6 +4886,9 @@ struct anv_gfx_state_ptr {
struct anv_graphics_pipeline {
struct anv_graphics_base_pipeline base;
uint32_t vs_source_hash;
uint32_t fs_source_hash;
struct vk_vertex_input_state vertex_input;
struct vk_sample_locations_state sample_locations;
struct vk_dynamic_graphics_state dynamic_state;
@ -5039,11 +5037,6 @@ struct anv_compute_pipeline {
uint32_t compute_walker[40];
} gfx125;
};
/* A small hash based of shader_info::source_sha1 for identifying shaders
* in renderdoc/shader-db.
*/
uint32_t source_hash;
};
struct anv_rt_shader_group {

View file

@ -75,36 +75,38 @@ end_debug_marker(VkCommandBuffer commandBuffer)
struct anv_cmd_compute_state *comp_state = &cmd_buffer->state.compute;
struct anv_compute_pipeline *pipeline =
anv_pipeline_to_compute(comp_state->base.pipeline);
const struct brw_cs_prog_data *cs_prog_data =
brw_cs_prog_data_const(pipeline->cs->prog_data);
cmd_buffer->state.rt.debug_marker_count--;
switch (cmd_buffer->state.rt.debug_markers[cmd_buffer->state.rt.debug_marker_count]) {
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_TOP:
trace_intel_end_as_build(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_BUILD_LEAVES:
trace_intel_end_as_build_leaves(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_MORTON_GENERATE:
trace_intel_end_as_morton_generate(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_MORTON_SORT:
trace_intel_end_as_morton_sort(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_LBVH_BUILD_INTERNAL:
trace_intel_end_as_lbvh_build_internal(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_PLOC_BUILD_INTERNAL:
trace_intel_end_as_ploc_build_internal(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
case VK_ACCELERATION_STRUCTURE_BUILD_STEP_ENCODE:
trace_intel_end_as_encode(&cmd_buffer->trace,
pipeline->source_hash);
cs_prog_data->base.source_hash);
break;
default:
unreachable("Invalid build step");
@ -726,6 +728,8 @@ genX(CmdCopyAccelerationStructureKHR)(
ANV_FROM_HANDLE(anv_pipeline, anv_pipeline, pipeline);
struct anv_compute_pipeline *compute_pipeline =
anv_pipeline_to_compute(anv_pipeline);
const struct brw_cs_prog_data *cs_prog_data =
brw_cs_prog_data_const(compute_pipeline->cs->prog_data);
struct anv_cmd_saved_state saved;
anv_cmd_buffer_save_state(cmd_buffer,
@ -770,7 +774,7 @@ genX(CmdCopyAccelerationStructureKHR)(
anv_cmd_buffer_restore_state(cmd_buffer, &saved);
trace_intel_end_as_copy(&cmd_buffer->trace,
compute_pipeline->source_hash);
cs_prog_data->base.source_hash);
}
void
@ -798,6 +802,8 @@ genX(CmdCopyAccelerationStructureToMemoryKHR)(
ANV_FROM_HANDLE(anv_pipeline, anv_pipeline, pipeline);
struct anv_compute_pipeline *compute_pipeline =
anv_pipeline_to_compute(anv_pipeline);
const struct brw_cs_prog_data *cs_prog_data =
brw_cs_prog_data_const(compute_pipeline->cs->prog_data);
struct anv_cmd_saved_state saved;
anv_cmd_buffer_save_state(cmd_buffer,
@ -846,7 +852,7 @@ genX(CmdCopyAccelerationStructureToMemoryKHR)(
anv_cmd_buffer_restore_state(cmd_buffer, &saved);
trace_intel_end_as_copy(&cmd_buffer->trace,
compute_pipeline->source_hash);
cs_prog_data->base.source_hash);
}
void
@ -873,6 +879,8 @@ genX(CmdCopyMemoryToAccelerationStructureKHR)(
ANV_FROM_HANDLE(anv_pipeline, anv_pipeline, pipeline);
struct anv_compute_pipeline *compute_pipeline =
anv_pipeline_to_compute(anv_pipeline);
const struct brw_cs_prog_data *cs_prog_data =
brw_cs_prog_data_const(compute_pipeline->cs->prog_data);
struct anv_cmd_saved_state saved;
anv_cmd_buffer_save_state(cmd_buffer,
@ -904,7 +912,7 @@ genX(CmdCopyMemoryToAccelerationStructureKHR)(
anv_cmd_buffer_restore_state(cmd_buffer, &saved);
trace_intel_end_as_copy(&cmd_buffer->trace,
compute_pipeline->source_hash);
cs_prog_data->base.source_hash);
}
void

View file

@ -642,7 +642,7 @@ void genX(CmdDispatchBase)(
if (cmd_buffer->state.rt.debug_marker_count == 0) {
trace_intel_end_compute(&cmd_buffer->trace,
groupCountX, groupCountY, groupCountZ,
pipeline->source_hash);
prog_data->base.source_hash);
}
}
@ -703,7 +703,7 @@ emit_unaligned_cs_walker(
if (cmd_buffer->state.rt.debug_marker_count == 0) {
trace_intel_end_compute(&cmd_buffer->trace,
groupCountX, groupCountY, groupCountZ,
pipeline->source_hash);
prog_data->base.source_hash);
}
}
@ -809,7 +809,7 @@ genX(cmd_buffer_dispatch_indirect)(struct anv_cmd_buffer *cmd_buffer,
if (cmd_buffer->state.rt.debug_marker_count == 0) {
trace_intel_end_compute_indirect(&cmd_buffer->trace,
anv_address_utrace(indirect_addr),
pipeline->source_hash);
prog_data->base.source_hash);
}
}

View file

@ -1131,8 +1131,8 @@ void genX(CmdDraw)(
cmd_buffer_post_draw_wa(cmd_buffer, vertexCount, SEQUENTIAL);
trace_intel_end_draw(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
void genX(CmdDrawMultiEXT)(
@ -1188,8 +1188,8 @@ void genX(CmdDrawMultiEXT)(
SEQUENTIAL);
trace_intel_end_draw_multi(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
#else
vk_foreach_multi_draw(draw, i, pVertexInfo, drawCount, stride) {
@ -1224,8 +1224,8 @@ void genX(CmdDrawMultiEXT)(
SEQUENTIAL);
trace_intel_end_draw_multi(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
#endif
}
@ -1296,8 +1296,8 @@ void genX(CmdDrawIndexed)(
cmd_buffer_post_draw_wa(cmd_buffer, indexCount, RANDOM);
trace_intel_end_draw_indexed(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
void genX(CmdDrawMultiIndexedEXT)(
@ -1369,8 +1369,8 @@ void genX(CmdDrawMultiIndexedEXT)(
RANDOM);
trace_intel_end_draw_indexed_multi(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
emitted = false;
}
} else {
@ -1409,8 +1409,8 @@ void genX(CmdDrawMultiIndexedEXT)(
RANDOM);
trace_intel_end_draw_indexed_multi(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
}
} else {
@ -1445,8 +1445,8 @@ void genX(CmdDrawMultiIndexedEXT)(
RANDOM);
trace_intel_end_draw_indexed_multi(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
}
#else
@ -1484,8 +1484,8 @@ void genX(CmdDrawMultiIndexedEXT)(
RANDOM);
trace_intel_end_draw_indexed_multi(&cmd_buffer->trace, count,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
#endif
}
@ -1606,8 +1606,8 @@ void genX(CmdDrawIndirectByteCountEXT)(
trace_intel_end_draw_indirect_byte_count(&cmd_buffer->trace,
instanceCount * pipeline->instance_multiplier,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
static void
@ -1941,8 +1941,8 @@ void genX(CmdDrawIndirect)(
}
trace_intel_end_draw_indirect(&cmd_buffer->trace, drawCount,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
void genX(CmdDrawIndexedIndirect)(
@ -1994,8 +1994,8 @@ void genX(CmdDrawIndexedIndirect)(
}
trace_intel_end_draw_indexed_indirect(&cmd_buffer->trace, drawCount,
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
#define MI_PREDICATE_SRC0 0x2400
@ -2203,8 +2203,8 @@ void genX(CmdDrawIndirectCount)(
trace_intel_end_draw_indirect_count(&cmd_buffer->trace,
anv_address_utrace(count_address),
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
void genX(CmdDrawIndexedIndirectCount)(
@ -2264,9 +2264,8 @@ void genX(CmdDrawIndexedIndirectCount)(
trace_intel_end_draw_indexed_indirect_count(&cmd_buffer->trace,
anv_address_utrace(count_address),
pipeline->base.source_hashes[MESA_SHADER_VERTEX],
pipeline->base.source_hashes[MESA_SHADER_FRAGMENT]);
pipeline->vs_source_hash,
pipeline->fs_source_hash);
}
void genX(CmdBeginTransformFeedbackEXT)(