diff options
| author | 2019-07-11 21:59:59 -0300 | |
|---|---|---|
| committer | 2019-09-05 20:35:51 -0300 | |
| commit | 2424eefad20b018bed72a0427cdeeabb08bea7b2 (patch) | |
| tree | 653458a597ab5f7a5b2594a4d5814a83907b0292 /src | |
| parent | kepler_compute: Implement texture queries (diff) | |
| download | yuzu-2424eefad20b018bed72a0427cdeeabb08bea7b2.tar.gz yuzu-2424eefad20b018bed72a0427cdeeabb08bea7b2.tar.xz yuzu-2424eefad20b018bed72a0427cdeeabb08bea7b2.zip | |
texture_cache: Pass TIC to texture cache
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_params.cpp | 37 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_params.h | 5 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 8 |
4 files changed, 25 insertions, 27 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 5375ab9e0..8a59b86e3 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -1022,7 +1022,7 @@ bool RasterizerOpenGL::SetupTexture(const Shader& shader, u32 binding, | |||
| 1022 | auto& unit{state.texture_units[binding]}; | 1022 | auto& unit{state.texture_units[binding]}; |
| 1023 | unit.sampler = sampler_cache.GetSampler(texture.tsc); | 1023 | unit.sampler = sampler_cache.GetSampler(texture.tsc); |
| 1024 | 1024 | ||
| 1025 | const auto view = texture_cache.GetTextureSurface(texture, entry); | 1025 | const auto view = texture_cache.GetImageSurface(texture.tic, entry); |
| 1026 | if (!view) { | 1026 | if (!view) { |
| 1027 | // Can occur when texture addr is null or its memory is unmapped/invalid | 1027 | // Can occur when texture addr is null or its memory is unmapped/invalid |
| 1028 | unit.texture = 0; | 1028 | unit.texture = 0; |
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp index fd5472451..2f8bd399c 100644 --- a/src/video_core/texture_cache/surface_params.cpp +++ b/src/video_core/texture_cache/surface_params.cpp | |||
| @@ -61,18 +61,17 @@ constexpr u32 GetMipmapSize(bool uncompressed, u32 mip_size, u32 tile) { | |||
| 61 | } | 61 | } |
| 62 | } // Anonymous namespace | 62 | } // Anonymous namespace |
| 63 | 63 | ||
| 64 | SurfaceParams SurfaceParams::CreateForTexture(Core::System& system, | 64 | SurfaceParams SurfaceParams::CreateForImage(const Tegra::Texture::TICEntry& tic, |
| 65 | const Tegra::Texture::FullTextureInfo& config, | 65 | const VideoCommon::Shader::Sampler& entry) { |
| 66 | const VideoCommon::Shader::Sampler& entry) { | ||
| 67 | SurfaceParams params; | 66 | SurfaceParams params; |
| 68 | params.is_tiled = config.tic.IsTiled(); | 67 | params.is_tiled = tic.IsTiled(); |
| 69 | params.srgb_conversion = config.tic.IsSrgbConversionEnabled(); | 68 | params.srgb_conversion = tic.IsSrgbConversionEnabled(); |
| 70 | params.block_width = params.is_tiled ? config.tic.BlockWidth() : 0, | 69 | params.block_width = params.is_tiled ? tic.BlockWidth() : 0, |
| 71 | params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0, | 70 | params.block_height = params.is_tiled ? tic.BlockHeight() : 0, |
| 72 | params.block_depth = params.is_tiled ? config.tic.BlockDepth() : 0, | 71 | params.block_depth = params.is_tiled ? tic.BlockDepth() : 0, |
| 73 | params.tile_width_spacing = params.is_tiled ? (1 << config.tic.tile_width_spacing.Value()) : 1; | 72 | params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1; |
| 74 | params.pixel_format = PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value(), | 73 | params.pixel_format = |
| 75 | params.srgb_conversion); | 74 | PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion); |
| 76 | params.type = GetFormatType(params.pixel_format); | 75 | params.type = GetFormatType(params.pixel_format); |
| 77 | if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) { | 76 | if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) { |
| 78 | switch (params.pixel_format) { | 77 | switch (params.pixel_format) { |
| @@ -92,25 +91,25 @@ SurfaceParams SurfaceParams::CreateForTexture(Core::System& system, | |||
| 92 | } | 91 | } |
| 93 | params.type = GetFormatType(params.pixel_format); | 92 | params.type = GetFormatType(params.pixel_format); |
| 94 | } | 93 | } |
| 95 | params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value()); | 94 | params.component_type = ComponentTypeFromTexture(tic.r_type.Value()); |
| 96 | params.type = GetFormatType(params.pixel_format); | 95 | params.type = GetFormatType(params.pixel_format); |
| 97 | // TODO: on 1DBuffer we should use the tic info. | 96 | // TODO: on 1DBuffer we should use the tic info. |
| 98 | if (!config.tic.IsBuffer()) { | 97 | if (!tic.IsBuffer()) { |
| 99 | params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray()); | 98 | params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray()); |
| 100 | params.width = config.tic.Width(); | 99 | params.width = tic.Width(); |
| 101 | params.height = config.tic.Height(); | 100 | params.height = tic.Height(); |
| 102 | params.depth = config.tic.Depth(); | 101 | params.depth = tic.Depth(); |
| 103 | params.pitch = params.is_tiled ? 0 : config.tic.Pitch(); | 102 | params.pitch = params.is_tiled ? 0 : tic.Pitch(); |
| 104 | if (params.target == SurfaceTarget::TextureCubemap || | 103 | if (params.target == SurfaceTarget::TextureCubemap || |
| 105 | params.target == SurfaceTarget::TextureCubeArray) { | 104 | params.target == SurfaceTarget::TextureCubeArray) { |
| 106 | params.depth *= 6; | 105 | params.depth *= 6; |
| 107 | } | 106 | } |
| 108 | params.num_levels = config.tic.max_mip_level + 1; | 107 | params.num_levels = tic.max_mip_level + 1; |
| 109 | params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap()); | 108 | params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap()); |
| 110 | params.is_layered = params.IsLayered(); | 109 | params.is_layered = params.IsLayered(); |
| 111 | } else { | 110 | } else { |
| 112 | params.target = SurfaceTarget::TextureBuffer; | 111 | params.target = SurfaceTarget::TextureBuffer; |
| 113 | params.width = config.tic.Width(); | 112 | params.width = tic.Width(); |
| 114 | params.pitch = params.width * params.GetBytesPerPixel(); | 113 | params.pitch = params.width * params.GetBytesPerPixel(); |
| 115 | params.height = 1; | 114 | params.height = 1; |
| 116 | params.depth = 1; | 115 | params.depth = 1; |
diff --git a/src/video_core/texture_cache/surface_params.h b/src/video_core/texture_cache/surface_params.h index e7ef66ee2..ee2efa594 100644 --- a/src/video_core/texture_cache/surface_params.h +++ b/src/video_core/texture_cache/surface_params.h | |||
| @@ -23,9 +23,8 @@ using VideoCore::Surface::SurfaceCompression; | |||
| 23 | class SurfaceParams { | 23 | class SurfaceParams { |
| 24 | public: | 24 | public: |
| 25 | /// Creates SurfaceCachedParams from a texture configuration. | 25 | /// Creates SurfaceCachedParams from a texture configuration. |
| 26 | static SurfaceParams CreateForTexture(Core::System& system, | 26 | static SurfaceParams CreateForImage(const Tegra::Texture::TICEntry& tic, |
| 27 | const Tegra::Texture::FullTextureInfo& config, | 27 | const VideoCommon::Shader::Sampler& entry); |
| 28 | const VideoCommon::Shader::Sampler& entry); | ||
| 29 | 28 | ||
| 30 | /// Creates SurfaceCachedParams for a depth buffer configuration. | 29 | /// Creates SurfaceCachedParams for a depth buffer configuration. |
| 31 | static SurfaceParams CreateForDepthBuffer( | 30 | static SurfaceParams CreateForDepthBuffer( |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 2ec0203d1..623cce068 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -89,14 +89,14 @@ public: | |||
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | TView GetTextureSurface(const Tegra::Texture::FullTextureInfo& config, | 92 | TView GetImageSurface(const Tegra::Texture::TICEntry& tic, |
| 93 | const VideoCommon::Shader::Sampler& entry) { | 93 | const VideoCommon::Shader::Sampler& entry) { |
| 94 | std::lock_guard lock{mutex}; | 94 | std::lock_guard lock{mutex}; |
| 95 | const auto gpu_addr{config.tic.Address()}; | 95 | const auto gpu_addr{tic.Address()}; |
| 96 | if (!gpu_addr) { | 96 | if (!gpu_addr) { |
| 97 | return {}; | 97 | return {}; |
| 98 | } | 98 | } |
| 99 | const auto params{SurfaceParams::CreateForTexture(system, config, entry)}; | 99 | const auto params{SurfaceParams::CreateForImage(tic, entry)}; |
| 100 | const auto [surface, view] = GetSurface(gpu_addr, params, true, false); | 100 | const auto [surface, view] = GetSurface(gpu_addr, params, true, false); |
| 101 | if (guard_samplers) { | 101 | if (guard_samplers) { |
| 102 | sampled_textures.push_back(surface); | 102 | sampled_textures.push_back(surface); |