From 73b23f700234f713f6ed7fa874e501ad1d0e05b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Jan 2014 17:05:08 +0100 Subject: [PATCH] (MSVC) Fix warnings --- deps/rzlib/ioapi.c | 2 +- gfx/d3d9/d3d.cpp | 2 +- gfx/d3d9/d3d9_pc.cpp | 1 - gfx/d3d9/render_chain.cpp | 47 +++++++++-------------- msvc/msvc-2010/RetroArch-msvc2010.vcxproj | 4 +- thread.c | 2 +- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/deps/rzlib/ioapi.c b/deps/rzlib/ioapi.c index 9dd881814f..dc3259bf00 100644 --- a/deps/rzlib/ioapi.c +++ b/deps/rzlib/ioapi.c @@ -190,7 +190,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(fseek((FILE *)stream, offset, fseek_origin) != 0) + if(fseek((FILE *)stream, (long)offset, fseek_origin) != 0) ret = -1; return ret; diff --git a/gfx/d3d9/d3d.cpp b/gfx/d3d9/d3d.cpp index bef692c10d..1f2251bf18 100644 --- a/gfx/d3d9/d3d.cpp +++ b/gfx/d3d9/d3d.cpp @@ -366,7 +366,7 @@ static void d3d_overlay_render(void *data, overlay_t &overlay) d3d->dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); // set vertex decl for overlay - D3DVERTEXELEMENT9 vElems[4] = { + D3DVERTEXELEMENT vElems[4] = { {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, {0, 20, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, diff --git a/gfx/d3d9/d3d9_pc.cpp b/gfx/d3d9/d3d9_pc.cpp index 2b98920e0f..b58cb4ef58 100644 --- a/gfx/d3d9/d3d9_pc.cpp +++ b/gfx/d3d9/d3d9_pc.cpp @@ -19,7 +19,6 @@ #include "render_chain.hpp" #include "../../file.h" #include "../context/win32_common.h" -#include #ifdef _MSC_VER #ifndef _XBOX diff --git a/gfx/d3d9/render_chain.cpp b/gfx/d3d9/render_chain.cpp index 093e4a40a8..d3b28b68db 100644 --- a/gfx/d3d9/render_chain.cpp +++ b/gfx/d3d9/render_chain.cpp @@ -14,12 +14,6 @@ */ #include "render_chain.hpp" -#include - -#include -#include -#include -#include namespace Global { @@ -136,9 +130,7 @@ bool RenderChain::set_pass_size(unsigned pass_index, unsigned width, unsigned he passes.back().info.pass->fbo.fp_fbo ? D3DFMT_A32B32G32R32F : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pass.tex, NULL))) - { return false; - } dev->SetTexture(0, pass.tex); dev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); @@ -167,18 +159,14 @@ bool RenderChain::add_pass(const LinkInfo &info) D3DPOOL_DEFAULT, &pass.vertex_buf, NULL))) - { return false; - } if (FAILED(dev->CreateTexture(info.tex_w, info.tex_h, 1, D3DUSAGE_RENDERTARGET, passes.back().info.pass->fbo.fp_fbo ? D3DFMT_A32B32G32R32F : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &pass.tex, NULL))) - { return false; - } dev->SetTexture(0, pass.tex); dev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); @@ -214,9 +202,7 @@ bool RenderChain::add_lut(const std::string &id, NULL, NULL, &lut))) - { return false; - } dev->SetTexture(0, lut); dev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); @@ -401,41 +387,41 @@ bool RenderChain::compile_shaders(CGprogram &fPrg, CGprogram &vPrg, const std::s { CGprofile vertex_profile = cgD3D9GetLatestVertexProfile(); CGprofile fragment_profile = cgD3D9GetLatestPixelProfile(); - RARCH_LOG("[D3D9 Cg]: Vertex profile: %s\n", cgGetProfileString(vertex_profile)); - RARCH_LOG("[D3D9 Cg]: Fragment profile: %s\n", cgGetProfileString(fragment_profile)); + RARCH_LOG("[D3D Cg]: Vertex profile: %s\n", cgGetProfileString(vertex_profile)); + RARCH_LOG("[D3D Cg]: Fragment profile: %s\n", cgGetProfileString(fragment_profile)); const char **fragment_opts = cgD3D9GetOptimalOptions(fragment_profile); const char **vertex_opts = cgD3D9GetOptimalOptions(vertex_profile); if (shader.length() > 0) { - RARCH_LOG("[D3D9 Cg]: Compiling shader: %s.\n", shader.c_str()); + RARCH_LOG("[D3D Cg]: Compiling shader: %s.\n", shader.c_str()); fPrg = cgCreateProgramFromFile(cgCtx, CG_SOURCE, shader.c_str(), fragment_profile, "main_fragment", fragment_opts); if (cgGetLastListing(cgCtx)) - RARCH_ERR("[D3D9 Cg]: Fragment error:\n%s\n", cgGetLastListing(cgCtx)); + RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(cgCtx)); vPrg = cgCreateProgramFromFile(cgCtx, CG_SOURCE, shader.c_str(), vertex_profile, "main_vertex", vertex_opts); if (cgGetLastListing(cgCtx)) - RARCH_ERR("[D3D9 Cg]: Vertex error:\n%s\n", cgGetLastListing(cgCtx)); + RARCH_ERR("[D3D Cg]: Vertex error:\n%s\n", cgGetLastListing(cgCtx)); } else { - RARCH_LOG("[D3D9 Cg]: Compiling stock shader.\n"); + RARCH_LOG("[D3D Cg]: Compiling stock shader.\n"); fPrg = cgCreateProgram(cgCtx, CG_SOURCE, Global::stock_program, fragment_profile, "main_fragment", fragment_opts); if (cgGetLastListing(cgCtx)) - RARCH_ERR("[D3D9 Cg]: Fragment error:\n%s\n", cgGetLastListing(cgCtx)); + RARCH_ERR("[D3D Cg]: Fragment error:\n%s\n", cgGetLastListing(cgCtx)); vPrg = cgCreateProgram(cgCtx, CG_SOURCE, Global::stock_program, vertex_profile, "main_vertex", vertex_opts); if (cgGetLastListing(cgCtx)) - RARCH_ERR("[D3D9 Cg]: Vertex error:\n%s\n", cgGetLastListing(cgCtx)); + RARCH_ERR("[D3D Cg]: Vertex error:\n%s\n", cgGetLastListing(cgCtx)); } if (!fPrg || !vPrg) @@ -448,8 +434,10 @@ bool RenderChain::compile_shaders(CGprogram &fPrg, CGprogram &vPrg, const std::s void RenderChain::set_shaders(CGprogram &fPrg, CGprogram &vPrg) { +#ifdef HAVE_CG cgD3D9BindProgram(fPrg); cgD3D9BindProgram(vPrg); +#endif } void RenderChain::set_vertices(Pass &pass, @@ -548,20 +536,17 @@ void RenderChain::set_cg_mvp(CGprogram &vPrg, cgD3D9SetUniformMatrix(cgpModelViewProj, &tmp); } -template -static void set_cg_param(CGprogram prog, const char *param, - const T& val) -{ - CGparameter cgp = cgGetNamedParameter(prog, param); - if (cgp) +#define set_cg_param(prog, param, val) \ + cgp = cgGetNamedParameter(prog, param); \ + if (cgp) \ cgD3D9SetUniform(cgp, &val); -} void RenderChain::set_cg_params(Pass &pass, unsigned video_w, unsigned video_h, unsigned tex_w, unsigned tex_h, unsigned viewport_w, unsigned viewport_h) { + CGparameter cgp; D3DXVECTOR2 video_size; video_size.x = video_w; video_size.y = video_h; @@ -732,6 +717,7 @@ void RenderChain::log_info(const LinkInfo &info) void RenderChain::bind_orig(Pass &pass) { + CGparameter cgp; D3DXVECTOR2 video_size; video_size.x = passes[0].last_width; video_size.y = passes[0].last_height; @@ -796,6 +782,7 @@ void RenderChain::bind_prev(Pass &pass) snprintf(attr_tex_size, sizeof(attr_tex_size), "%s.texture_size", prev_names[i]); snprintf(attr_coord, sizeof(attr_coord), "%s.tex_coord", prev_names[i]); + CGparameter cgp; D3DXVECTOR2 video_size; video_size.x = prev.last_width[(prev.ptr - (i + 1)) & TexturesMask]; video_size.y = prev.last_height[(prev.ptr - (i + 1)) & TexturesMask]; @@ -842,6 +829,7 @@ void RenderChain::bind_pass(Pass &pass, unsigned pass_index) for (unsigned i = 1; i < pass_index - 1; i++) { + CGparameter cgp; char pass_base[64]; snprintf(pass_base, sizeof(pass_base), "PASS%u.", i); @@ -1146,6 +1134,7 @@ void RenderChain::bind_tracker(Pass &pass, unsigned pass_index) for (unsigned i = 0; i < uniform_cnt; i++) { + CGparameter cgp; set_cg_param(pass.fPrg, uniform_info[i].id, uniform_info[i].value); set_cg_param(pass.vPrg, uniform_info[i].id, uniform_info[i].value); } diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index f6baffe5e6..230a2d2d34 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -100,7 +100,7 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_WIN32_D3D9;HAVE_CG;HAVE_GLSL;HAVE_FBO;HAVE_ZLIB;WANT_MINIZ;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_BUILTIN_AUTOCONFIG;HAVE_DINPUT;HAVE_WINXINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC + WIN32;RARCH_INTERNAL;HAVE_WIN32_D3D9;HAVE_CG;HAVE_GLSL;HAVE_FBO;HAVE_ZLIB;WANT_MINIZ;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_BUILTIN_AUTOCONFIG;HAVE_DINPUT;HAVE_WINXINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\deps\rzlib;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp @@ -142,7 +142,7 @@ MaxSpeed true true - WIN32;RARCH_INTERNAL;HAVE_WIN32_D3D9;HAVE_CG;HAVE_GLSL;HAVE_FBO;HAVE_ZLIB;WANT_MINIZ;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_BUILTIN_AUTOCONFIG;HAVE_DINPUT;HAVE_WINXINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC + WIN32;RARCH_INTERNAL;HAVE_WIN32_D3D9;HAVE_CG;HAVE_GLSL;HAVE_FBO;HAVE_ZLIB;WANT_MINIZ;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_SCREENSHOTS;HAVE_BSV_MOVIE;HAVE_BUILTIN_AUTOCONFIG;HAVE_DINPUT;HAVE_WINXINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETPLAY;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\deps\rzlib;%(AdditionalIncludeDirectories) MultiThreaded CompileAsCpp diff --git a/thread.c b/thread.c index 4634fdedfb..7281eafc31 100644 --- a/thread.c +++ b/thread.c @@ -165,7 +165,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us) WaitForSingleObject(cond->event, 0); slock_unlock(lock); - DWORD res = WaitForSingleObject(cond->event, timeout_us / 1000); + DWORD res = WaitForSingleObject(cond->event, (DWORD)(timeout_us) / 1000); slock_lock(lock); return res == WAIT_OBJECT_0;