Fix an issue with mipmap levels when using non-square textures

This commit is contained in:
Luke Usher 2019-04-09 11:59:45 +01:00
parent 670d90651c
commit 53dc6441c6
1 changed files with 4 additions and 4 deletions

View File

@ -4908,9 +4908,9 @@ void CreateHostResource(XTL::X_D3DResource *pResource, DWORD D3DUsage, int iText
// Because of this, we need to cap dwMipMapLevels when required // Because of this, we need to cap dwMipMapLevels when required
if (dwMipMapLevels > 0) { if (dwMipMapLevels > 0) {
// Calculate how many mip-map levels it takes to get to a texture of 1 pixels in either dimension // Calculate how many mip-map levels it takes to get to a texture of 1 pixels in either dimension
UINT highestMipMapLevel = 0; UINT highestMipMapLevel = 1;
UINT width = dwWidth; UINT height = dwHeight; UINT width = dwWidth; UINT height = dwHeight;
while (width > 1 && height > 1) { while (width > 1 || height > 1) {
width /= 2; width /= 2;
height /= 2; height /= 2;
highestMipMapLevel++; highestMipMapLevel++;
@ -4918,9 +4918,9 @@ void CreateHostResource(XTL::X_D3DResource *pResource, DWORD D3DUsage, int iText
// If the desired mip-map level was higher than the maximum possible, cap it // If the desired mip-map level was higher than the maximum possible, cap it
// Test case: Shin Megami Tensei: Nine // Test case: Shin Megami Tensei: Nine
if (dwMipMapLevels > highestMipMapLevel + 1) { if (dwMipMapLevels > highestMipMapLevel) {
LOG_TEST_CASE("Too many mip-map levels"); LOG_TEST_CASE("Too many mip-map levels");
dwMipMapLevels = highestMipMapLevel + 1; dwMipMapLevels = highestMipMapLevel;
} }
} }