From 0a473b4f865d5faa820f359de3eb39ebc7a9c0fd Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 18 Mar 2018 21:38:48 +0100 Subject: [PATCH] [d3d11] Return error if an application creates an RTV for a buffer Vulkan does not support buffer RTVs, and neither does DXVK, so we should return an error in that case. Previously, DXVK would crash upon querying image information. --- src/d3d11/d3d11_device.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index a27ac835..0a97e73f 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -581,10 +581,15 @@ namespace dxvk { ID3D11Resource* pResource, const D3D11_RENDER_TARGET_VIEW_DESC* pDesc, ID3D11RenderTargetView** ppRTView) { - // Only 2D textures and 2D texture arrays are allowed + // DXVK only supports render target views for image resources D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; pResource->GetType(&resourceDim); + if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) { + Logger::err("D3D11: Cannot create render target view for a buffer"); + return E_INVALIDARG; + } + // The view description is optional. If not defined, it // will use the resource's format and all array layers. D3D11_RENDER_TARGET_VIEW_DESC desc; @@ -698,7 +703,6 @@ namespace dxvk { ID3D11Resource* pResource, const D3D11_DEPTH_STENCIL_VIEW_DESC* pDesc, ID3D11DepthStencilView** ppDepthStencilView) { - // Only 2D textures and 2D texture arrays are allowed D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; pResource->GetType(&resourceDim);