diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2025-05-27 18:31:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-28 01:31:25 +0000 |
| commit | c9e9efaaf064dc0a3d3a538506f5f0f47de9b674 (patch) | |
| tree | 565ce3c55d2e24861bd20cab13b3e747a7a45185 | |
| parent | 3a9f189c6a087cb3a58bed2f81543ceb26e62b0e (diff) | |
Change default descriptor binding to be VkMutable (#7224)
* change default descriptor binding to be VkMutable
4 files changed, 34 insertions, 11 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md index d522daf81..948809110 100644 --- a/docs/user-guide/03-convenience-features.md +++ b/docs/user-guide/03-convenience-features.md @@ -610,12 +610,12 @@ Default behavior assigns binding-indicies based on descriptor types: | Sampler | VK_DESCRIPTOR_TYPE_SAMPLER | 0 | | CombinedTextureSampler | VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER | 1 | | Texture_Read | VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE | 2 | -| Texture_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_IMAGE | 3 | -| TexelBuffer_Read | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER | 4 | -| TexelBuffer_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER | 5 | -| Buffer_Read | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER | 6 | -| Buffer_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER | 7 | -| Unknown | Other | 8 | +| Texture_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_IMAGE | 2 | +| TexelBuffer_Read | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER | 2 | +| TexelBuffer_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER | 2 | +| Buffer_Read | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER | 2 | +| Buffer_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER | 2 | +| Unknown | Other | 3 | > `ACCELERATION_STRUCTURE` is excluded from the list of types since Slang by default uses the handle to a `RaytracingAccelerationStructure` as a GPU address, casting the handle to a `RaytracingAccelerationStructure`. This removes the need for a binding-slot of `RaytracingAccelerationStructure`. @@ -672,11 +672,24 @@ Additionally, `defaultGetDescriptorFromHandle()` takes an optional argument whos ```slang public enum BindlessDescriptorOptions { - None = 0, /// Bind assuming regular binding model rules. - VkMutable = 1, /// Bind assuming `VK_EXT_mutable_descriptor_type` without mutable `AccelerationStructure` binding support. + None = 0, /// Bind assuming regular binding model rules. + VkMutable = 1, /// **Current Default** Bind assuming `VK_EXT_mutable_descriptor_type` } ``` +`None` provides the following bindings for descriptor types: +| Enum Value | Vulkan Descriptor Type | Binding Index | +|------------------------|-------------------------------------------|---------------| +| Sampler | VK_DESCRIPTOR_TYPE_SAMPLER | 0 | +| CombinedTextureSampler | VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER | 1 | +| Texture_Read | VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE | 2 | +| Texture_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_IMAGE | 3 | +| TexelBuffer_Read | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER | 4 | +| TexelBuffer_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER | 5 | +| Buffer_Read | VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER | 6 | +| Buffer_ReadWrite | VK_DESCRIPTOR_TYPE_STORAGE_BUFFER | 7 | +| Unknown | Other | 8 | + `VkMutable` provides the following bindings for descriptor types: | Enum Value | Vulkan Descriptor Type | Binding Index | |------------------------|-------------------------------------------|---------------| diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 9b15392ec..801c61481 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -22749,14 +22749,14 @@ T __castDescriptorHandleToResource<T:IOpaqueDescriptor>(DescriptorHandle<T> ptr) public enum BindlessDescriptorOptions { - None = 0, /// Bind assuming regular binding model rules. - VkMutable = 1, /// Bind assuming `VK_EXT_mutable_descriptor_type` without mutable `AccelerationStructure` binding support. + None = 0, /// Bind assuming regular binding model rules. + VkMutable = 1, /// **Current Default** Bind assuming `VK_EXT_mutable_descriptor_type` } /// The default implementation of `getDescriptorFromHandle`, which converts from a descriptor handle /// to a descriptor object. [ForceInline] -T defaultGetDescriptorFromHandle<T:IOpaqueDescriptor>(DescriptorHandle<T> handleValue, constexpr BindlessDescriptorOptions bindlessOptions = BindlessDescriptorOptions.None) +T defaultGetDescriptorFromHandle<T:IOpaqueDescriptor>(DescriptorHandle<T> handleValue, constexpr BindlessDescriptorOptions bindlessOptions = BindlessDescriptorOptions.VkMutable) { __target_switch { diff --git a/tests/language-feature/descriptor-handle/desc-handle-default.slang b/tests/language-feature/descriptor-handle/desc-handle-default.slang index d442fb610..016b04bfb 100644 --- a/tests/language-feature/descriptor-handle/desc-handle-default.slang +++ b/tests/language-feature/descriptor-handle/desc-handle-default.slang @@ -10,6 +10,12 @@ //TEST:SIMPLE(filecheck=SAMPLED_IMAGE): -target spirv -stage compute -entry computeMain -DSAMPLED_IMAGE //TEST:SIMPLE(filecheck=MIX): -target spirv -stage compute -entry computeMain -DSAMPLER -DSTORAGE_TEXEL_BUFFER -DUNIFORM_BUFFER -DACCELERATION_STRUCTURE + +export T getDescriptorFromHandle<T : IOpaqueDescriptor>(DescriptorHandle<T> handleValue) +{ + return defaultGetDescriptorFromHandle(handleValue, BindlessDescriptorOptions.None); +} + // To intentionally fill up binding slots [[vk::binding(0, 1)]] RWTexture1D<float> t1; diff --git a/tests/language-feature/descriptor-handle/desc-handle-vk-mutable-descriptor.slang b/tests/language-feature/descriptor-handle/desc-handle-vk-mutable-descriptor.slang index 8fc2d3283..2bf57d0ef 100644 --- a/tests/language-feature/descriptor-handle/desc-handle-vk-mutable-descriptor.slang +++ b/tests/language-feature/descriptor-handle/desc-handle-vk-mutable-descriptor.slang @@ -1,4 +1,5 @@ //TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry computeMain +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry computeMain -DIS_DEFAULT // To intentionally fill up binding slots [[vk::binding(0, 1)]] @@ -25,10 +26,13 @@ Texture1D<float> t4; //CHECK-NOT: OpDecorate %__slang_resource_heap{{.*}} Binding 7 //CHECK-NOT: OpDecorate %__slang_resource_heap{{.*}} Binding 8 //CHECK-NOT: OpDecorate %__slang_resource_heap{{.*}} Binding 9 + +#ifndef IS_DEFAULT export T getDescriptorFromHandle<T:IOpaqueDescriptor>(DescriptorHandle<T> handleValue) { return defaultGetDescriptorFromHandle(handleValue, BindlessDescriptorOptions.VkMutable); } +#endif uniform SamplerState.Handle sampler; uniform Sampler1DShadow.Handle combinedSampler; |
