mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-20 17:52:11 +01:00
[d3d11] Fix potential crash when mapping a default image fails
This also marginally shortens common code paths.
This commit is contained in:
parent
c2928ab3e2
commit
e499f2e081
@ -280,23 +280,14 @@ namespace dxvk {
|
|||||||
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||||
pResource->GetType(&resourceDim);
|
pResource->GetType(&resourceDim);
|
||||||
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
if (likely(resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER)) {
|
if (likely(resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER)) {
|
||||||
hr = MapBuffer(
|
return MapBuffer(
|
||||||
static_cast<D3D11Buffer*>(pResource),
|
static_cast<D3D11Buffer*>(pResource),
|
||||||
MapType, MapFlags, pMappedResource);
|
MapType, MapFlags, pMappedResource);
|
||||||
} else {
|
} else {
|
||||||
hr = MapImage(
|
return MapImage(GetCommonTexture(pResource),
|
||||||
GetCommonTexture(pResource),
|
Subresource, MapType, MapFlags, pMappedResource);
|
||||||
Subresource, MapType, MapFlags,
|
|
||||||
pMappedResource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(FAILED(hr)))
|
|
||||||
*pMappedResource = D3D11_MAPPED_SUBRESOURCE();
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,6 +319,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (unlikely(pResource->GetMapMode() == D3D11_COMMON_BUFFER_MAP_MODE_NONE)) {
|
if (unlikely(pResource->GetMapMode() == D3D11_COMMON_BUFFER_MAP_MODE_NONE)) {
|
||||||
Logger::err("D3D11: Cannot map a device-local buffer");
|
Logger::err("D3D11: Cannot map a device-local buffer");
|
||||||
|
*pMappedResource = D3D11_MAPPED_SUBRESOURCE();
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,8 +391,10 @@ namespace dxvk {
|
|||||||
pMappedResource->DepthPitch = bufferSize;
|
pMappedResource->DepthPitch = bufferSize;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} else {
|
} else {
|
||||||
if (!WaitForResource(*buffer, sequenceNumber, MapType, MapFlags))
|
if (!WaitForResource(*buffer, sequenceNumber, MapType, MapFlags)) {
|
||||||
|
*pMappedResource = D3D11_MAPPED_SUBRESOURCE();
|
||||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||||
|
}
|
||||||
|
|
||||||
pMappedResource->pData = pResource->GetMapPtr();
|
pMappedResource->pData = pResource->GetMapPtr();
|
||||||
pMappedResource->RowPitch = bufferSize;
|
pMappedResource->RowPitch = bufferSize;
|
||||||
@ -422,6 +416,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
auto mapMode = pResource->GetMapMode();
|
auto mapMode = pResource->GetMapMode();
|
||||||
|
|
||||||
|
if (pMappedResource)
|
||||||
|
*pMappedResource = D3D11_MAPPED_SUBRESOURCE();
|
||||||
|
|
||||||
if (unlikely(mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_NONE)) {
|
if (unlikely(mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_NONE)) {
|
||||||
Logger::err("D3D11: Cannot map a device-local image");
|
Logger::err("D3D11: Cannot map a device-local image");
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user