diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index d860d0c07..8296f6d6b 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -73,6 +73,16 @@ namespace dxvk { | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT; } + // Set host read bit as necessary. We may internally read staging + // buffer contents even if the buffer is not marked for reading. + if (pDesc->CPUAccessFlags && pDesc->Usage != D3D11_USAGE_DYNAMIC) { + info.stages |= VK_PIPELINE_STAGE_HOST_BIT; + info.access |= VK_ACCESS_HOST_READ_BIT; + + if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) + info.access |= VK_ACCESS_HOST_WRITE_BIT; + } + if (!(pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)) { // Create the buffer and set the entire buffer slice as mapped, // so that we only have to update it when invalidating the buffer diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index 5289202a6..ba6ad0cc1 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -168,6 +168,14 @@ namespace dxvk { if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) { imageInfo.tiling = VK_IMAGE_TILING_LINEAR; imageInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; + + if (pDesc->Usage != D3D11_USAGE_DYNAMIC) { + imageInfo.stages |= VK_PIPELINE_STAGE_HOST_BIT; + imageInfo.access |= VK_ACCESS_HOST_READ_BIT; + + if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) + imageInfo.access |= VK_ACCESS_HOST_WRITE_BIT; + } } // If necessary, create the mapped linear buffer @@ -684,7 +692,17 @@ namespace dxvk { | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; - + + // We may read mapped buffers even if it is + // marked as CPU write-only on the D3D11 side. + if (m_desc.Usage != D3D11_USAGE_DYNAMIC) { + info.stages |= VK_PIPELINE_STAGE_HOST_BIT; + info.access |= VK_ACCESS_HOST_READ_BIT; + + if (m_desc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) + info.access |= VK_ACCESS_HOST_WRITE_BIT; + } + VkMemoryPropertyFlags memType = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;