diff options
| author | 2023-04-11 11:59:18 -0400 | |
|---|---|---|
| committer | 2023-04-11 11:59:18 -0400 | |
| commit | 54b4c84ab6d353867dc483ac35f947d50766c36e (patch) | |
| tree | 4c78268adfa55161c6f9cf11cc9b577564bd8da1 /src | |
| parent | Merge pull request #10027 from bylaws/master (diff) | |
| parent | video_core: Keep the definition of DimensionControl consistent with nvidia op... (diff) | |
| download | yuzu-54b4c84ab6d353867dc483ac35f947d50766c36e.tar.gz yuzu-54b4c84ab6d353867dc483ac35f947d50766c36e.tar.xz yuzu-54b4c84ab6d353867dc483ac35f947d50766c36e.zip | |
Merge pull request #10008 from vonchenplus/texture_cache
video_core: update imageinfo implement
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 8 | ||||
| -rw-r--r-- | src/video_core/texture_cache/image_info.cpp | 88 | ||||
| -rw-r--r-- | src/video_core/texture_cache/image_info.h | 7 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 4 |
4 files changed, 57 insertions, 50 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index c89969bb4..6c19354e1 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -856,8 +856,8 @@ public: | |||
| 856 | 856 | ||
| 857 | struct ZetaSize { | 857 | struct ZetaSize { |
| 858 | enum class DimensionControl : u32 { | 858 | enum class DimensionControl : u32 { |
| 859 | DepthDefinesArray = 0, | 859 | DefineArraySize = 0, |
| 860 | ArraySizeOne = 1, | 860 | ArraySizeIsOne = 1, |
| 861 | }; | 861 | }; |
| 862 | 862 | ||
| 863 | u32 width; | 863 | u32 width; |
| @@ -1104,8 +1104,8 @@ public: | |||
| 1104 | 1104 | ||
| 1105 | struct TileMode { | 1105 | struct TileMode { |
| 1106 | enum class DimensionControl : u32 { | 1106 | enum class DimensionControl : u32 { |
| 1107 | DepthDefinesArray = 0, | 1107 | DefineArraySize = 0, |
| 1108 | DepthDefinesDepth = 1, | 1108 | DefineDepthSize = 1, |
| 1109 | }; | 1109 | }; |
| 1110 | union { | 1110 | union { |
| 1111 | BitField<0, 4, u32> block_width; | 1111 | BitField<0, 4, u32> block_width; |
diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp index a1296b574..11f3f78a1 100644 --- a/src/video_core/texture_cache/image_info.cpp +++ b/src/video_core/texture_cache/image_info.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | namespace VideoCommon { | 15 | namespace VideoCommon { |
| 16 | 16 | ||
| 17 | using Tegra::Engines::Fermi2D; | ||
| 17 | using Tegra::Engines::Maxwell3D; | 18 | using Tegra::Engines::Maxwell3D; |
| 18 | using Tegra::Texture::TextureType; | 19 | using Tegra::Texture::TextureType; |
| 19 | using Tegra::Texture::TICEntry; | 20 | using Tegra::Texture::TICEntry; |
| @@ -114,86 +115,89 @@ ImageInfo::ImageInfo(const TICEntry& config) noexcept { | |||
| 114 | } | 115 | } |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | ImageInfo::ImageInfo(const Maxwell3D::Regs& regs, size_t index) noexcept { | 118 | ImageInfo::ImageInfo(const Maxwell3D::Regs::RenderTargetConfig& ct, |
| 118 | const auto& rt = regs.rt[index]; | 119 | Tegra::Texture::MsaaMode msaa_mode) noexcept { |
| 119 | format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(rt.format); | 120 | format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(ct.format); |
| 120 | rescaleable = false; | 121 | rescaleable = false; |
| 121 | if (rt.tile_mode.is_pitch_linear) { | 122 | if (ct.tile_mode.is_pitch_linear) { |
| 122 | ASSERT(rt.tile_mode.dim_control == | 123 | ASSERT(ct.tile_mode.dim_control == |
| 123 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); | 124 | Maxwell3D::Regs::TileMode::DimensionControl::DefineArraySize); |
| 124 | type = ImageType::Linear; | 125 | type = ImageType::Linear; |
| 125 | pitch = rt.width; | 126 | pitch = ct.width; |
| 126 | size = Extent3D{ | 127 | size = Extent3D{ |
| 127 | .width = pitch / BytesPerBlock(format), | 128 | .width = pitch / BytesPerBlock(format), |
| 128 | .height = rt.height, | 129 | .height = ct.height, |
| 129 | .depth = 1, | 130 | .depth = 1, |
| 130 | }; | 131 | }; |
| 131 | return; | 132 | return; |
| 132 | } | 133 | } |
| 133 | size.width = rt.width; | 134 | size.width = ct.width; |
| 134 | size.height = rt.height; | 135 | size.height = ct.height; |
| 135 | layer_stride = rt.array_pitch * 4; | 136 | layer_stride = ct.array_pitch * 4; |
| 136 | maybe_unaligned_layer_stride = layer_stride; | 137 | maybe_unaligned_layer_stride = layer_stride; |
| 137 | num_samples = NumSamples(regs.anti_alias_samples_mode); | 138 | num_samples = NumSamples(msaa_mode); |
| 138 | block = Extent3D{ | 139 | block = Extent3D{ |
| 139 | .width = rt.tile_mode.block_width, | 140 | .width = ct.tile_mode.block_width, |
| 140 | .height = rt.tile_mode.block_height, | 141 | .height = ct.tile_mode.block_height, |
| 141 | .depth = rt.tile_mode.block_depth, | 142 | .depth = ct.tile_mode.block_depth, |
| 142 | }; | 143 | }; |
| 143 | if (rt.tile_mode.dim_control == | 144 | if (ct.tile_mode.dim_control == Maxwell3D::Regs::TileMode::DimensionControl::DefineDepthSize) { |
| 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 Maxwell3D::Regs::Zeta& zt, const Maxwell3D::Regs::ZetaSize& zt_size, |
| 157 | format = VideoCore::Surface::PixelFormatFromDepthFormat(regs.zeta.format); | 157 | Tegra::Texture::MsaaMode msaa_mode) noexcept { |
| 158 | size.width = regs.zeta_size.width; | 158 | format = VideoCore::Surface::PixelFormatFromDepthFormat(zt.format); |
| 159 | size.height = regs.zeta_size.height; | 159 | size.width = zt_size.width; |
| 160 | size.height = zt_size.height; | ||
| 160 | rescaleable = false; | 161 | rescaleable = false; |
| 161 | resources.levels = 1; | 162 | resources.levels = 1; |
| 162 | layer_stride = regs.zeta.array_pitch * 4; | 163 | layer_stride = zt.array_pitch * 4; |
| 163 | maybe_unaligned_layer_stride = layer_stride; | 164 | maybe_unaligned_layer_stride = layer_stride; |
| 164 | num_samples = NumSamples(regs.anti_alias_samples_mode); | 165 | num_samples = NumSamples(msaa_mode); |
| 165 | block = Extent3D{ | 166 | block = Extent3D{ |
| 166 | .width = regs.zeta.tile_mode.block_width, | 167 | .width = zt.tile_mode.block_width, |
| 167 | .height = regs.zeta.tile_mode.block_height, | 168 | .height = zt.tile_mode.block_height, |
| 168 | .depth = regs.zeta.tile_mode.block_depth, | 169 | .depth = zt.tile_mode.block_depth, |
| 169 | }; | 170 | }; |
| 170 | if (regs.zeta.tile_mode.is_pitch_linear) { | 171 | if (zt.tile_mode.is_pitch_linear) { |
| 171 | ASSERT(regs.zeta.tile_mode.dim_control == | 172 | ASSERT(zt.tile_mode.dim_control == |
| 172 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); | 173 | Maxwell3D::Regs::TileMode::DimensionControl::DefineArraySize); |
| 173 | type = ImageType::Linear; | 174 | type = ImageType::Linear; |
| 174 | pitch = size.width * BytesPerBlock(format); | 175 | pitch = size.width * BytesPerBlock(format); |
| 175 | } else if (regs.zeta.tile_mode.dim_control == | 176 | } else if (zt.tile_mode.dim_control == |
| 176 | Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) { | 177 | Maxwell3D::Regs::TileMode::DimensionControl::DefineDepthSize) { |
| 177 | ASSERT(regs.zeta.tile_mode.is_pitch_linear == 0); | 178 | ASSERT(zt_size.dim_control == Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeIsOne); |
| 178 | ASSERT(regs.zeta_size.dim_control == | ||
| 179 | Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeOne); | ||
| 180 | type = ImageType::e3D; | 179 | type = ImageType::e3D; |
| 181 | size.depth = regs.zeta_size.depth; | 180 | size.depth = zt_size.depth; |
| 182 | } else { | 181 | } else { |
| 183 | ASSERT(regs.zeta_size.dim_control == | ||
| 184 | Maxwell3D::Regs::ZetaSize::DimensionControl::DepthDefinesArray); | ||
| 185 | rescaleable = block.depth == 0; | 182 | rescaleable = block.depth == 0; |
| 186 | downscaleable = size.height > 512; | 183 | downscaleable = size.height > 512; |
| 187 | type = ImageType::e2D; | 184 | type = ImageType::e2D; |
| 188 | resources.layers = regs.zeta_size.depth; | 185 | switch (zt_size.dim_control) { |
| 186 | case Maxwell3D::Regs::ZetaSize::DimensionControl::DefineArraySize: | ||
| 187 | resources.layers = zt_size.depth; | ||
| 188 | break; | ||
| 189 | case Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeIsOne: | ||
| 190 | resources.layers = 1; | ||
| 191 | break; | ||
| 192 | } | ||
| 189 | } | 193 | } |
| 190 | } | 194 | } |
| 191 | 195 | ||
| 192 | ImageInfo::ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept { | 196 | ImageInfo::ImageInfo(const Fermi2D::Surface& config) noexcept { |
| 193 | UNIMPLEMENTED_IF_MSG(config.layer != 0, "Surface layer is not zero"); | 197 | UNIMPLEMENTED_IF_MSG(config.layer != 0, "Surface layer is not zero"); |
| 194 | format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(config.format); | 198 | format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(config.format); |
| 195 | rescaleable = false; | 199 | rescaleable = false; |
| 196 | if (config.linear == Tegra::Engines::Fermi2D::MemoryLayout::Pitch) { | 200 | if (config.linear == Fermi2D::MemoryLayout::Pitch) { |
| 197 | type = ImageType::Linear; | 201 | type = ImageType::Linear; |
| 198 | size = Extent3D{ | 202 | size = Extent3D{ |
| 199 | .width = config.pitch / VideoCore::Surface::BytesPerBlock(format), | 203 | .width = config.pitch / VideoCore::Surface::BytesPerBlock(format), |
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 62fb98b55..ed5c768d8 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 | ||