diff options
| author | 2017-05-05 21:33:32 -0700 | |
|---|---|---|
| committer | 2017-05-05 21:33:32 -0700 | |
| commit | 2a01a03375401f4110a3a80de8ebf9bd48e46bc7 (patch) | |
| tree | 91c3dd5e60e0d977406b8e39adc1732d09a9d1ce /src | |
| parent | Create a random console_unique_id (#2668) (diff) | |
| parent | pica: shader_dirty if texture2 coord changed (diff) | |
| download | yuzu-2a01a03375401f4110a3a80de8ebf9bd48e46bc7.tar.gz yuzu-2a01a03375401f4110a3a80de8ebf9bd48e46bc7.tar.xz yuzu-2a01a03375401f4110a3a80de8ebf9bd48e46bc7.zip | |
Merge pull request #2686 from wwylele/tex-coord-reg
pica: use correct coordinates for texture 2
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/regs.h | 2 | ||||
| -rw-r--r-- | src/video_core/regs_texturing.h | 12 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 17 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.h | 1 | ||||
| -rw-r--r-- | src/video_core/swrasterizer/rasterizer.cpp | 6 |
6 files changed, 32 insertions, 10 deletions
diff --git a/src/video_core/regs.h b/src/video_core/regs.h index 86826088b..1776dad89 100644 --- a/src/video_core/regs.h +++ b/src/video_core/regs.h | |||
| @@ -93,7 +93,7 @@ ASSERT_REG_POSITION(rasterizer.viewport_corner, 0x68); | |||
| 93 | ASSERT_REG_POSITION(rasterizer.depthmap_enable, 0x6D); | 93 | ASSERT_REG_POSITION(rasterizer.depthmap_enable, 0x6D); |
| 94 | 94 | ||
| 95 | ASSERT_REG_POSITION(texturing, 0x80); | 95 | ASSERT_REG_POSITION(texturing, 0x80); |
| 96 | ASSERT_REG_POSITION(texturing.texture0_enable, 0x80); | 96 | ASSERT_REG_POSITION(texturing.main_config, 0x80); |
| 97 | ASSERT_REG_POSITION(texturing.texture0, 0x81); | 97 | ASSERT_REG_POSITION(texturing.texture0, 0x81); |
| 98 | ASSERT_REG_POSITION(texturing.texture0_format, 0x8e); | 98 | ASSERT_REG_POSITION(texturing.texture0_format, 0x8e); |
| 99 | ASSERT_REG_POSITION(texturing.fragment_lighting_enable, 0x8f); | 99 | ASSERT_REG_POSITION(texturing.fragment_lighting_enable, 0x8f); |
diff --git a/src/video_core/regs_texturing.h b/src/video_core/regs_texturing.h index 0b62da145..8a7c6efe4 100644 --- a/src/video_core/regs_texturing.h +++ b/src/video_core/regs_texturing.h | |||
| @@ -122,7 +122,11 @@ struct TexturingRegs { | |||
| 122 | BitField<0, 1, u32> texture0_enable; | 122 | BitField<0, 1, u32> texture0_enable; |
| 123 | BitField<1, 1, u32> texture1_enable; | 123 | BitField<1, 1, u32> texture1_enable; |
| 124 | BitField<2, 1, u32> texture2_enable; | 124 | BitField<2, 1, u32> texture2_enable; |
| 125 | }; | 125 | BitField<8, 2, u32> texture3_coordinates; // TODO: unimplemented |
| 126 | BitField<10, 1, u32> texture3_enable; // TODO: unimplemented | ||
| 127 | BitField<13, 1, u32> texture2_use_coord1; | ||
| 128 | BitField<16, 1, u32> clear_texture_cache; // TODO: unimplemented | ||
| 129 | } main_config; | ||
| 126 | TextureConfig texture0; | 130 | TextureConfig texture0; |
| 127 | INSERT_PADDING_WORDS(0x8); | 131 | INSERT_PADDING_WORDS(0x8); |
| 128 | BitField<0, 4, TextureFormat> texture0_format; | 132 | BitField<0, 4, TextureFormat> texture0_format; |
| @@ -142,9 +146,9 @@ struct TexturingRegs { | |||
| 142 | }; | 146 | }; |
| 143 | const std::array<FullTextureConfig, 3> GetTextures() const { | 147 | const std::array<FullTextureConfig, 3> GetTextures() const { |
| 144 | return {{ | 148 | return {{ |
| 145 | {texture0_enable.ToBool(), texture0, texture0_format}, | 149 | {main_config.texture0_enable.ToBool(), texture0, texture0_format}, |
| 146 | {texture1_enable.ToBool(), texture1, texture1_format}, | 150 | {main_config.texture1_enable.ToBool(), texture1, texture1_format}, |
| 147 | {texture2_enable.ToBool(), texture2, texture2_format}, | 151 | {main_config.texture2_enable.ToBool(), texture2, texture2_format}, |
| 148 | }}; | 152 | }}; |
| 149 | } | 153 | } |
| 150 | 154 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index a47307099..12ac9bbd9 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -402,6 +402,10 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { | |||
| 402 | SyncLogicOp(); | 402 | SyncLogicOp(); |
| 403 | break; | 403 | break; |
| 404 | 404 | ||
| 405 | case PICA_REG_INDEX(texturing.main_config): | ||
| 406 | shader_dirty = true; | ||
| 407 | break; | ||
| 408 | |||
| 405 | // Texture 0 type | 409 | // Texture 0 type |
| 406 | case PICA_REG_INDEX(texturing.texture0.type): | 410 | case PICA_REG_INDEX(texturing.texture0.type): |
| 407 | shader_dirty = true; | 411 | shader_dirty = true; |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 0f889b172..7b44dade8 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -40,6 +40,8 @@ PicaShaderConfig PicaShaderConfig::BuildFromRegs(const Pica::Regs& regs) { | |||
| 40 | 40 | ||
| 41 | state.texture0_type = regs.texturing.texture0.type; | 41 | state.texture0_type = regs.texturing.texture0.type; |
| 42 | 42 | ||
| 43 | state.texture2_use_coord1 = regs.texturing.main_config.texture2_use_coord1 != 0; | ||
| 44 | |||
| 43 | // Copy relevant tev stages fields. | 45 | // Copy relevant tev stages fields. |
| 44 | // We don't sync const_color here because of the high variance, it is a | 46 | // We don't sync const_color here because of the high variance, it is a |
| 45 | // shader uniform instead. | 47 | // shader uniform instead. |
| @@ -126,6 +128,15 @@ static bool IsPassThroughTevStage(const TevStageConfig& stage) { | |||
| 126 | stage.GetColorMultiplier() == 1 && stage.GetAlphaMultiplier() == 1); | 128 | stage.GetColorMultiplier() == 1 && stage.GetAlphaMultiplier() == 1); |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 131 | static std::string TexCoord(const PicaShaderConfig& config, int texture_unit) { | ||
| 132 | if (texture_unit == 2 && config.state.texture2_use_coord1) { | ||
| 133 | return "texcoord[1]"; | ||
| 134 | } | ||
| 135 | // TODO: if texture unit 3 (procedural texture) implementation also uses this function, | ||
| 136 | // config.state.texture3_coordinates should be repected here. | ||
| 137 | return "texcoord[" + std::to_string(texture_unit) + "]"; | ||
| 138 | } | ||
| 139 | |||
| 129 | /// Writes the specified TEV stage source component(s) | 140 | /// Writes the specified TEV stage source component(s) |
| 130 | static void AppendSource(std::string& out, const PicaShaderConfig& config, | 141 | static void AppendSource(std::string& out, const PicaShaderConfig& config, |
| 131 | TevStageConfig::Source source, const std::string& index_name) { | 142 | TevStageConfig::Source source, const std::string& index_name) { |
| @@ -162,7 +173,7 @@ static void AppendSource(std::string& out, const PicaShaderConfig& config, | |||
| 162 | out += "texture(tex[1], texcoord[1])"; | 173 | out += "texture(tex[1], texcoord[1])"; |
| 163 | break; | 174 | break; |
| 164 | case Source::Texture2: | 175 | case Source::Texture2: |
| 165 | out += "texture(tex[2], texcoord[2])"; | 176 | out += "texture(tex[2], " + TexCoord(config, 2) + ")"; |
| 166 | break; | 177 | break; |
| 167 | case Source::PreviousBuffer: | 178 | case Source::PreviousBuffer: |
| 168 | out += "combiner_buffer"; | 179 | out += "combiner_buffer"; |
| @@ -473,8 +484,8 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) { | |||
| 473 | // Bump mapping is enabled using a normal map, read perturbation vector from the selected | 484 | // Bump mapping is enabled using a normal map, read perturbation vector from the selected |
| 474 | // texture | 485 | // texture |
| 475 | std::string bump_selector = std::to_string(lighting.bump_selector); | 486 | std::string bump_selector = std::to_string(lighting.bump_selector); |
| 476 | out += "vec3 surface_normal = 2.0 * texture(tex[" + bump_selector + "], texcoord[" + | 487 | out += "vec3 surface_normal = 2.0 * texture(tex[" + bump_selector + "], " + |
| 477 | bump_selector + "]).rgb - 1.0;\n"; | 488 | TexCoord(config, lighting.bump_selector) + ").rgb - 1.0;\n"; |
| 478 | 489 | ||
| 479 | // Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher | 490 | // Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher |
| 480 | // precision result | 491 | // precision result |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 921d976a1..3fb046b76 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h | |||
| @@ -79,6 +79,7 @@ union PicaShaderConfig { | |||
| 79 | Pica::FramebufferRegs::CompareFunc alpha_test_func; | 79 | Pica::FramebufferRegs::CompareFunc alpha_test_func; |
| 80 | Pica::RasterizerRegs::ScissorMode scissor_test_mode; | 80 | Pica::RasterizerRegs::ScissorMode scissor_test_mode; |
| 81 | Pica::TexturingRegs::TextureConfig::TextureType texture0_type; | 81 | Pica::TexturingRegs::TextureConfig::TextureType texture0_type; |
| 82 | bool texture2_use_coord1; | ||
| 82 | std::array<TevStageConfigRaw, 6> tev_stages; | 83 | std::array<TevStageConfigRaw, 6> tev_stages; |
| 83 | u8 combiner_buffer_input; | 84 | u8 combiner_buffer_input; |
| 84 | 85 | ||
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index cb1b90a81..20addf0bd 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp | |||
| @@ -276,8 +276,10 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve | |||
| 276 | 276 | ||
| 277 | DEBUG_ASSERT(0 != texture.config.address); | 277 | DEBUG_ASSERT(0 != texture.config.address); |
| 278 | 278 | ||
| 279 | float24 u = uv[i].u(); | 279 | int coordinate_i = |
| 280 | float24 v = uv[i].v(); | 280 | (i == 2 && regs.texturing.main_config.texture2_use_coord1) ? 1 : i; |
| 281 | float24 u = uv[coordinate_i].u(); | ||
| 282 | float24 v = uv[coordinate_i].v(); | ||
| 281 | 283 | ||
| 282 | // Only unit 0 respects the texturing type (according to 3DBrew) | 284 | // Only unit 0 respects the texturing type (according to 3DBrew) |
| 283 | // TODO: Refactor so cubemaps and shadowmaps can be handled | 285 | // TODO: Refactor so cubemaps and shadowmaps can be handled |