diff --git a/tools/bin/shaderc.exe b/tools/bin/shaderc.exe index d42fdf7a..bc2f44e2 100644 Binary files a/tools/bin/shaderc.exe and b/tools/bin/shaderc.exe differ diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 0329b406..c1ad8a27 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -1671,32 +1671,60 @@ int main(int _argc, const char* _argv[]) if (fragment) { - preprocessor.writef("#define void_main() \\\n"); - preprocessor.writef("\tvoid main(vec4 gl_FragCoord : SV_POSITION \\\n"); + bool hasFragCoord = NULL != strstr(data, "gl_FragCoord") || hlsl > 3; + bool hasFragDepth = NULL != strstr(data, "gl_FragDepth"); + bool hasFrontFacing = NULL != strstr(data, "gl_FrontFacing"); + + preprocessor.writef("#define void_main()"); + preprocessor.writef(" \\\n\tvoid main("); + + uint32_t arg = 0; + + if (hasFragCoord) + { + preprocessor.writef(" \\\n\tvec4 gl_FragCoord : SV_POSITION"); + ++arg; + } + for (InOut::const_iterator it = shaderInputs.begin(), itEnd = shaderInputs.end(); it != itEnd; ++it) { VaryingMap::const_iterator varyingIt = varyingMap.find(*it); if (varyingIt != varyingMap.end() ) { const Varying& var = varyingIt->second; - preprocessor.writef("\t, %s %s : %s \\\n", var.m_type.c_str(), var.m_name.c_str(), var.m_semantics.c_str() ); + preprocessor.writef(" \\\n\t%s%s %s : %s", arg > 0 ? ", " : "", var.m_type.c_str(), var.m_name.c_str(), var.m_semantics.c_str() ); + ++arg; } } preprocessor.writef( - ", out vec4 gl_FragColor : SV_TARGET \\\n" + " \\\n\t, out vec4 gl_FragColor : SV_TARGET" ); - if (NULL != strstr(data, "gl_FragDepth") ) + if (hasFragDepth) { preprocessor.writef( - ", out float gl_FragDepth : SV_DEPTH \\\n" + " \\\n\t, out float gl_FragDepth : SV_DEPTH" + ); + } + + if (hasFrontFacing) + { + preprocessor.writef( + " \\\n\t, float __vface : VFACE" ); } preprocessor.writef( - ")\n" + " \\\n\t)\n" ); + + if (hasFrontFacing) + { + preprocessor.writef( + "#define gl_FrontFacing (__vface <= 0.0)\n" + ); + } } else {