From 4c0dbe64206b12210ff4862dd77f10e0c704179d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 13 May 2020 15:45:06 -0500 Subject: [PATCH] anv: Advertise ray-tracing on DG2 Also disable ray-tracing support if with_intel_vk_rt is not set. Signed-off-by: Jordan Justen Reviewed-by: Lionel Landwerlin Acked-by: Caio Oliveira Part-of: --- src/intel/vulkan/anv_device.c | 46 ++++++++++++++++++++++++++++----- src/intel/vulkan/anv_pipeline.c | 4 +-- src/intel/vulkan/genX_query.c | 2 +- src/intel/vulkan/genX_state.c | 6 ++--- src/intel/vulkan/meson.build | 21 +++++++++++---- 5 files changed, 61 insertions(+), 18 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 44d7d4d4c7d..9b6dbebbe3e 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -192,6 +192,8 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_8bit_storage = true, .KHR_16bit_storage = true, .KHR_acceleration_structure = device->info.has_ray_tracing, + .KHR_acceleration_structure = ANV_SUPPORT_RT && + device->info.has_ray_tracing, .KHR_bind_memory2 = true, .KHR_buffer_device_address = true, .KHR_copy_commands2 = true, @@ -231,7 +233,10 @@ get_device_extensions(const struct anv_physical_device *device, .KHR_pipeline_executable_properties = true, .KHR_pipeline_library = true, .KHR_push_descriptor = true, - .KHR_ray_query = device->info.has_ray_tracing, + .KHR_ray_query = + ANV_SUPPORT_RT && device->info.has_ray_tracing, + .KHR_ray_tracing_pipeline = + ANV_SUPPORT_RT && device->info.has_ray_tracing, .KHR_relaxed_block_layout = true, .KHR_sampler_mirror_clamp_to_edge = true, .KHR_sampler_ycbcr_conversion = true, @@ -1344,12 +1349,13 @@ void anv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR: { VkPhysicalDeviceAccelerationStructureFeaturesKHR *features = (void *)ext; - features->accelerationStructure = pdevice->info.has_ray_tracing; + features->accelerationStructure = + ANV_SUPPORT_RT && pdevice->info.has_ray_tracing; features->accelerationStructureCaptureReplay = false; /* TODO */ features->accelerationStructureIndirectBuild = false; /* TODO */ features->accelerationStructureHostCommands = false; features->descriptorBindingAccelerationStructureUpdateAfterBind = - pdevice->info.has_ray_tracing; + ANV_SUPPORT_RT && pdevice->info.has_ray_tracing; break; } @@ -1549,7 +1555,17 @@ void anv_GetPhysicalDeviceFeatures2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR: { VkPhysicalDeviceRayQueryFeaturesKHR *features = (void *)ext; - features->rayQuery = pdevice->info.has_ray_tracing; + features->rayQuery = ANV_SUPPORT_RT && pdevice->info.has_ray_tracing; + break; + } + + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR: { + VkPhysicalDeviceRayTracingPipelineFeaturesKHR *features = (void *)ext; + features->rayTracingPipeline = pdevice->info.has_ray_tracing; + features->rayTracingPipelineShaderGroupHandleCaptureReplay = false; + features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed = false; + features->rayTracingPipelineTraceRaysIndirect = true; + features->rayTraversalPrimitiveCulling = false; break; } @@ -2559,6 +2575,22 @@ void anv_GetPhysicalDeviceProperties2( break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR: { + VkPhysicalDeviceRayTracingPipelinePropertiesKHR *props = (void *)ext; + /* TODO */ + props->shaderGroupHandleSize = 32; + props->maxRayRecursionDepth = 31; + /* MemRay::hitGroupSRStride is 16 bits */ + props->maxShaderGroupStride = UINT16_MAX; + /* MemRay::hitGroupSRBasePtr requires 16B alignment */ + props->shaderGroupBaseAlignment = 16; + props->shaderGroupHandleAlignment = 16; + props->shaderGroupHandleCaptureReplaySize = 32; + props->maxRayDispatchInvocationCount = 1U << 30; /* required min limit */ + props->maxRayHitAttributeSize = BRW_RT_SIZEOF_HIT_ATTRIB_DATA; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT: { VkPhysicalDeviceRobustness2PropertiesEXT *properties = (void *)ext; properties->robustStorageBufferAccessSizeAlignment = @@ -3461,7 +3493,7 @@ 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) { + if (ANV_SUPPORT_RT && 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); @@ -3523,7 +3555,7 @@ VkResult anv_CreateDevice( fail_default_pipeline_cache: vk_pipeline_cache_destroy(device->default_pipeline_cache, NULL); fail_btd_fifo_bo: - if (device->info->has_ray_tracing) + if (ANV_SUPPORT_RT && 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); @@ -3595,7 +3627,7 @@ 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) + if (ANV_SUPPORT_RT && device->info->has_ray_tracing) anv_device_release_bo(device, device->btd_fifo_bo); #ifdef HAVE_VALGRIND diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index 16f001c3786..807c05841a3 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -227,8 +227,8 @@ anv_shader_stage_to_nir(struct anv_device *device, .post_depth_coverage = true, .runtime_descriptor_array = true, .float_controls = true, - .ray_query = pdevice->info.has_ray_tracing, - .ray_tracing = pdevice->info.has_ray_tracing, + .ray_query = ANV_SUPPORT_RT && pdevice->info.has_ray_tracing, + .ray_tracing = ANV_SUPPORT_RT && pdevice->info.has_ray_tracing, .shader_clock = true, .shader_viewport_index_layer = true, .stencil_export = true, diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c index 0f1940a5043..e36b5ccd212 100644 --- a/src/intel/vulkan/genX_query.c +++ b/src/intel/vulkan/genX_query.c @@ -1510,7 +1510,7 @@ void genX(CmdCopyQueryPoolResults)( } } -#if GFX_VERx10 >= 125 +#if GFX_VERx10 >= 125 && ANV_SUPPORT_RT #include "grl/include/GRLRTASCommon.h" #include "grl/grl_metakernel_postbuild_info.h" diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c index 378dcd35dee..5914ab69393 100644 --- a/src/intel/vulkan/genX_state.c +++ b/src/intel/vulkan/genX_state.c @@ -37,7 +37,7 @@ #include "vk_standard_sample_locations.h" -#if GFX_VERx10 >= 125 +#if GFX_VERx10 >= 125 && ANV_SUPPORT_RT #include "grl/genX_grl.h" #endif @@ -235,7 +235,7 @@ init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch) #endif #if GFX_VERx10 >= 125 - if (device->info->has_ray_tracing) { + if (ANV_SUPPORT_RT && 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 @@ -471,7 +471,7 @@ void genX(init_physical_device_state)(ASSERTED struct anv_physical_device *pdevice) { assert(pdevice->info.verx10 == GFX_VERx10); -#if GFX_VERx10 >= 125 +#if GFX_VERx10 >= 125 && ANV_SUPPORT_RT genX(grl_load_rt_uuid)(pdevice->rt_uuid); #endif } diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index dd50d057e69..b0277572025 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -27,7 +27,15 @@ anv_flags = [ anv_cpp_flags = [] -subdir('grl') +if with_intel_vk_rt + subdir('grl') + optional_libgrl = [libgrl] + anv_flags += '-DANV_SUPPORT_RT=1' +else + idep_grl = null_dep + optional_libgrl = [] + anv_flags += '-DANV_SUPPORT_RT=0' +endif anv_entrypoints = custom_target( 'anv_entrypoints', @@ -80,7 +88,6 @@ endif libanv_per_hw_ver_libs = [] anv_per_hw_ver_files = files( - 'genX_acceleration_structure.c', 'genX_blorp_exec.c', 'genX_cmd_buffer.c', 'genX_gpu_memcpy.c', @@ -88,6 +95,10 @@ anv_per_hw_ver_files = files( 'genX_query.c', 'genX_state.c', ) +if with_intel_vk_rt + anv_per_hw_ver_files += files('genX_acceleration_structure.c',) +endif + foreach g : [['90', ['gfx8_cmd_buffer.c']], ['110', ['gfx8_cmd_buffer.c']], ['120', ['gfx8_cmd_buffer.c']], @@ -193,7 +204,7 @@ libvulkan_intel = shared_library( include_directories : [ inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_intel, inc_compiler, ], - link_whole : [libanv_common, libanv_per_hw_ver_libs, libgrl], + link_whole : [libanv_common, libanv_per_hw_ver_libs] + optional_libgrl, link_with : [ libintel_compiler, libintel_dev, libisl, libblorp, libintel_perf, ], @@ -231,9 +242,9 @@ if with_tests ], link_whole : libanv_common, link_with : [ - libanv_per_hw_ver_libs, libgrl, libintel_compiler, libintel_common, libintel_dev, + libanv_per_hw_ver_libs, libintel_compiler, libintel_common, libintel_dev, libisl, libblorp, libintel_perf, - ], + ] + optional_libgrl, dependencies : [ dep_thread, dep_dl, dep_m, anv_deps, idep_nir, idep_vulkan_util, idep_vulkan_wsi, idep_vulkan_runtime,