1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 13:24:20 +01:00

[d3d9] Handle map failure in texture initializer

This commit is contained in:
Paul Gofman 2024-07-31 11:50:31 -06:00 committed by Philip Rebohle
parent e38693cdbc
commit 5c987ea3d1
3 changed files with 20 additions and 8 deletions

View File

@ -194,6 +194,8 @@ namespace dxvk {
m_data.Map(); m_data.Map();
uint8_t* ptr = reinterpret_cast<uint8_t*>(m_data.Ptr()); uint8_t* ptr = reinterpret_cast<uint8_t*>(m_data.Ptr());
if (ptr == nullptr)
return nullptr;
ptr += m_memoryOffset[Subresource]; ptr += m_memoryOffset[Subresource];
return ptr; return ptr;
} }

View File

@ -44,11 +44,21 @@ namespace dxvk {
if (pTexture->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_NONE) if (pTexture->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_NONE)
return; return;
void* mapPtr = nullptr;
if (pTexture->Desc()->Pool != D3DPOOL_DEFAULT) {
mapPtr = pTexture->GetData(0);
if (mapPtr == nullptr)
throw DxvkError("D3D9: InitTexture: map failed");
}
if (pTexture->GetImage() != nullptr) if (pTexture->GetImage() != nullptr)
InitDeviceLocalTexture(pTexture); InitDeviceLocalTexture(pTexture);
if (pTexture->Desc()->Pool != D3DPOOL_DEFAULT) if (mapPtr != nullptr) {
InitHostVisibleTexture(pTexture, pInitialData); InitHostVisibleTexture(pTexture, pInitialData, mapPtr);
pTexture->UnmapData();
}
} }
@ -109,11 +119,11 @@ namespace dxvk {
void D3D9Initializer::InitHostVisibleTexture( void D3D9Initializer::InitHostVisibleTexture(
D3D9CommonTexture* pTexture, D3D9CommonTexture* pTexture,
void* pInitialData) { void* pInitialData,
void* mapPtr) {
// If the buffer is mapped, we can write data directly // If the buffer is mapped, we can write data directly
// to the mapped memory region instead of doing it on // to the mapped memory region instead of doing it on
// the GPU. Same goes for zero-initialization. // the GPU. Same goes for zero-initialization.
void* mapPtr = pTexture->GetData(0);
if (pInitialData) { if (pInitialData) {
// Initial data is only supported for textures with 1 subresource // Initial data is only supported for textures with 1 subresource
VkExtent3D mipExtent = pTexture->GetExtentMip(0); VkExtent3D mipExtent = pTexture->GetExtentMip(0);
@ -141,7 +151,6 @@ namespace dxvk {
mapPtr, 0, mapPtr, 0,
pTexture->GetTotalSize()); pTexture->GetTotalSize());
} }
pTexture->UnmapData();
} }

View File

@ -52,7 +52,8 @@ namespace dxvk {
void InitHostVisibleTexture( void InitHostVisibleTexture(
D3D9CommonTexture* pTexture, D3D9CommonTexture* pTexture,
void* pInitialData); void* pInitialData,
void* mapPtr);
void FlushImplicit(); void FlushImplicit();
void FlushInternal(); void FlushInternal();