diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 0b743bca17c..881b7b87d37 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -998,7 +998,7 @@ VkResult anv_CreateDevice( if (!device->info->has_64bit_float) anv_load_fp64_shader(device); - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (anv_needs_printf_buffer()) { result = anv_device_print_init(device); if (result != VK_SUCCESS) goto fail_internal_cache; @@ -1140,7 +1140,7 @@ VkResult anv_CreateDevice( device->companion_rcs_cmd_pool, NULL); } fail_print: - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) + if (anv_needs_printf_buffer()) anv_device_print_fini(device); fail_internal_cache: vk_pipeline_cache_destroy(device->internal_cache, NULL); @@ -1277,7 +1277,7 @@ void anv_DestroyDevice( anv_device_finish_descriptors_view(device); - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) + if (anv_needs_printf_buffer()) anv_device_print_fini(device); vk_pipeline_cache_destroy(device->internal_cache, NULL); diff --git a/src/intel/vulkan/anv_instance.c b/src/intel/vulkan/anv_instance.c index e47474c3996..a8c667d24ba 100644 --- a/src/intel/vulkan/anv_instance.c +++ b/src/intel/vulkan/anv_instance.c @@ -102,6 +102,7 @@ static const struct debug_control debug_control[] = { { "shader-hash", ANV_DEBUG_SHADER_HASH}, { "no-slab", ANV_DEBUG_NO_SLAB}, { "desc-dirty", ANV_DEBUG_DESCRIPTOR_DIRTY}, + { "shader-print", ANV_DEBUG_SHADER_PRINT}, { NULL, 0 } }; diff --git a/src/intel/vulkan/anv_internal_kernels.c b/src/intel/vulkan/anv_internal_kernels.c index ad0f9a7765d..ff419bb6db1 100644 --- a/src/intel/vulkan/anv_internal_kernels.c +++ b/src/intel/vulkan/anv_internal_kernels.c @@ -173,7 +173,7 @@ compile_shader(struct anv_device *device, prog_data.base.push_sizes[0] = align(prog_data.base.push_sizes[0], REG_SIZE); program = brw_compile_fs(compiler, ¶ms); - if (!INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (!ANV_DEBUG(SHADER_PRINT)) { unsigned stat_idx = 0; if (prog_data.fs.dispatch_8) { check_sends(&stats[stat_idx++], sends_count_expectation); @@ -204,7 +204,7 @@ compile_shader(struct anv_device *device, }; program = brw_compile_cs(compiler, ¶ms); - if (!INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (!ANV_DEBUG(SHADER_PRINT)) { check_sends(&stats, sends_count_expectation); } } diff --git a/src/intel/vulkan/anv_pipeline_cache.c b/src/intel/vulkan/anv_pipeline_cache.c index fefceea1fd7..cd614fd9f0a 100644 --- a/src/intel/vulkan/anv_pipeline_cache.c +++ b/src/intel/vulkan/anv_pipeline_cache.c @@ -116,7 +116,7 @@ anv_shader_internal_create(struct anv_device *device, shader->code = code; memcpy(shader->code, kernel_data, kernel_size); - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (anv_needs_printf_buffer()) { struct intel_shader_reloc_value reloc_values[3]; uint32_t rv_count = 0; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index bd11bde2505..67d3481cf97 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1799,12 +1799,18 @@ enum anv_debug { ANV_DEBUG_SHADER_HASH = BITFIELD_BIT(7), ANV_DEBUG_NO_SLAB = BITFIELD_BIT(8), ANV_DEBUG_DESCRIPTOR_DIRTY = BITFIELD_BIT(9), + ANV_DEBUG_SHADER_PRINT = BITFIELD_BIT(10), }; extern enum anv_debug anv_debug; #define ANV_DEBUG(name) unlikely(anv_debug & ANV_DEBUG_##name) +static inline bool anv_needs_printf_buffer(void) +{ + return ANV_DEBUG(SHADER_PRINT); +} + struct anv_instance { struct vk_instance vk; diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index 0223a03e01e..d19f8249e6d 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -95,7 +95,7 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue, * submission feature, shader-print feature, or BVH dump. */ if (INTEL_DEBUG(DEBUG_SYNC) || - INTEL_DEBUG(DEBUG_SHADER_PRINT) || + ANV_DEBUG(SHADER_PRINT) || INTEL_DEBUG_BVH_ANY) { result = vk_sync_create(&device->vk, &device->physical->sync_syncobj_type, diff --git a/src/intel/vulkan/anv_shader.c b/src/intel/vulkan/anv_shader.c index 5efe5acfe42..811a9716551 100644 --- a/src/intel/vulkan/anv_shader.c +++ b/src/intel/vulkan/anv_shader.c @@ -520,7 +520,7 @@ anv_shader_set_relocs(struct anv_device *device, }; } - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (anv_needs_printf_buffer()) { struct anv_bo *bo = device->printf.bo; assert(bo != NULL); diff --git a/src/intel/vulkan/anv_shader_compile.c b/src/intel/vulkan/anv_shader_compile.c index 3bf6884a808..1315df9d27f 100644 --- a/src/intel/vulkan/anv_shader_compile.c +++ b/src/intel/vulkan/anv_shader_compile.c @@ -219,7 +219,7 @@ anv_shader_get_spirv_options(struct vk_physical_device *device, .phys_ssbo_addr_format = nir_address_format_64bit_global, .push_const_addr_format = nir_address_format_logical, - .printf = INTEL_DEBUG(DEBUG_SHADER_PRINT), + .printf = ANV_DEBUG(SHADER_PRINT), /* TODO: Consider changing this to an address format that has the NULL * pointer equals to 0. That might be a better format to play nice @@ -270,7 +270,7 @@ anv_shader_preprocess_nir(struct vk_physical_device *device, NIR_PASS(_, nir, nir_opt_barrier_modes); NIR_PASS(_, nir, nir_opt_acquire_release_barriers, SCOPE_QUEUE_FAMILY); - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (ANV_DEBUG(SHADER_PRINT)) { const nir_lower_printf_options printf_opts = { .ptr_bit_size = 64, .hash_format_strings = true, diff --git a/src/intel/vulkan/i915/anv_device.c b/src/intel/vulkan/i915/anv_device.c index ecbe7663f1c..787dde32e80 100644 --- a/src/intel/vulkan/i915/anv_device.c +++ b/src/intel/vulkan/i915/anv_device.c @@ -379,7 +379,7 @@ anv_i915_device_check_status(struct vk_device *vk_device) } done: - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (anv_needs_printf_buffer()) { VkResult print_result = vk_check_printf_status(vk_device, &device->printf); /* Report the device error if there is one, only report the printf error diff --git a/src/intel/vulkan/xe/anv_batch_chain.c b/src/intel/vulkan/xe/anv_batch_chain.c index d0c2cc9bad2..8f50e60aa23 100644 --- a/src/intel/vulkan/xe/anv_batch_chain.c +++ b/src/intel/vulkan/xe/anv_batch_chain.c @@ -146,7 +146,7 @@ xe_exec_ioctl_impl(struct anv_queue *queue, struct drm_xe_exec *exec, int ret = xe_gem_exec_ioctl(device->fd, device->info, exec); if (ret) { - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) + if (anv_needs_printf_buffer()) vk_check_printf_status(&device->vk, &device->printf); return vk_queue_set_lost(&queue->vk, "%s(%d) failed: %m", func, line); } diff --git a/src/intel/vulkan/xe/anv_device.c b/src/intel/vulkan/xe/anv_device.c index 04d199f3c20..82374adbc3c 100644 --- a/src/intel/vulkan/xe/anv_device.c +++ b/src/intel/vulkan/xe/anv_device.c @@ -209,7 +209,7 @@ anv_xe_device_check_status(struct vk_device *vk_device) } done: - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + if (anv_needs_printf_buffer()) { VkResult print_result = vk_check_printf_status(vk_device, &device->printf); /* Report the device error if there is one, only report the printf error