diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 6e5a04218cd..24ae598d51a 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -4172,12 +4172,6 @@ anv_CreateRayTracingPipelinesKHR( return result; } -#define WRITE_STR(field, ...) ({ \ - memset(field, 0, sizeof(field)); \ - UNUSED int i = snprintf(field, sizeof(field), __VA_ARGS__); \ - assert(i > 0 && i < sizeof(field)); \ -}) - VkResult anv_GetPipelineExecutablePropertiesKHR( VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, @@ -4196,19 +4190,19 @@ VkResult anv_GetPipelineExecutablePropertiesKHR( unsigned simd_width = exe->stats.dispatch_width; if (stage == MESA_SHADER_FRAGMENT) { if (exe->stats.max_polygons > 1) - WRITE_STR(props->name, "SIMD%dx%d %s", + VK_PRINT_STR(props->name, "SIMD%dx%d %s", exe->stats.max_polygons, simd_width / exe->stats.max_polygons, _mesa_shader_stage_to_string(stage)); else - WRITE_STR(props->name, "%s%d %s", + VK_PRINT_STR(props->name, "%s%d %s", simd_width ? "SIMD" : "vec", simd_width ? simd_width : 4, _mesa_shader_stage_to_string(stage)); } else { - WRITE_STR(props->name, "%s", _mesa_shader_stage_to_string(stage)); + VK_COPY_STR(props->name, _mesa_shader_stage_to_string(stage)); } - WRITE_STR(props->description, "%s%d %s shader", + VK_PRINT_STR(props->description, "%s%d %s shader", simd_width ? "SIMD" : "vec", simd_width ? simd_width : 4, _mesa_shader_stage_to_string(stage)); @@ -4269,8 +4263,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Instruction Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Instruction Count"); + VK_COPY_STR(stat->description, "Number of GEN instructions in the final generated " "shader executable."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; @@ -4278,8 +4272,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "SEND Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "SEND Count"); + VK_COPY_STR(stat->description, "Number of instructions in the final generated shader " "executable which access external units such as the " "constant cache or the sampler."); @@ -4288,8 +4282,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Loop Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Loop Count"); + VK_COPY_STR(stat->description, "Number of loops (not unrolled) in the final generated " "shader executable."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; @@ -4297,8 +4291,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Cycle Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Cycle Count"); + VK_COPY_STR(stat->description, "Estimate of the number of EU cycles required to execute " "the final generated executable. This is an estimate only " "and may vary greatly from actual run-time performance."); @@ -4307,8 +4301,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Spill Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Spill Count"); + VK_COPY_STR(stat->description, "Number of scratch spill operations. This gives a rough " "estimate of the cost incurred due to spilling temporary " "values to memory. If this is non-zero, you may want to " @@ -4318,8 +4312,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Fill Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Fill Count"); + VK_COPY_STR(stat->description, "Number of scratch fill operations. This gives a rough " "estimate of the cost incurred due to spilling temporary " "values to memory. If this is non-zero, you may want to " @@ -4329,8 +4323,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Scratch Memory Size"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Scratch Memory Size"); + VK_COPY_STR(stat->description, "Number of bytes of scratch memory required by the " "generated shader executable. If this is non-zero, you " "may want to adjust your shader to reduce register " @@ -4341,8 +4335,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( if (pipeline->device->info->ver >= 30) { vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "GRF registers"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "GRF registers"); + VK_COPY_STR(stat->description, "Number of GRF registers required by the shader."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; stat->value.u64 = prog_data->grf_used; @@ -4350,8 +4344,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Max dispatch width"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Max dispatch width"); + VK_COPY_STR(stat->description, "Largest SIMD dispatch width."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; /* Report the max dispatch width only on the smallest SIMD variant */ @@ -4362,16 +4356,16 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Max live registers"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Max live registers"); + VK_COPY_STR(stat->description, "Maximum number of registers used across the entire shader."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; stat->value.u64 = exe->stats.max_live_registers; } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Workgroup Memory Size"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Workgroup Memory Size"); + VK_COPY_STR(stat->description, "Number of bytes of workgroup shared memory used by this " "shader including any padding."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; @@ -4389,16 +4383,16 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( 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, + VK_COPY_STR(stat->name, "Source hash"); + VK_PRINT_STR(stat->description, "hash = 0x%08x. Hash generated from shader source.", hash); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; stat->value.u64 = hash; } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Non SSA regs after NIR"); - WRITE_STR(stat->description, "Non SSA regs after NIR translation to BRW."); + VK_COPY_STR(stat->name, "Non SSA regs after NIR"); + VK_COPY_STR(stat->description, "Non SSA regs after NIR translation to BRW."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; stat->value.u64 = exe->stats.non_ssa_registers_after_nir; } @@ -4443,8 +4437,8 @@ VkResult anv_GetPipelineExecutableInternalRepresentationsKHR( if (exe->nir) { vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { - WRITE_STR(ir->name, "Final NIR"); - WRITE_STR(ir->description, + VK_COPY_STR(ir->name, "Final NIR"); + VK_COPY_STR(ir->description, "Final NIR before going into the back-end compiler"); if (!write_ir_text(ir, exe->nir)) @@ -4454,8 +4448,8 @@ VkResult anv_GetPipelineExecutableInternalRepresentationsKHR( if (exe->disasm) { vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { - WRITE_STR(ir->name, "GEN Assembly"); - WRITE_STR(ir->description, + VK_COPY_STR(ir->name, "GEN Assembly"); + VK_COPY_STR(ir->description, "Final GEN assembly for the generated shader binary"); if (!write_ir_text(ir, exe->disasm)) diff --git a/src/intel/vulkan_hasvk/anv_pipeline.c b/src/intel/vulkan_hasvk/anv_pipeline.c index 62bc3873d79..27161ae245e 100644 --- a/src/intel/vulkan_hasvk/anv_pipeline.c +++ b/src/intel/vulkan_hasvk/anv_pipeline.c @@ -1882,12 +1882,6 @@ VkResult anv_CreateGraphicsPipelines( return result; } -#define WRITE_STR(field, ...) ({ \ - memset(field, 0, sizeof(field)); \ - UNUSED int i = snprintf(field, sizeof(field), __VA_ARGS__); \ - assert(i > 0 && i < sizeof(field)); \ -}) - VkResult anv_GetPipelineExecutablePropertiesKHR( VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, @@ -1905,14 +1899,14 @@ VkResult anv_GetPipelineExecutablePropertiesKHR( unsigned simd_width = exe->stats.dispatch_width; if (stage == MESA_SHADER_FRAGMENT) { - WRITE_STR(props->name, "%s%d %s", + VK_PRINT_STR(props->name, "%s%d %s", simd_width ? "SIMD" : "vec", simd_width ? simd_width : 4, _mesa_shader_stage_to_string(stage)); } else { - WRITE_STR(props->name, "%s", _mesa_shader_stage_to_string(stage)); + VK_COPY_STR(props->name, _mesa_shader_stage_to_string(stage)); } - WRITE_STR(props->description, "%s%d %s shader", + VK_PRINT_STR(props->description, "%s%d %s shader", simd_width ? "SIMD" : "vec", simd_width ? simd_width : 4, _mesa_shader_stage_to_string(stage)); @@ -1964,8 +1958,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Instruction Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Instruction Count"); + VK_COPY_STR(stat->description, "Number of GEN instructions in the final generated " "shader executable."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; @@ -1973,8 +1967,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "SEND Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "SEND Count"); + VK_COPY_STR(stat->description, "Number of instructions in the final generated shader " "executable which access external units such as the " "constant cache or the sampler."); @@ -1983,8 +1977,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Loop Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Loop Count"); + VK_COPY_STR(stat->description, "Number of loops (not unrolled) in the final generated " "shader executable."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; @@ -1992,8 +1986,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Cycle Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Cycle Count"); + VK_COPY_STR(stat->description, "Estimate of the number of EU cycles required to execute " "the final generated executable. This is an estimate only " "and may vary greatly from actual run-time performance."); @@ -2002,8 +1996,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Spill Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Spill Count"); + VK_COPY_STR(stat->description, "Number of scratch spill operations. This gives a rough " "estimate of the cost incurred due to spilling temporary " "values to memory. If this is non-zero, you may want to " @@ -2013,8 +2007,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Fill Count"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Fill Count"); + VK_COPY_STR(stat->description, "Number of scratch fill operations. This gives a rough " "estimate of the cost incurred due to spilling temporary " "values to memory. If this is non-zero, you may want to " @@ -2024,8 +2018,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( } vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Scratch Memory Size"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Scratch Memory Size"); + VK_COPY_STR(stat->description, "Number of bytes of scratch memory required by the " "generated shader executable. If this is non-zero, you " "may want to adjust your shader to reduce register " @@ -2036,8 +2030,8 @@ VkResult anv_GetPipelineExecutableStatisticsKHR( if (gl_shader_stage_uses_workgroup(exe->stage)) { vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { - WRITE_STR(stat->name, "Workgroup Memory Size"); - WRITE_STR(stat->description, + VK_COPY_STR(stat->name, "Workgroup Memory Size"); + VK_COPY_STR(stat->description, "Number of bytes of workgroup shared memory used by this " "shader including any padding."); stat->format = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR; @@ -2085,8 +2079,8 @@ VkResult anv_GetPipelineExecutableInternalRepresentationsKHR( if (exe->nir) { vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { - WRITE_STR(ir->name, "Final NIR"); - WRITE_STR(ir->description, + VK_COPY_STR(ir->name, "Final NIR"); + VK_COPY_STR(ir->description, "Final NIR before going into the back-end compiler"); if (!write_ir_text(ir, exe->nir)) @@ -2096,8 +2090,8 @@ VkResult anv_GetPipelineExecutableInternalRepresentationsKHR( if (exe->disasm) { vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { - WRITE_STR(ir->name, "GEN Assembly"); - WRITE_STR(ir->description, + VK_COPY_STR(ir->name, "GEN Assembly"); + VK_COPY_STR(ir->description, "Final GEN assembly for the generated shader binary"); if (!write_ir_text(ir, exe->disasm))