diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/pica.h | 10 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 29 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 88 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_util.h | 1 | ||||
| -rw-r--r-- | src/video_core/shader/shader.h | 3 |
7 files changed, 106 insertions, 38 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index a81a7b984..86c0a0096 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -138,6 +138,15 @@ struct Regs { | |||
| 138 | INSERT_PADDING_WORDS(0x12); | 138 | INSERT_PADDING_WORDS(0x12); |
| 139 | 139 | ||
| 140 | struct TextureConfig { | 140 | struct TextureConfig { |
| 141 | enum TextureType : u32 { | ||
| 142 | Texture2D = 0, | ||
| 143 | TextureCube = 1, | ||
| 144 | Shadow2D = 2, | ||
| 145 | Projection2D = 3, | ||
| 146 | ShadowCube = 4, | ||
| 147 | Disabled = 5, | ||
| 148 | }; | ||
| 149 | |||
| 141 | enum WrapMode : u32 { | 150 | enum WrapMode : u32 { |
| 142 | ClampToEdge = 0, | 151 | ClampToEdge = 0, |
| 143 | ClampToBorder = 1, | 152 | ClampToBorder = 1, |
| @@ -168,6 +177,7 @@ struct Regs { | |||
| 168 | BitField< 2, 1, TextureFilter> min_filter; | 177 | BitField< 2, 1, TextureFilter> min_filter; |
| 169 | BitField< 8, 2, WrapMode> wrap_t; | 178 | BitField< 8, 2, WrapMode> wrap_t; |
| 170 | BitField<12, 2, WrapMode> wrap_s; | 179 | BitField<12, 2, WrapMode> wrap_s; |
| 180 | BitField<28, 2, TextureType> type; ///< @note Only valid for texture 0 according to 3DBrew. | ||
| 171 | }; | 181 | }; |
| 172 | 182 | ||
| 173 | INSERT_PADDING_WORDS(0x1); | 183 | INSERT_PADDING_WORDS(0x1); |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 80cad9056..65168f05a 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -442,8 +442,33 @@ static void ProcessTriangleInternal(const Shader::OutputVertex& v0, | |||
| 442 | 442 | ||
| 443 | DEBUG_ASSERT(0 != texture.config.address); | 443 | DEBUG_ASSERT(0 != texture.config.address); |
| 444 | 444 | ||
| 445 | int s = (int)(uv[i].u() * float24::FromFloat32(static_cast<float>(texture.config.width))).ToFloat32(); | 445 | float24 u = uv[i].u(); |
| 446 | int t = (int)(uv[i].v() * float24::FromFloat32(static_cast<float>(texture.config.height))).ToFloat32(); | 446 | float24 v = uv[i].v(); |
| 447 | |||
| 448 | // Only unit 0 respects the texturing type (according to 3DBrew) | ||
| 449 | // TODO: Refactor so cubemaps and shadowmaps can be handled | ||
| 450 | if (i == 0) { | ||
| 451 | switch(texture.config.type) { | ||
| 452 | case Regs::TextureConfig::Texture2D: | ||
| 453 | break; | ||
| 454 | case Regs::TextureConfig::Projection2D: { | ||
| 455 | auto tc0_w = GetInterpolatedAttribute(v0.tc0_w, v1.tc0_w, v2.tc0_w); | ||
| 456 | u /= tc0_w; | ||
| 457 | v /= tc0_w; | ||
| 458 | break; | ||
| 459 | } | ||
| 460 | default: | ||
| 461 | // TODO: Change to LOG_ERROR when more types are handled. | ||
| 462 | LOG_DEBUG(HW_GPU, "Unhandled texture type %x", (int)texture.config.type); | ||
| 463 | UNIMPLEMENTED(); | ||
| 464 | break; | ||
| 465 | } | ||
| 466 | } | ||
| 467 | |||
| 468 | int s = (int)(u * float24::FromFloat32(static_cast<float>(texture.config.width))).ToFloat32(); | ||
| 469 | int t = (int)(v * float24::FromFloat32(static_cast<float>(texture.config.height))).ToFloat32(); | ||
| 470 | |||
| 471 | |||
| 447 | static auto GetWrappedTexCoord = [](Regs::TextureConfig::WrapMode mode, int val, unsigned size) { | 472 | static auto GetWrappedTexCoord = [](Regs::TextureConfig::WrapMode mode, int val, unsigned size) { |
| 448 | switch (mode) { | 473 | switch (mode) { |
| 449 | case Regs::TextureConfig::ClampToEdge: | 474 | case Regs::TextureConfig::ClampToEdge: |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d1d9beccb..ed2e2f3ae 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -76,6 +76,9 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) { | |||
| 76 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD1); | 76 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD1); |
| 77 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD2); | 77 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD2); |
| 78 | 78 | ||
| 79 | glVertexAttribPointer(GLShader::ATTRIBUTE_TEXCOORD0_W, 1, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, tex_coord0_w)); | ||
| 80 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_TEXCOORD0_W); | ||
| 81 | |||
| 79 | glVertexAttribPointer(GLShader::ATTRIBUTE_NORMQUAT, 4, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, normquat)); | 82 | glVertexAttribPointer(GLShader::ATTRIBUTE_NORMQUAT, 4, GL_FLOAT, GL_FALSE, sizeof(HardwareVertex), (GLvoid*)offsetof(HardwareVertex, normquat)); |
| 80 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_NORMQUAT); | 83 | glEnableVertexAttribArray(GLShader::ATTRIBUTE_NORMQUAT); |
| 81 | 84 | ||
| @@ -319,6 +322,11 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { | |||
| 319 | SyncLogicOp(); | 322 | SyncLogicOp(); |
| 320 | break; | 323 | break; |
| 321 | 324 | ||
| 325 | // Texture 0 type | ||
| 326 | case PICA_REG_INDEX(texture0.type): | ||
| 327 | shader_dirty = true; | ||
| 328 | break; | ||
| 329 | |||
| 322 | // TEV stages | 330 | // TEV stages |
| 323 | case PICA_REG_INDEX(tev_stage0.color_source1): | 331 | case PICA_REG_INDEX(tev_stage0.color_source1): |
| 324 | case PICA_REG_INDEX(tev_stage0.color_modifier1): | 332 | case PICA_REG_INDEX(tev_stage0.color_modifier1): |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index b9315ed33..eed00011a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -61,6 +61,8 @@ union PicaShaderConfig { | |||
| 61 | state.alpha_test_func = regs.output_merger.alpha_test.enable ? | 61 | state.alpha_test_func = regs.output_merger.alpha_test.enable ? |
| 62 | regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always; | 62 | regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always; |
| 63 | 63 | ||
| 64 | state.texture0_type = regs.texture0.type; | ||
| 65 | |||
| 64 | // Copy relevant tev stages fields. | 66 | // Copy relevant tev stages fields. |
| 65 | // We don't sync const_color here because of the high variance, it is a | 67 | // We don't sync const_color here because of the high variance, it is a |
| 66 | // shader uniform instead. | 68 | // shader uniform instead. |
| @@ -170,6 +172,7 @@ union PicaShaderConfig { | |||
| 170 | struct State { | 172 | struct State { |
| 171 | 173 | ||
| 172 | Pica::Regs::CompareFunc alpha_test_func; | 174 | Pica::Regs::CompareFunc alpha_test_func; |
| 175 | Pica::Regs::TextureConfig::TextureType texture0_type; | ||
| 173 | std::array<TevStageConfigRaw, 6> tev_stages; | 176 | std::array<TevStageConfigRaw, 6> tev_stages; |
| 174 | u8 combiner_buffer_input; | 177 | u8 combiner_buffer_input; |
| 175 | 178 | ||
| @@ -281,6 +284,7 @@ private: | |||
| 281 | tex_coord1[1] = v.tc1.y.ToFloat32(); | 284 | tex_coord1[1] = v.tc1.y.ToFloat32(); |
| 282 | tex_coord2[0] = v.tc2.x.ToFloat32(); | 285 | tex_coord2[0] = v.tc2.x.ToFloat32(); |
| 283 | tex_coord2[1] = v.tc2.y.ToFloat32(); | 286 | tex_coord2[1] = v.tc2.y.ToFloat32(); |
| 287 | tex_coord0_w = v.tc0_w.ToFloat32(); | ||
| 284 | normquat[0] = v.quat.x.ToFloat32(); | 288 | normquat[0] = v.quat.x.ToFloat32(); |
| 285 | normquat[1] = v.quat.y.ToFloat32(); | 289 | normquat[1] = v.quat.y.ToFloat32(); |
| 286 | normquat[2] = v.quat.z.ToFloat32(); | 290 | normquat[2] = v.quat.z.ToFloat32(); |
| @@ -301,6 +305,7 @@ private: | |||
| 301 | GLfloat tex_coord0[2]; | 305 | GLfloat tex_coord0[2]; |
| 302 | GLfloat tex_coord1[2]; | 306 | GLfloat tex_coord1[2]; |
| 303 | GLfloat tex_coord2[2]; | 307 | GLfloat tex_coord2[2]; |
| 308 | GLfloat tex_coord0_w; | ||
| 304 | GLfloat normquat[4]; | 309 | GLfloat normquat[4]; |
| 305 | GLfloat view[3]; | 310 | GLfloat view[3]; |
| 306 | }; | 311 | }; |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 0c3153e8f..71d60e69c 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -32,8 +32,9 @@ static bool IsPassThroughTevStage(const TevStageConfig& stage) { | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | /// Writes the specified TEV stage source component(s) | 34 | /// Writes the specified TEV stage source component(s) |
| 35 | static void AppendSource(std::string& out, TevStageConfig::Source source, | 35 | static void AppendSource(std::string& out, const PicaShaderConfig& config, TevStageConfig::Source source, |
| 36 | const std::string& index_name) { | 36 | const std::string& index_name) { |
| 37 | const auto& state = config.state; | ||
| 37 | using Source = TevStageConfig::Source; | 38 | using Source = TevStageConfig::Source; |
| 38 | switch (source) { | 39 | switch (source) { |
| 39 | case Source::PrimaryColor: | 40 | case Source::PrimaryColor: |
| @@ -46,7 +47,20 @@ static void AppendSource(std::string& out, TevStageConfig::Source source, | |||
| 46 | out += "secondary_fragment_color"; | 47 | out += "secondary_fragment_color"; |
| 47 | break; | 48 | break; |
| 48 | case Source::Texture0: | 49 | case Source::Texture0: |
| 49 | out += "texture(tex[0], texcoord[0])"; | 50 | // Only unit 0 respects the texturing type (according to 3DBrew) |
| 51 | switch(state.texture0_type) { | ||
| 52 | case Pica::Regs::TextureConfig::Texture2D: | ||
| 53 | out += "texture(tex[0], texcoord[0])"; | ||
| 54 | break; | ||
| 55 | case Pica::Regs::TextureConfig::Projection2D: | ||
| 56 | out += "textureProj(tex[0], vec3(texcoord[0], texcoord0_w))"; | ||
| 57 | break; | ||
| 58 | default: | ||
| 59 | out += "texture(tex[0], texcoord[0])"; | ||
| 60 | LOG_CRITICAL(HW_GPU, "Unhandled texture type %x", static_cast<int>(state.texture0_type)); | ||
| 61 | UNIMPLEMENTED(); | ||
| 62 | break; | ||
| 63 | } | ||
| 50 | break; | 64 | break; |
| 51 | case Source::Texture1: | 65 | case Source::Texture1: |
| 52 | out += "texture(tex[1], texcoord[1])"; | 66 | out += "texture(tex[1], texcoord[1])"; |
| @@ -71,53 +85,53 @@ static void AppendSource(std::string& out, TevStageConfig::Source source, | |||
| 71 | } | 85 | } |
| 72 | 86 | ||
| 73 | /// Writes the color components to use for the specified TEV stage color modifier | 87 | /// Writes the color components to use for the specified TEV stage color modifier |
| 74 | static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier modifier, | 88 | static void AppendColorModifier(std::string& out, const PicaShaderConfig& config, TevStageConfig::ColorModifier modifier, |
| 75 | TevStageConfig::Source source, const std::string& index_name) { | 89 | TevStageConfig::Source source, const std::string& index_name) { |
| 76 | using ColorModifier = TevStageConfig::ColorModifier; | 90 | using ColorModifier = TevStageConfig::ColorModifier; |
| 77 | switch (modifier) { | 91 | switch (modifier) { |
| 78 | case ColorModifier::SourceColor: | 92 | case ColorModifier::SourceColor: |
| 79 | AppendSource(out, source, index_name); | 93 | AppendSource(out, config, source, index_name); |
| 80 | out += ".rgb"; | 94 | out += ".rgb"; |
| 81 | break; | 95 | break; |
| 82 | case ColorModifier::OneMinusSourceColor: | 96 | case ColorModifier::OneMinusSourceColor: |
| 83 | out += "vec3(1.0) - "; | 97 | out += "vec3(1.0) - "; |
| 84 | AppendSource(out, source, index_name); | 98 | AppendSource(out, config, source, index_name); |
| 85 | out += ".rgb"; | 99 | out += ".rgb"; |
| 86 | break; | 100 | break; |
| 87 | case ColorModifier::SourceAlpha: | 101 | case ColorModifier::SourceAlpha: |
| 88 | AppendSource(out, source, index_name); | 102 | AppendSource(out, config, source, index_name); |
| 89 | out += ".aaa"; | 103 | out += ".aaa"; |
| 90 | break; | 104 | break; |
| 91 | case ColorModifier::OneMinusSourceAlpha: | 105 | case ColorModifier::OneMinusSourceAlpha: |
| 92 | out += "vec3(1.0) - "; | 106 | out += "vec3(1.0) - "; |
| 93 | AppendSource(out, source, index_name); | 107 | AppendSource(out, config, source, index_name); |
| 94 | out += ".aaa"; | 108 | out += ".aaa"; |
| 95 | break; | 109 | break; |
| 96 | case ColorModifier::SourceRed: | 110 | case ColorModifier::SourceRed: |
| 97 | AppendSource(out, source, index_name); | 111 | AppendSource(out, config, source, index_name); |
| 98 | out += ".rrr"; | 112 | out += ".rrr"; |
| 99 | break; | 113 | break; |
| 100 | case ColorModifier::OneMinusSourceRed: | 114 | case ColorModifier::OneMinusSourceRed: |
| 101 | out += "vec3(1.0) - "; | 115 | out += "vec3(1.0) - "; |
| 102 | AppendSource(out, source, index_name); | 116 | AppendSource(out, config, source, index_name); |
| 103 | out += ".rrr"; | 117 | out += ".rrr"; |
| 104 | break; | 118 | break; |
| 105 | case ColorModifier::SourceGreen: | 119 | case ColorModifier::SourceGreen: |
| 106 | AppendSource(out, source, index_name); | 120 | AppendSource(out, config, source, index_name); |
| 107 | out += ".ggg"; | 121 | out += ".ggg"; |
| 108 | break; | 122 | break; |
| 109 | case ColorModifier::OneMinusSourceGreen: | 123 | case ColorModifier::OneMinusSourceGreen: |
| 110 | out += "vec3(1.0) - "; | 124 | out += "vec3(1.0) - "; |
| 111 | AppendSource(out, source, index_name); | 125 | AppendSource(out, config, source, index_name); |
| 112 | out += ".ggg"; | 126 | out += ".ggg"; |
| 113 | break; | 127 | break; |
| 114 | case ColorModifier::SourceBlue: | 128 | case ColorModifier::SourceBlue: |
| 115 | AppendSource(out, source, index_name); | 129 | AppendSource(out, config, source, index_name); |
| 116 | out += ".bbb"; | 130 | out += ".bbb"; |
| 117 | break; | 131 | break; |
| 118 | case ColorModifier::OneMinusSourceBlue: | 132 | case ColorModifier::OneMinusSourceBlue: |
| 119 | out += "vec3(1.0) - "; | 133 | out += "vec3(1.0) - "; |
| 120 | AppendSource(out, source, index_name); | 134 | AppendSource(out, config, source, index_name); |
| 121 | out += ".bbb"; | 135 | out += ".bbb"; |
| 122 | break; | 136 | break; |
| 123 | default: | 137 | default: |
| @@ -128,44 +142,44 @@ static void AppendColorModifier(std::string& out, TevStageConfig::ColorModifier | |||
| 128 | } | 142 | } |
| 129 | 143 | ||
| 130 | /// Writes the alpha component to use for the specified TEV stage alpha modifier | 144 | /// Writes the alpha component to use for the specified TEV stage alpha modifier |
| 131 | static void AppendAlphaModifier(std::string& out, TevStageConfig::AlphaModifier modifier, | 145 | static void AppendAlphaModifier(std::string& out, const PicaShaderConfig& config, TevStageConfig::AlphaModifier modifier, |
| 132 | TevStageConfig::Source source, const std::string& index_name) { | 146 | TevStageConfig::Source source, const std::string& index_name) { |
| 133 | using AlphaModifier = TevStageConfig::AlphaModifier; | 147 | using AlphaModifier = TevStageConfig::AlphaModifier; |
| 134 | switch (modifier) { | 148 | switch (modifier) { |
| 135 | case AlphaModifier::SourceAlpha: | 149 | case AlphaModifier::SourceAlpha: |
| 136 | AppendSource(out, source, index_name); | 150 | AppendSource(out, config, source, index_name); |
| 137 | out += ".a"; | 151 | out += ".a"; |
| 138 | break; | 152 | break; |
| 139 | case AlphaModifier::OneMinusSourceAlpha: | 153 | case AlphaModifier::OneMinusSourceAlpha: |
| 140 | out += "1.0 - "; | 154 | out += "1.0 - "; |
| 141 | AppendSource(out, source, index_name); | 155 | AppendSource(out, config, source, index_name); |
| 142 | out += ".a"; | 156 | out += ".a"; |
| 143 | break; | 157 | break; |
| 144 | case AlphaModifier::SourceRed: | 158 | case AlphaModifier::SourceRed: |
| 145 | AppendSource(out, source, index_name); | 159 | AppendSource(out, config, source, index_name); |
| 146 | out += ".r"; | 160 | out += ".r"; |
| 147 | break; | 161 | break; |
| 148 | case AlphaModifier::OneMinusSourceRed: | 162 | case AlphaModifier::OneMinusSourceRed: |
| 149 | out += "1.0 - "; | 163 | out += "1.0 - "; |
| 150 | AppendSource(out, source, index_name); | 164 | AppendSource(out, config, source, index_name); |
| 151 | out += ".r"; | 165 | out += ".r"; |
| 152 | break; | 166 | break; |
| 153 | case AlphaModifier::SourceGreen: | 167 | case AlphaModifier::SourceGreen: |
| 154 | AppendSource(out, source, index_name); | 168 | AppendSource(out, config, source, index_name); |
| 155 | out += ".g"; | 169 | out += ".g"; |
| 156 | break; | 170 | break; |
| 157 | case AlphaModifier::OneMinusSourceGreen: | 171 | case AlphaModifier::OneMinusSourceGreen: |
| 158 | out += "1.0 - "; | 172 | out += "1.0 - "; |
| 159 | AppendSource(out, source, index_name); | 173 | AppendSource(out, config, source, index_name); |
| 160 | out += ".g"; | 174 | out += ".g"; |
| 161 | break; | 175 | break; |
| 162 | case AlphaModifier::SourceBlue: | 176 | case AlphaModifier::SourceBlue: |
| 163 | AppendSource(out, source, index_name); | 177 | AppendSource(out, config, source, index_name); |
| 164 | out += ".b"; | 178 | out += ".b"; |
| 165 | break; | 179 | break; |
| 166 | case AlphaModifier::OneMinusSourceBlue: | 180 | case AlphaModifier::OneMinusSourceBlue: |
| 167 | out += "1.0 - "; | 181 | out += "1.0 - "; |
| 168 | AppendSource(out, source, index_name); | 182 | AppendSource(out, config, source, index_name); |
| 169 | out += ".b"; | 183 | out += ".b"; |
| 170 | break; | 184 | break; |
| 171 | default: | 185 | default: |
| @@ -292,11 +306,11 @@ static void WriteTevStage(std::string& out, const PicaShaderConfig& config, unsi | |||
| 292 | std::string index_name = std::to_string(index); | 306 | std::string index_name = std::to_string(index); |
| 293 | 307 | ||
| 294 | out += "vec3 color_results_" + index_name + "[3] = vec3[3]("; | 308 | out += "vec3 color_results_" + index_name + "[3] = vec3[3]("; |
| 295 | AppendColorModifier(out, stage.color_modifier1, stage.color_source1, index_name); | 309 | AppendColorModifier(out, config, stage.color_modifier1, stage.color_source1, index_name); |
| 296 | out += ", "; | 310 | out += ", "; |
| 297 | AppendColorModifier(out, stage.color_modifier2, stage.color_source2, index_name); | 311 | AppendColorModifier(out, config, stage.color_modifier2, stage.color_source2, index_name); |
| 298 | out += ", "; | 312 | out += ", "; |
| 299 | AppendColorModifier(out, stage.color_modifier3, stage.color_source3, index_name); | 313 | AppendColorModifier(out, config, stage.color_modifier3, stage.color_source3, index_name); |
| 300 | out += ");\n"; | 314 | out += ");\n"; |
| 301 | 315 | ||
| 302 | out += "vec3 color_output_" + index_name + " = "; | 316 | out += "vec3 color_output_" + index_name + " = "; |
| @@ -304,11 +318,11 @@ static void WriteTevStage(std::string& out, const PicaShaderConfig& config, unsi | |||
| 304 | out += ";\n"; | 318 | out += ";\n"; |
| 305 | 319 | ||
| 306 | out += "float alpha_results_" + index_name + "[3] = float[3]("; | 320 | out += "float alpha_results_" + index_name + "[3] = float[3]("; |
| 307 | AppendAlphaModifier(out, stage.alpha_modifier1, stage.alpha_source1, index_name); | 321 | AppendAlphaModifier(out, config, stage.alpha_modifier1, stage.alpha_source1, index_name); |
| 308 | out += ", "; | 322 | out += ", "; |
| 309 | AppendAlphaModifier(out, stage.alpha_modifier2, stage.alpha_source2, index_name); | 323 | AppendAlphaModifier(out, config, stage.alpha_modifier2, stage.alpha_source2, index_name); |
| 310 | out += ", "; | 324 | out += ", "; |
| 311 | AppendAlphaModifier(out, stage.alpha_modifier3, stage.alpha_source3, index_name); | 325 | AppendAlphaModifier(out, config, stage.alpha_modifier3, stage.alpha_source3, index_name); |
| 312 | out += ");\n"; | 326 | out += ");\n"; |
| 313 | 327 | ||
| 314 | out += "float alpha_output_" + index_name + " = "; | 328 | out += "float alpha_output_" + index_name + " = "; |
| @@ -523,6 +537,7 @@ std::string GenerateFragmentShader(const PicaShaderConfig& config) { | |||
| 523 | 537 | ||
| 524 | in vec4 primary_color; | 538 | in vec4 primary_color; |
| 525 | in vec2 texcoord[3]; | 539 | in vec2 texcoord[3]; |
| 540 | in float texcoord0_w; | ||
| 526 | in vec4 normquat; | 541 | in vec4 normquat; |
| 527 | in vec3 view; | 542 | in vec3 view; |
| 528 | 543 | ||
| @@ -598,17 +613,19 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 598 | std::string GenerateVertexShader() { | 613 | std::string GenerateVertexShader() { |
| 599 | std::string out = "#version 330 core\n"; | 614 | std::string out = "#version 330 core\n"; |
| 600 | 615 | ||
| 601 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_POSITION) + ") in vec4 vert_position;\n"; | 616 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_POSITION) + ") in vec4 vert_position;\n"; |
| 602 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_COLOR) + ") in vec4 vert_color;\n"; | 617 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_COLOR) + ") in vec4 vert_color;\n"; |
| 603 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD0) + ") in vec2 vert_texcoord0;\n"; | 618 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD0) + ") in vec2 vert_texcoord0;\n"; |
| 604 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD1) + ") in vec2 vert_texcoord1;\n"; | 619 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD1) + ") in vec2 vert_texcoord1;\n"; |
| 605 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD2) + ") in vec2 vert_texcoord2;\n"; | 620 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD2) + ") in vec2 vert_texcoord2;\n"; |
| 606 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_NORMQUAT) + ") in vec4 vert_normquat;\n"; | 621 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_TEXCOORD0_W) + ") in float vert_texcoord0_w;\n"; |
| 607 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_VIEW) + ") in vec3 vert_view;\n"; | 622 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_NORMQUAT) + ") in vec4 vert_normquat;\n"; |
| 623 | out += "layout(location = " + std::to_string((int)ATTRIBUTE_VIEW) + ") in vec3 vert_view;\n"; | ||
| 608 | 624 | ||
| 609 | out += R"( | 625 | out += R"( |
| 610 | out vec4 primary_color; | 626 | out vec4 primary_color; |
| 611 | out vec2 texcoord[3]; | 627 | out vec2 texcoord[3]; |
| 628 | out float texcoord0_w; | ||
| 612 | out vec4 normquat; | 629 | out vec4 normquat; |
| 613 | out vec3 view; | 630 | out vec3 view; |
| 614 | 631 | ||
| @@ -617,6 +634,7 @@ void main() { | |||
| 617 | texcoord[0] = vert_texcoord0; | 634 | texcoord[0] = vert_texcoord0; |
| 618 | texcoord[1] = vert_texcoord1; | 635 | texcoord[1] = vert_texcoord1; |
| 619 | texcoord[2] = vert_texcoord2; | 636 | texcoord[2] = vert_texcoord2; |
| 637 | texcoord0_w = vert_texcoord0_w; | ||
| 620 | normquat = vert_normquat; | 638 | normquat = vert_normquat; |
| 621 | view = vert_view; | 639 | view = vert_view; |
| 622 | gl_Position = vec4(vert_position.x, vert_position.y, -vert_position.z, vert_position.w); | 640 | gl_Position = vec4(vert_position.x, vert_position.y, -vert_position.z, vert_position.w); |
diff --git a/src/video_core/renderer_opengl/gl_shader_util.h b/src/video_core/renderer_opengl/gl_shader_util.h index 097242f6f..f59912f79 100644 --- a/src/video_core/renderer_opengl/gl_shader_util.h +++ b/src/video_core/renderer_opengl/gl_shader_util.h | |||
| @@ -14,6 +14,7 @@ enum Attributes { | |||
| 14 | ATTRIBUTE_TEXCOORD0, | 14 | ATTRIBUTE_TEXCOORD0, |
| 15 | ATTRIBUTE_TEXCOORD1, | 15 | ATTRIBUTE_TEXCOORD1, |
| 16 | ATTRIBUTE_TEXCOORD2, | 16 | ATTRIBUTE_TEXCOORD2, |
| 17 | ATTRIBUTE_TEXCOORD0_W, | ||
| 17 | ATTRIBUTE_NORMQUAT, | 18 | ATTRIBUTE_NORMQUAT, |
| 18 | ATTRIBUTE_VIEW, | 19 | ATTRIBUTE_VIEW, |
| 19 | }; | 20 | }; |
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index cfbb7f2ee..7f417675a 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h | |||
| @@ -43,7 +43,8 @@ struct OutputVertex { | |||
| 43 | Math::Vec4<float24> color; | 43 | Math::Vec4<float24> color; |
| 44 | Math::Vec2<float24> tc0; | 44 | Math::Vec2<float24> tc0; |
| 45 | Math::Vec2<float24> tc1; | 45 | Math::Vec2<float24> tc1; |
| 46 | INSERT_PADDING_WORDS(2); | 46 | float24 tc0_w; |
| 47 | INSERT_PADDING_WORDS(1); | ||
| 47 | Math::Vec3<float24> view; | 48 | Math::Vec3<float24> view; |
| 48 | INSERT_PADDING_WORDS(1); | 49 | INSERT_PADDING_WORDS(1); |
| 49 | Math::Vec2<float24> tc2; | 50 | Math::Vec2<float24> tc2; |