mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 10:54:16 +01:00
[d3d9] Respect aligned pitch when using initial data
This commit is contained in:
parent
a58feaa16e
commit
b4e6f81cb5
@ -413,6 +413,9 @@ namespace dxvk {
|
||||
return m_dirtyBoxes[layer];
|
||||
}
|
||||
|
||||
static VkImageType GetImageTypeFromResourceType(
|
||||
D3DRESOURCETYPE Dimension);
|
||||
|
||||
private:
|
||||
|
||||
D3D9DeviceEx* m_device;
|
||||
@ -490,9 +493,6 @@ namespace dxvk {
|
||||
VkImageLayout OptimizeLayout(
|
||||
VkImageUsageFlags Usage) const;
|
||||
|
||||
static VkImageType GetImageTypeFromResourceType(
|
||||
D3DRESOURCETYPE Dimension);
|
||||
|
||||
static VkImageViewType GetImageViewTypeFromResourceType(
|
||||
D3DRESOURCETYPE Dimension,
|
||||
UINT Layer);
|
||||
|
@ -131,18 +131,36 @@ namespace dxvk {
|
||||
// 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.
|
||||
for (uint32_t i = 0; i < pTexture->CountSubresources(); i++) {
|
||||
DxvkBufferSliceHandle mapSlice = pTexture->GetBuffer(i)->getSliceHandle();
|
||||
const D3D9_COMMON_TEXTURE_DESC* desc = pTexture->Desc();
|
||||
for (uint32_t a = 0; a < desc->ArraySize; a++) {
|
||||
for (uint32_t m = 0; m < desc->MipLevels; m++) {
|
||||
uint32_t subresource = pTexture->CalcSubresource(a, m);
|
||||
DxvkBufferSliceHandle mapSlice = pTexture->GetBuffer(subresource)->getSliceHandle();
|
||||
|
||||
if (pInitialData != nullptr) {
|
||||
std::memcpy(
|
||||
mapSlice.mapPtr,
|
||||
pInitialData,
|
||||
mapSlice.length);
|
||||
} else {
|
||||
std::memset(
|
||||
mapSlice.mapPtr, 0,
|
||||
mapSlice.length);
|
||||
if (pInitialData != nullptr) {
|
||||
VkExtent3D mipExtent = pTexture->GetExtentMip(m);
|
||||
const DxvkFormatInfo* formatInfo = imageFormatInfo(pTexture->GetFormatMapping().FormatColor);
|
||||
VkExtent3D blockCount = util::computeBlockCount(mipExtent, formatInfo->blockSize);
|
||||
uint32_t pitch = blockCount.width * formatInfo->elementSize;
|
||||
uint32_t alignedPitch = align(pitch, 4);
|
||||
|
||||
util::packImageData(
|
||||
mapSlice.mapPtr,
|
||||
pInitialData,
|
||||
pitch,
|
||||
pitch * blockCount.height,
|
||||
alignedPitch,
|
||||
alignedPitch * blockCount.height,
|
||||
D3D9CommonTexture::GetImageTypeFromResourceType(pTexture->GetType()),
|
||||
mipExtent,
|
||||
pTexture->Desc()->ArraySize,
|
||||
formatInfo,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
} else {
|
||||
std::memset(
|
||||
mapSlice.mapPtr, 0,
|
||||
mapSlice.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user