1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-02-13 03:40:49 +00:00

rsx: Style changes

This commit is contained in:
Jake 2015-12-02 03:44:56 -06:00
parent 19cf749944
commit 52be47ca89
3 changed files with 43 additions and 31 deletions

@ -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<u32[]> tempSwizzled(new u32[currentHeight * currentWidth]);
rsx::convert_linear_swizzle<u32>(castedSrc, tempSwizzled.get(), currentWidth, currentHeight, true);
std::unique_ptr<u32[]> temp_swizzled(new u32[currentHeight * currentWidth]);
rsx::convert_linear_swizzle<u32>(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<u16[]> tempSwizzled(new u16[currentHeight * currentWidth]);
rsx::convert_linear_swizzle<u16>(castedSrc, tempSwizzled.get(), currentWidth, currentHeight, true);
std::unique_ptr<u16[]> temp_swizzled(new u16[currentHeight * currentWidth]);
rsx::convert_linear_swizzle<u16>(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);
}

@ -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<u8>(linear_pixels, sw_temp2.get(), out_w, out_h, sw_width, sw_height);
break;

@ -126,16 +126,19 @@ namespace rsx
u32 get_address(u32 offset, u32 location);
template<typename T>
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<T*>(inputPixels);
dst = static_cast<T*>(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<T*>(inputPixels) + y*width;
dst = static_cast<T*>(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<T*>(inputPixels) + offs_y;
dst = static_cast<T*>(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;
}