emit_context.cpp 995 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "shader_recompiler/backend/bindings.h"
  5. #include "shader_recompiler/backend/glsl/emit_context.h"
  6. #include "shader_recompiler/frontend/ir/program.h"
  7. namespace Shader::Backend::GLSL {
  8. EmitContext::EmitContext(IR::Program& program, [[maybe_unused]] Bindings& bindings,
  9. const Profile& profile_)
  10. : info{program.info}, profile{profile_} {
  11. std::string header = "#version 450 core\n";
  12. header += "layout(local_size_x=1, local_size_y=1, local_size_z=1) in;";
  13. code += header;
  14. DefineConstantBuffers();
  15. code += "void main(){";
  16. }
  17. void EmitContext::DefineConstantBuffers() {
  18. if (info.constant_buffer_descriptors.empty()) {
  19. return;
  20. }
  21. for (const auto& desc : info.constant_buffer_descriptors) {
  22. Add("uniform uint c{}[{}];", desc.index, desc.count);
  23. }
  24. }
  25. } // namespace Shader::Backend::GLSL