From 63d8d9c3db3df2f39e5194a22b755aaa81e41f97 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 13 Jun 2019 03:06:11 +0200 Subject: [PATCH] [d3d11] Validate buffer descriptions --- src/d3d11/d3d11_buffer.cpp | 16 ++++++++++++++++ src/d3d11/d3d11_buffer.h | 9 +++++++++ src/d3d11/d3d11_device.cpp | 3 +++ 3 files changed, 28 insertions(+) diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index f9b634ba..bfb8f016 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -198,6 +198,22 @@ namespace dxvk { } + HRESULT D3D11Buffer::ValidateBufferProperties( + const D3D11_BUFFER_DESC* pDesc) { + // Basic validation for structured buffers + if ((pDesc->MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED) + && ((pDesc->StructureByteStride == 0) + || (pDesc->StructureByteStride & 0x3))) + return E_INVALIDARG; + + // Mip generation obviously doesn't work for buffers + if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS) + return E_INVALIDARG; + + return S_OK; + } + + BOOL D3D11Buffer::CheckFormatFeatureSupport( VkFormat Format, VkFormatFeatureFlags Features) const { diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index cfaaa01d..3211c74e 100644 --- a/src/d3d11/d3d11_buffer.h +++ b/src/d3d11/d3d11_buffer.h @@ -112,6 +112,15 @@ namespace dxvk { return &m_d3d10; } + /** + * \brief Validates buffer description + * + * \param [in] pDesc Buffer description + * \returns \c S_OK if the parameters are valid + */ + static HRESULT ValidateBufferProperties( + const D3D11_BUFFER_DESC* pDesc); + private: const Com m_device; diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 1d390106..d613d8ca 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -80,6 +80,9 @@ namespace dxvk { if (pDesc == nullptr) return E_INVALIDARG; + + if (FAILED(D3D11Buffer::ValidateBufferProperties(pDesc))) + return E_INVALIDARG; if (ppBuffer == nullptr) return S_FALSE;