1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 19:24:12 +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();
uint8_t* ptr = reinterpret_cast<uint8_t*>(m_data.Ptr());
if (ptr == nullptr)
return nullptr;
ptr += m_memoryOffset[Subresource];
return ptr;
}

View File

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

View File

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