From 29b7249fc11a636266288550be512f3e2c8c75ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 18 Oct 2014 15:44:45 -0700 Subject: [PATCH] Cleanup. --- 3rdparty/glsl-optimizer/include/c99_compat.h | 14 +++++----- .../src/glsl/builtin_functions.cpp | 1 + .../glsl-optimizer/src/glsl/glsl_types.cpp | 2 +- 3rdparty/glsl-optimizer/src/glsl/glsl_types.h | 2 +- 3rdparty/glsl-optimizer/src/glsl/linker.cpp | 2 +- .../glsl-optimizer/src/glsl/opt_algebraic.cpp | 4 +-- .../glsl-optimizer/src/mesa/main/errors.h | 2 +- makefile | 26 +++++++++---------- scripts/bgfx.lua | 2 +- scripts/genie.lua | 7 ++++- scripts/shaderc.lua | 2 +- src/renderer_d3d11.cpp | 11 +++----- src/renderer_d3d11.h | 15 +++++------ tools/shaderc/shaderc.cpp | 3 +++ 14 files changed, 48 insertions(+), 45 deletions(-) diff --git a/3rdparty/glsl-optimizer/include/c99_compat.h b/3rdparty/glsl-optimizer/include/c99_compat.h index 6df1075d8..e8ae7dcf1 100644 --- a/3rdparty/glsl-optimizer/include/c99_compat.h +++ b/3rdparty/glsl-optimizer/include/c99_compat.h @@ -134,7 +134,13 @@ * C99 __func__ macro */ #ifndef __func__ -# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +# if defined(_MSC_VER) +# if _MSC_VER >= 1300 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */ # elif defined(__SUNPRO_C) && defined(__C99FEATURES__) /* C99 */ @@ -144,12 +150,6 @@ # else # define __func__ "" # endif -# elif defined(_MSC_VER) -# if _MSC_VER >= 1300 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif # else # define __func__ "" # endif diff --git a/3rdparty/glsl-optimizer/src/glsl/builtin_functions.cpp b/3rdparty/glsl-optimizer/src/glsl/builtin_functions.cpp index ee85b44bb..2848c2c52 100644 --- a/3rdparty/glsl-optimizer/src/glsl/builtin_functions.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/builtin_functions.cpp @@ -53,6 +53,7 @@ * name and parameters. */ +#define _USE_MATH_DEFINES #include #include #include "main/core.h" /* for struct gl_shader */ diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp index 9135d0933..4e10082cd 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.cpp @@ -642,7 +642,7 @@ glsl_type::field_type(const char *name) const return error_type; } -const glsl_precision +glsl_precision glsl_type::field_precision(const char *name) const { if (this->base_type != GLSL_TYPE_STRUCT) diff --git a/3rdparty/glsl-optimizer/src/glsl/glsl_types.h b/3rdparty/glsl-optimizer/src/glsl/glsl_types.h index f45e6dd6f..8bcfd75d3 100644 --- a/3rdparty/glsl-optimizer/src/glsl/glsl_types.h +++ b/3rdparty/glsl-optimizer/src/glsl/glsl_types.h @@ -578,7 +578,7 @@ struct glsl_type { */ const glsl_type *field_type(const char *name) const; - const glsl_precision field_precision(const char *name) const; + glsl_precision field_precision(const char *name) const; /** diff --git a/3rdparty/glsl-optimizer/src/glsl/linker.cpp b/3rdparty/glsl-optimizer/src/glsl/linker.cpp index 1069268fb..ec6e409d3 100644 --- a/3rdparty/glsl-optimizer/src/glsl/linker.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/linker.cpp @@ -2531,7 +2531,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) } prog->ARB_fragment_coord_conventions_enable |= - prog->Shaders[i]->ARB_fragment_coord_conventions_enable; + GLboolean(prog->Shaders[i]->ARB_fragment_coord_conventions_enable); gl_shader_stage shader_type = prog->Shaders[i]->Stage; shader_list[shader_type][num_shaders[shader_type]] = prog->Shaders[i]; diff --git a/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp b/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp index ce3cc5c74..ab1c1c990 100644 --- a/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/opt_algebraic.cpp @@ -129,7 +129,7 @@ is_less_than_one(ir_constant *ir) return false; unsigned component = 0; - for (int c = 0; c < ir->type->vector_elements; c++) { + for (unsigned c = 0; c < ir->type->vector_elements; c++) { if (ir->get_float_component(c) < 1.0f) component++; } @@ -144,7 +144,7 @@ is_greater_than_zero(ir_constant *ir) return false; unsigned component = 0; - for (int c = 0; c < ir->type->vector_elements; c++) { + for (unsigned c = 0; c < ir->type->vector_elements; c++) { if (ir->get_float_component(c) > 0.0f) component++; } diff --git a/3rdparty/glsl-optimizer/src/mesa/main/errors.h b/3rdparty/glsl-optimizer/src/mesa/main/errors.h index 2cb750532..593e23272 100644 --- a/3rdparty/glsl-optimizer/src/mesa/main/errors.h +++ b/3rdparty/glsl-optimizer/src/mesa/main/errors.h @@ -35,7 +35,7 @@ #ifndef ERRORS_H #define ERRORS_H - +#include "c99_compat.h" #ifdef __cplusplus extern "C" { diff --git a/makefile b/makefile index 8947a5247..fd03455b4 100644 --- a/makefile +++ b/makefile @@ -21,7 +21,7 @@ all: $(GENIE) --with-tools --with-shared-lib vs2010 $(GENIE) --with-tools --with-shared-lib vs2012 $(GENIE) --with-tools --with-shared-lib vs2013 - $(GENIE) --with-tools --with-shared-lib --gcc=mingw gmake + $(GENIE) --with-tools --with-shared-lib --gcc=mingw-gcc gmake $(GENIE) --with-tools --with-shared-lib --gcc=linux-gcc gmake $(GENIE) --with-tools --with-shared-lib --gcc=osx gmake $(GENIE) --with-tools --with-shared-lib xcode4 @@ -81,16 +81,16 @@ linux-release64: .build/projects/gmake-linux make -R -C .build/projects/gmake-linux config=release64 linux: linux-debug32 linux-release32 linux-debug64 linux-release64 -.build/projects/gmake-mingw: - $(GENIE) --with-tools --with-shared-lib --gcc=mingw gmake -mingw-debug32: .build/projects/gmake-mingw - make -R -C .build/projects/gmake-mingw config=debug32 -mingw-release32: .build/projects/gmake-mingw - make -R -C .build/projects/gmake-mingw config=release32 -mingw-debug64: .build/projects/gmake-mingw - make -R -C .build/projects/gmake-mingw config=debug64 -mingw-release64: .build/projects/gmake-mingw - make -R -C .build/projects/gmake-mingw config=release64 +.build/projects/gmake-mingw-gcc: + $(GENIE) --with-tools --with-shared-lib --gcc=mingw-gcc gmake +mingw-debug32: .build/projects/gmake-mingw-gcc + make -R -C .build/projects/gmake-mingw-gcc config=debug32 +mingw-release32: .build/projects/gmake-mingw-gcc + make -R -C .build/projects/gmake-mingw-gcc config=release32 +mingw-debug64: .build/projects/gmake-mingw-gcc + make -R -C .build/projects/gmake-mingw-gcc config=debug64 +mingw-release64: .build/projects/gmake-mingw-gcc + make -R -C .build/projects/gmake-mingw-gcc config=release64 mingw: mingw-debug32 mingw-release32 mingw-debug64 mingw-release64 .build/projects/vs2008: @@ -214,8 +214,8 @@ EXE= endif else OS=windows -BUILD_PROJECT_DIR=gmake-mingw -BUILD_OUTPUT_DIR=win32_mingw +BUILD_PROJECT_DIR=gmake-mingw-gcc +BUILD_OUTPUT_DIR=win32_mingw-gcc BUILD_TOOLS_CONFIG=release32 EXE=.exe endif diff --git a/scripts/bgfx.lua b/scripts/bgfx.lua index b10d56e44..8d948392c 100644 --- a/scripts/bgfx.lua +++ b/scripts/bgfx.lua @@ -56,7 +56,7 @@ function bgfxProject(_name, _kind, _defines) BGFX_DIR .. "3rdparty/khronos", } - configuration { "x64", "vs* or mingw" } + configuration { "x64", "vs* or mingw*" } defines { "_WIN32_WINNT=0x601", } diff --git a/scripts/genie.lua b/scripts/genie.lua index 8ba5d9586..811b8286f 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -111,12 +111,17 @@ function exampleProject(_name) "/DELAYLOAD:\"libGLESv2.dll\"", } - configuration { "windows" } + configuration { "vs20* or mingw*" } links { "gdi32", "psapi", } + configuration { "mingw*" } + links { + "dxguid", + } + configuration { "mingw-clang" } kind "ConsoleApp" diff --git a/scripts/shaderc.lua b/scripts/shaderc.lua index dc99b946e..1222b3ed9 100644 --- a/scripts/shaderc.lua +++ b/scripts/shaderc.lua @@ -31,7 +31,7 @@ project "shaderc" "/wd4996" -- warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. } - configuration { "mingw or linux or osx" } + configuration { "mingw* or linux or osx" } buildoptions { "-fno-strict-aliasing" -- glsl-optimizer has bugs if strict aliasing is used. } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 4cd16e522..b51801946 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -332,10 +332,9 @@ namespace bgfx ID3D11SamplerState* m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; }; -#if BX_COMPILER_CLANG -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-const-variable" -#endif // BX_COMPILER_CLANG + BX_PRAGMA_DIAGNOSTIC_PUSH(); + BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wunused-const-variable"); + BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wunneeded-internal-declaration"); static const GUID WKPDID_D3DDebugObjectName = { 0x429b8c22, 0x9188, 0x4b0c, { 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00 } }; @@ -355,9 +354,7 @@ namespace bgfx } } -#if BX_COMPILER_CLANG -# pragma GCC diagnostic pop -#endif // BX_COMPILER_CLANG + BX_PRAGMA_DIAGNOSTIC_POP(); static BX_NO_INLINE bool getIntelExtensions(ID3D11Device* _device) { diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index d21ecb2a5..919eea505 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -13,16 +13,13 @@ # define BGFX_CONFIG_DEBUG_PIX 0 #endif // !USE_D3D11_DYNAMIC_LIB +BX_PRAGMA_DIAGNOSTIC_PUSH(); +BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wunknown-pragmas" ); +BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wpragmas"); +BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4005) // warning C4005: '' : macro redefinition #define D3D11_NO_HELPERS -#if BX_COMPILER_MSVC -# pragma warning(push) -// winerror.h and dxgitypes.h both define DXGI_ERRORs. -# pragma warning(disable:4005) // warning C4005: '' : macro redefinition -# include -# pragma warning(pop) -#else -# include -#endif // BX_COMPILER_MSVC +#include +BX_PRAGMA_DIAGNOSTIC_POP() #include "renderer_d3d.h" diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 4f8aca654..e1a07c0dd 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -72,8 +72,11 @@ extern "C" #if BX_PLATFORM_WINDOWS # include # define __D3DX9MATH_INL__ // not used and MinGW complains about type-punning + BX_PRAGMA_DIAGNOSTIC_PUSH(); + BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wundef"); # include # include + BX_PRAGMA_DIAGNOSTIC_POP(); #endif // BX_PLATFORM_WINDOWS long int fsize(FILE* _file)