Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow shaderc custom void main() method #3002

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tools/shaderc/shaderc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace bgfx
// 4.2 420 11.0 vhdgf+c 5.0
// 4.3 430 vhdgf+c
// 4.4 440
// 4.6 460
//
// SPIR-V profile naming convention:
// spirv<SPIR-V version>-<Vulkan version>
Expand Down Expand Up @@ -121,6 +122,7 @@ namespace bgfx
{ ShadingLang::GLSL, 420, "420" },
{ ShadingLang::GLSL, 430, "430" },
{ ShadingLang::GLSL, 440, "440" },
{ ShadingLang::GLSL, 460, "460" },
};

static const char* s_ARB_shader_texture_lod[] =
Expand Down Expand Up @@ -1712,7 +1714,9 @@ namespace bgfx
{
bx::StringView shader(input);
bx::StringView entry = bx::strFind(shader, "void main()");
if (entry.isEmpty() )
bx::StringView entryCustom = bx::strFind(shader, "void main(");
const bool useCustomMain = entry.isEmpty() && !entryCustom.isEmpty();
if (entry.isEmpty() && !useCustomMain)
{
bx::write(_messageWriter, &messageErr, "Shader entry point 'void main()' is not found.\n");
}
Expand Down Expand Up @@ -1841,7 +1845,7 @@ namespace bgfx

*const_cast<char*>(entry.getPtr() + 4) = '_';

if ('f' == _options.shaderType)
if ('f' == _options.shaderType && !useCustomMain)
{
bx::StringView insert = bx::strFind(bx::StringView(entry.getPtr(), shader.getTerm() ), "{");
if (!insert.isEmpty() )
Expand Down