diff options
| author | 2021-05-21 02:12:32 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:33 -0400 | |
| commit | 9e7b6622c25aa858b96bf0f1c7f94223a2f449a2 (patch) | |
| tree | 48c62889aeb79d6f0f01a467ba0d1ac01dec512b /src/shader_recompiler/backend/glasm/emit_context.cpp | |
| parent | emit_glasm_context_get_and_set.cpp: Add missing semicolons (diff) | |
| download | yuzu-9e7b6622c25aa858b96bf0f1c7f94223a2f449a2.tar.gz yuzu-9e7b6622c25aa858b96bf0f1c7f94223a2f449a2.tar.xz yuzu-9e7b6622c25aa858b96bf0f1c7f94223a2f449a2.zip | |
shader: Split profile and runtime information in separate structs
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_context.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.cpp b/src/shader_recompiler/backend/glasm/emit_context.cpp index e42f186c1..659ff6d17 100644 --- a/src/shader_recompiler/backend/glasm/emit_context.cpp +++ b/src/shader_recompiler/backend/glasm/emit_context.cpp | |||
| @@ -23,23 +23,25 @@ std::string_view InterpDecorator(Interpolation interp) { | |||
| 23 | } | 23 | } |
| 24 | } // Anonymous namespace | 24 | } // Anonymous namespace |
| 25 | 25 | ||
| 26 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_) | 26 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| 27 | : info{program.info}, profile{profile_} { | 27 | const RuntimeInfo& runtime_info_) |
| 28 | : profile{profile_}, runtime_info{runtime_info_} { | ||
| 28 | // FIXME: Temporary partial implementation | 29 | // FIXME: Temporary partial implementation |
| 30 | const auto& info{program.info}; | ||
| 29 | u32 cbuf_index{}; | 31 | u32 cbuf_index{}; |
| 30 | for (const auto& desc : program.info.constant_buffer_descriptors) { | 32 | for (const auto& desc : info.constant_buffer_descriptors) { |
| 31 | if (desc.count != 1) { | 33 | if (desc.count != 1) { |
| 32 | throw NotImplementedException("Constant buffer descriptor array"); | 34 | throw NotImplementedException("Constant buffer descriptor array"); |
| 33 | } | 35 | } |
| 34 | Add("CBUFFER c{}[]={{program.buffer[{}]}};", desc.index, cbuf_index); | 36 | Add("CBUFFER c{}[]={{program.buffer[{}]}};", desc.index, cbuf_index); |
| 35 | ++cbuf_index; | 37 | ++cbuf_index; |
| 36 | } | 38 | } |
| 37 | for (const auto& desc : program.info.storage_buffers_descriptors) { | 39 | for (const auto& desc : info.storage_buffers_descriptors) { |
| 38 | if (desc.count != 1) { | 40 | if (desc.count != 1) { |
| 39 | throw NotImplementedException("Storage buffer descriptor array"); | 41 | throw NotImplementedException("Storage buffer descriptor array"); |
| 40 | } | 42 | } |
| 41 | } | 43 | } |
| 42 | if (const size_t num = program.info.storage_buffers_descriptors.size(); num > 0) { | 44 | if (const size_t num = info.storage_buffers_descriptors.size(); num > 0) { |
| 43 | Add("PARAM c[{}]={{program.local[0..{}]}};", num, num - 1); | 45 | Add("PARAM c[{}]={{program.local[0..{}]}};", num, num - 1); |
| 44 | } | 46 | } |
| 45 | stage = program.stage; | 47 | stage = program.stage; |
| @@ -67,8 +69,8 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 67 | break; | 69 | break; |
| 68 | } | 70 | } |
| 69 | const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"}; | 71 | const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"}; |
| 70 | for (size_t index = 0; index < program.info.input_generics.size(); ++index) { | 72 | for (size_t index = 0; index < info.input_generics.size(); ++index) { |
| 71 | const auto& generic{program.info.input_generics[index]}; | 73 | const auto& generic{info.input_generics[index]}; |
| 72 | if (generic.used) { | 74 | if (generic.used) { |
| 73 | Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};", | 75 | Add("{}ATTRIB in_attr{}[]={{{}.attrib[{}..{}]}};", |
| 74 | InterpDecorator(generic.interpolation), index, attr_stage, index, index); | 76 | InterpDecorator(generic.interpolation), index, attr_stage, index, index); |
| @@ -101,8 +103,8 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 101 | index, index); | 103 | index, index); |
| 102 | } | 104 | } |
| 103 | } | 105 | } |
| 104 | for (size_t index = 0; index < program.info.stores_frag_color.size(); ++index) { | 106 | for (size_t index = 0; index < info.stores_frag_color.size(); ++index) { |
| 105 | if (!program.info.stores_frag_color[index]) { | 107 | if (!info.stores_frag_color[index]) { |
| 106 | continue; | 108 | continue; |
| 107 | } | 109 | } |
| 108 | if (index == 0) { | 110 | if (index == 0) { |
| @@ -111,28 +113,28 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 111 | Add("OUTPUT frag_color{}=result.color[{}];", index, index); | 113 | Add("OUTPUT frag_color{}=result.color[{}];", index, index); |
| 112 | } | 114 | } |
| 113 | } | 115 | } |
| 114 | for (size_t index = 0; index < program.info.stores_generics.size(); ++index) { | 116 | for (size_t index = 0; index < info.stores_generics.size(); ++index) { |
| 115 | if (program.info.stores_generics[index]) { | 117 | if (info.stores_generics[index]) { |
| 116 | Add("OUTPUT out_attr{}[]={{result.attrib[{}..{}]}};", index, index, index); | 118 | Add("OUTPUT out_attr{}[]={{result.attrib[{}..{}]}};", index, index, index); |
| 117 | } | 119 | } |
| 118 | } | 120 | } |
| 119 | image_buffer_bindings.reserve(program.info.image_buffer_descriptors.size()); | 121 | image_buffer_bindings.reserve(info.image_buffer_descriptors.size()); |
| 120 | for (const auto& desc : program.info.image_buffer_descriptors) { | 122 | for (const auto& desc : info.image_buffer_descriptors) { |
| 121 | image_buffer_bindings.push_back(bindings.image); | 123 | image_buffer_bindings.push_back(bindings.image); |
| 122 | bindings.image += desc.count; | 124 | bindings.image += desc.count; |
| 123 | } | 125 | } |
| 124 | image_bindings.reserve(program.info.image_descriptors.size()); | 126 | image_bindings.reserve(info.image_descriptors.size()); |
| 125 | for (const auto& desc : program.info.image_descriptors) { | 127 | for (const auto& desc : info.image_descriptors) { |
| 126 | image_bindings.push_back(bindings.image); | 128 | image_bindings.push_back(bindings.image); |
| 127 | bindings.image += desc.count; | 129 | bindings.image += desc.count; |
| 128 | } | 130 | } |
| 129 | texture_buffer_bindings.reserve(program.info.texture_buffer_descriptors.size()); | 131 | texture_buffer_bindings.reserve(info.texture_buffer_descriptors.size()); |
| 130 | for (const auto& desc : program.info.texture_buffer_descriptors) { | 132 | for (const auto& desc : info.texture_buffer_descriptors) { |
| 131 | texture_buffer_bindings.push_back(bindings.texture); | 133 | texture_buffer_bindings.push_back(bindings.texture); |
| 132 | bindings.texture += desc.count; | 134 | bindings.texture += desc.count; |
| 133 | } | 135 | } |
| 134 | texture_bindings.reserve(program.info.texture_descriptors.size()); | 136 | texture_bindings.reserve(info.texture_descriptors.size()); |
| 135 | for (const auto& desc : program.info.texture_descriptors) { | 137 | for (const auto& desc : info.texture_descriptors) { |
| 136 | texture_bindings.push_back(bindings.texture); | 138 | texture_bindings.push_back(bindings.texture); |
| 137 | bindings.texture += desc.count; | 139 | bindings.texture += desc.count; |
| 138 | } | 140 | } |