mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[d3d11] Enable device address usage for non-mappable buffers
NVAPI queries the GPU address of certain resources in a way that could break otherwise.
This commit is contained in:
parent
fb552db65f
commit
c8410e578e
@ -94,17 +94,27 @@ namespace dxvk {
|
||||
if (m_desc.CPUAccessFlags)
|
||||
m_11on12.Resource->Map(0, nullptr, &importInfo.mapPtr);
|
||||
|
||||
// D3D12 will always have BDA enabled
|
||||
info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
|
||||
|
||||
m_buffer = m_parent->GetDXVKDevice()->importBuffer(info, importInfo, GetMemoryFlags());
|
||||
m_mapped = m_buffer->getSliceHandle();
|
||||
|
||||
m_mapMode = DetermineMapMode();
|
||||
m_mapMode = DetermineMapMode(m_buffer->memFlags());
|
||||
} else if (!(pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)) {
|
||||
VkMemoryPropertyFlags memoryFlags = GetMemoryFlags();
|
||||
m_mapMode = DetermineMapMode(memoryFlags);
|
||||
|
||||
// Prevent buffer renaming for buffers that are not mappable, so
|
||||
// that interop interfaces can safely query the GPU address.
|
||||
if (m_mapMode == D3D11_COMMON_BUFFER_MAP_MODE_NONE
|
||||
&& m_parent->GetDXVKDevice()->features().vk12.bufferDeviceAddress)
|
||||
info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
|
||||
|
||||
// Create the buffer and set the entire buffer slice as mapped,
|
||||
// so that we only have to update it when invalidating the buffer
|
||||
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, GetMemoryFlags());
|
||||
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, memoryFlags);
|
||||
m_mapped = m_buffer->getSliceHandle();
|
||||
|
||||
m_mapMode = DetermineMapMode();
|
||||
} else {
|
||||
m_sparseAllocator = m_parent->GetDXVKDevice()->createSparsePageAllocator();
|
||||
m_sparseAllocator->setCapacity(info.size / SparseMemoryPageSize);
|
||||
@ -369,8 +379,8 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
D3D11_COMMON_BUFFER_MAP_MODE D3D11Buffer::DetermineMapMode() {
|
||||
return (m_buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
D3D11_COMMON_BUFFER_MAP_MODE D3D11Buffer::DetermineMapMode(VkMemoryPropertyFlags MemFlags) {
|
||||
return (MemFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
? D3D11_COMMON_BUFFER_MAP_MODE_DIRECT
|
||||
: D3D11_COMMON_BUFFER_MAP_MODE_NONE;
|
||||
}
|
||||
|
@ -198,7 +198,8 @@ namespace dxvk {
|
||||
|
||||
Rc<DxvkBuffer> CreateSoCounterBuffer();
|
||||
|
||||
D3D11_COMMON_BUFFER_MAP_MODE DetermineMapMode();
|
||||
static D3D11_COMMON_BUFFER_MAP_MODE DetermineMapMode(
|
||||
VkMemoryPropertyFlags MemFlags);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user