Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
warnings and code formatting
  • Loading branch information
Jordan Cristiano authored and Jordan Cristiano committed Nov 13, 2013
1 parent 038ffea commit f96e9e1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Source/Core/Common/Src/ChunkFile.h
Expand Up @@ -193,10 +193,12 @@ class PointerWrap
void DoPointer(T*& x, T* const base)
{
// pointers can be more than 2^31 apart, but you're using this function wrong if you need that much range
s32 offset = x - base;
ptrdiff_t offset = x - base;
Do(offset);
if (mode == MODE_READ)
{
x = base + offset;
}
}

// Let's pretend std::list doesn't exist!
Expand Down
12 changes: 8 additions & 4 deletions Source/Core/Common/Src/StringUtil.cpp
Expand Up @@ -404,26 +404,30 @@ std::string UriEncode(const std::string & sSrc)

std::string UTF16ToUTF8(const std::wstring& input)
{
auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), input.size(), nullptr, 0, nullptr, nullptr);
auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), (int)input.size(), nullptr, 0, nullptr, nullptr);

std::string output;
output.resize(size);

if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), input.size(), &output[0], output.size(), nullptr, nullptr))
if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), (int)input.size(), &output[0], (int)output.size(), nullptr, nullptr))
{
output.clear();
}

return output;
}

std::wstring CPToUTF16(u32 code_page, const std::string& input)
{
auto const size = MultiByteToWideChar(code_page, 0, input.data(), input.size(), nullptr, 0);
auto const size = MultiByteToWideChar(code_page, 0, input.data(), (int)input.size(), nullptr, 0);

std::wstring output;
output.resize(size);

if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), input.size(), &output[0], output.size()))
if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), (int)input.size(), &output[0], (int)output.size()))
{
output.clear();
}

return output;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/SysConf.cpp
Expand Up @@ -153,7 +153,7 @@ unsigned int create_item(SSysConfEntry &item, SysconfType type, const std::strin
{
item.offset = offset;
item.type = type;
item.nameLength = name.length();
item.nameLength = (u8)(name.length());
strncpy(item.name, name.c_str(), 32);
item.dataLength = data_length;
item.data = new u8[data_length];
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D/Src/PerfQuery.cpp
Expand Up @@ -116,7 +116,7 @@ void PerfQuery::FlushOne()
}

// NOTE: Reported pixel metrics should be referenced to native resolution
m_results[entry.query_type] += (u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight();
m_results[entry.query_type] += (u32)(result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());

m_query_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
--m_query_count;
Expand Down Expand Up @@ -147,7 +147,7 @@ void PerfQuery::WeakFlush()
if (hr == S_OK)
{
// NOTE: Reported pixel metrics should be referenced to native resolution
m_results[entry.query_type] += (u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight();
m_results[entry.query_type] += (u32)(result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());

m_query_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
--m_query_count;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D/Src/Render.cpp
Expand Up @@ -693,10 +693,10 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
// D3DX11SaveTextureToFileA doesn't allow us to ignore the alpha channel, so we need to strip it out ourselves
D3D11_MAPPED_SUBRESOURCE map;
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ_WRITE, 0, &map);
for (unsigned int y = 0; y < rc.GetHeight(); ++y)
for (auto y = 0; y < rc.GetHeight(); ++y)
{
u8* ptr = (u8*)map.pData + y * map.RowPitch + 3;
for (unsigned int x = 0; x < rc.GetWidth(); ++x)
for (auto x = 0; x < rc.GetWidth(); ++x)
{
*ptr = 0xFF;
ptr += 4;
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D/Src/VertexManager.cpp
Expand Up @@ -222,9 +222,9 @@ void VertexManager::vFlush()
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
tex.texTlut[i&3].tlut_format,
(tex.texMode0[i&3].min_filter & 3),
((tex.texMode0[i&3].min_filter & 3) != 0),
(tex.texMode1[i&3].max_lod + 0xf) / 0x10,
tex.texImage1[i&3].image_type);
(tex.texImage1[i&3].image_type != 0));

if (tentry)
{
Expand Down
12 changes: 9 additions & 3 deletions Source/Core/VideoCommon/Src/PixelShaderGen.cpp
Expand Up @@ -316,8 +316,10 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T

// compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes
for (int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{
out.Write("VARYIN float3 uv%d_2;\n", i);
}
out.Write("VARYIN float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
Expand Down Expand Up @@ -392,9 +394,13 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
out.Write("float4 colors_1 = colors_12;\n");
// compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes
if(numTexgen)
for (int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
if (numTexgen)
{
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{
out.Write("float3 uv%d = uv%d_2;\n", i, i);
}
}
out.Write("float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/VideoCommon/Src/PixelShaderManager.cpp
Expand Up @@ -84,7 +84,7 @@ void PixelShaderManager::SetConstants(u32 components)
// they are the coefficients from the center to the border of the screen
// so to simplify I use the hi coefficient as K in the shader taking 256 as the scale
constants.fog[2][0] = ScreenSpaceCenter;
constants.fog[2][1] = Renderer::EFBToScaledX((int)(2.0f * xfregs.viewport.wd));
constants.fog[2][1] = (float)Renderer::EFBToScaledX((int)(2.0f * xfregs.viewport.wd));
constants.fog[2][2] = bpmem.fogRange.K[4].HI / 256.0f;
}
else
Expand Down Expand Up @@ -263,8 +263,8 @@ void PixelShaderManager::SetZTextureTypeChanged()
void PixelShaderManager::SetTexCoordChanged(u8 texmapid)
{
TCoordInfo& tc = bpmem.texcoords[texmapid];
constants.texdims[texmapid][2] = tc.s.scale_minus_1 + 1;
constants.texdims[texmapid][3] = tc.t.scale_minus_1 + 1;
constants.texdims[texmapid][2] = (float)(tc.s.scale_minus_1 + 1);
constants.texdims[texmapid][3] = (float)(tc.t.scale_minus_1 + 1);
dirty = true;
}

Expand All @@ -283,7 +283,7 @@ void PixelShaderManager::SetFogParamChanged()
constants.fog[1][0] = bpmem.fog.a.GetA();
constants.fog[1][1] = (float)bpmem.fog.b_magnitude / 0xFFFFFF;
constants.fog[1][2] = bpmem.fog.c_proj_fsel.GetC();
constants.fog[1][3] = 1 << bpmem.fog.b_shift;
constants.fog[1][3] = (float)(1 << bpmem.fog.b_shift);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/Src/ShaderGenCommon.h
Expand Up @@ -236,7 +236,7 @@ class UidChecker
u32 value = ((u32*)&new_uid.GetUidData())[i];
if ((i % 4) == 0)
{
unsigned int last_value = (i+3 < new_uid.GetUidDataSize()-1) ? i+3 : new_uid.GetUidDataSize();
auto last_value = (i+3 < new_uid.GetUidDataSize()-1) ? i+3 : new_uid.GetUidDataSize();
file << std::setfill(' ') << std::dec;
file << "Values " << std::setw(2) << i << " - " << last_value << ": ";
}
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/VideoCommon/Src/VertexShaderGen.cpp
Expand Up @@ -130,9 +130,13 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
}

// Let's set up attributes
for (int i = 0; i < 8; ++i)
for (size_t i = 0; i < 8; ++i)
{
if (i < xfregs.numTexGen.numTexGens)
{
out.Write("VARYOUT float3 uv%d_2;\n", i);
}
}
out.Write("VARYOUT float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
out.Write("VARYOUT float4 Normal_2;\n");
Expand Down

0 comments on commit f96e9e1

Please sign in to comment.