Skip to content

Commit 5002ae2

Browse files
Merge pull request #2599 from rdb/glsl-use-entry-point-name
GLSL: Add option to emit custom entry point name
2 parents bf6bb5c + a40ccc1 commit 5002ae2

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

spirv_glsl.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,10 @@ string CompilerGLSL::compile()
807807
// The body was implemented in lieu of main().
808808
if (interlocked_is_complex)
809809
{
810-
statement("void main()");
810+
if (options.use_entry_point_name)
811+
statement("void ", get_entry_point().name, "()");
812+
else
813+
statement("void main()");
811814
begin_scope();
812815
statement("// Interlocks were used in a way not compatible with GLSL, this is very slow.");
813816
statement("SPIRV_Cross_beginInvocationInterlock();");
@@ -817,7 +820,8 @@ string CompilerGLSL::compile()
817820
}
818821

819822
// Entry point in GLSL is always main().
820-
get_entry_point().name = "main";
823+
if (!options.use_entry_point_name)
824+
get_entry_point().name = "main";
821825

822826
return buffer.str();
823827
}
@@ -17383,6 +17387,8 @@ void CompilerGLSL::emit_function_prototype(SPIRFunction &func, const Bitset &ret
1738317387
// and interlock the entire shader ...
1738417388
if (interlocked_is_complex)
1738517389
decl += "spvMainInterlockedBody";
17390+
else if (options.use_entry_point_name)
17391+
decl += get_entry_point().name;
1738617392
else
1738717393
decl += "main";
1738817394

spirv_glsl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ class CompilerGLSL : public Compiler
159159
// If non-zero, controls layout(num_views = N) in; in GL_OVR_multiview2.
160160
uint32_t ovr_multiview_view_count = 0;
161161

162+
// Emit the entry point name in SPIR-V rather than "main".
163+
bool use_entry_point_name = false;
164+
162165
enum Precision
163166
{
164167
DontCare,

0 commit comments

Comments
 (0)