VideoCommon: Clean up brace placements

This commit is contained in:
Lioncash 2014-08-30 16:51:27 -04:00
parent bc14d6966f
commit 4af8d9d248
7 changed files with 59 additions and 31 deletions

View File

@ -972,7 +972,8 @@ union UPE_Copy
BitField<15,1,u32> intensity_fmt; // if set, is an intensity format (I4,I8,IA4,IA8)
BitField<16,1,u32> auto_conv; // if 0 automatic color conversion by texture format and pixel type
u32 tp_realFormat() {
u32 tp_realFormat()
{
return target_pixel_format / 2 + (target_pixel_format & 1) * 8;
}
};

View File

@ -41,14 +41,16 @@ bool TextureToPng(u8* data, int row_stride, const std::string& filename, int wid
// Open file for writing (binary mode)
File::IOFile fp(filename, "wb");
if (!fp.IsOpen()) {
if (!fp.IsOpen())
{
PanicAlert("Screenshot failed: Could not open file %s %d\n", filename.c_str(), errno);
goto finalise;
}
// Initialize write structure
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (png_ptr == nullptr) {
if (png_ptr == nullptr)
{
PanicAlert("Screenshot failed: Could not allocate write struct\n");
goto finalise;
@ -56,13 +58,15 @@ bool TextureToPng(u8* data, int row_stride, const std::string& filename, int wid
// Initialize info structure
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == nullptr) {
if (info_ptr == nullptr)
{
PanicAlert("Screenshot failed: Could not allocate info struct\n");
goto finalise;
}
// Setup Exception handling
if (setjmp(png_jmpbuf(png_ptr))) {
if (setjmp(png_jmpbuf(png_ptr)))
{
PanicAlert("Screenshot failed: Error during png creation\n");
goto finalise;
}

View File

@ -753,7 +753,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
ColorMask[4] = ColorMask[7] = 1.0f / 15.0f;
cbufid = 16;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 17;
@ -763,7 +764,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1.0f;
cbufid = 18;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 19;
@ -774,7 +776,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1.0f;
cbufid = 20;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[0] = 1.0f;
fConstAdd[1] = 1.0f;
@ -821,7 +824,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
ColorMask[7] = 1.0f / 7.0f;
cbufid = 27;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 28;
@ -831,7 +835,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1.0f;
cbufid = 29;
if (!efbHasAlpha) {
if (!efbHasAlpha)
{
ColorMask[3] = 0.0f;
fConstAdd[3] = 1.0f;
cbufid = 30;

View File

@ -27,7 +27,8 @@ bool TexFmt_Overlay_Center=false;
int TexDecoder_GetTexelSizeInNibbles(int format)
{
switch (format & 0x3f) {
switch (format & 0x3f)
{
case GX_TF_I4: return 1;
case GX_TF_I8: return 2;
case GX_TF_IA4: return 2;
@ -450,7 +451,8 @@ inline void decodebytesARGB8_4(u32 *dst, const u16 *src, const u16 *src2)
inline void decodebytesARGB8_4ToRgba(u32 *dst, const u16 *src, const u16 * src2)
{
#if 0
for (int x = 0; x < 4; x++) {
for (int x = 0; x < 4; x++)
{
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
}
#else
@ -864,7 +866,7 @@ PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int he
memset(dst+(y + iy) * width + x + ix * 2 + 1 , i2,4);
}
}
break;
break;
case GX_TF_I8: // speed critical
{
// Reference C implementation

View File

@ -47,7 +47,8 @@ static bool TexFmt_Overlay_Center=false;
int TexDecoder_GetTexelSizeInNibbles(int format)
{
switch (format & 0x3f) {
switch (format & 0x3f)
{
case GX_TF_I4: return 1;
case GX_TF_I8: return 2;
case GX_TF_IA4: return 2;
@ -496,7 +497,8 @@ inline void decodebytesARGB8_4(u32 *dst, const u16 *src, const u16 *src2)
inline void decodebytesARGB8_4ToRgba(u32 *dst, const u16 *src, const u16 * src2)
{
#if 0
for (int x = 0; x < 4; x++) {
for (int x = 0; x < 4; x++)
{
dst[x] = ((src[x] & 0xFF) << 24) | ((src[x] & 0xFF00)>>8) | (src2[x] << 8);
}
#else
@ -755,13 +757,15 @@ static PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, in
#if _M_SSE >= 0x301
if (cpu_info.bSSSE3) {
if (cpu_info.bSSSE3)
{
#pragma omp parallel for
for (int y = 0; y < height; y += 4)
for (int x = 0, yStep = (y / 4) * Wsteps8; x < width; x += 8, yStep++)
for (int iy = 0, xStep = 4 * yStep; iy < 4; iy++, xStep++)
decodebytesC8_To_Raw16_SSSE3((u16*)dst + (y + iy) * width + x, src + 8 * xStep, tlutaddr);
} else
}
else
#endif
{
#pragma omp parallel for
@ -844,12 +848,14 @@ static PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, in
#if _M_SSE >= 0x301
if (cpu_info.bSSSE3) {
if (cpu_info.bSSSE3)
{
#pragma omp parallel for
for (int y = 0; y < height; y += 4) {
for (int y = 0; y < height; y += 4)
{
__m128i* p = (__m128i*)(src + y * width * 4);
for (int x = 0; x < width; x += 4) {
for (int x = 0; x < width; x += 4)
{
// We use _mm_loadu_si128 instead of _mm_load_si128
// because "p" may not be aligned in 16-bytes alignment.
// See Issue 3493.
@ -882,7 +888,8 @@ static PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, in
_mm_stream_si128((__m128i*)((u32*)dst + (y + 3) * width + x), c3);
}
}
} else
}
else
#endif
@ -998,7 +1005,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
#if _M_SSE >= 0x301
// xsacha optimized with SSSE3 intrinsics
// Produces a ~40% speed improvement over SSE2 implementation
if (cpu_info.bSSSE3) {
if (cpu_info.bSSSE3)
{
const __m128i mask9180 = _mm_set_epi8(9,9,9,9,1,1,1,1,8,8,8,8,0,0,0,0);
const __m128i maskB3A2 = _mm_set_epi8(11,11,11,11,3,3,3,3,10,10,10,10,2,2,2,2);
const __m128i maskD5C4 = _mm_set_epi8(13,13,13,13,5,5,5,5,12,12,12,12,4,4,4,4);
@ -1033,7 +1041,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
_mm_storeu_si128( (__m128i*)( dst+(y + iy+1) * width + x ), o3 );
_mm_storeu_si128( (__m128i*)( dst+(y + iy+1) * width + x + 4 ), o4 );
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics.
// Produces a ~76% speed improvement over reference C implementation.
@ -1102,7 +1111,7 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
}
}
}
break;
break;
case GX_TF_I8: // speed critical
{
#if _M_SSE >= 0x301
@ -1130,7 +1139,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
_mm_storeu_si128(quaddst+1, rgba1);
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics.
// Produces an ~86% speed improvement over reference C implementation.
@ -1275,7 +1285,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
const __m128i r1 = _mm_shuffle_epi8(r0, mask);
_mm_storeu_si128( (__m128i*)(dst + (y + iy) * width + x), r1 );
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics.
// Produces an ~80% speed improvement over reference C implementation.
@ -1530,7 +1541,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
}
}
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics (2 in 4 cases)
// Produces a ~25% speed improvement over reference C implementation.
@ -1675,7 +1687,8 @@ static PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width,
dst128 = (__m128i*)( dst + (y + 3) * width + x );
_mm_storeu_si128(dst128, rgba11);
}
} else
}
else
#endif
// JSD optimized with SSE2 intrinsics
// Produces a ~68% speed improvement over reference C implementation.

View File

@ -883,7 +883,8 @@ void VertexLoader::SetVAT(const VAT& vat)
m_VtxAttr.texCoord[7].Format = vat.g2.Tex7CoordFormat;
m_VtxAttr.texCoord[7].Frac = vat.g2.Tex7Frac;
if (!m_VtxAttr.ByteDequant) {
if (!m_VtxAttr.ByteDequant)
{
ERROR_LOG(VIDEO, "ByteDequant is set to zero");
}
};

View File

@ -188,11 +188,13 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
{
out.Write("float4 pos = float4(dot(" I_TRANSFORMMATRICES"[posmtx], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+1], rawpos), dot(" I_TRANSFORMMATRICES"[posmtx+2], rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
if (components & VB_HAS_NRMALL)
{
out.Write("int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
out.Write("float3 N0 = " I_NORMALMATRICES"[normidx].xyz, N1 = " I_NORMALMATRICES"[normidx+1].xyz, N2 = " I_NORMALMATRICES"[normidx+2].xyz;\n");
}
}
if (components & VB_HAS_NRM0)
out.Write("float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n");
if (components & VB_HAS_NRM1)