diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 184385f8..a4e70812 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -162,6 +162,11 @@ namespace dxvk { D3D11_BUFFER_DESC resourceDesc; resource->GetDesc(&resourceDesc); + if ((resourceDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) { + Logger::warn("D3D11: Trying to create SRV for buffer without D3D11_BIND_SHADER_RESOURCE"); + return E_INVALIDARG; + } + DxvkBufferViewCreateInfo viewInfo; D3D11_BUFFEREX_SRV bufInfo; @@ -223,6 +228,11 @@ namespace dxvk { const D3D11TextureInfo* textureInfo = GetCommonTextureInfo(pResource); + if ((textureInfo->bindFlags & D3D11_BIND_SHADER_RESOURCE) == 0) { + Logger::warn("D3D11: Trying to create SRV for texture without D3D11_BIND_SHADER_RESOURCE"); + return E_INVALIDARG; + } + // Fill in the view info. The view type depends solely // on the view dimension field in the view description, // not on the resource type. @@ -358,6 +368,11 @@ namespace dxvk { D3D11_BUFFER_DESC resourceDesc; resource->GetDesc(&resourceDesc); + if ((resourceDesc.BindFlags & D3D11_BIND_UNORDERED_ACCESS) == 0) { + Logger::warn("D3D11: Trying to create UAV for buffer without D3D11_BIND_UNORDERED_ACCESS"); + return E_INVALIDARG; + } + DxvkBufferViewCreateInfo viewInfo; if (desc.Buffer.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) { @@ -409,6 +424,11 @@ namespace dxvk { const D3D11TextureInfo* textureInfo = GetCommonTextureInfo(pResource); + if ((textureInfo->bindFlags & D3D11_BIND_UNORDERED_ACCESS) == 0) { + Logger::warn("D3D11: Trying to create UAV for texture without D3D11_BIND_UNORDERED_ACCESS"); + return E_INVALIDARG; + } + // Fill in the view info. The view type depends solely // on the view dimension field in the view description, // not on the resource type. @@ -514,6 +534,11 @@ namespace dxvk { const D3D11TextureInfo* textureInfo = GetCommonTextureInfo(pResource); + if ((textureInfo->bindFlags & D3D11_BIND_RENDER_TARGET) == 0) { + Logger::warn("D3D11: Trying to create RTV for texture without D3D11_BIND_RENDER_TARGET"); + return E_INVALIDARG; + } + // Fill in Vulkan image view info DxvkImageViewCreateInfo viewInfo; viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DxgiFormatMode::Color).format; @@ -610,6 +635,11 @@ namespace dxvk { const D3D11TextureInfo* textureInfo = GetCommonTextureInfo(pResource); + if ((textureInfo->bindFlags & D3D11_BIND_DEPTH_STENCIL) == 0) { + Logger::warn("D3D11: Trying to create DSV for texture without D3D11_BIND_DEPTH_STENCIL"); + return E_INVALIDARG; + } + // Fill in Vulkan image view info DxvkImageViewCreateInfo viewInfo; viewInfo.format = m_dxgiAdapter->LookupFormat(desc.Format, DxgiFormatMode::Depth).format; diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index 585c6da7..83e1efa7 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -205,6 +205,9 @@ namespace dxvk { m_texInfo.imageBuffer = m_desc.CPUAccessFlags != 0 ? CreateImageBuffer(pDevice->GetDXVKDevice(), info.format, info.extent) : nullptr; + + m_texInfo.usage = m_desc.Usage; + m_texInfo.bindFlags = m_desc.BindFlags; } /////////////////////////////////////////// @@ -302,6 +305,9 @@ namespace dxvk { m_texInfo.imageBuffer = m_desc.CPUAccessFlags != 0 ? CreateImageBuffer(pDevice->GetDXVKDevice(), info.format, info.extent) : nullptr; + + m_texInfo.usage = m_desc.Usage; + m_texInfo.bindFlags = m_desc.BindFlags; } @@ -396,6 +402,9 @@ namespace dxvk { m_texInfo.imageBuffer = m_desc.CPUAccessFlags != 0 ? CreateImageBuffer(pDevice->GetDXVKDevice(), info.format, info.extent) : nullptr; + + m_texInfo.usage = m_desc.Usage; + m_texInfo.bindFlags = m_desc.BindFlags; } diff --git a/src/d3d11/d3d11_texture.h b/src/d3d11/d3d11_texture.h index d185367d..350bdf89 100644 --- a/src/d3d11/d3d11_texture.h +++ b/src/d3d11/d3d11_texture.h @@ -20,6 +20,9 @@ namespace dxvk { Rc imageBuffer; Rc image; + D3D11_USAGE usage; + UINT bindFlags; + VkImageSubresource mappedSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 }; };