diff options
| author | 2020-02-24 10:14:50 -0500 | |
|---|---|---|
| committer | 2020-02-24 10:14:50 -0500 | |
| commit | e22ad52cdb18842a12037e8b85d7be854b95206c (patch) | |
| tree | f60ec07ce5a4e6f56a1c9c5e18884de52de81334 /src/video_core/texture_cache | |
| parent | Merge pull request #3424 from ReinUsesLisp/spirv-layer (diff) | |
| parent | texture_cache: Implement layered framebuffer attachments (diff) | |
| download | yuzu-e22ad52cdb18842a12037e8b85d7be854b95206c.tar.gz yuzu-e22ad52cdb18842a12037e8b85d7be854b95206c.tar.xz yuzu-e22ad52cdb18842a12037e8b85d7be854b95206c.zip | |
Merge pull request #3425 from ReinUsesLisp/layered-framebuffer
texture_cache: Implement layered framebuffer attachments
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/surface_params.cpp | 47 | ||||
| -rw-r--r-- | src/video_core/texture_cache/surface_params.h | 5 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 5 |
3 files changed, 26 insertions, 31 deletions
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp index 38b3a4ba8..f00839313 100644 --- a/src/video_core/texture_cache/surface_params.cpp +++ b/src/video_core/texture_cache/surface_params.cpp | |||
| @@ -84,19 +84,16 @@ SurfaceParams SurfaceParams::CreateForTexture(const FormatLookupTable& lookup_ta | |||
| 84 | if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) { | 84 | if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) { |
| 85 | switch (params.pixel_format) { | 85 | switch (params.pixel_format) { |
| 86 | case PixelFormat::R16U: | 86 | case PixelFormat::R16U: |
| 87 | case PixelFormat::R16F: { | 87 | case PixelFormat::R16F: |
| 88 | params.pixel_format = PixelFormat::Z16; | 88 | params.pixel_format = PixelFormat::Z16; |
| 89 | break; | 89 | break; |
| 90 | } | 90 | case PixelFormat::R32F: |
| 91 | case PixelFormat::R32F: { | ||
| 92 | params.pixel_format = PixelFormat::Z32F; | 91 | params.pixel_format = PixelFormat::Z32F; |
| 93 | break; | 92 | break; |
| 94 | } | 93 | default: |
| 95 | default: { | ||
| 96 | UNIMPLEMENTED_MSG("Unimplemented shadow convert format: {}", | 94 | UNIMPLEMENTED_MSG("Unimplemented shadow convert format: {}", |
| 97 | static_cast<u32>(params.pixel_format)); | 95 | static_cast<u32>(params.pixel_format)); |
| 98 | } | 96 | } |
| 99 | } | ||
| 100 | params.type = GetFormatType(params.pixel_format); | 97 | params.type = GetFormatType(params.pixel_format); |
| 101 | } | 98 | } |
| 102 | params.type = GetFormatType(params.pixel_format); | 99 | params.type = GetFormatType(params.pixel_format); |
| @@ -168,27 +165,29 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl | |||
| 168 | return params; | 165 | return params; |
| 169 | } | 166 | } |
| 170 | 167 | ||
| 171 | SurfaceParams SurfaceParams::CreateForDepthBuffer( | 168 | SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) { |
| 172 | Core::System& system, u32 zeta_width, u32 zeta_height, Tegra::DepthFormat format, | 169 | const auto& regs = system.GPU().Maxwell3D().regs; |
| 173 | u32 block_width, u32 block_height, u32 block_depth, | 170 | regs.zeta_width, regs.zeta_height, regs.zeta.format, regs.zeta.memory_layout.type; |
| 174 | Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout type) { | ||
| 175 | SurfaceParams params; | 171 | SurfaceParams params; |
| 176 | params.is_tiled = type == Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear; | 172 | params.is_tiled = regs.zeta.memory_layout.type == |
| 173 | Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear; | ||
| 177 | params.srgb_conversion = false; | 174 | params.srgb_conversion = false; |
| 178 | params.block_width = std::min(block_width, 5U); | 175 | params.block_width = std::min(regs.zeta.memory_layout.block_width.Value(), 5U); |
| 179 | params.block_height = std::min(block_height, 5U); | 176 | params.block_height = std::min(regs.zeta.memory_layout.block_height.Value(), 5U); |
| 180 | params.block_depth = std::min(block_depth, 5U); | 177 | params.block_depth = std::min(regs.zeta.memory_layout.block_depth.Value(), 5U); |
| 181 | params.tile_width_spacing = 1; | 178 | params.tile_width_spacing = 1; |
| 182 | params.pixel_format = PixelFormatFromDepthFormat(format); | 179 | params.pixel_format = PixelFormatFromDepthFormat(regs.zeta.format); |
| 183 | params.type = GetFormatType(params.pixel_format); | 180 | params.type = GetFormatType(params.pixel_format); |
| 184 | params.width = zeta_width; | 181 | params.width = regs.zeta_width; |
| 185 | params.height = zeta_height; | 182 | params.height = regs.zeta_height; |
| 186 | params.target = SurfaceTarget::Texture2D; | ||
| 187 | params.depth = 1; | ||
| 188 | params.pitch = 0; | 183 | params.pitch = 0; |
| 189 | params.num_levels = 1; | 184 | params.num_levels = 1; |
| 190 | params.emulated_levels = 1; | 185 | params.emulated_levels = 1; |
| 191 | params.is_layered = false; | 186 | |
| 187 | const bool is_layered = regs.zeta_layers > 1 && params.block_depth == 0; | ||
| 188 | params.is_layered = is_layered; | ||
| 189 | params.target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D; | ||
| 190 | params.depth = is_layered ? regs.zeta_layers.Value() : 1U; | ||
| 192 | return params; | 191 | return params; |
| 193 | } | 192 | } |
| 194 | 193 | ||
| @@ -214,11 +213,13 @@ SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::siz | |||
| 214 | params.width = params.pitch / bpp; | 213 | params.width = params.pitch / bpp; |
| 215 | } | 214 | } |
| 216 | params.height = config.height; | 215 | params.height = config.height; |
| 217 | params.depth = 1; | ||
| 218 | params.target = SurfaceTarget::Texture2D; | ||
| 219 | params.num_levels = 1; | 216 | params.num_levels = 1; |
| 220 | params.emulated_levels = 1; | 217 | params.emulated_levels = 1; |
| 221 | params.is_layered = false; | 218 | |
| 219 | const bool is_layered = config.layers > 1 && params.block_depth == 0; | ||
| 220 | params.is_layered = is_layered; | ||
| 221 | params.depth = is_layered ? config.layers.Value() : 1; | ||
| 222 | params.target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D; | ||
| 222 | return params; | 223 | return params; |
| 223 | } | 224 | } |
| 224 | 225 | ||
diff --git a/src/video_core/texture_cache/surface_params.h b/src/video_core/texture_cache/surface_params.h index 9256fd6d9..995cc3818 100644 --- a/src/video_core/texture_cache/surface_params.h +++ b/src/video_core/texture_cache/surface_params.h | |||
| @@ -35,10 +35,7 @@ public: | |||
| 35 | const VideoCommon::Shader::Image& entry); | 35 | const VideoCommon::Shader::Image& entry); |
| 36 | 36 | ||
| 37 | /// Creates SurfaceCachedParams for a depth buffer configuration. | 37 | /// Creates SurfaceCachedParams for a depth buffer configuration. |
| 38 | static SurfaceParams CreateForDepthBuffer( | 38 | static SurfaceParams CreateForDepthBuffer(Core::System& system); |
| 39 | Core::System& system, u32 zeta_width, u32 zeta_height, Tegra::DepthFormat format, | ||
| 40 | u32 block_width, u32 block_height, u32 block_depth, | ||
| 41 | Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout type); | ||
| 42 | 39 | ||
| 43 | /// Creates SurfaceCachedParams from a framebuffer configuration. | 40 | /// Creates SurfaceCachedParams from a framebuffer configuration. |
| 44 | static SurfaceParams CreateForFramebuffer(Core::System& system, std::size_t index); | 41 | static SurfaceParams CreateForFramebuffer(Core::System& system, std::size_t index); |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 0d105d386..c70e4aec2 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -160,10 +160,7 @@ public: | |||
| 160 | SetEmptyDepthBuffer(); | 160 | SetEmptyDepthBuffer(); |
| 161 | return {}; | 161 | return {}; |
| 162 | } | 162 | } |
| 163 | const auto depth_params{SurfaceParams::CreateForDepthBuffer( | 163 | const auto depth_params{SurfaceParams::CreateForDepthBuffer(system)}; |
| 164 | system, regs.zeta_width, regs.zeta_height, regs.zeta.format, | ||
| 165 | regs.zeta.memory_layout.block_width, regs.zeta.memory_layout.block_height, | ||
| 166 | regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; | ||
| 167 | auto surface_view = GetSurface(gpu_addr, cache_addr, depth_params, preserve_contents, true); | 164 | auto surface_view = GetSurface(gpu_addr, cache_addr, depth_params, preserve_contents, true); |
| 168 | if (depth_buffer.target) | 165 | if (depth_buffer.target) |
| 169 | depth_buffer.target->MarkAsRenderTarget(false, NO_RT); | 166 | depth_buffer.target->MarkAsRenderTarget(false, NO_RT); |