emit_spirv_context_get_set.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/spirv/emit_spirv.h"
  5. namespace Shader::Backend::SPIRV {
  6. void EmitSPIRV::EmitGetRegister(EmitContext&) {
  7. throw NotImplementedException("SPIR-V Instruction");
  8. }
  9. void EmitSPIRV::EmitSetRegister(EmitContext&) {
  10. throw NotImplementedException("SPIR-V Instruction");
  11. }
  12. void EmitSPIRV::EmitGetPred(EmitContext&) {
  13. throw NotImplementedException("SPIR-V Instruction");
  14. }
  15. void EmitSPIRV::EmitSetPred(EmitContext&) {
  16. throw NotImplementedException("SPIR-V Instruction");
  17. }
  18. void EmitSPIRV::EmitSetGotoVariable(EmitContext&) {
  19. throw NotImplementedException("SPIR-V Instruction");
  20. }
  21. void EmitSPIRV::EmitGetGotoVariable(EmitContext&) {
  22. throw NotImplementedException("SPIR-V Instruction");
  23. }
  24. Id EmitSPIRV::EmitGetCbuf(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset) {
  25. if (!binding.IsImmediate()) {
  26. throw NotImplementedException("Constant buffer indexing");
  27. }
  28. if (!offset.IsImmediate()) {
  29. throw NotImplementedException("Variable constant buffer offset");
  30. }
  31. return ctx.Name(ctx.OpUndef(ctx.u32[1]), "unimplemented_cbuf");
  32. }
  33. void EmitSPIRV::EmitGetAttribute(EmitContext&) {
  34. throw NotImplementedException("SPIR-V Instruction");
  35. }
  36. void EmitSPIRV::EmitSetAttribute(EmitContext&) {
  37. throw NotImplementedException("SPIR-V Instruction");
  38. }
  39. void EmitSPIRV::EmitGetAttributeIndexed(EmitContext&) {
  40. throw NotImplementedException("SPIR-V Instruction");
  41. }
  42. void EmitSPIRV::EmitSetAttributeIndexed(EmitContext&) {
  43. throw NotImplementedException("SPIR-V Instruction");
  44. }
  45. void EmitSPIRV::EmitGetZFlag(EmitContext&) {
  46. throw NotImplementedException("SPIR-V Instruction");
  47. }
  48. void EmitSPIRV::EmitGetSFlag(EmitContext&) {
  49. throw NotImplementedException("SPIR-V Instruction");
  50. }
  51. void EmitSPIRV::EmitGetCFlag(EmitContext&) {
  52. throw NotImplementedException("SPIR-V Instruction");
  53. }
  54. void EmitSPIRV::EmitGetOFlag(EmitContext&) {
  55. throw NotImplementedException("SPIR-V Instruction");
  56. }
  57. void EmitSPIRV::EmitSetZFlag(EmitContext&) {
  58. throw NotImplementedException("SPIR-V Instruction");
  59. }
  60. void EmitSPIRV::EmitSetSFlag(EmitContext&) {
  61. throw NotImplementedException("SPIR-V Instruction");
  62. }
  63. void EmitSPIRV::EmitSetCFlag(EmitContext&) {
  64. throw NotImplementedException("SPIR-V Instruction");
  65. }
  66. void EmitSPIRV::EmitSetOFlag(EmitContext&) {
  67. throw NotImplementedException("SPIR-V Instruction");
  68. }
  69. Id EmitSPIRV::EmitWorkgroupId(EmitContext& ctx) {
  70. if (ctx.workgroup_id.value == 0) {
  71. ctx.workgroup_id = ctx.AddGlobalVariable(
  72. ctx.TypePointer(spv::StorageClass::Input, ctx.u32[3]), spv::StorageClass::Input);
  73. ctx.Decorate(ctx.workgroup_id, spv::Decoration::BuiltIn, spv::BuiltIn::WorkgroupId);
  74. }
  75. return ctx.OpLoad(ctx.u32[3], ctx.workgroup_id);
  76. }
  77. Id EmitSPIRV::EmitLocalInvocationId(EmitContext& ctx) {
  78. if (ctx.local_invocation_id.value == 0) {
  79. ctx.local_invocation_id = ctx.AddGlobalVariable(
  80. ctx.TypePointer(spv::StorageClass::Input, ctx.u32[3]), spv::StorageClass::Input);
  81. ctx.Decorate(ctx.local_invocation_id, spv::Decoration::BuiltIn,
  82. spv::BuiltIn::LocalInvocationId);
  83. }
  84. return ctx.OpLoad(ctx.u32[3], ctx.local_invocation_id);
  85. }
  86. } // namespace Shader::Backend::SPIRV