warnings and code formatting

This commit is contained in:
Jordan Cristiano 2013-11-13 04:03:46 -05:00
parent 038ffea369
commit f96e9e1ae4
10 changed files with 37 additions and 21 deletions

View File

@ -193,11 +193,13 @@ public:
void DoPointer(T*& x, T* const base) 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 // 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); Do(offset);
if (mode == MODE_READ) if (mode == MODE_READ)
{
x = base + offset; x = base + offset;
} }
}
// Let's pretend std::list doesn't exist! // Let's pretend std::list doesn't exist!
template <class T, LinkedListItem<T>* (*TNew)(), void (*TFree)(LinkedListItem<T>*), void (*TDo)(PointerWrap&, T*)> template <class T, LinkedListItem<T>* (*TNew)(), void (*TFree)(LinkedListItem<T>*), void (*TDo)(PointerWrap&, T*)>

View File

@ -404,26 +404,30 @@ std::string UriEncode(const std::string & sSrc)
std::string UTF16ToUTF8(const std::wstring& input) 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; std::string output;
output.resize(size); 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(); output.clear();
}
return output; return output;
} }
std::wstring CPToUTF16(u32 code_page, const std::string& input) 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; std::wstring output;
output.resize(size); 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(); output.clear();
}
return output; return output;
} }

View File

@ -153,7 +153,7 @@ unsigned int create_item(SSysConfEntry &item, SysconfType type, const std::strin
{ {
item.offset = offset; item.offset = offset;
item.type = type; item.type = type;
item.nameLength = name.length(); item.nameLength = (u8)(name.length());
strncpy(item.name, name.c_str(), 32); strncpy(item.name, name.c_str(), 32);
item.dataLength = data_length; item.dataLength = data_length;
item.data = new u8[data_length]; item.data = new u8[data_length];

View File

@ -116,7 +116,7 @@ void PerfQuery::FlushOne()
} }
// NOTE: Reported pixel metrics should be referenced to native resolution // 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_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
--m_query_count; --m_query_count;
@ -147,7 +147,7 @@ void PerfQuery::WeakFlush()
if (hr == S_OK) if (hr == S_OK)
{ {
// NOTE: Reported pixel metrics should be referenced to native resolution // 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_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
--m_query_count; --m_query_count;

View File

@ -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 // D3DX11SaveTextureToFileA doesn't allow us to ignore the alpha channel, so we need to strip it out ourselves
D3D11_MAPPED_SUBRESOURCE map; D3D11_MAPPED_SUBRESOURCE map;
D3D::context->Map(s_screenshot_texture, 0, D3D11_MAP_READ_WRITE, 0, &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; 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 = 0xFF;
ptr += 4; ptr += 4;

View File

@ -222,9 +222,9 @@ void VertexManager::vFlush()
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1, 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.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
tex.texTlut[i&3].tlut_format, 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.texMode1[i&3].max_lod + 0xf) / 0x10,
tex.texImage1[i&3].image_type); (tex.texImage1[i&3].image_type != 0));
if (tentry) if (tentry)
{ {

View File

@ -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 // compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes // 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 float3 uv%d_2;\n", i);
}
out.Write("VARYIN float4 clipPos_2;\n"); out.Write("VARYIN float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {
@ -393,8 +395,12 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
// compute window position if needed because binding semantic WPOS is not widely supported // compute window position if needed because binding semantic WPOS is not widely supported
// Let's set up attributes // Let's set up attributes
if (numTexgen) if (numTexgen)
for (int i = 0; i < xfregs.numTexGen.numTexGens; ++i) {
for (unsigned int i = 0; i < xfregs.numTexGen.numTexGens; ++i)
{
out.Write("float3 uv%d = uv%d_2;\n", i, i); out.Write("float3 uv%d = uv%d_2;\n", i, i);
}
}
out.Write("float4 clipPos = clipPos_2;\n"); out.Write("float4 clipPos = clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {

View File

@ -84,7 +84,7 @@ void PixelShaderManager::SetConstants(u32 components)
// they are the coefficients from the center to the border of the screen // 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 // 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][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; constants.fog[2][2] = bpmem.fogRange.K[4].HI / 256.0f;
} }
else else
@ -263,8 +263,8 @@ void PixelShaderManager::SetZTextureTypeChanged()
void PixelShaderManager::SetTexCoordChanged(u8 texmapid) void PixelShaderManager::SetTexCoordChanged(u8 texmapid)
{ {
TCoordInfo& tc = bpmem.texcoords[texmapid]; TCoordInfo& tc = bpmem.texcoords[texmapid];
constants.texdims[texmapid][2] = tc.s.scale_minus_1 + 1; constants.texdims[texmapid][2] = (float)(tc.s.scale_minus_1 + 1);
constants.texdims[texmapid][3] = tc.t.scale_minus_1 + 1; constants.texdims[texmapid][3] = (float)(tc.t.scale_minus_1 + 1);
dirty = true; dirty = true;
} }
@ -283,7 +283,7 @@ void PixelShaderManager::SetFogParamChanged()
constants.fog[1][0] = bpmem.fog.a.GetA(); constants.fog[1][0] = bpmem.fog.a.GetA();
constants.fog[1][1] = (float)bpmem.fog.b_magnitude / 0xFFFFFF; constants.fog[1][1] = (float)bpmem.fog.b_magnitude / 0xFFFFFF;
constants.fog[1][2] = bpmem.fog.c_proj_fsel.GetC(); 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 else
{ {

View File

@ -236,7 +236,7 @@ public:
u32 value = ((u32*)&new_uid.GetUidData())[i]; u32 value = ((u32*)&new_uid.GetUidData())[i];
if ((i % 4) == 0) 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 << std::setfill(' ') << std::dec;
file << "Values " << std::setw(2) << i << " - " << last_value << ": "; file << "Values " << std::setw(2) << i << " - " << last_value << ": ";
} }

View File

@ -130,9 +130,13 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
} }
// Let's set up attributes // 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) if (i < xfregs.numTexGen.numTexGens)
{
out.Write("VARYOUT float3 uv%d_2;\n", i); out.Write("VARYOUT float3 uv%d_2;\n", i);
}
}
out.Write("VARYOUT float4 clipPos_2;\n"); out.Write("VARYOUT float4 clipPos_2;\n");
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
out.Write("VARYOUT float4 Normal_2;\n"); out.Write("VARYOUT float4 Normal_2;\n");