1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-07 16:54:14 +01:00

[d3d11] Validate buffer view format compatibility

Prevents the app from creating illegal buffer views.
This commit is contained in:
Philip Rebohle 2018-08-09 23:37:41 +02:00
parent 9373bab3e3
commit f9e096e954
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 19 additions and 3 deletions

View File

@ -74,8 +74,12 @@ namespace dxvk {
if ((m_buffer->info().usage & usage) != usage) if ((m_buffer->info().usage & usage) != usage)
return false; return false;
// TODO implement format validation // Check whether the given combination of buffer view
return true; // 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);
} }
@ -165,6 +169,14 @@ namespace dxvk {
} }
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) { D3D11Buffer* GetCommonBuffer(ID3D11Resource* pResource) {
D3D11_RESOURCE_DIMENSION dimension = D3D11_RESOURCE_DIMENSION_UNKNOWN; D3D11_RESOURCE_DIMENSION dimension = D3D11_RESOURCE_DIMENSION_UNKNOWN;
pResource->GetType(&dimension); pResource->GetType(&dimension);

View File

@ -84,6 +84,10 @@ namespace dxvk {
Rc<DxvkBuffer> CreateBuffer( Rc<DxvkBuffer> CreateBuffer(
const D3D11_BUFFER_DESC* pDesc) const; const D3D11_BUFFER_DESC* pDesc) const;
BOOL CheckFormatFeatureSupport(
VkFormat Format,
VkFormatFeatureFlags Features) const;
}; };