mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d: Validate sub-resource index in d3d12_resource_Map().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
dc36ab41e3
commit
91c11eed03
@ -811,6 +811,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
|
||||
const D3D12_RANGE *read_range, void **data)
|
||||
{
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
|
||||
unsigned int sub_resource_count;
|
||||
struct d3d12_device *device;
|
||||
VkResult vr;
|
||||
HRESULT hr;
|
||||
@ -826,6 +827,13 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
sub_resource_count = d3d12_resource_desc_get_sub_resource_count(&resource->desc);
|
||||
if (sub_resource >= sub_resource_count)
|
||||
{
|
||||
WARN("Sub-resource index %u is out of range (%u sub-resources).\n", sub_resource, sub_resource_count);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (d3d12_resource_is_texture(resource))
|
||||
{
|
||||
/* Textures seem to be mappable only on UMA adapters. */
|
||||
|
@ -861,6 +861,11 @@ static inline unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOU
|
||||
return desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? desc->DepthOrArraySize : 1;
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_sub_resource_count(const D3D12_RESOURCE_DESC *desc)
|
||||
{
|
||||
return d3d12_resource_desc_get_layer_count(desc) * desc->MipLevels;
|
||||
}
|
||||
|
||||
enum VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op) DECLSPEC_HIDDEN;
|
||||
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc) DECLSPEC_HIDDEN;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user