shaderc: Adding metal shader type.

This commit is contained in:
Branimir Karadžić
2015-06-12 15:08:01 -07:00
parent 3dd3a86a4d
commit ce1b41336d
2 changed files with 40 additions and 7 deletions

View File

@@ -707,10 +707,11 @@ int main(int _argc, const char* _argv[])
bool raw = cmdLine.hasArg('\0', "raw");
uint32_t glsl = 0;
uint32_t essl = 0;
uint32_t hlsl = 2;
uint32_t d3d = 11;
uint32_t glsl = 0;
uint32_t essl = 0;
uint32_t hlsl = 2;
uint32_t d3d = 11;
uint32_t metal = 0;
const char* profile = cmdLine.findOption('p', "profile");
if (NULL != profile)
{
@@ -731,6 +732,10 @@ int main(int _argc, const char* _argv[])
{
hlsl = 5;
}
else if (0 == strcmp(profile, "metal") )
{
metal = 1;
}
else
{
glsl = atoi(profile);
@@ -796,6 +801,7 @@ int main(int _argc, const char* _argv[])
// preprocessor.setDefaultDefine("BGFX_SHADER_LANGUAGE_ESSL");
preprocessor.setDefaultDefine("BGFX_SHADER_LANGUAGE_GLSL");
preprocessor.setDefaultDefine("BGFX_SHADER_LANGUAGE_HLSL");
preprocessor.setDefaultDefine("BGFX_SHADER_LANGUAGE_METAL");
preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_COMPUTE");
preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_FRAGMENT");
preprocessor.setDefaultDefine("BGFX_SHADER_TYPE_VERTEX");
@@ -832,6 +838,9 @@ int main(int _argc, const char* _argv[])
{
preprocessor.setDefine("BX_PLATFORM_OSX=1");
preprocessor.setDefine(glslDefine);
char temp[256];
bx::snprintf(temp, sizeof(temp), "BGFX_SHADER_LANGUAGE_METAL=%d", metal);
preprocessor.setDefine(temp);
}
else if (0 == bx::stricmp(platform, "windows") )
{
@@ -1102,7 +1111,8 @@ int main(int _argc, const char* _argv[])
else
{
if (0 != glsl
|| 0 != essl)
|| 0 != essl
|| 0 != metal)
{
}
else
@@ -1346,6 +1356,9 @@ int main(int _argc, const char* _argv[])
}
}
}
else if (0 != metal)
{
}
else
{
preprocessor.writef(
@@ -1711,11 +1724,27 @@ int main(int _argc, const char* _argv[])
}
code += preprocessor.m_preprocessed;
compiled = compileGLSLShader(cmdLine, essl, code, writer);
compiled = compileGLSLShader(cmdLine
, essl
, code
, writer
);
}
else if (0 != metal)
{
compiled = compileGLSLShader(cmdLine
, BX_MAKEFOURCC('M', 'T', 'L', 0)
, preprocessor.m_preprocessed
, writer
);
}
else
{
compiled = compileHLSLShader(cmdLine, d3d, preprocessor.m_preprocessed, writer);
compiled = compileHLSLShader(cmdLine
, d3d
, preprocessor.m_preprocessed
, writer
);
}
writer->close();

View File

@@ -16,6 +16,10 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str
glslopt_target target = kGlslTargetOpenGL;
switch (_gles)
{
case BX_MAKEFOURCC('M', 'T', 'L', 0):
target = kGlslTargetMetal;
break;
case 2:
target = kGlslTargetOpenGLES20;
break;