From 5380fd9dba1feb1f6efed40d3f9c007179a5a4e9 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Fri, 16 Oct 2015 18:00:03 -0400 Subject: [PATCH 1/2] VideoCommon: fix variable types fed to Write() function --- Source/Core/VideoCommon/PixelShaderGen.cpp | 2 +- Source/Core/VideoCommon/VertexShaderGen.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index b6b5b7e369..16f24cacb2 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -184,7 +184,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T out.Write("//Pixel Shader for TEV stages\n"); out.Write("//%i TEV stages, %i texgens, %i IND stages\n", - numStages, numTexgen, bpmem.genMode.numindstages); + numStages, numTexgen, bpmem.genMode.numindstages.Value()); uid_data->dstAlphaMode = dstAlphaMode; uid_data->genMode_numindstages = bpmem.genMode.numindstages; diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 63f80488e4..fba8fbcbae 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -83,11 +83,11 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ else { // Let's set up attributes - for (size_t i = 0; i < 8; ++i) + for (u32 i = 0; i < 8; ++i) { if (i < xfmem.numTexGen.numTexGens) { - out.Write("%s out float3 uv%d;\n", GetInterpolationQualifier(api_type), i); + out.Write("%s out float3 uv%u;\n", GetInterpolationQualifier(api_type), i); } } out.Write("%s out float4 clipPos;\n", GetInterpolationQualifier(api_type)); From 2fc2b82963a5f0e3e212a447c223b2e7bcb5e5e5 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Fri, 16 Oct 2015 18:00:44 -0400 Subject: [PATCH 2/2] VideoCommon: teach gcc to type-check the arguments fed to Write() Note that the "this" implicit argument counts as 1, which is why all the printf arguments are shifted over one. --- Source/Core/VideoCommon/ShaderGenCommon.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h index 2fd6c51819..ece50e6c38 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/ShaderGenCommon.h @@ -32,8 +32,11 @@ public: * Can be used like printf. * @note In the ShaderCode implementation, this does indeed write the parameter string to an internal buffer. However, you're free to do whatever you like with the parameter. */ - template - void Write(const char*, Args...) {} + void Write(const char*, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 3))) +#endif + {} /* * Returns a read pointer to the internal buffer. @@ -116,6 +119,9 @@ public: } void Write(const char* fmt, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 3))) +#endif { va_list arglist; va_start(arglist, fmt);