glsl: Declare local memory in main

This commit is contained in:
ameerj 2021-06-24 20:14:31 -04:00
parent f7352411f0
commit 00fa09dc45

View File

@ -217,14 +217,14 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR
EmitCode(ctx, program); EmitCode(ctx, program);
const std::string version{fmt::format("#version 450{}\n", GlslVersionSpecifier(ctx))}; const std::string version{fmt::format("#version 450{}\n", GlslVersionSpecifier(ctx))};
ctx.header.insert(0, version); ctx.header.insert(0, version);
if (program.local_memory_size > 0) {
ctx.header += fmt::format("uint lmem[{}];", Common::AlignUp(program.local_memory_size, 4));
}
if (program.shared_memory_size > 0) { if (program.shared_memory_size > 0) {
ctx.header += ctx.header +=
fmt::format("shared uint smem[{}];", Common::AlignUp(program.shared_memory_size, 4)); fmt::format("shared uint smem[{}];", Common::AlignUp(program.shared_memory_size, 4));
} }
ctx.header += "void main(){\n"; ctx.header += "void main(){\n";
if (program.local_memory_size > 0) {
ctx.header += fmt::format("uint lmem[{}];", Common::AlignUp(program.local_memory_size, 4));
}
DefineVariables(ctx, ctx.header); DefineVariables(ctx, ctx.header);
if (ctx.uses_cc_carry) { if (ctx.uses_cc_carry) {
ctx.header += "uint carry;"; ctx.header += "uint carry;";