diff options
| author | 2023-03-14 22:36:34 +0800 | |
|---|---|---|
| committer | 2023-03-14 22:36:34 +0800 | |
| commit | 11ffbee5ae4c2930936d5be9201e2a0c04706579 (patch) | |
| tree | 4fadfac722f0a142c15fc4ebb9b9c75ca03eb063 /src | |
| parent | Merge pull request #9951 from Morph1984/save (diff) | |
| download | yuzu-11ffbee5ae4c2930936d5be9201e2a0c04706579.tar.gz yuzu-11ffbee5ae4c2930936d5be9201e2a0c04706579.tar.xz yuzu-11ffbee5ae4c2930936d5be9201e2a0c04706579.zip | |
video_core: Better defined ImageInfo parameters
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/texture_cache/image_info.cpp | 71 | ||||
| -rw-r--r-- | src/video_core/texture_cache/image_info.h | 7 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 4 |
3 files changed, 43 insertions, 39 deletions
diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp index a1296b574..0b231887c 100644 --- a/src/video_core/texture_cache/image_info.cpp +++ b/src/video_core/texture_cache/image_info.cpp | |||
| @@ -114,78 +114,79 @@ ImageInfo::ImageInfo(const TICEntry& config) noexcept { | |||
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | ImageInfo::ImageInfo(const Maxwell3D::Regs& regs, size_t index) noexcept { | 117 | ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& ct, |
| 118 | const auto& rt = regs.rt[index]; | 118 | Tegra::Texture::MsaaMode msaa_mode) noexcept { |
| 119 | format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(rt.format); | 119 | format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(ct.format); |
| 120 | rescaleable = false; | 120 | rescaleable = false; |
| 121 | if (rt.tile_mode.is_pitch_linear) { | 121 | if (ct.tile_mode.is_pitch_linear) { |
| 122 | ASSERT(rt.tile_mode.dim_control == | 122 | ASSERT(ct.tile_mode.dim_control == |
| 123 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); | 123 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); |
| 124 | type = ImageType::Linear; | 124 | type = ImageType::Linear; |
| 125 | pitch = rt.width; | 125 | pitch = ct.width; |
| 126 | size = Extent3D{ | 126 | size = Extent3D{ |
| 127 | .width = pitch / BytesPerBlock(format), | 127 | .width = pitch / BytesPerBlock(format), |
| 128 | .height = rt.height, | 128 | .height = ct.height, |
| 129 | .depth = 1, | 129 | .depth = 1, |
| 130 | }; | 130 | }; |
| 131 | return; | 131 | return; |
| 132 | } | 132 | } |
| 133 | size.width = rt.width; | 133 | size.width = ct.width; |
| 134 | size.height = rt.height; | 134 | size.height = ct.height; |
| 135 | layer_stride = rt.array_pitch * 4; | 135 | layer_stride = ct.array_pitch * 4; |
| 136 | maybe_unaligned_layer_stride = layer_stride; | 136 | maybe_unaligned_layer_stride = layer_stride; |
| 137 | num_samples = NumSamples(regs.anti_alias_samples_mode); | 137 | num_samples = NumSamples(msaa_mode); |
| 138 | block = Extent3D{ | 138 | block = Extent3D{ |
| 139 | .width = rt.tile_mode.block_width, | 139 | .width = ct.tile_mode.block_width, |
| 140 | .height = rt.tile_mode.block_height, | 140 | .height = ct.tile_mode.block_height, |
| 141 | .depth = rt.tile_mode.block_depth, | 141 | .depth = ct.tile_mode.block_depth, |
| 142 | }; | 142 | }; |
| 143 | if (rt.tile_mode.dim_control == | 143 | if (ct.tile_mode.dim_control == |
| 144 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) { | 144 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) { |
| 145 | type = ImageType::e3D; | 145 | type = ImageType::e3D; |
| 146 | size.depth = rt.depth; | 146 | size.depth = ct.depth; |
| 147 | } else { | 147 | } else { |
| 148 | rescaleable = block.depth == 0; | 148 | rescaleable = block.depth == 0; |
| 149 | rescaleable &= size.height > 256; | 149 | rescaleable &= size.height > 256; |
| 150 | downscaleable = size.height > 512; | 150 | downscaleable = size.height > 512; |
| 151 | type = ImageType::e2D; | 151 | type = ImageType::e2D; |
| 152 | resources.layers = rt.depth; | 152 | resources.layers = ct.depth; |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept { | 156 | ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs::Zeta& zt, |
| 157 | format = VideoCore::Surface::PixelFormatFromDepthFormat(regs.zeta.format); | 157 | const Tegra::Engines::Maxwell3D::Regs::ZetaSize& zt_size, |
| 158 | size.width = regs.zeta_size.width; | 158 | Tegra::Texture::MsaaMode msaa_mode) noexcept { |
| 159 | size.height = regs.zeta_size.height; | 159 | format = VideoCore::Surface::PixelFormatFromDepthFormat(zt.format); |
| 160 | size.width = zt_size.width; | ||
| 161 | size.height = zt_size.height; | ||
| 160 | rescaleable = false; | 162 | rescaleable = false; |
| 161 | resources.levels = 1; | 163 | resources.levels = 1; |
| 162 | layer_stride = regs.zeta.array_pitch * 4; | 164 | layer_stride = zt.array_pitch * 4; |
| 163 | maybe_unaligned_layer_stride = layer_stride; | 165 | maybe_unaligned_layer_stride = layer_stride; |
| 164 | num_samples = NumSamples(regs.anti_alias_samples_mode); | 166 | num_samples = NumSamples(msaa_mode); |
| 165 | block = Extent3D{ | 167 | block = Extent3D{ |
| 166 | .width = regs.zeta.tile_mode.block_width, | 168 | .width = zt.tile_mode.block_width, |
| 167 | .height = regs.zeta.tile_mode.block_height, | 169 | .height = zt.tile_mode.block_height, |
| 168 | .depth = regs.zeta.tile_mode.block_depth, | 170 | .depth = zt.tile_mode.block_depth, |
| 169 | }; | 171 | }; |
| 170 | if (regs.zeta.tile_mode.is_pitch_linear) { | 172 | if (zt.tile_mode.is_pitch_linear) { |
| 171 | ASSERT(regs.zeta.tile_mode.dim_control == | 173 | ASSERT(zt.tile_mode.dim_control == |
| 172 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); | 174 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); |
| 173 | type = ImageType::Linear; | 175 | type = ImageType::Linear; |
| 174 | pitch = size.width * BytesPerBlock(format); | 176 | pitch = size.width * BytesPerBlock(format); |
| 175 | } else if (regs.zeta.tile_mode.dim_control == | 177 | } else if (zt.tile_mode.dim_control == |
| 176 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) { | 178 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) { |
| 177 | ASSERT(regs.zeta.tile_mode.is_pitch_linear == 0); | 179 | ASSERT(zt.tile_mode.is_pitch_linear == 0); |
| 178 | ASSERT(regs.zeta_size.dim_control == | 180 | ASSERT(zt_size.dim_control == Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeOne); |
| 179 | Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeOne); | ||
| 180 | type = ImageType::e3D; | 181 | type = ImageType::e3D; |
| 181 | size.depth = regs.zeta_size.depth; | 182 | size.depth = zt_size.depth; |
| 182 | } else { | 183 | } else { |
| 183 | ASSERT(regs.zeta_size.dim_control == | 184 | ASSERT(zt_size.dim_control == |
| 184 | Maxwell3D::Regs::ZetaSize::DimensionControl::DepthDefinesArray); | 185 | Maxwell3D::Regs::ZetaSize::DimensionControl::DepthDefinesArray); |
| 185 | rescaleable = block.depth == 0; | 186 | rescaleable = block.depth == 0; |
| 186 | downscaleable = size.height > 512; | 187 | downscaleable = size.height > 512; |
| 187 | type = ImageType::e2D; | 188 | type = ImageType::e2D; |
| 188 | resources.layers = regs.zeta_size.depth; | 189 | resources.layers = zt_size.depth; |
| 189 | } | 190 | } |
| 190 | } | 191 | } |
| 191 | 192 | ||
diff --git a/src/video_core/texture_cache/image_info.h b/src/video_core/texture_cache/image_info.h index a12f5b44f..4b7dfa315 100644 --- a/src/video_core/texture_cache/image_info.h +++ b/src/video_core/texture_cache/image_info.h | |||
| @@ -17,8 +17,11 @@ using VideoCore::Surface::PixelFormat; | |||
| 17 | struct ImageInfo { | 17 | struct ImageInfo { |
| 18 | ImageInfo() = default; | 18 | ImageInfo() = default; |
| 19 | explicit ImageInfo(const TICEntry& config) noexcept; | 19 | explicit ImageInfo(const TICEntry& config) noexcept; |
| 20 | explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs, size_t index) noexcept; | 20 | explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& ct, |
| 21 | explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept; | 21 | Tegra::Texture::MsaaMode msaa_mode) noexcept; |
| 22 | explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs::Zeta& zt, | ||
| 23 | const Tegra::Engines::Maxwell3D::Regs::ZetaSize& zt_size, | ||
| 24 | Tegra::Texture::MsaaMode msaa_mode) noexcept; | ||
| 22 | explicit ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept; | 25 | explicit ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept; |
| 23 | explicit ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept; | 26 | explicit ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept; |
| 24 | 27 | ||
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 8e8b9a5e6..c09eecd1a 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -1503,7 +1503,7 @@ ImageViewId TextureCache<P>::FindColorBuffer(size_t index, bool is_clear) { | |||
| 1503 | if (rt.format == Tegra::RenderTargetFormat::NONE) { | 1503 | if (rt.format == Tegra::RenderTargetFormat::NONE) { |
| 1504 | return ImageViewId{}; | 1504 | return ImageViewId{}; |
| 1505 | } | 1505 | } |
| 1506 | const ImageInfo info(regs, index); | 1506 | const ImageInfo info(regs.rt[index], regs.anti_alias_samples_mode); |
| 1507 | return FindRenderTargetView(info, gpu_addr, is_clear); | 1507 | return FindRenderTargetView(info, gpu_addr, is_clear); |
| 1508 | } | 1508 | } |
| 1509 | 1509 | ||
| @@ -1517,7 +1517,7 @@ ImageViewId TextureCache<P>::FindDepthBuffer(bool is_clear) { | |||
| 1517 | if (gpu_addr == 0) { | 1517 | if (gpu_addr == 0) { |
| 1518 | return ImageViewId{}; | 1518 | return ImageViewId{}; |
| 1519 | } | 1519 | } |
| 1520 | const ImageInfo info(regs); | 1520 | const ImageInfo info(regs.zeta, regs.zeta_size, regs.anti_alias_samples_mode); |
| 1521 | return FindRenderTargetView(info, gpu_addr, is_clear); | 1521 | return FindRenderTargetView(info, gpu_addr, is_clear); |
| 1522 | } | 1522 | } |
| 1523 | 1523 | ||