diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 7 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 1fcd13f04..14d82a7bc 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -738,7 +738,7 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, Shader& shader, | |||
| 738 | } | 738 | } |
| 739 | 739 | ||
| 740 | texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); | 740 | texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); |
| 741 | Surface surface = res_cache.GetTextureSurface(texture); | 741 | Surface surface = res_cache.GetTextureSurface(texture, entry); |
| 742 | if (surface != nullptr) { | 742 | if (surface != nullptr) { |
| 743 | state.texture_units[current_bindpoint].texture = surface->Texture().handle; | 743 | state.texture_units[current_bindpoint].texture = surface->Texture().handle; |
| 744 | state.texture_units[current_bindpoint].target = surface->Target(); | 744 | state.texture_units[current_bindpoint].target = surface->Target(); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index b11206925..00351d743 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -41,7 +41,7 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) { | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | /*static*/ SurfaceParams SurfaceParams::CreateForTexture( | 43 | /*static*/ SurfaceParams SurfaceParams::CreateForTexture( |
| 44 | const Tegra::Texture::FullTextureInfo& config) { | 44 | const Tegra::Texture::FullTextureInfo& config, const GLShader::SamplerEntry& entry) { |
| 45 | SurfaceParams params{}; | 45 | SurfaceParams params{}; |
| 46 | params.addr = TryGetCpuAddr(config.tic.Address()); | 46 | params.addr = TryGetCpuAddr(config.tic.Address()); |
| 47 | params.is_tiled = config.tic.IsTiled(); | 47 | params.is_tiled = config.tic.IsTiled(); |
| @@ -61,8 +61,19 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) { | |||
| 61 | params.depth = 1; | 61 | params.depth = 1; |
| 62 | break; | 62 | break; |
| 63 | case SurfaceTarget::Texture3D: | 63 | case SurfaceTarget::Texture3D: |
| 64 | params.depth = config.tic.Depth(); | ||
| 65 | break; | ||
| 64 | case SurfaceTarget::Texture2DArray: | 66 | case SurfaceTarget::Texture2DArray: |
| 65 | params.depth = config.tic.Depth(); | 67 | params.depth = config.tic.Depth(); |
| 68 | if (!entry.IsArray()) { | ||
| 69 | // TODO(bunnei): We have seen games re-use a Texture2D as Texture2DArray with depth of | ||
| 70 | // one, but sample the texture in the shader as if it were not an array texture. This | ||
| 71 | // probably is valid on hardware, but we still need to write a test to confirm this. In | ||
| 72 | // emulation, the workaround here is to continue to treat this as a Texture2D. An | ||
| 73 | // example game that does this is Super Mario Odyssey (in Cloud Kingdom). | ||
| 74 | ASSERT(params.depth == 1); | ||
| 75 | params.target = SurfaceTarget::Texture2D; | ||
| 76 | } | ||
| 66 | break; | 77 | break; |
| 67 | default: | 78 | default: |
| 68 | LOG_CRITICAL(HW_GPU, "Unknown depth for target={}", static_cast<u32>(params.target)); | 79 | LOG_CRITICAL(HW_GPU, "Unknown depth for target={}", static_cast<u32>(params.target)); |
| @@ -726,8 +737,9 @@ RasterizerCacheOpenGL::RasterizerCacheOpenGL() { | |||
| 726 | copy_pbo.Create(); | 737 | copy_pbo.Create(); |
| 727 | } | 738 | } |
| 728 | 739 | ||
| 729 | Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextureInfo& config) { | 740 | Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextureInfo& config, |
| 730 | return GetSurface(SurfaceParams::CreateForTexture(config)); | 741 | const GLShader::SamplerEntry& entry) { |
| 742 | return GetSurface(SurfaceParams::CreateForTexture(config, entry)); | ||
| 731 | } | 743 | } |
| 732 | 744 | ||
| 733 | Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) { | 745 | Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 9df909d01..6474d9129 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "video_core/engines/maxwell_3d.h" | 15 | #include "video_core/engines/maxwell_3d.h" |
| 16 | #include "video_core/rasterizer_cache.h" | 16 | #include "video_core/rasterizer_cache.h" |
| 17 | #include "video_core/renderer_opengl/gl_resource_manager.h" | 17 | #include "video_core/renderer_opengl/gl_resource_manager.h" |
| 18 | #include "video_core/renderer_opengl/gl_shader_gen.h" | ||
| 18 | #include "video_core/textures/texture.h" | 19 | #include "video_core/textures/texture.h" |
| 19 | 20 | ||
| 20 | namespace OpenGL { | 21 | namespace OpenGL { |
| @@ -704,7 +705,8 @@ struct SurfaceParams { | |||
| 704 | } | 705 | } |
| 705 | 706 | ||
| 706 | /// Creates SurfaceParams from a texture configuration | 707 | /// Creates SurfaceParams from a texture configuration |
| 707 | static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config); | 708 | static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, |
| 709 | const GLShader::SamplerEntry& entry); | ||
| 708 | 710 | ||
| 709 | /// Creates SurfaceParams from a framebuffer configuration | 711 | /// Creates SurfaceParams from a framebuffer configuration |
| 710 | static SurfaceParams CreateForFramebuffer(std::size_t index); | 712 | static SurfaceParams CreateForFramebuffer(std::size_t index); |
| @@ -806,7 +808,8 @@ public: | |||
| 806 | RasterizerCacheOpenGL(); | 808 | RasterizerCacheOpenGL(); |
| 807 | 809 | ||
| 808 | /// Get a surface based on the texture configuration | 810 | /// Get a surface based on the texture configuration |
| 809 | Surface GetTextureSurface(const Tegra::Texture::FullTextureInfo& config); | 811 | Surface GetTextureSurface(const Tegra::Texture::FullTextureInfo& config, |
| 812 | const GLShader::SamplerEntry& entry); | ||
| 810 | 813 | ||
| 811 | /// Get the depth surface based on the framebuffer configuration | 814 | /// Get the depth surface based on the framebuffer configuration |
| 812 | Surface GetDepthBufferSurface(bool preserve_contents); | 815 | Surface GetDepthBufferSurface(bool preserve_contents); |