mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-21 13:54:18 +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];
|
return m_dirtyBoxes[layer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VkImageType GetImageTypeFromResourceType(
|
||||||
|
D3DRESOURCETYPE Dimension);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
D3D9DeviceEx* m_device;
|
D3D9DeviceEx* m_device;
|
||||||
@ -490,9 +493,6 @@ namespace dxvk {
|
|||||||
VkImageLayout OptimizeLayout(
|
VkImageLayout OptimizeLayout(
|
||||||
VkImageUsageFlags Usage) const;
|
VkImageUsageFlags Usage) const;
|
||||||
|
|
||||||
static VkImageType GetImageTypeFromResourceType(
|
|
||||||
D3DRESOURCETYPE Dimension);
|
|
||||||
|
|
||||||
static VkImageViewType GetImageViewTypeFromResourceType(
|
static VkImageViewType GetImageViewTypeFromResourceType(
|
||||||
D3DRESOURCETYPE Dimension,
|
D3DRESOURCETYPE Dimension,
|
||||||
UINT Layer);
|
UINT Layer);
|
||||||
|
@ -131,18 +131,36 @@ namespace dxvk {
|
|||||||
// 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.
|
||||||
for (uint32_t i = 0; i < pTexture->CountSubresources(); i++) {
|
const D3D9_COMMON_TEXTURE_DESC* desc = pTexture->Desc();
|
||||||
DxvkBufferSliceHandle mapSlice = pTexture->GetBuffer(i)->getSliceHandle();
|
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) {
|
if (pInitialData != nullptr) {
|
||||||
std::memcpy(
|
VkExtent3D mipExtent = pTexture->GetExtentMip(m);
|
||||||
mapSlice.mapPtr,
|
const DxvkFormatInfo* formatInfo = imageFormatInfo(pTexture->GetFormatMapping().FormatColor);
|
||||||
pInitialData,
|
VkExtent3D blockCount = util::computeBlockCount(mipExtent, formatInfo->blockSize);
|
||||||
mapSlice.length);
|
uint32_t pitch = blockCount.width * formatInfo->elementSize;
|
||||||
} else {
|
uint32_t alignedPitch = align(pitch, 4);
|
||||||
std::memset(
|
|
||||||
mapSlice.mapPtr, 0,
|
util::packImageData(
|
||||||
mapSlice.length);
|
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