glasm: Implement local memory for glasm

This commit is contained in:
ameerj 2021-05-14 21:18:53 -04:00
parent ab5dbe7c29
commit 057dee4856
4 changed files with 12 additions and 9 deletions

View File

@ -306,6 +306,9 @@ std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) {
for (size_t index = 0; index < ctx.reg_alloc.NumUsedRegisters(); ++index) { for (size_t index = 0; index < ctx.reg_alloc.NumUsedRegisters(); ++index) {
header += fmt::format("R{},", index); header += fmt::format("R{},", index);
} }
if (program.local_memory_size > 0) {
header += fmt::format("lmem[{}],", program.local_memory_size);
}
header += "RC;" header += "RC;"
"LONG TEMP "; "LONG TEMP ";
for (size_t index = 0; index < ctx.reg_alloc.NumUsedLongRegisters(); ++index) { for (size_t index = 0; index < ctx.reg_alloc.NumUsedLongRegisters(); ++index) {

View File

@ -113,4 +113,12 @@ void EmitSetFragDepth([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Scalar
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, ScalarU32 word_offset) {
ctx.Add("MOV.U {},lmem[{}].x;", inst, word_offset);
}
void EmitWriteLocal(EmitContext& ctx, ScalarU32 word_offset, ScalarU32 value) {
ctx.Add("MOV.U lmem[{}].x,{};", word_offset, value);
}
} // namespace Shader::Backend::GLASM } // namespace Shader::Backend::GLASM

View File

@ -71,7 +71,7 @@ void EmitInvocationId(EmitContext& ctx);
void EmitSampleId(EmitContext& ctx); void EmitSampleId(EmitContext& ctx);
void EmitIsHelperInvocation(EmitContext& ctx); void EmitIsHelperInvocation(EmitContext& ctx);
void EmitYDirection(EmitContext& ctx); void EmitYDirection(EmitContext& ctx);
void EmitLoadLocal(EmitContext& ctx, ScalarU32 word_offset); void EmitLoadLocal(EmitContext& ctx, IR::Inst& inst, ScalarU32 word_offset);
void EmitWriteLocal(EmitContext& ctx, ScalarU32 word_offset, ScalarU32 value); void EmitWriteLocal(EmitContext& ctx, ScalarU32 word_offset, ScalarU32 value);
void EmitUndefU1(EmitContext& ctx); void EmitUndefU1(EmitContext& ctx);
void EmitUndefU8(EmitContext& ctx); void EmitUndefU8(EmitContext& ctx);

View File

@ -168,14 +168,6 @@ void EmitYDirection(EmitContext& ctx) {
NotImplemented(); NotImplemented();
} }
void EmitLoadLocal(EmitContext& ctx, ScalarU32 word_offset) {
NotImplemented();
}
void EmitWriteLocal(EmitContext& ctx, ScalarU32 word_offset, ScalarU32 value) {
NotImplemented();
}
void EmitUndefU1(EmitContext& ctx) { void EmitUndefU1(EmitContext& ctx) {
NotImplemented(); NotImplemented();
} }