yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Merge pull request #10008 from vonchenplus/texture_cache

video_core: update imageinfo implement
This commit is contained in:
liamwhite 2023-04-11 11:59:18 -04:00 committed by GitHub
commit 54b4c84ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 50 deletions

View File

@ -856,8 +856,8 @@ public:
struct ZetaSize { struct ZetaSize {
enum class DimensionControl : u32 { enum class DimensionControl : u32 {
DepthDefinesArray = 0, DefineArraySize = 0,
ArraySizeOne = 1, ArraySizeIsOne = 1,
}; };
u32 width; u32 width;
@ -1104,8 +1104,8 @@ public:
struct TileMode { struct TileMode {
enum class DimensionControl : u32 { enum class DimensionControl : u32 {
DepthDefinesArray = 0, DefineArraySize = 0,
DepthDefinesDepth = 1, DefineDepthSize = 1,
}; };
union { union {
BitField<0, 4, u32> block_width; BitField<0, 4, u32> block_width;

View File

@ -14,6 +14,7 @@
namespace VideoCommon { namespace VideoCommon {
using Tegra::Engines::Fermi2D;
using Tegra::Engines::Maxwell3D; using Tegra::Engines::Maxwell3D;
using Tegra::Texture::TextureType; using Tegra::Texture::TextureType;
using Tegra::Texture::TICEntry; using Tegra::Texture::TICEntry;
@ -114,86 +115,89 @@ ImageInfo::ImageInfo(const TICEntry& config) noexcept {
} }
} }
ImageInfo::ImageInfo(const Maxwell3D::Regs& regs, size_t index) noexcept { ImageInfo::ImageInfo(const Maxwell3D::Regs::RenderTargetConfig& ct,
const auto& rt = regs.rt[index]; Tegra::Texture::MsaaMode msaa_mode) noexcept {
format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(rt.format); format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(ct.format);
rescaleable = false; rescaleable = false;
if (rt.tile_mode.is_pitch_linear) { if (ct.tile_mode.is_pitch_linear) {
ASSERT(rt.tile_mode.dim_control == ASSERT(ct.tile_mode.dim_control ==
Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); Maxwell3D::Regs::TileMode::DimensionControl::DefineArraySize);
type = ImageType::Linear; type = ImageType::Linear;
pitch = rt.width; pitch = ct.width;
size = Extent3D{ size = Extent3D{
.width = pitch / BytesPerBlock(format), .width = pitch / BytesPerBlock(format),
.height = rt.height, .height = ct.height,
.depth = 1, .depth = 1,
}; };
return; return;
} }
size.width = rt.width; size.width = ct.width;
size.height = rt.height; size.height = ct.height;
layer_stride = rt.array_pitch * 4; layer_stride = ct.array_pitch * 4;
maybe_unaligned_layer_stride = layer_stride; maybe_unaligned_layer_stride = layer_stride;
num_samples = NumSamples(regs.anti_alias_samples_mode); num_samples = NumSamples(msaa_mode);
block = Extent3D{ block = Extent3D{
.width = rt.tile_mode.block_width, .width = ct.tile_mode.block_width,
.height = rt.tile_mode.block_height, .height = ct.tile_mode.block_height,
.depth = rt.tile_mode.block_depth, .depth = ct.tile_mode.block_depth,
}; };
if (rt.tile_mode.dim_control == if (ct.tile_mode.dim_control == Maxwell3D::Regs::TileMode::DimensionControl::DefineDepthSize) {
Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) {
type = ImageType::e3D; type = ImageType::e3D;
size.depth = rt.depth; size.depth = ct.depth;
} else { } else {
rescaleable = block.depth == 0; rescaleable = block.depth == 0;
rescaleable &= size.height > 256; rescaleable &= size.height > 256;
downscaleable = size.height > 512; downscaleable = size.height > 512;
type = ImageType::e2D; type = ImageType::e2D;
resources.layers = rt.depth; resources.layers = ct.depth;
} }
} }
ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept { ImageInfo::ImageInfo(const Maxwell3D::Regs::Zeta& zt, const Maxwell3D::Regs::ZetaSize& zt_size,
format = VideoCore::Surface::PixelFormatFromDepthFormat(regs.zeta.format); Tegra::Texture::MsaaMode msaa_mode) noexcept {
size.width = regs.zeta_size.width; format = VideoCore::Surface::PixelFormatFromDepthFormat(zt.format);
size.height = regs.zeta_size.height; size.width = zt_size.width;
size.height = zt_size.height;
rescaleable = false; rescaleable = false;
resources.levels = 1; resources.levels = 1;
layer_stride = regs.zeta.array_pitch * 4; layer_stride = zt.array_pitch * 4;
maybe_unaligned_layer_stride = layer_stride; maybe_unaligned_layer_stride = layer_stride;
num_samples = NumSamples(regs.anti_alias_samples_mode); num_samples = NumSamples(msaa_mode);
block = Extent3D{ block = Extent3D{
.width = regs.zeta.tile_mode.block_width, .width = zt.tile_mode.block_width,
.height = regs.zeta.tile_mode.block_height, .height = zt.tile_mode.block_height,
.depth = regs.zeta.tile_mode.block_depth, .depth = zt.tile_mode.block_depth,
}; };
if (regs.zeta.tile_mode.is_pitch_linear) { if (zt.tile_mode.is_pitch_linear) {
ASSERT(regs.zeta.tile_mode.dim_control == ASSERT(zt.tile_mode.dim_control ==
Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray); Maxwell3D::Regs::TileMode::DimensionControl::DefineArraySize);
type = ImageType::Linear; type = ImageType::Linear;
pitch = size.width * BytesPerBlock(format); pitch = size.width * BytesPerBlock(format);
} else if (regs.zeta.tile_mode.dim_control == } else if (zt.tile_mode.dim_control ==
Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) { Maxwell3D::Regs::TileMode::DimensionControl::DefineDepthSize) {
ASSERT(regs.zeta.tile_mode.is_pitch_linear == 0); ASSERT(zt_size.dim_control == Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeIsOne);
ASSERT(regs.zeta_size.dim_control ==
Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeOne);
type = ImageType::e3D; type = ImageType::e3D;
size.depth = regs.zeta_size.depth; size.depth = zt_size.depth;
} else { } else {
ASSERT(regs.zeta_size.dim_control ==
Maxwell3D::Regs::ZetaSize::DimensionControl::DepthDefinesArray);
rescaleable = block.depth == 0; rescaleable = block.depth == 0;
downscaleable = size.height > 512; downscaleable = size.height > 512;
type = ImageType::e2D; type = ImageType::e2D;
resources.layers = regs.zeta_size.depth; switch (zt_size.dim_control) {
case Maxwell3D::Regs::ZetaSize::DimensionControl::DefineArraySize:
resources.layers = zt_size.depth;
break;
case Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeIsOne:
resources.layers = 1;
break;
}
} }
} }
ImageInfo::ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept { ImageInfo::ImageInfo(const Fermi2D::Surface& config) noexcept {
UNIMPLEMENTED_IF_MSG(config.layer != 0, "Surface layer is not zero"); UNIMPLEMENTED_IF_MSG(config.layer != 0, "Surface layer is not zero");
format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(config.format); format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(config.format);
rescaleable = false; rescaleable = false;
if (config.linear == Tegra::Engines::Fermi2D::MemoryLayout::Pitch) { if (config.linear == Fermi2D::MemoryLayout::Pitch) {
type = ImageType::Linear; type = ImageType::Linear;
size = Extent3D{ size = Extent3D{
.width = config.pitch / VideoCore::Surface::BytesPerBlock(format), .width = config.pitch / VideoCore::Surface::BytesPerBlock(format),

View File

@ -17,8 +17,11 @@ using VideoCore::Surface::PixelFormat;
struct ImageInfo { struct ImageInfo {
ImageInfo() = default; ImageInfo() = default;
explicit ImageInfo(const TICEntry& config) noexcept; explicit ImageInfo(const TICEntry& config) noexcept;
explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs, size_t index) noexcept; explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& ct,
explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept; Tegra::Texture::MsaaMode msaa_mode) noexcept;
explicit ImageInfo(const Tegra::Engines::Maxwell3D::Regs::Zeta& zt,
const Tegra::Engines::Maxwell3D::Regs::ZetaSize& zt_size,
Tegra::Texture::MsaaMode msaa_mode) noexcept;
explicit ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept; explicit ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept;
explicit ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept; explicit ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept;

View File

@ -1503,7 +1503,7 @@ ImageViewId TextureCache<P>::FindColorBuffer(size_t index, bool is_clear) {
if (rt.format == Tegra::RenderTargetFormat::NONE) { if (rt.format == Tegra::RenderTargetFormat::NONE) {
return ImageViewId{}; return ImageViewId{};
} }
const ImageInfo info(regs, index); const ImageInfo info(regs.rt[index], regs.anti_alias_samples_mode);
return FindRenderTargetView(info, gpu_addr, is_clear); return FindRenderTargetView(info, gpu_addr, is_clear);
} }
@ -1517,7 +1517,7 @@ ImageViewId TextureCache<P>::FindDepthBuffer(bool is_clear) {
if (gpu_addr == 0) { if (gpu_addr == 0) {
return ImageViewId{}; return ImageViewId{};
} }
const ImageInfo info(regs); const ImageInfo info(regs.zeta, regs.zeta_size, regs.anti_alias_samples_mode);
return FindRenderTargetView(info, gpu_addr, is_clear); return FindRenderTargetView(info, gpu_addr, is_clear);
} }