mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Apparently only MSVC can handle the ambiguity.
This commit is contained in:
parent
97e8d5b93b
commit
ce4ee010ac
5 changed files with 22 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<size_t T>
|
||||
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();
|
||||
|
|
|
@ -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#",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fd6f5bc01afb419eacca538b425c01eb2a055393
|
||||
Subproject commit d5a2a51942377820764604d9bb424fa9a879c4bd
|
Loading…
Add table
Reference in a new issue