summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2018-04-15 20:26:45 -0400
committerGravatar bunnei2018-04-17 16:36:40 -0400
commit8d4899d6ead9413a6bf8f237508a1941dc12493d (patch)
tree9ce09038da050a59a0c6625d365f2103755b106a
parentgl_shader_decompiler: Implement IPA instruction. (diff)
downloadyuzu-8d4899d6ead9413a6bf8f237508a1941dc12493d.tar.gz
yuzu-8d4899d6ead9413a6bf8f237508a1941dc12493d.tar.xz
yuzu-8d4899d6ead9413a6bf8f237508a1941dc12493d.zip
gl_shader_decompiler: Allow vertex position to be used in fragment shader.
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp28
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp6
2 files changed, 18 insertions, 16 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 045ccdb0f..1d8057927 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -156,23 +156,27 @@ private:
156 156
157 /// Generates code representing an input attribute register. 157 /// Generates code representing an input attribute register.
158 std::string GetInputAttribute(Attribute::Index attribute) { 158 std::string GetInputAttribute(Attribute::Index attribute) {
159 declr_input_attribute.insert(attribute); 159 switch (attribute) {
160 case Attribute::Index::Position:
161 return "position";
162 default:
163 const u32 index{static_cast<u32>(attribute) -
164 static_cast<u32>(Attribute::Index::Attribute_0)};
165 if (attribute >= Attribute::Index::Attribute_0) {
166 declr_input_attribute.insert(attribute);
167 return "input_attribute_" + std::to_string(index);
168 }
160 169
161 const u32 index{static_cast<u32>(attribute) - 170 LOG_CRITICAL(HW_GPU, "Unhandled input attribute: 0x%02x", index);
162 static_cast<u32>(Attribute::Index::Attribute_0)}; 171 UNREACHABLE();
163 if (attribute >= Attribute::Index::Attribute_0) {
164 return "input_attribute_" + std::to_string(index);
165 } 172 }
166
167 LOG_CRITICAL(HW_GPU, "Unhandled input attribute: 0x%02x", index);
168 UNREACHABLE();
169 } 173 }
170 174
171 /// Generates code representing an output attribute register. 175 /// Generates code representing an output attribute register.
172 std::string GetOutputAttribute(Attribute::Index attribute) { 176 std::string GetOutputAttribute(Attribute::Index attribute) {
173 switch (attribute) { 177 switch (attribute) {
174 case Attribute::Index::Position: 178 case Attribute::Index::Position:
175 return "gl_Position"; 179 return "position";
176 default: 180 default:
177 const u32 index{static_cast<u32>(attribute) - 181 const u32 index{static_cast<u32>(attribute) -
178 static_cast<u32>(Attribute::Index::Attribute_0)}; 182 static_cast<u32>(Attribute::Index::Attribute_0)};
@@ -381,12 +385,6 @@ private:
381 } 385 }
382 case OpCode::Id::IPA: { 386 case OpCode::Id::IPA: {
383 const auto& attribute = instr.attribute.fmt28; 387 const auto& attribute = instr.attribute.fmt28;
384
385 if (attribute.index == Attribute::Index::Position) {
386 LOG_CRITICAL(HW_GPU, "Unimplemented");
387 break;
388 }
389
390 std::string dest = GetRegister(instr.gpr0); 388 std::string dest = GetRegister(instr.gpr0);
391 SetDest(attribute.element, dest, GetInputAttribute(attribute.index), 1, 4); 389 SetDest(attribute.element, dest, GetInputAttribute(attribute.index), 1, 4);
392 break; 390 break;
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index aeea1c805..8b7f17601 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -27,10 +27,13 @@ out gl_PerVertex {
27 vec4 gl_Position; 27 vec4 gl_Position;
28}; 28};
29 29
30out vec4 position;
31
30void main() { 32void main() {
31 exec_shader(); 33 exec_shader();
32}
33 34
35 gl_Position = position;
36}
34)"; 37)";
35 out += program.first; 38 out += program.first;
36 return {out, program.second}; 39 return {out, program.second};
@@ -46,6 +49,7 @@ ProgramResult GenerateFragmentShader(const ShaderSetup& setup, const MaxwellFSCo
46 .get_value_or({}); 49 .get_value_or({});
47 out += R"( 50 out += R"(
48 51
52in vec4 position;
49out vec4 color; 53out vec4 color;
50 54
51uniform sampler2D tex[32]; 55uniform sampler2D tex[32];