diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 612d9f6c7d..cb55b2ad35 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -31,7 +31,7 @@ #include "GPU/ge_constants.h" #include "GPU/GPUState.h" -#define WRITE(p, ...) p.W(__VA_ARGS__) +#define WRITE(p, ...) p.F(__VA_ARGS__) bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLanguageDesc &compat, uint64_t *uniformMask, std::string *errorString) { *uniformMask = 0; diff --git a/GPU/Common/ShaderWriter.cpp b/GPU/Common/ShaderWriter.cpp index f4db37f53e..323bd3b86c 100644 --- a/GPU/Common/ShaderWriter.cpp +++ b/GPU/Common/ShaderWriter.cpp @@ -59,7 +59,7 @@ const char *hlsl_preamble_vs = "\n"; // Unsafe. But doesn't matter, we'll use big buffers for shader gen. -void ShaderWriter::W(char *format, ...) { +void ShaderWriter::F(const char *format, ...) { va_list args; va_start(args, format); p_ += vsprintf(p_, format, args); @@ -95,30 +95,30 @@ void ShaderWriter::Preamble(const char **gl_extensions, size_t num_gl_extensions } break; default: // OpenGL - W("#version %d%s\n", lang_.glslVersionNumber, lang_.gles && lang_.glslES30 ? " es" : ""); + F("#version %d%s\n", lang_.glslVersionNumber, lang_.gles && lang_.glslES30 ? " es" : ""); switch (stage_) { case ShaderStage::Fragment: - W("#define DISCARD discard\n"); + C("#define DISCARD discard\n"); if (lang_.gles) { - W("precision lowp float;\n"); + C("precision lowp float;\n"); } break; case ShaderStage::Vertex: if (lang_.gles) { - W("precision highp float;\n"); + C("precision highp float;\n"); } break; } for (size_t i = 0; i < num_gl_extensions; i++) { - W("%s\n", gl_extensions[i]); + F("%s\n", gl_extensions[i]); } if (!lang_.gles) { - W("#define lowp\n"); - W("#define mediump\n"); - W("#define highp\n"); + C("#define lowp\n"); + C("#define mediump\n"); + C("#define highp\n"); } - W("#define splat3(x) vec3(x)\n"); - W("#define mul(x, y) ((x) * (y))\n"); + C("#define splat3(x) vec3(x)\n"); + C("#define mul(x, y) ((x) * (y))\n"); break; } } diff --git a/GPU/Common/ShaderWriter.h b/GPU/Common/ShaderWriter.h index 757c76fa46..1d670be780 100644 --- a/GPU/Common/ShaderWriter.h +++ b/GPU/Common/ShaderWriter.h @@ -15,20 +15,25 @@ public: Preamble(gl_extensions, num_gl_extensions); } + // I tried to call all three write functions "W", but only MSVC + // managed to disentangle the ambiguities, so had to give up on that. + // Assumes the input is zero-terminated. + // C : Copies a buffer directly to the stream. template - void W(const char(&text)[T]) { + void C(const char(&text)[T]) { memcpy(p_, text, T); p_ += T; } + // W: Writes a zero-terminated string to the stream. void W(const char *text) { size_t len = strlen(text); memcpy(p_, text, len + 1); p_ += len; } - // Formats into the buffer. - void W(const char *format, ...); + // F: Formats into the buffer. + void F(const char *format, ...); // void BeginMain(); // void EndMain(); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 634d9b7e6b..da781e111a 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -32,7 +32,7 @@ #undef WRITE -#define WRITE(p, ...) p.W(__VA_ARGS__) +#define WRITE(p, ...) p.F(__VA_ARGS__) static const char * const boneWeightAttrDecl[9] = { "#ERROR#", diff --git a/assets/lang b/assets/lang index fd6f5bc01a..d5a2a51942 160000 --- a/assets/lang +++ b/assets/lang @@ -1 +1 @@ -Subproject commit fd6f5bc01afb419eacca538b425c01eb2a055393 +Subproject commit d5a2a51942377820764604d9bb424fa9a879c4bd