summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache/image_info.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/texture_cache/image_info.cpp163
1 files changed, 114 insertions, 49 deletions
diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp
index 852ec2519..b72788c6d 100644
--- a/src/video_core/texture_cache/image_info.cpp
+++ b/src/video_core/texture_cache/image_info.cpp
@@ -4,6 +4,7 @@
#include <fmt/format.h>
#include "common/assert.h"
+#include "common/settings.h"
#include "video_core/surface.h"
#include "video_core/texture_cache/format_lookup_table.h"
#include "video_core/texture_cache/image_info.h"
@@ -14,13 +15,19 @@
namespace VideoCommon {
+using Tegra::Engines::Fermi2D;
using Tegra::Engines::Maxwell3D;
using Tegra::Texture::TextureType;
using Tegra::Texture::TICEntry;
using VideoCore::Surface::PixelFormat;
using VideoCore::Surface::SurfaceType;
+constexpr u32 RescaleHeightThreshold = 288;
+constexpr u32 DownscaleHeightThreshold = 512;
+
ImageInfo::ImageInfo(const TICEntry& config) noexcept {
+ forced_flushed = config.IsPitchLinear() && !Settings::values.use_reactive_flushing.GetValue();
+ dma_downloaded = forced_flushed;
format = PixelFormatFromTextureInfo(config.format, config.r_type, config.g_type, config.b_type,
config.a_type, config.srgb_conversion);
num_samples = NumSamples(config.msaa_mode);
@@ -100,96 +107,113 @@ ImageInfo::ImageInfo(const TICEntry& config) noexcept {
ASSERT_MSG(false, "Invalid texture_type={}", static_cast<int>(config.texture_type.Value()));
break;
}
+ if (num_samples > 1) {
+ size.width *= NumSamplesX(config.msaa_mode);
+ size.height *= NumSamplesY(config.msaa_mode);
+ }
if (type != ImageType::Linear) {
// FIXME: Call this without passing *this
layer_stride = CalculateLayerStride(*this);
maybe_unaligned_layer_stride = CalculateLayerSize(*this);
rescaleable &= (block.depth == 0) && resources.levels == 1;
- rescaleable &= size.height > 256 || GetFormatType(format) != SurfaceType::ColorTexture;
- downscaleable = size.height > 512;
+ rescaleable &= size.height > RescaleHeightThreshold ||
+ GetFormatType(format) != SurfaceType::ColorTexture;
+ downscaleable = size.height > DownscaleHeightThreshold;
}
}
-ImageInfo::ImageInfo(const Maxwell3D::Regs& regs, size_t index) noexcept {
- const auto& rt = regs.rt[index];
- format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(rt.format);
+ImageInfo::ImageInfo(const Maxwell3D::Regs::RenderTargetConfig& ct,
+ Tegra::Texture::MsaaMode msaa_mode) noexcept {
+ forced_flushed =
+ ct.tile_mode.is_pitch_linear && !Settings::values.use_reactive_flushing.GetValue();
+ dma_downloaded = forced_flushed;
+ format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(ct.format);
rescaleable = false;
- if (rt.tile_mode.is_pitch_linear) {
- ASSERT(rt.tile_mode.dim_control ==
- Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray);
+ if (ct.tile_mode.is_pitch_linear) {
+ ASSERT(ct.tile_mode.dim_control ==
+ Maxwell3D::Regs::TileMode::DimensionControl::DefineArraySize);
type = ImageType::Linear;
- pitch = rt.width;
+ pitch = ct.width;
size = Extent3D{
.width = pitch / BytesPerBlock(format),
- .height = rt.height,
+ .height = ct.height,
.depth = 1,
};
return;
}
- size.width = rt.width;
- size.height = rt.height;
- layer_stride = rt.array_pitch * 4;
+ size.width = ct.width;
+ size.height = ct.height;
+ layer_stride = ct.array_pitch * 4;
maybe_unaligned_layer_stride = layer_stride;
- num_samples = NumSamples(regs.anti_alias_samples_mode);
+ num_samples = NumSamples(msaa_mode);
block = Extent3D{
- .width = rt.tile_mode.block_width,
- .height = rt.tile_mode.block_height,
- .depth = rt.tile_mode.block_depth,
+ .width = ct.tile_mode.block_width,
+ .height = ct.tile_mode.block_height,
+ .depth = ct.tile_mode.block_depth,
};
- if (rt.tile_mode.dim_control ==
- Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) {
+ if (ct.tile_mode.dim_control == Maxwell3D::Regs::TileMode::DimensionControl::DefineDepthSize) {
type = ImageType::e3D;
- size.depth = rt.depth;
+ size.depth = ct.depth;
} else {
rescaleable = block.depth == 0;
- rescaleable &= size.height > 256;
- downscaleable = size.height > 512;
+ rescaleable &= size.height > RescaleHeightThreshold;
+ downscaleable = size.height > DownscaleHeightThreshold;
type = ImageType::e2D;
- resources.layers = rt.depth;
+ resources.layers = ct.depth;
}
}
-ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept {
- format = VideoCore::Surface::PixelFormatFromDepthFormat(regs.zeta.format);
- size.width = regs.zeta_size.width;
- size.height = regs.zeta_size.height;
+ImageInfo::ImageInfo(const Maxwell3D::Regs::Zeta& zt, const Maxwell3D::Regs::ZetaSize& zt_size,
+ Tegra::Texture::MsaaMode msaa_mode) noexcept {
+ forced_flushed =
+ zt.tile_mode.is_pitch_linear && !Settings::values.use_reactive_flushing.GetValue();
+ dma_downloaded = forced_flushed;
+ format = VideoCore::Surface::PixelFormatFromDepthFormat(zt.format);
+ size.width = zt_size.width;
+ size.height = zt_size.height;
rescaleable = false;
resources.levels = 1;
- layer_stride = regs.zeta.array_pitch * 4;
+ layer_stride = zt.array_pitch * 4;
maybe_unaligned_layer_stride = layer_stride;
- num_samples = NumSamples(regs.anti_alias_samples_mode);
+ num_samples = NumSamples(msaa_mode);
block = Extent3D{
- .width = regs.zeta.tile_mode.block_width,
- .height = regs.zeta.tile_mode.block_height,
- .depth = regs.zeta.tile_mode.block_depth,
+ .width = zt.tile_mode.block_width,
+ .height = zt.tile_mode.block_height,
+ .depth = zt.tile_mode.block_depth,
};
- if (regs.zeta.tile_mode.is_pitch_linear) {
- ASSERT(regs.zeta.tile_mode.dim_control ==
- Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray);
+ if (zt.tile_mode.is_pitch_linear) {
+ ASSERT(zt.tile_mode.dim_control ==
+ Maxwell3D::Regs::TileMode::DimensionControl::DefineArraySize);
type = ImageType::Linear;
pitch = size.width * BytesPerBlock(format);
- } else if (regs.zeta.tile_mode.dim_control ==
- Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) {
- ASSERT(regs.zeta.tile_mode.is_pitch_linear == 0);
- ASSERT(regs.zeta_size.dim_control ==
- Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeOne);
+ } else if (zt.tile_mode.dim_control ==
+ Maxwell3D::Regs::TileMode::DimensionControl::DefineDepthSize) {
+ ASSERT(zt_size.dim_control == Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeIsOne);
type = ImageType::e3D;
- size.depth = regs.zeta_size.depth;
+ size.depth = zt_size.depth;
} else {
- ASSERT(regs.zeta_size.dim_control ==
- Maxwell3D::Regs::ZetaSize::DimensionControl::DepthDefinesArray);
rescaleable = block.depth == 0;
downscaleable = size.height > 512;
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");
+ forced_flushed = config.linear == Fermi2D::MemoryLayout::Pitch &&
+ !Settings::values.use_reactive_flushing.GetValue();
+ dma_downloaded = forced_flushed;
format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(config.format);
rescaleable = false;
- if (config.linear == Tegra::Engines::Fermi2D::MemoryLayout::Pitch) {
+ if (config.linear == Fermi2D::MemoryLayout::Pitch) {
type = ImageType::Linear;
size = Extent3D{
.width = config.pitch / VideoCore::Surface::BytesPerBlock(format),
@@ -212,10 +236,51 @@ ImageInfo::ImageInfo(const Tegra::Engines::Fermi2D::Surface& config) noexcept {
.height = config.height,
.depth = 1,
};
- rescaleable = block.depth == 0;
- rescaleable &= size.height > 256;
- downscaleable = size.height > 512;
+ rescaleable = block.depth == 0 && size.height > RescaleHeightThreshold;
+ downscaleable = size.height > DownscaleHeightThreshold;
+ }
+}
+
+static PixelFormat ByteSizeToFormat(u32 bytes_per_pixel) {
+ switch (bytes_per_pixel) {
+ case 1:
+ return PixelFormat::R8_UINT;
+ case 2:
+ return PixelFormat::R8G8_UINT;
+ case 4:
+ return PixelFormat::A8B8G8R8_UINT;
+ case 8:
+ return PixelFormat::R16G16B16A16_UINT;
+ case 16:
+ return PixelFormat::R32G32B32A32_UINT;
+ default:
+ UNIMPLEMENTED();
+ return PixelFormat::Invalid;
}
}
+ImageInfo::ImageInfo(const Tegra::DMA::ImageOperand& config) noexcept {
+ const u32 bytes_per_pixel = config.bytes_per_pixel;
+ format = ByteSizeToFormat(bytes_per_pixel);
+ type = config.params.block_size.depth > 0 ? ImageType::e3D : ImageType::e2D;
+ num_samples = 1;
+ block = Extent3D{
+ .width = config.params.block_size.width,
+ .height = config.params.block_size.height,
+ .depth = config.params.block_size.depth,
+ };
+ size = Extent3D{
+ .width = config.params.width,
+ .height = config.params.height,
+ .depth = config.params.depth,
+ };
+ tile_width_spacing = 0;
+ resources.levels = 1;
+ resources.layers = 1;
+ layer_stride = CalculateLayerStride(*this);
+ maybe_unaligned_layer_stride = CalculateLayerSize(*this);
+ rescaleable = block.depth == 0 && size.height > RescaleHeightThreshold;
+ downscaleable = size.height > DownscaleHeightThreshold;
+}
+
} // namespace VideoCommon