diff --git a/src/intel/genxml/gen125.xml b/src/intel/genxml/gen125.xml index 9ac368e6384..e9fa18ada93 100644 --- a/src/intel/genxml/gen125.xml +++ b/src/intel/genxml/gen125.xml @@ -1711,6 +1711,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 0596e4f9dda..36070e97441 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3454,16 +3454,30 @@ VkResult anv_CreateDevice( /* TODO(RT): Do we want some sort of data structure for this? */ memset(device->rt_scratch_bos, 0, sizeof(device->rt_scratch_bos)); + if (device->info->has_ray_tracing) { + /* The docs say to always allocate 128KB per DSS */ + const uint32_t btd_fifo_bo_size = + 128 * 1024 * intel_device_info_dual_subslice_id_bound(device->info); + result = anv_device_alloc_bo(device, + "rt-btd-fifo", + btd_fifo_bo_size, + 0 /* alloc_flags */, + 0 /* explicit_address */, + &device->btd_fifo_bo); + if (result != VK_SUCCESS) + goto fail_trivial_batch_bo_and_scratch_pool; + } + result = anv_genX(device->info, init_device_state)(device); if (result != VK_SUCCESS) - goto fail_trivial_batch_bo_and_scratch_pool; + goto fail_btd_fifo_bo; struct vk_pipeline_cache_create_info pcc_info = { }; device->default_pipeline_cache = vk_pipeline_cache_create(&device->vk, &pcc_info, NULL); if (!device->default_pipeline_cache) { result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - goto fail_trivial_batch_bo_and_scratch_pool; + goto fail_btd_fifo_bo; } /* Internal shaders need their own pipeline cache because, unlike the rest @@ -3501,6 +3515,9 @@ VkResult anv_CreateDevice( vk_pipeline_cache_destroy(device->internal_cache, NULL); fail_default_pipeline_cache: vk_pipeline_cache_destroy(device->default_pipeline_cache, NULL); + fail_btd_fifo_bo: + if (device->info->has_ray_tracing) + anv_device_release_bo(device, device->btd_fifo_bo); fail_trivial_batch_bo_and_scratch_pool: anv_scratch_pool_finish(device, &device->scratch_pool); fail_trivial_batch: @@ -3571,6 +3588,9 @@ void anv_DestroyDevice( vk_pipeline_cache_destroy(device->internal_cache, NULL); vk_pipeline_cache_destroy(device->default_pipeline_cache, NULL); + if (device->info->has_ray_tracing) + anv_device_release_bo(device, device->btd_fifo_bo); + #ifdef HAVE_VALGRIND /* We only need to free these to prevent valgrind errors. The backing * BO will go away in a couple of lines so we don't actually leak. @@ -4754,9 +4774,9 @@ vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion) * * - Loader interface v4 differs from v3 in: * - The ICD must implement vk_icdGetPhysicalDeviceProcAddr(). - * + * * - Loader interface v5 differs from v4 in: - * - The ICD must support Vulkan API version 1.1 and must not return + * - The ICD must support Vulkan API version 1.1 and must not return * VK_ERROR_INCOMPATIBLE_DRIVER from vkCreateInstance() unless a * Vulkan Loader with interface v4 or smaller is being used and the * application provides an API version that is greater than 1.0. diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 727b4bfcb35..8ad7c0d3e06 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1140,6 +1140,7 @@ struct anv_device { struct anv_scratch_pool scratch_pool; struct anv_bo *rt_scratch_bos[16]; + struct anv_bo *btd_fifo_bo; /** Shadow ray query BO * diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 3da36fbb7f7..d197bb3afac 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -5379,6 +5379,9 @@ cmd_buffer_trace_rays(struct anv_cmd_buffer *cmd_buffer, anv_reloc_list_add_bo(cmd_buffer->batch.relocs, cmd_buffer->batch.alloc, rt->scratch.bo); + anv_reloc_list_add_bo(cmd_buffer->batch.relocs, + cmd_buffer->batch.alloc, + cmd_buffer->device->btd_fifo_bo); /* Allocate and set up our RT_DISPATCH_GLOBALS */ struct anv_state rtdg_state = diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c index 9d0b7c26d37..e45ed6a4f51 100644 --- a/src/intel/vulkan/genX_state.c +++ b/src/intel/vulkan/genX_state.c @@ -228,6 +228,29 @@ init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch) sba.L1CacheControl = L1CC_WB; } #endif + +#if GFX_VERx10 >= 125 + if (device->info->has_ray_tracing) { + anv_batch_emit(batch, GENX(3DSTATE_BTD), btd) { + /* TODO: This is the timeout after which the bucketed thread + * dispatcher will kick off a wave of threads. We go with the + * lowest value for now. It could be tweaked on a per + * application basis (drirc). + */ + btd.DispatchTimeoutCounter = _64clocks; + /* BSpec 43851: "This field must be programmed to 6h i.e. memory + * backed buffer must be 128KB." + */ + btd.PerDSSMemoryBackedBufferSize = 6; + btd.MemoryBackedBufferBasePointer = (struct anv_address) { + /* This batch doesn't have a reloc list so we can't use the BO + * here. We just use the address directly. + */ + .offset = device->btd_fifo_bo->offset, + }; + } + } +#endif } static VkResult