diff options
Diffstat (limited to 'src/shader_recompiler')
9 files changed, 337 insertions, 191 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index 7b6c6d22b..8e5983909 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -14,17 +14,63 @@ EmitContext::EmitContext(IR::Program& program, [[maybe_unused]] Bindings& bindin | |||
| 14 | : info{program.info}, profile{profile_} { | 14 | : info{program.info}, profile{profile_} { |
| 15 | std::string header = "#version 450\n"; | 15 | std::string header = "#version 450\n"; |
| 16 | SetupExtensions(header); | 16 | SetupExtensions(header); |
| 17 | if (program.stage == Stage::Compute) { | 17 | stage = program.stage; |
| 18 | switch (program.stage) { | ||
| 19 | case Stage::VertexA: | ||
| 20 | case Stage::VertexB: | ||
| 21 | stage_name = "vertex"; | ||
| 22 | attrib_name = "vertex"; | ||
| 23 | // TODO: add only what's used by the shader | ||
| 24 | header += | ||
| 25 | "out gl_PerVertex {vec4 gl_Position;float gl_PointSize;float gl_ClipDistance[];};"; | ||
| 26 | break; | ||
| 27 | case Stage::TessellationControl: | ||
| 28 | case Stage::TessellationEval: | ||
| 29 | stage_name = "primitive"; | ||
| 30 | attrib_name = "primitive"; | ||
| 31 | break; | ||
| 32 | case Stage::Geometry: | ||
| 33 | stage_name = "primitive"; | ||
| 34 | attrib_name = "vertex"; | ||
| 35 | break; | ||
| 36 | case Stage::Fragment: | ||
| 37 | stage_name = "fragment"; | ||
| 38 | attrib_name = "fragment"; | ||
| 39 | break; | ||
| 40 | case Stage::Compute: | ||
| 41 | stage_name = "invocation"; | ||
| 18 | header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;\n", | 42 | header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;\n", |
| 19 | program.workgroup_size[0], program.workgroup_size[1], | 43 | program.workgroup_size[0], program.workgroup_size[1], |
| 20 | program.workgroup_size[2]); | 44 | program.workgroup_size[2]); |
| 45 | break; | ||
| 21 | } | 46 | } |
| 22 | code += header; | 47 | code += header; |
| 23 | 48 | const std::string_view attr_stage{stage == Stage::Fragment ? "fragment" : "vertex"}; | |
| 49 | for (size_t index = 0; index < info.input_generics.size(); ++index) { | ||
| 50 | const auto& generic{info.input_generics[index]}; | ||
| 51 | if (generic.used) { | ||
| 52 | Add("layout(location={})in vec4 in_attr{};", index, index); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | for (size_t index = 0; index < info.stores_frag_color.size(); ++index) { | ||
| 56 | if (!info.stores_frag_color[index]) { | ||
| 57 | continue; | ||
| 58 | } | ||
| 59 | Add("layout(location={})out vec4 frag_color{};", index, index); | ||
| 60 | } | ||
| 61 | for (size_t index = 0; index < info.stores_generics.size(); ++index) { | ||
| 62 | if (info.stores_generics[index]) { | ||
| 63 | Add("layout(location={}) out vec4 out_attr{};", index, index); | ||
| 64 | } | ||
| 65 | } | ||
| 24 | DefineConstantBuffers(); | 66 | DefineConstantBuffers(); |
| 25 | DefineStorageBuffers(); | 67 | DefineStorageBuffers(); |
| 26 | DefineHelperFunctions(); | 68 | DefineHelperFunctions(); |
| 27 | code += "void main(){\n"; | 69 | Add("void main(){{"); |
| 70 | |||
| 71 | if (stage == Stage::VertexA || stage == Stage::VertexB) { | ||
| 72 | Add("gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);"); | ||
| 73 | } | ||
| 28 | } | 74 | } |
| 29 | 75 | ||
| 30 | void EmitContext::SetupExtensions(std::string& header) { | 76 | void EmitContext::SetupExtensions(std::string& header) { |
diff --git a/src/shader_recompiler/backend/glsl/emit_context.h b/src/shader_recompiler/backend/glsl/emit_context.h index 7f8857fa7..087eaff6a 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.h +++ b/src/shader_recompiler/backend/glsl/emit_context.h | |||
| @@ -89,6 +89,11 @@ public: | |||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | template <typename... Args> | 91 | template <typename... Args> |
| 92 | void AddF32x4(const char* format_str, IR::Inst& inst, Args&&... args) { | ||
| 93 | Add<Type::F32x4>(format_str, inst, args...); | ||
| 94 | } | ||
| 95 | |||
| 96 | template <typename... Args> | ||
| 92 | void Add(const char* format_str, Args&&... args) { | 97 | void Add(const char* format_str, Args&&... args) { |
| 93 | code += fmt::format(format_str, std::forward<Args>(args)...); | 98 | code += fmt::format(format_str, std::forward<Args>(args)...); |
| 94 | // TODO: Remove this | 99 | // TODO: Remove this |
| @@ -100,6 +105,10 @@ public: | |||
| 100 | const Info& info; | 105 | const Info& info; |
| 101 | const Profile& profile; | 106 | const Profile& profile; |
| 102 | 107 | ||
| 108 | Stage stage{}; | ||
| 109 | std::string_view stage_name = "invalid"; | ||
| 110 | std::string_view attrib_name = "invalid"; | ||
| 111 | |||
| 103 | private: | 112 | private: |
| 104 | void SetupExtensions(std::string& header); | 113 | void SetupExtensions(std::string& header); |
| 105 | void DefineConstantBuffers(); | 114 | void DefineConstantBuffers(); |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp index 8e7ad68bd..048b12f38 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_composite.cpp | |||
| @@ -155,16 +155,14 @@ void EmitCompositeExtractF32x2(EmitContext& ctx, IR::Inst& inst, std::string_vie | |||
| 155 | ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]); | 155 | ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | void EmitCompositeExtractF32x3([[maybe_unused]] EmitContext& ctx, | 158 | void EmitCompositeExtractF32x3(EmitContext& ctx, IR::Inst& inst, std::string_view composite, |
| 159 | [[maybe_unused]] std::string_view composite, | 159 | u32 index) { |
| 160 | [[maybe_unused]] u32 index) { | 160 | ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]); |
| 161 | throw NotImplementedException("GLSL Instruction"); | ||
| 162 | } | 161 | } |
| 163 | 162 | ||
| 164 | void EmitCompositeExtractF32x4([[maybe_unused]] EmitContext& ctx, | 163 | void EmitCompositeExtractF32x4(EmitContext& ctx, IR::Inst& inst, std::string_view composite, |
| 165 | [[maybe_unused]] std::string_view composite, | 164 | u32 index) { |
| 166 | [[maybe_unused]] u32 index) { | 165 | ctx.AddF32("{}={}.{};", inst, composite, SWIZZLE[index]); |
| 167 | throw NotImplementedException("GLSL Instruction"); | ||
| 168 | } | 166 | } |
| 169 | 167 | ||
| 170 | void EmitCompositeInsertF32x2([[maybe_unused]] EmitContext& ctx, | 168 | void EmitCompositeInsertF32x2([[maybe_unused]] EmitContext& ctx, |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp index 7c9cadd7e..441818c0b 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp | |||
| @@ -51,4 +51,57 @@ void EmitGetCbufU32x2([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] const | |||
| 51 | [[maybe_unused]] const IR::Value& offset) { | 51 | [[maybe_unused]] const IR::Value& offset) { |
| 52 | throw NotImplementedException("GLSL"); | 52 | throw NotImplementedException("GLSL"); |
| 53 | } | 53 | } |
| 54 | |||
| 55 | void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, | ||
| 56 | [[maybe_unused]] std::string_view vertex) { | ||
| 57 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 58 | const char swizzle{"xyzw"[element]}; | ||
| 59 | if (IR::IsGeneric(attr)) { | ||
| 60 | const u32 index{IR::GenericAttributeIndex(attr)}; | ||
| 61 | ctx.AddF32("{}=in_attr{}.{};", inst, index, swizzle); | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | switch (attr) { | ||
| 65 | case IR::Attribute::PositionX: | ||
| 66 | case IR::Attribute::PositionY: | ||
| 67 | case IR::Attribute::PositionZ: | ||
| 68 | case IR::Attribute::PositionW: | ||
| 69 | ctx.AddF32("{}=gl_Position.{};", inst, swizzle); | ||
| 70 | break; | ||
| 71 | default: | ||
| 72 | fmt::print("Get attribute {}", attr); | ||
| 73 | throw NotImplementedException("Get attribute {}", attr); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value, | ||
| 78 | [[maybe_unused]] std::string_view vertex) { | ||
| 79 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 80 | const char swizzle{"xyzw"[element]}; | ||
| 81 | if (IR::IsGeneric(attr)) { | ||
| 82 | const u32 index{IR::GenericAttributeIndex(attr)}; | ||
| 83 | ctx.Add("out_attr{}.{}={};", index, swizzle, value); | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | switch (attr) { | ||
| 87 | case IR::Attribute::PointSize: | ||
| 88 | ctx.Add("gl_Pointsize={};", value); | ||
| 89 | break; | ||
| 90 | case IR::Attribute::PositionX: | ||
| 91 | case IR::Attribute::PositionY: | ||
| 92 | case IR::Attribute::PositionZ: | ||
| 93 | case IR::Attribute::PositionW: | ||
| 94 | ctx.Add("gl_Position.{}={};", swizzle, value); | ||
| 95 | break; | ||
| 96 | default: | ||
| 97 | fmt::print("Set attribute {}", attr); | ||
| 98 | throw NotImplementedException("Set attribute {}", attr); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, std::string_view value) { | ||
| 103 | const char swizzle{"xyzw"[component]}; | ||
| 104 | ctx.Add("frag_color{}.{}={};", index, swizzle, value); | ||
| 105 | } | ||
| 106 | |||
| 54 | } // namespace Shader::Backend::GLSL | 107 | } // namespace Shader::Backend::GLSL |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp index e69de29bb..109938e0e 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_image.cpp | |||
| @@ -0,0 +1,205 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <string_view> | ||
| 6 | |||
| 7 | #include "shader_recompiler/backend/glsl/emit_context.h" | ||
| 8 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" | ||
| 9 | #include "shader_recompiler/frontend/ir/value.h" | ||
| 10 | #include "shader_recompiler/profile.h" | ||
| 11 | |||
| 12 | namespace Shader::Backend::GLSL { | ||
| 13 | |||
| 14 | void EmitImageSampleImplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 15 | [[maybe_unused]] const IR::Value& index, | ||
| 16 | [[maybe_unused]] std::string_view coords, | ||
| 17 | [[maybe_unused]] std::string_view bias_lc, | ||
| 18 | [[maybe_unused]] const IR::Value& offset) { | ||
| 19 | throw NotImplementedException("GLSL Instruction"); | ||
| 20 | } | ||
| 21 | |||
| 22 | void EmitImageSampleExplicitLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 23 | [[maybe_unused]] const IR::Value& index, | ||
| 24 | [[maybe_unused]] std::string_view coords, | ||
| 25 | [[maybe_unused]] std::string_view lod_lc, | ||
| 26 | [[maybe_unused]] const IR::Value& offset) { | ||
| 27 | throw NotImplementedException("GLSL Instruction"); | ||
| 28 | } | ||
| 29 | |||
| 30 | void EmitImageSampleDrefImplicitLod([[maybe_unused]] EmitContext& ctx, | ||
| 31 | [[maybe_unused]] IR::Inst& inst, | ||
| 32 | [[maybe_unused]] const IR::Value& index, | ||
| 33 | [[maybe_unused]] std::string_view coords, | ||
| 34 | [[maybe_unused]] std::string_view dref, | ||
| 35 | [[maybe_unused]] std::string_view bias_lc, | ||
| 36 | [[maybe_unused]] const IR::Value& offset) { | ||
| 37 | throw NotImplementedException("GLSL Instruction"); | ||
| 38 | } | ||
| 39 | |||
| 40 | void EmitImageSampleDrefExplicitLod([[maybe_unused]] EmitContext& ctx, | ||
| 41 | [[maybe_unused]] IR::Inst& inst, | ||
| 42 | [[maybe_unused]] const IR::Value& index, | ||
| 43 | [[maybe_unused]] std::string_view coords, | ||
| 44 | [[maybe_unused]] std::string_view dref, | ||
| 45 | [[maybe_unused]] std::string_view lod_lc, | ||
| 46 | [[maybe_unused]] const IR::Value& offset) { | ||
| 47 | throw NotImplementedException("GLSL Instruction"); | ||
| 48 | } | ||
| 49 | |||
| 50 | void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 51 | [[maybe_unused]] const IR::Value& index, | ||
| 52 | [[maybe_unused]] std::string_view coords, | ||
| 53 | [[maybe_unused]] const IR::Value& offset, | ||
| 54 | [[maybe_unused]] const IR::Value& offset2) { | ||
| 55 | throw NotImplementedException("GLSL Instruction"); | ||
| 56 | } | ||
| 57 | |||
| 58 | void EmitImageGatherDref([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 59 | [[maybe_unused]] const IR::Value& index, | ||
| 60 | [[maybe_unused]] std::string_view coords, | ||
| 61 | [[maybe_unused]] const IR::Value& offset, | ||
| 62 | [[maybe_unused]] const IR::Value& offset2, | ||
| 63 | [[maybe_unused]] std::string_view dref) { | ||
| 64 | throw NotImplementedException("GLSL Instruction"); | ||
| 65 | } | ||
| 66 | |||
| 67 | void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 68 | [[maybe_unused]] const IR::Value& index, | ||
| 69 | [[maybe_unused]] std::string_view coords, | ||
| 70 | [[maybe_unused]] std::string_view offset, [[maybe_unused]] std::string_view lod, | ||
| 71 | [[maybe_unused]] std::string_view ms) { | ||
| 72 | throw NotImplementedException("GLSL Instruction"); | ||
| 73 | } | ||
| 74 | |||
| 75 | void EmitImageQueryDimensions([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 76 | [[maybe_unused]] const IR::Value& index, | ||
| 77 | [[maybe_unused]] std::string_view lod) { | ||
| 78 | throw NotImplementedException("GLSL Instruction"); | ||
| 79 | } | ||
| 80 | |||
| 81 | void EmitImageQueryLod([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 82 | [[maybe_unused]] const IR::Value& index, | ||
| 83 | [[maybe_unused]] std::string_view coords) { | ||
| 84 | throw NotImplementedException("GLSL Instruction"); | ||
| 85 | } | ||
| 86 | |||
| 87 | void EmitImageGradient([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 88 | [[maybe_unused]] const IR::Value& index, | ||
| 89 | [[maybe_unused]] std::string_view coords, | ||
| 90 | [[maybe_unused]] std::string_view derivates, | ||
| 91 | [[maybe_unused]] std::string_view offset, | ||
| 92 | [[maybe_unused]] std::string_view lod_clamp) { | ||
| 93 | throw NotImplementedException("GLSL Instruction"); | ||
| 94 | } | ||
| 95 | |||
| 96 | void EmitImageRead([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 97 | [[maybe_unused]] const IR::Value& index, | ||
| 98 | [[maybe_unused]] std::string_view coords) { | ||
| 99 | throw NotImplementedException("GLSL Instruction"); | ||
| 100 | } | ||
| 101 | |||
| 102 | void EmitImageWrite([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | ||
| 103 | [[maybe_unused]] const IR::Value& index, | ||
| 104 | [[maybe_unused]] std::string_view coords, | ||
| 105 | [[maybe_unused]] std::string_view color) { | ||
| 106 | throw NotImplementedException("GLSL Instruction"); | ||
| 107 | } | ||
| 108 | |||
| 109 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | ||
| 110 | throw NotImplementedException("GLSL Instruction"); | ||
| 111 | } | ||
| 112 | |||
| 113 | void EmitBindlessImageSampleExplicitLod(EmitContext&) { | ||
| 114 | throw NotImplementedException("GLSL Instruction"); | ||
| 115 | } | ||
| 116 | |||
| 117 | void EmitBindlessImageSampleDrefImplicitLod(EmitContext&) { | ||
| 118 | throw NotImplementedException("GLSL Instruction"); | ||
| 119 | } | ||
| 120 | |||
| 121 | void EmitBindlessImageSampleDrefExplicitLod(EmitContext&) { | ||
| 122 | throw NotImplementedException("GLSL Instruction"); | ||
| 123 | } | ||
| 124 | |||
| 125 | void EmitBindlessImageGather(EmitContext&) { | ||
| 126 | throw NotImplementedException("GLSL Instruction"); | ||
| 127 | } | ||
| 128 | |||
| 129 | void EmitBindlessImageGatherDref(EmitContext&) { | ||
| 130 | throw NotImplementedException("GLSL Instruction"); | ||
| 131 | } | ||
| 132 | |||
| 133 | void EmitBindlessImageFetch(EmitContext&) { | ||
| 134 | throw NotImplementedException("GLSL Instruction"); | ||
| 135 | } | ||
| 136 | |||
| 137 | void EmitBindlessImageQueryDimensions(EmitContext&) { | ||
| 138 | throw NotImplementedException("GLSL Instruction"); | ||
| 139 | } | ||
| 140 | |||
| 141 | void EmitBindlessImageQueryLod(EmitContext&) { | ||
| 142 | throw NotImplementedException("GLSL Instruction"); | ||
| 143 | } | ||
| 144 | |||
| 145 | void EmitBindlessImageGradient(EmitContext&) { | ||
| 146 | throw NotImplementedException("GLSL Instruction"); | ||
| 147 | } | ||
| 148 | |||
| 149 | void EmitBindlessImageRead(EmitContext&) { | ||
| 150 | throw NotImplementedException("GLSL Instruction"); | ||
| 151 | } | ||
| 152 | |||
| 153 | void EmitBindlessImageWrite(EmitContext&) { | ||
| 154 | throw NotImplementedException("GLSL Instruction"); | ||
| 155 | } | ||
| 156 | |||
| 157 | void EmitBoundImageSampleImplicitLod(EmitContext&) { | ||
| 158 | throw NotImplementedException("GLSL Instruction"); | ||
| 159 | } | ||
| 160 | |||
| 161 | void EmitBoundImageSampleExplicitLod(EmitContext&) { | ||
| 162 | throw NotImplementedException("GLSL Instruction"); | ||
| 163 | } | ||
| 164 | |||
| 165 | void EmitBoundImageSampleDrefImplicitLod(EmitContext&) { | ||
| 166 | throw NotImplementedException("GLSL Instruction"); | ||
| 167 | } | ||
| 168 | |||
| 169 | void EmitBoundImageSampleDrefExplicitLod(EmitContext&) { | ||
| 170 | throw NotImplementedException("GLSL Instruction"); | ||
| 171 | } | ||
| 172 | |||
| 173 | void EmitBoundImageGather(EmitContext&) { | ||
| 174 | throw NotImplementedException("GLSL Instruction"); | ||
| 175 | } | ||
| 176 | |||
| 177 | void EmitBoundImageGatherDref(EmitContext&) { | ||
| 178 | throw NotImplementedException("GLSL Instruction"); | ||
| 179 | } | ||
| 180 | |||
| 181 | void EmitBoundImageFetch(EmitContext&) { | ||
| 182 | throw NotImplementedException("GLSL Instruction"); | ||
| 183 | } | ||
| 184 | |||
| 185 | void EmitBoundImageQueryDimensions(EmitContext&) { | ||
| 186 | throw NotImplementedException("GLSL Instruction"); | ||
| 187 | } | ||
| 188 | |||
| 189 | void EmitBoundImageQueryLod(EmitContext&) { | ||
| 190 | throw NotImplementedException("GLSL Instruction"); | ||
| 191 | } | ||
| 192 | |||
| 193 | void EmitBoundImageGradient(EmitContext&) { | ||
| 194 | throw NotImplementedException("GLSL Instruction"); | ||
| 195 | } | ||
| 196 | |||
| 197 | void EmitBoundImageRead(EmitContext&) { | ||
| 198 | throw NotImplementedException("GLSL Instruction"); | ||
| 199 | } | ||
| 200 | |||
| 201 | void EmitBoundImageWrite(EmitContext&) { | ||
| 202 | throw NotImplementedException("GLSL Instruction"); | ||
| 203 | } | ||
| 204 | |||
| 205 | } // namespace Shader::Backend::GLSL | ||
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index 9f32070b0..49ab108bb 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | |||
| @@ -61,7 +61,8 @@ void EmitGetCbufU32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | |||
| 61 | void EmitGetCbufF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 61 | void EmitGetCbufF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 62 | const IR::Value& offset); | 62 | const IR::Value& offset); |
| 63 | void EmitGetCbufU32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset); | 63 | void EmitGetCbufU32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset); |
| 64 | void EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view vertex); | 64 | void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, |
| 65 | std::string_view vertex); | ||
| 65 | void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value, | 66 | void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value, |
| 66 | std::string_view vertex); | 67 | std::string_view vertex); |
| 67 | void EmitGetAttributeIndexed(EmitContext& ctx, std::string_view offset, std::string_view vertex); | 68 | void EmitGetAttributeIndexed(EmitContext& ctx, std::string_view offset, std::string_view vertex); |
| @@ -180,8 +181,10 @@ void EmitCompositeConstructF32x4(EmitContext& ctx, std::string_view e1, std::str | |||
| 180 | std::string_view e3, std::string_view e4); | 181 | std::string_view e3, std::string_view e4); |
| 181 | void EmitCompositeExtractF32x2(EmitContext& ctx, IR::Inst& inst, std::string_view composite, | 182 | void EmitCompositeExtractF32x2(EmitContext& ctx, IR::Inst& inst, std::string_view composite, |
| 182 | u32 index); | 183 | u32 index); |
| 183 | void EmitCompositeExtractF32x3(EmitContext& ctx, std::string_view composite, u32 index); | 184 | void EmitCompositeExtractF32x3(EmitContext& ctx, IR::Inst& inst, std::string_view composite, |
| 184 | void EmitCompositeExtractF32x4(EmitContext& ctx, std::string_view composite, u32 index); | 185 | u32 index); |
| 186 | void EmitCompositeExtractF32x4(EmitContext& ctx, IR::Inst& inst, std::string_view composite, | ||
| 187 | u32 index); | ||
| 185 | void EmitCompositeInsertF32x2(EmitContext& ctx, std::string_view composite, std::string_view object, | 188 | void EmitCompositeInsertF32x2(EmitContext& ctx, std::string_view composite, std::string_view object, |
| 186 | u32 index); | 189 | u32 index); |
| 187 | void EmitCompositeInsertF32x3(EmitContext& ctx, std::string_view composite, std::string_view object, | 190 | void EmitCompositeInsertF32x3(EmitContext& ctx, std::string_view composite, std::string_view object, |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp index b37b3c76d..14a2edd74 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp | |||
| @@ -83,7 +83,7 @@ void EmitUnreachable(EmitContext& ctx) { | |||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | void EmitDemoteToHelperInvocation(EmitContext& ctx, std::string_view continue_label) { | 85 | void EmitDemoteToHelperInvocation(EmitContext& ctx, std::string_view continue_label) { |
| 86 | NotImplemented(); | 86 | ctx.Add("discard;"); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | void EmitBarrier(EmitContext& ctx) { | 89 | void EmitBarrier(EmitContext& ctx) { |
| @@ -146,15 +146,6 @@ void EmitGetIndirectBranchVariable(EmitContext& ctx) { | |||
| 146 | NotImplemented(); | 146 | NotImplemented(); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | void EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view vertex) { | ||
| 150 | NotImplemented(); | ||
| 151 | } | ||
| 152 | |||
| 153 | void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view value, | ||
| 154 | std::string_view vertex) { | ||
| 155 | NotImplemented(); | ||
| 156 | } | ||
| 157 | |||
| 158 | void EmitGetAttributeIndexed(EmitContext& ctx, std::string_view offset, std::string_view vertex) { | 149 | void EmitGetAttributeIndexed(EmitContext& ctx, std::string_view offset, std::string_view vertex) { |
| 159 | NotImplemented(); | 150 | NotImplemented(); |
| 160 | } | 151 | } |
| @@ -172,10 +163,6 @@ void EmitSetPatch(EmitContext& ctx, IR::Patch patch, std::string_view value) { | |||
| 172 | NotImplemented(); | 163 | NotImplemented(); |
| 173 | } | 164 | } |
| 174 | 165 | ||
| 175 | void EmitSetFragColor(EmitContext& ctx, u32 index, u32 component, std::string_view value) { | ||
| 176 | NotImplemented(); | ||
| 177 | } | ||
| 178 | |||
| 179 | void EmitSetSampleMask(EmitContext& ctx, std::string_view value) { | 166 | void EmitSetSampleMask(EmitContext& ctx, std::string_view value) { |
| 180 | NotImplemented(); | 167 | NotImplemented(); |
| 181 | } | 168 | } |
| @@ -456,169 +443,6 @@ void EmitSharedAtomicExchange64(EmitContext& ctx, std::string_view pointer_offse | |||
| 456 | NotImplemented(); | 443 | NotImplemented(); |
| 457 | } | 444 | } |
| 458 | 445 | ||
| 459 | void EmitBindlessImageSampleImplicitLod(EmitContext&) { | ||
| 460 | NotImplemented(); | ||
| 461 | } | ||
| 462 | |||
| 463 | void EmitBindlessImageSampleExplicitLod(EmitContext&) { | ||
| 464 | NotImplemented(); | ||
| 465 | } | ||
| 466 | |||
| 467 | void EmitBindlessImageSampleDrefImplicitLod(EmitContext&) { | ||
| 468 | NotImplemented(); | ||
| 469 | } | ||
| 470 | |||
| 471 | void EmitBindlessImageSampleDrefExplicitLod(EmitContext&) { | ||
| 472 | NotImplemented(); | ||
| 473 | } | ||
| 474 | |||
| 475 | void EmitBindlessImageGather(EmitContext&) { | ||
| 476 | NotImplemented(); | ||
| 477 | } | ||
| 478 | |||
| 479 | void EmitBindlessImageGatherDref(EmitContext&) { | ||
| 480 | NotImplemented(); | ||
| 481 | } | ||
| 482 | |||
| 483 | void EmitBindlessImageFetch(EmitContext&) { | ||
| 484 | NotImplemented(); | ||
| 485 | } | ||
| 486 | |||
| 487 | void EmitBindlessImageQueryDimensions(EmitContext&) { | ||
| 488 | NotImplemented(); | ||
| 489 | } | ||
| 490 | |||
| 491 | void EmitBindlessImageQueryLod(EmitContext&) { | ||
| 492 | NotImplemented(); | ||
| 493 | } | ||
| 494 | |||
| 495 | void EmitBindlessImageGradient(EmitContext&) { | ||
| 496 | NotImplemented(); | ||
| 497 | } | ||
| 498 | |||
| 499 | void EmitBindlessImageRead(EmitContext&) { | ||
| 500 | NotImplemented(); | ||
| 501 | } | ||
| 502 | |||
| 503 | void EmitBindlessImageWrite(EmitContext&) { | ||
| 504 | NotImplemented(); | ||
| 505 | } | ||
| 506 | |||
| 507 | void EmitBoundImageSampleImplicitLod(EmitContext&) { | ||
| 508 | NotImplemented(); | ||
| 509 | } | ||
| 510 | |||
| 511 | void EmitBoundImageSampleExplicitLod(EmitContext&) { | ||
| 512 | NotImplemented(); | ||
| 513 | } | ||
| 514 | |||
| 515 | void EmitBoundImageSampleDrefImplicitLod(EmitContext&) { | ||
| 516 | NotImplemented(); | ||
| 517 | } | ||
| 518 | |||
| 519 | void EmitBoundImageSampleDrefExplicitLod(EmitContext&) { | ||
| 520 | NotImplemented(); | ||
| 521 | } | ||
| 522 | |||
| 523 | void EmitBoundImageGather(EmitContext&) { | ||
| 524 | NotImplemented(); | ||
| 525 | } | ||
| 526 | |||
| 527 | void EmitBoundImageGatherDref(EmitContext&) { | ||
| 528 | NotImplemented(); | ||
| 529 | } | ||
| 530 | |||
| 531 | void EmitBoundImageFetch(EmitContext&) { | ||
| 532 | NotImplemented(); | ||
| 533 | } | ||
| 534 | |||
| 535 | void EmitBoundImageQueryDimensions(EmitContext&) { | ||
| 536 | NotImplemented(); | ||
| 537 | } | ||
| 538 | |||
| 539 | void EmitBoundImageQueryLod(EmitContext&) { | ||
| 540 | NotImplemented(); | ||
| 541 | } | ||
| 542 | |||
| 543 | void EmitBoundImageGradient(EmitContext&) { | ||
| 544 | NotImplemented(); | ||
| 545 | } | ||
| 546 | |||
| 547 | void EmitBoundImageRead(EmitContext&) { | ||
| 548 | NotImplemented(); | ||
| 549 | } | ||
| 550 | |||
| 551 | void EmitBoundImageWrite(EmitContext&) { | ||
| 552 | NotImplemented(); | ||
| 553 | } | ||
| 554 | |||
| 555 | void EmitImageSampleImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 556 | std::string_view coords, std::string_view bias_lc, | ||
| 557 | const IR::Value& offset) { | ||
| 558 | NotImplemented(); | ||
| 559 | } | ||
| 560 | |||
| 561 | void EmitImageSampleExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 562 | std::string_view coords, std::string_view lod_lc, | ||
| 563 | const IR::Value& offset) { | ||
| 564 | NotImplemented(); | ||
| 565 | } | ||
| 566 | |||
| 567 | void EmitImageSampleDrefImplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 568 | std::string_view coords, std::string_view dref, | ||
| 569 | std::string_view bias_lc, const IR::Value& offset) { | ||
| 570 | NotImplemented(); | ||
| 571 | } | ||
| 572 | |||
| 573 | void EmitImageSampleDrefExplicitLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 574 | std::string_view coords, std::string_view dref, | ||
| 575 | std::string_view lod_lc, const IR::Value& offset) { | ||
| 576 | NotImplemented(); | ||
| 577 | } | ||
| 578 | |||
| 579 | void EmitImageGather(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 580 | std::string_view coords, const IR::Value& offset, const IR::Value& offset2) { | ||
| 581 | NotImplemented(); | ||
| 582 | } | ||
| 583 | |||
| 584 | void EmitImageGatherDref(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 585 | std::string_view coords, const IR::Value& offset, const IR::Value& offset2, | ||
| 586 | std::string_view dref) { | ||
| 587 | NotImplemented(); | ||
| 588 | } | ||
| 589 | |||
| 590 | void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 591 | std::string_view coords, std::string_view offset, std::string_view lod, | ||
| 592 | std::string_view ms) { | ||
| 593 | NotImplemented(); | ||
| 594 | } | ||
| 595 | |||
| 596 | void EmitImageQueryDimensions(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 597 | std::string_view lod) { | ||
| 598 | NotImplemented(); | ||
| 599 | } | ||
| 600 | |||
| 601 | void EmitImageQueryLod(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 602 | std::string_view coords) { | ||
| 603 | NotImplemented(); | ||
| 604 | } | ||
| 605 | |||
| 606 | void EmitImageGradient(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 607 | std::string_view coords, std::string_view derivates, std::string_view offset, | ||
| 608 | std::string_view lod_clamp) { | ||
| 609 | NotImplemented(); | ||
| 610 | } | ||
| 611 | |||
| 612 | void EmitImageRead(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 613 | std::string_view coords) { | ||
| 614 | NotImplemented(); | ||
| 615 | } | ||
| 616 | |||
| 617 | void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index, | ||
| 618 | std::string_view coords, std::string_view color) { | ||
| 619 | NotImplemented(); | ||
| 620 | } | ||
| 621 | |||
| 622 | void EmitBindlessImageAtomicIAdd32(EmitContext&) { | 446 | void EmitBindlessImageAtomicIAdd32(EmitContext&) { |
| 623 | NotImplemented(); | 447 | NotImplemented(); |
| 624 | } | 448 | } |
diff --git a/src/shader_recompiler/backend/glsl/reg_alloc.cpp b/src/shader_recompiler/backend/glsl/reg_alloc.cpp index c60a87d91..a080d5341 100644 --- a/src/shader_recompiler/backend/glsl/reg_alloc.cpp +++ b/src/shader_recompiler/backend/glsl/reg_alloc.cpp | |||
| @@ -55,6 +55,8 @@ std::string MakeImm(const IR::Value& value) { | |||
| 55 | return fmt::format("{}ul", value.U64()); | 55 | return fmt::format("{}ul", value.U64()); |
| 56 | case IR::Type::F64: | 56 | case IR::Type::F64: |
| 57 | return FormatFloat(fmt::format("{}", value.F64()), IR::Type::F64); | 57 | return FormatFloat(fmt::format("{}", value.F64()), IR::Type::F64); |
| 58 | case IR::Type::Void: | ||
| 59 | return ""; | ||
| 58 | default: | 60 | default: |
| 59 | throw NotImplementedException("Immediate type {}", value.Type()); | 61 | throw NotImplementedException("Immediate type {}", value.Type()); |
| 60 | } | 62 | } |
| @@ -131,6 +133,10 @@ std::string RegAlloc::GetType(Type type, u32 index) { | |||
| 131 | return "uvec2 "; | 133 | return "uvec2 "; |
| 132 | case Type::F32x2: | 134 | case Type::F32x2: |
| 133 | return "vec2 "; | 135 | return "vec2 "; |
| 136 | case Type::U32x4: | ||
| 137 | return "uvec4 "; | ||
| 138 | case Type::F32x4: | ||
| 139 | return "vec4 "; | ||
| 134 | case Type::Void: | 140 | case Type::Void: |
| 135 | return ""; | 141 | return ""; |
| 136 | default: | 142 | default: |
diff --git a/src/shader_recompiler/backend/glsl/reg_alloc.h b/src/shader_recompiler/backend/glsl/reg_alloc.h index 419e1e761..df067d3ad 100644 --- a/src/shader_recompiler/backend/glsl/reg_alloc.h +++ b/src/shader_recompiler/backend/glsl/reg_alloc.h | |||
| @@ -27,6 +27,8 @@ enum class Type : u32 { | |||
| 27 | F64, | 27 | F64, |
| 28 | U32x2, | 28 | U32x2, |
| 29 | F32x2, | 29 | F32x2, |
| 30 | U32x4, | ||
| 31 | F32x4, | ||
| 30 | Void, | 32 | Void, |
| 31 | }; | 33 | }; |
| 32 | 34 | ||