glsl: Fix "reg" allocing
based on glasm with some tweaks
This commit is contained in:
parent
eaff1030de
commit
64337f004d
10 changed files with 938 additions and 898 deletions
|
@ -11,19 +11,39 @@ namespace Shader::Backend::GLSL {
|
|||
EmitContext::EmitContext(IR::Program& program, [[maybe_unused]] Bindings& bindings,
|
||||
const Profile& profile_)
|
||||
: info{program.info}, profile{profile_} {
|
||||
std::string header = "#version 450 core\n";
|
||||
header += "layout(local_size_x=1, local_size_y=1, local_size_z=1) in;";
|
||||
std::string header = "#version 450\n";
|
||||
if (program.stage == Stage::Compute) {
|
||||
header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;\n",
|
||||
program.workgroup_size[0], program.workgroup_size[1],
|
||||
program.workgroup_size[2]);
|
||||
}
|
||||
code += header;
|
||||
DefineConstantBuffers();
|
||||
code += "void main(){";
|
||||
DefineStorageBuffers();
|
||||
code += "void main(){\n";
|
||||
}
|
||||
|
||||
void EmitContext::DefineConstantBuffers() {
|
||||
if (info.constant_buffer_descriptors.empty()) {
|
||||
return;
|
||||
}
|
||||
u32 binding{};
|
||||
for (const auto& desc : info.constant_buffer_descriptors) {
|
||||
Add("uniform uint c{}[{}];", desc.index, desc.count);
|
||||
Add("layout(std140,binding={}) uniform cbuf_{}{{uint cbuf{}[];}};", binding, binding,
|
||||
desc.index, desc.count);
|
||||
++binding;
|
||||
}
|
||||
}
|
||||
|
||||
void EmitContext::DefineStorageBuffers() {
|
||||
if (info.storage_buffers_descriptors.empty()) {
|
||||
return;
|
||||
}
|
||||
u32 binding{};
|
||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
||||
Add("layout(std430,binding={}) buffer buff_{}{{uint buff{}[];}};", binding, binding,
|
||||
desc.cbuf_index, desc.count);
|
||||
++binding;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue