diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index 62be0f449..b741d9401 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -74,8 +74,12 @@ namespace dxvk { if ((m_buffer->info().usage & usage) != usage) return false; - // TODO implement format validation - return true; + // Check whether the given combination of buffer view + // type and view format is supported by the device + DXGI_VK_FORMAT_INFO viewFormat = m_device->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY); + VkFormatFeatureFlags features = GetBufferFormatFeatures(BindFlags); + + return CheckFormatFeatureSupport(viewFormat.Format, features); } @@ -163,6 +167,14 @@ namespace dxvk { return m_device->GetDXVKDevice()->createBuffer(info, memoryFlags); } + + + BOOL D3D11Buffer::CheckFormatFeatureSupport( + VkFormat Format, + VkFormatFeatureFlags Features) const { + VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format); + return (properties.bufferFeatures & Features) == Features; + } D3D11Buffer* GetCommonBuffer(ID3D11Resource* pResource) { diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index e10b8b951..1e1ac21a2 100644 --- a/src/d3d11/d3d11_buffer.h +++ b/src/d3d11/d3d11_buffer.h @@ -82,7 +82,11 @@ namespace dxvk { DxvkPhysicalBufferSlice m_mappedSlice; Rc<DxvkBuffer> CreateBuffer( - const D3D11_BUFFER_DESC* pDesc) const; + const D3D11_BUFFER_DESC* pDesc) const; + + BOOL CheckFormatFeatureSupport( + VkFormat Format, + VkFormatFeatureFlags Features) const; };