mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[d3d11] Validate subresource index in MapImage
Fixes crashes when passing an invalid subresource index.
This commit is contained in:
parent
3168626f4b
commit
754cf6da30
@ -214,6 +214,9 @@ namespace dxvk {
|
||||
Logger::err("D3D11: Cannot map a device-local image");
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (unlikely(Subresource >= pTexture->CountSubresources()))
|
||||
return E_INVALIDARG;
|
||||
|
||||
VkFormat packedFormat = m_parent->LookupPackedFormat(
|
||||
pTexture->Desc()->Format, pTexture->GetFormatMode()).Format;
|
||||
|
@ -339,6 +339,9 @@ namespace dxvk {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (unlikely(Subresource >= pResource->CountSubresources()))
|
||||
return E_INVALIDARG;
|
||||
|
||||
pResource->SetMapType(Subresource, MapType);
|
||||
|
||||
VkFormat packedFormat = m_parent->LookupPackedFormat(
|
||||
|
@ -74,6 +74,14 @@ namespace dxvk {
|
||||
const D3D11_COMMON_TEXTURE_DESC* Desc() const {
|
||||
return &m_desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Counts number of subresources
|
||||
* \returns Number of subresources
|
||||
*/
|
||||
UINT CountSubresources() const {
|
||||
return m_desc.ArraySize * m_desc.MipLevels;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Map mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user