diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 86a31f02e4..1aa78dbc72 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -65,10 +65,10 @@ writeTexelsSwizzled(const char *src, char *dst, size_t widthInBlock, size_t heig castedSrc = (u32*)src + offsetInSrc; castedDst = (u32*)dst + offsetInDst; - std::unique_ptr tempSwizzled(new u32[currentHeight * currentWidth]); - rsx::convert_linear_swizzle(castedSrc, tempSwizzled.get(), currentWidth, currentHeight, true); + std::unique_ptr temp_swizzled(new u32[currentHeight * currentWidth]); + rsx::convert_linear_swizzle(castedSrc, temp_swizzled.get(), currentWidth, currentHeight, true); for (unsigned row = 0; row < currentHeight; row++) - memcpy((char*)dst + offsetInDst + row * rowPitch, (char*)tempSwizzled.get() + offsetInSrc + row * widthInBlock * blockSize, currentWidth * blockSize); + memcpy((char*)dst + offsetInDst + row * rowPitch, (char*)temp_swizzled.get() + offsetInSrc + row * widthInBlock * blockSize, currentWidth * blockSize); offsetInDst += currentHeight * rowPitch; offsetInSrc += currentHeight * widthInBlock * blockSize; @@ -138,12 +138,12 @@ write16bTexelsSwizzled(const char *src, char *dst, size_t widthInBlock, size_t h castedSrc = (u16*)src + offsetInSrc; castedDst = (u16*)dst + offsetInDst; - std::unique_ptr tempSwizzled(new u16[currentHeight * currentWidth]); - rsx::convert_linear_swizzle(castedSrc, tempSwizzled.get(), currentWidth, currentHeight, true); + std::unique_ptr temp_swizzled(new u16[currentHeight * currentWidth]); + rsx::convert_linear_swizzle(castedSrc, temp_swizzled.get(), currentWidth, currentHeight, true); for (unsigned row = 0; row < heightInBlock; row++) for (int j = 0; j < currentWidth; j++) { - u16 tmp = tempSwizzled[offsetInSrc / 2 + row * srcPitch / 2 + j]; + u16 tmp = temp_swizzled[offsetInSrc / 2 + row * srcPitch / 2 + j]; castedDst[offsetInDst / 2 + row * rowPitch / 2 + j] = (tmp >> 8) | (tmp << 8); } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 75bed43a8c..c8a39e3060 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -359,7 +359,8 @@ namespace rsx // handle weird RSX quirk, doesn't report less than 16 pixels width in some cases u16 src_width = method_registers[NV3089_IMAGE_IN_SIZE]; - if (src_width == 16 && out_w < 16 && method_registers[NV3089_DS_DX] == (1 << 20)) { + if (src_width == 16 && out_w < 16 && method_registers[NV3089_DS_DX] == (1 << 20)) + { src_width = out_w; } @@ -524,10 +525,12 @@ namespace rsx u8* swizzled_pixels = sw_temp.get(); // Check and pad texture out if we are given non square texture for swizzle to be correct - if (sw_width != out_w || sw_height != out_h) { + if (sw_width != out_w || sw_height != out_h) + { sw_temp2.reset(new u8[out_bpp * sw_width * sw_height]()); - switch (out_bpp) { + switch (out_bpp) + { case 1: pad_texture(linear_pixels, sw_temp2.get(), out_w, out_h, sw_width, sw_height); break; diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index ee0add933f..c65e9133cb 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -126,16 +126,19 @@ namespace rsx u32 get_address(u32 offset, u32 location); template - void pad_texture(void* inputPixels, void* outputPixels, u16 inputWidth, u16 inputHeight, u16 outputWidth, u16 outputHeight) { + void pad_texture(void* inputPixels, void* outputPixels, u16 inputWidth, u16 inputHeight, u16 outputWidth, u16 outputHeight) + { T *src, *dst; - src = (T *)(inputPixels); - dst = (T *)(outputPixels); + src = static_cast(inputPixels); + dst = static_cast(outputPixels); - for (u16 h = 0; h < inputHeight; ++h) { - const u32 paddedPos = h * outputWidth; + for (u16 h = 0; h < inputHeight; ++h) + { + const u32 padded_pos = h * outputWidth; const u32 pos = h * inputWidth; - for (u16 w = 0; w < inputWidth; ++w) { - dst[paddedPos + w] = src[pos + w]; + for (u16 w = 0; w < inputWidth; ++w) + { + dst[padded_pos + w] = src[pos + w]; } } } @@ -158,28 +161,31 @@ namespace rsx u32 y_mask = 0xAAAAAAAA; // We have to limit the masks to the lower of the two dimensions to allow for non-square textures - u32 limitMask = (log2width < log2height) ? log2width : log2height; + u32 limit_mask = (log2width < log2height) ? log2width : log2height; // double the limit mask to account for bits in both x and y - limitMask = 1 << (limitMask << 1); + limit_mask = 1 << (limit_mask << 1); //x_mask, bits above limit are 1's for x-carry - x_mask = (x_mask | ~(limitMask - 1)); + x_mask = (x_mask | ~(limit_mask - 1)); //y_mask. bits above limit are 0'd, as we use a different method for y-carry over - y_mask = (y_mask & (limitMask - 1)); + y_mask = (y_mask & (limit_mask - 1)); u32 offs_y = 0; u32 offs_x = 0; u32 offs_x0 = 0; //total y-carry offset for x - u32 y_incr = limitMask; + u32 y_incr = limit_mask; T *src, *dst; - if (!inputIsSwizzled) { - for (int y = 0; y < height; ++y) { - src = (T *)((T*)inputPixels + y*width); - dst = (T *)((T*)outputPixels + offs_y); + if (!inputIsSwizzled) + { + for (int y = 0; y < height; ++y) + { + src = static_cast(inputPixels) + y*width; + dst = static_cast(outputPixels) + offs_y; offs_x = offs_x0; - for (int x = 0; x < width; ++x) { + for (int x = 0; x < width; ++x) + { dst[offs_x] = src[x]; offs_x = (offs_x - x_mask) & x_mask; } @@ -187,12 +193,15 @@ namespace rsx if (offs_y == 0) offs_x0 += y_incr; } } - else { - for (int y = 0; y < height; ++y) { - src = (T *)((T*)inputPixels + offs_y); - dst = (T *)((T*)outputPixels + y*width); + else + { + for (int y = 0; y < height; ++y) + { + src = static_cast(inputPixels) + offs_y; + dst = static_cast(outputPixels) + y*width; offs_x = offs_x0; - for (int x = 0; x < width; ++x) { + for (int x = 0; x < width; ++x) + { dst[x] = src[offs_x]; offs_x = (offs_x - x_mask) & x_mask; }