Skip to content

Commit 8014f6c

Browse files
authored
add preliminary vulkan bindless support (#337)
1 parent 028778b commit 8014f6c

21 files changed

+769
-57
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ if(SLANG_RHI_ENABLE_VULKAN)
573573
target_sources(slang-rhi PRIVATE
574574
src/vulkan/vk-acceleration-structure.cpp
575575
src/vulkan/vk-api.cpp
576+
src/vulkan/vk-bindless-descriptor-set.cpp
576577
src/vulkan/vk-buffer.cpp
577578
src/vulkan/vk-command.cpp
578579
src/vulkan/vk-constant-buffer-pool.cpp

src/vulkan/vk-acceleration-structure.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ DeviceAddress AccelerationStructureImpl::getDeviceAddress()
3636
return m_buffer->getDeviceAddress();
3737
}
3838

39+
Result AccelerationStructureImpl::getDescriptorHandle(DescriptorHandle* outHandle)
40+
{
41+
DeviceImpl* device = getDevice<DeviceImpl>();
42+
43+
if (!device->m_bindlessDescriptorSet)
44+
{
45+
return SLANG_E_NOT_AVAILABLE;
46+
}
47+
48+
if (!m_descriptorHandle)
49+
{
50+
SLANG_RETURN_ON_FAIL(
51+
device->m_bindlessDescriptorSet->allocAccelerationStructureHandle(this, &m_descriptorHandle)
52+
);
53+
}
54+
55+
*outHandle = m_descriptorHandle;
56+
return SLANG_OK;
57+
}
58+
3959
Result AccelerationStructureBuildDescConverter::convert(
4060
const AccelerationStructureBuildDesc& buildDesc,
4161
IDebugCallback* debugCallback

src/vulkan/vk-acceleration-structure.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class AccelerationStructureImpl : public AccelerationStructure
99
public:
1010
VkAccelerationStructureKHR m_vkHandle = VK_NULL_HANDLE;
1111
RefPtr<BufferImpl> m_buffer;
12+
DescriptorHandle m_descriptorHandle;
1213

1314
public:
1415
AccelerationStructureImpl(Device* device, const AccelerationStructureDesc& desc);
@@ -18,6 +19,7 @@ class AccelerationStructureImpl : public AccelerationStructure
1819
virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) override;
1920
virtual SLANG_NO_THROW AccelerationStructureHandle getHandle() override;
2021
virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() override;
22+
virtual SLANG_NO_THROW Result SLANG_MCALL getDescriptorHandle(DescriptorHandle* outHandle) override;
2123
};
2224

2325
struct AccelerationStructureBuildDescConverter

src/vulkan/vk-api.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ namespace rhi::vk {
221221
x(vkCmdDrawMeshTasksEXT) \
222222
x(vkConvertCooperativeVectorMatrixNV) \
223223
x(vkCmdConvertCooperativeVectorMatrixNV) \
224+
x(vkGetDescriptorSetLayoutSupport) \
224225
/* */
225226

226227
#define VK_API_ALL_GLOBAL_PROCS(x) \
@@ -373,6 +374,16 @@ struct VulkanExtendedFeatureProperties
373374
VkPhysicalDeviceCooperativeMatrixFeaturesKHR cooperativeMatrix1Features = {
374375
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR
375376
};
377+
378+
// Descriptor indexing features
379+
VkPhysicalDeviceDescriptorIndexingFeatures descriptorIndexingFeatures = {
380+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES
381+
};
382+
383+
// Mutable descriptor type features
384+
VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT mutableDescriptorTypeFeatures = {
385+
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT
386+
};
376387
};
377388

378389
struct VulkanApi

0 commit comments

Comments
 (0)