@@ -1788,12 +1788,6 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic
1788
1788
1789
1789
VkResult ret = ObjDisp (device)->CreateBuffer (Unwrap (device), &patched, NULL , &buf);
1790
1790
1791
- if (CreateInfo.flags &
1792
- (VK_BUFFER_CREATE_SPARSE_BINDING_BIT | VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT))
1793
- {
1794
- APIProps.SparseResources = true ;
1795
- }
1796
-
1797
1791
SetBufferUsageFlags (&CreateInfo, origusage);
1798
1792
1799
1793
if (ret != VK_SUCCESS)
@@ -1811,6 +1805,34 @@ bool WrappedVulkan::Serialise_vkCreateBuffer(SerialiserType &ser, VkDevice devic
1811
1805
memoryRequirements);
1812
1806
}
1813
1807
1808
+ if (CreateInfo.flags &
1809
+ (VK_BUFFER_CREATE_SPARSE_BINDING_BIT | VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT))
1810
+ {
1811
+ APIProps.SparseResources = true ;
1812
+
1813
+ // for sparse BDA buffers we can and must request the address now since it won't be queried on memory bind
1814
+ if (CreateInfo.usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT)
1815
+ {
1816
+ VulkanCreationInfo::Buffer &bufInfo = m_CreationInfo.m_Buffer [GetResID (buf)];
1817
+
1818
+ VkBufferDeviceAddressInfo getInfo = {
1819
+ VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
1820
+ NULL ,
1821
+ Unwrap (buf),
1822
+ };
1823
+
1824
+ RDCCOMPILE_ASSERT (VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO ==
1825
+ VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_EXT,
1826
+ " KHR and EXT buffer_device_address should be interchangeable here." );
1827
+
1828
+ if (GetExtensions (GetRecord (device)).ext_KHR_buffer_device_address )
1829
+ bufInfo.gpuAddress = ObjDisp (device)->GetBufferDeviceAddress (Unwrap (device), &getInfo);
1830
+ else if (GetExtensions (GetRecord (device)).ext_EXT_buffer_device_address )
1831
+ bufInfo.gpuAddress = ObjDisp (device)->GetBufferDeviceAddressEXT (Unwrap (device), &getInfo);
1832
+ m_CreationInfo.m_BufferAddresses [bufInfo.gpuAddress ] = GetResID (buf);
1833
+ }
1834
+ }
1835
+
1814
1836
AddResource (Buffer, ResourceType::Buffer, " Buffer" );
1815
1837
DerivedResource (device, Buffer);
1816
1838
}
0 commit comments