To help developers.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6318>
if (program->collect_statistics)
memset(program->statistics, 0, sizeof(program->statistics));
+ program->debug.func = args->options->debug.func;
+ program->debug.private_data = args->options->debug.private_data;
+
/* Instruction Selection */
if (args->is_gs_copy_shader)
aco::select_gs_copy_shader(program.get(), shaders[0], &config, args);
#include "aco_opcodes.h"
#include "aco_util.h"
+#include "vulkan/radv_shader.h"
+
struct radv_nir_compiler_options;
struct radv_shader_args;
struct radv_shader_info;
bool collect_statistics = false;
uint32_t statistics[num_statistics];
+ struct {
+ void (*func)(void *private_data,
+ enum radv_compiler_debug_level level,
+ const char *message);
+ void *private_data;
+ } debug;
+
uint32_t allocateId()
{
assert(allocationID <= 16777215);
namespace aco {
-static void aco_log(Program *program, const char *prefix,
- const char *file, unsigned line,
+static void aco_log(Program *program, enum radv_compiler_debug_level level,
+ const char *prefix, const char *file, unsigned line,
const char *fmt, va_list args)
{
char *msg;
ralloc_asprintf_append(&msg, " ");
ralloc_vasprintf_append(&msg, fmt, args);
- /* TODO: log messages via callback if available too. */
+ if (program->debug.func)
+ program->debug.func(program->debug.private_data, level, msg);
fprintf(stderr, "%s\n", msg);
va_list args;
va_start(args, fmt);
- aco_log(program, "ACO PERFWARN:\n", file, line, fmt, args);
+ aco_log(program, RADV_COMPILER_DEBUG_LEVEL_PERFWARN,
+ "ACO PERFWARN:\n", file, line, fmt, args);
va_end(args);
}
va_list args;
va_start(args, fmt);
- aco_log(program, "ACO ERROR:\n", file, line, fmt, args);
+ aco_log(program, RADV_COMPILER_DEBUG_LEVEL_ERROR,
+ "ACO ERROR:\n", file, line, fmt, args);
va_end(args);
}
*align = comp_size;
}
-struct radv_spirv_debug_data {
+struct radv_shader_debug_data {
struct radv_device *device;
const struct radv_shader_module *module;
};
size_t spirv_offset,
const char *message)
{
- struct radv_spirv_debug_data *debug_data = private_data;
+ struct radv_shader_debug_data *debug_data = private_data;
struct radv_instance *instance = debug_data->device->instance;
static const VkDebugReportFlagsEXT vk_flags[] = {
0, 0, "radv", buffer);
}
+static void radv_compiler_debug(void *private_data,
+ enum radv_compiler_debug_level level,
+ const char *message)
+{
+ struct radv_shader_debug_data *debug_data = private_data;
+ struct radv_instance *instance = debug_data->device->instance;
+
+ static const VkDebugReportFlagsEXT vk_flags[] = {
+ [RADV_COMPILER_DEBUG_LEVEL_PERFWARN] = VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
+ [RADV_COMPILER_DEBUG_LEVEL_ERROR] = VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ };
+
+ /* VK_DEBUG_REPORT_DEBUG_BIT_EXT specifies diagnostic information
+ * from the implementation and layers.
+ */
+ vk_debug_report(&instance->debug_report_callbacks,
+ vk_flags[level] | VK_DEBUG_REPORT_DEBUG_BIT_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
+ (uint64_t)(uintptr_t)debug_data->module,
+ 0, 0, "radv", message);
+}
+
nir_shader *
radv_shader_compile_to_nir(struct radv_device *device,
struct radv_shader_module *module,
}
}
- struct radv_spirv_debug_data spirv_debug_data = {
+ struct radv_shader_debug_data spirv_debug_data = {
.device = device,
.module = module,
};
enum radeon_family chip_family = device->physical_device->rad_info.family;
struct radv_shader_binary *binary = NULL;
+ struct radv_shader_debug_data debug_data = {
+ .device = device,
+ .module = module,
+ };
+
options->family = chip_family;
options->chip_class = device->physical_device->rad_info.chip_class;
options->dump_shader = radv_can_dump_shader(device, module, gs_copy_shader);
options->has_ls_vgpr_init_bug = device->physical_device->rad_info.has_ls_vgpr_init_bug;
options->use_ngg_streamout = device->physical_device->use_ngg_streamout;
options->enable_mrt_output_nan_fixup = device->instance->enable_mrt_output_nan_fixup;
+ options->debug.func = radv_compiler_debug;
+ options->debug.private_data = &debug_data;
struct radv_shader_args args = {};
args.options = options;
bool has_multiview_view_index;
};
+enum radv_compiler_debug_level {
+ RADV_COMPILER_DEBUG_LEVEL_PERFWARN,
+ RADV_COMPILER_DEBUG_LEVEL_ERROR,
+};
+
struct radv_nir_compiler_options {
struct radv_pipeline_layout *layout;
struct radv_shader_variant_key key;
enum chip_class chip_class;
uint32_t tess_offchip_block_dw_size;
uint32_t address32_hi;
+
+ struct {
+ void (*func)(void *private_data,
+ enum radv_compiler_debug_level level,
+ const char *message);
+ void *private_data;
+ } debug;
};
enum radv_ud_index {