Fix mipmapped cubemaps
which had broken faces (other than the first face) because the slice pitch calculation did not account for mipmaps. We are iterating the mipmaps already, so just calculate the slice pitch directly rather than trying to generalize CxbxGetPixelContainerMeasures
This commit is contained in:
parent
31a47cde37
commit
6cbb385b89
|
@ -5848,6 +5848,7 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex
|
|||
blockSize = X_Format == xbox::X_D3DFMT_DXT1 ? 8 : 16;
|
||||
}
|
||||
|
||||
DWORD actualSlicePitch = dwSlicePitch;
|
||||
for (int face = D3DCUBEMAP_FACE_POSITIVE_X; face <= last_face; face++) {
|
||||
// As we iterate through mipmap levels, we'll adjust the source resource offset
|
||||
DWORD dwMipOffset = 0;
|
||||
|
@ -5924,6 +5925,11 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex
|
|||
|
||||
uint8_t *pSrc = (uint8_t *)VirtualAddr + dwCubeFaceOffset + dwMipOffset;
|
||||
|
||||
// If this is the final mip of the first cube face, set the cube face size
|
||||
if (face == D3DCUBEMAP_FACE_POSITIVE_X && mipmap_level >= dwMipMapLevels - 1) {
|
||||
actualSlicePitch = ROUND_UP(((UINT)pSrc + mipSlicePitch) - (UINT)VirtualAddr, X_D3DTEXTURE_CUBEFACE_ALIGNMENT);
|
||||
}
|
||||
|
||||
// Copy texture data to the host resource
|
||||
if (bConvertToARGB) {
|
||||
EmuLog(LOG_LEVEL::DEBUG, "Unsupported texture format, expanding to D3DFMT_A8R8G8B8");
|
||||
|
@ -6023,7 +6029,7 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex
|
|||
}
|
||||
} // for mipmap levels
|
||||
|
||||
dwCubeFaceOffset += dwSlicePitch;
|
||||
dwCubeFaceOffset += actualSlicePitch;
|
||||
} // for cube faces
|
||||
|
||||
|
||||
|
|
|
@ -1614,6 +1614,7 @@ void CxbxGetPixelContainerMeasures
|
|||
UINT* pHeight,
|
||||
UINT* pDepth,
|
||||
UINT* pRowPitch,
|
||||
// Slice pitch (does not include mipmaps!)
|
||||
UINT* pSlicePitch
|
||||
)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue