summaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
authorGravatar Kelebek12022-08-12 10:58:09 +0100
committerGravatar Kelebek12022-10-07 14:13:45 +0100
commit752659aef3f16111981a097989dd7a5ddecff316 (patch)
tree775fbe8d1a478b2b8c201d86432743d4f3ddb2a4 /src/video_core/texture_cache
parentMerge pull request #6142 from lat9nq/prog_meta_ref_bind_address (diff)
downloadyuzu-752659aef3f16111981a097989dd7a5ddecff316.tar.gz
yuzu-752659aef3f16111981a097989dd7a5ddecff316.tar.xz
yuzu-752659aef3f16111981a097989dd7a5ddecff316.zip
Update 3D regs
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r--src/video_core/texture_cache/image_info.cpp37
-rw-r--r--src/video_core/texture_cache/texture_cache.h19
2 files changed, 34 insertions, 22 deletions
diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp
index 6c073ee57..852ec2519 100644
--- a/src/video_core/texture_cache/image_info.cpp
+++ b/src/video_core/texture_cache/image_info.cpp
@@ -1,6 +1,8 @@
1// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <fmt/format.h>
5
4#include "common/assert.h" 6#include "common/assert.h"
5#include "video_core/surface.h" 7#include "video_core/surface.h"
6#include "video_core/texture_cache/format_lookup_table.h" 8#include "video_core/texture_cache/format_lookup_table.h"
@@ -12,6 +14,7 @@
12 14
13namespace VideoCommon { 15namespace VideoCommon {
14 16
17using Tegra::Engines::Maxwell3D;
15using Tegra::Texture::TextureType; 18using Tegra::Texture::TextureType;
16using Tegra::Texture::TICEntry; 19using Tegra::Texture::TICEntry;
17using VideoCore::Surface::PixelFormat; 20using VideoCore::Surface::PixelFormat;
@@ -107,12 +110,13 @@ ImageInfo::ImageInfo(const TICEntry& config) noexcept {
107 } 110 }
108} 111}
109 112
110ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs, size_t index) noexcept { 113ImageInfo::ImageInfo(const Maxwell3D::Regs& regs, size_t index) noexcept {
111 const auto& rt = regs.rt[index]; 114 const auto& rt = regs.rt[index];
112 format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(rt.format); 115 format = VideoCore::Surface::PixelFormatFromRenderTargetFormat(rt.format);
113 rescaleable = false; 116 rescaleable = false;
114 if (rt.tile_mode.is_pitch_linear) { 117 if (rt.tile_mode.is_pitch_linear) {
115 ASSERT(rt.tile_mode.is_3d == 0); 118 ASSERT(rt.tile_mode.dim_control ==
119 Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray);
116 type = ImageType::Linear; 120 type = ImageType::Linear;
117 pitch = rt.width; 121 pitch = rt.width;
118 size = Extent3D{ 122 size = Extent3D{
@@ -124,15 +128,16 @@ ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs, size_t index)
124 } 128 }
125 size.width = rt.width; 129 size.width = rt.width;
126 size.height = rt.height; 130 size.height = rt.height;
127 layer_stride = rt.layer_stride * 4; 131 layer_stride = rt.array_pitch * 4;
128 maybe_unaligned_layer_stride = layer_stride; 132 maybe_unaligned_layer_stride = layer_stride;
129 num_samples = NumSamples(regs.multisample_mode); 133 num_samples = NumSamples(regs.anti_alias_samples_mode);
130 block = Extent3D{ 134 block = Extent3D{
131 .width = rt.tile_mode.block_width, 135 .width = rt.tile_mode.block_width,
132 .height = rt.tile_mode.block_height, 136 .height = rt.tile_mode.block_height,
133 .depth = rt.tile_mode.block_depth, 137 .depth = rt.tile_mode.block_depth,
134 }; 138 };
135 if (rt.tile_mode.is_3d) { 139 if (rt.tile_mode.dim_control ==
140 Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) {
136 type = ImageType::e3D; 141 type = ImageType::e3D;
137 size.depth = rt.depth; 142 size.depth = rt.depth;
138 } else { 143 } else {
@@ -146,31 +151,37 @@ ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs, size_t index)
146 151
147ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept { 152ImageInfo::ImageInfo(const Tegra::Engines::Maxwell3D::Regs& regs) noexcept {
148 format = VideoCore::Surface::PixelFormatFromDepthFormat(regs.zeta.format); 153 format = VideoCore::Surface::PixelFormatFromDepthFormat(regs.zeta.format);
149 size.width = regs.zeta_width; 154 size.width = regs.zeta_size.width;
150 size.height = regs.zeta_height; 155 size.height = regs.zeta_size.height;
151 rescaleable = false; 156 rescaleable = false;
152 resources.levels = 1; 157 resources.levels = 1;
153 layer_stride = regs.zeta.layer_stride * 4; 158 layer_stride = regs.zeta.array_pitch * 4;
154 maybe_unaligned_layer_stride = layer_stride; 159 maybe_unaligned_layer_stride = layer_stride;
155 num_samples = NumSamples(regs.multisample_mode); 160 num_samples = NumSamples(regs.anti_alias_samples_mode);
156 block = Extent3D{ 161 block = Extent3D{
157 .width = regs.zeta.tile_mode.block_width, 162 .width = regs.zeta.tile_mode.block_width,
158 .height = regs.zeta.tile_mode.block_height, 163 .height = regs.zeta.tile_mode.block_height,
159 .depth = regs.zeta.tile_mode.block_depth, 164 .depth = regs.zeta.tile_mode.block_depth,
160 }; 165 };
161 if (regs.zeta.tile_mode.is_pitch_linear) { 166 if (regs.zeta.tile_mode.is_pitch_linear) {
162 ASSERT(regs.zeta.tile_mode.is_3d == 0); 167 ASSERT(regs.zeta.tile_mode.dim_control ==
168 Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesArray);
163 type = ImageType::Linear; 169 type = ImageType::Linear;
164 pitch = size.width * BytesPerBlock(format); 170 pitch = size.width * BytesPerBlock(format);
165 } else if (regs.zeta.tile_mode.is_3d) { 171 } else if (regs.zeta.tile_mode.dim_control ==
172 Maxwell3D::Regs::TileMode::DimensionControl::DepthDefinesDepth) {
166 ASSERT(regs.zeta.tile_mode.is_pitch_linear == 0); 173 ASSERT(regs.zeta.tile_mode.is_pitch_linear == 0);
174 ASSERT(regs.zeta_size.dim_control ==
175 Maxwell3D::Regs::ZetaSize::DimensionControl::ArraySizeOne);
167 type = ImageType::e3D; 176 type = ImageType::e3D;
168 size.depth = regs.zeta_depth; 177 size.depth = regs.zeta_size.depth;
169 } else { 178 } else {
179 ASSERT(regs.zeta_size.dim_control ==
180 Maxwell3D::Regs::ZetaSize::DimensionControl::DepthDefinesArray);
170 rescaleable = block.depth == 0; 181 rescaleable = block.depth == 0;
171 downscaleable = size.height > 512; 182 downscaleable = size.height > 512;
172 type = ImageType::e2D; 183 type = ImageType::e2D;
173 resources.layers = regs.zeta_depth; 184 resources.layers = regs.zeta_size.depth;
174 } 185 }
175} 186}
176 187
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index eaf4a1c95..413baf730 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -189,15 +189,16 @@ typename P::Sampler* TextureCache<P>::GetComputeSampler(u32 index) {
189 189
190template <class P> 190template <class P>
191void TextureCache<P>::SynchronizeGraphicsDescriptors() { 191void TextureCache<P>::SynchronizeGraphicsDescriptors() {
192 using SamplerIndex = Tegra::Engines::Maxwell3D::Regs::SamplerIndex; 192 using SamplerBinding = Tegra::Engines::Maxwell3D::Regs::SamplerBinding;
193 const bool linked_tsc = maxwell3d->regs.sampler_index == SamplerIndex::ViaHeaderIndex; 193 const bool linked_tsc = maxwell3d->regs.sampler_binding == SamplerBinding::ViaHeaderBinding;
194 const u32 tic_limit = maxwell3d->regs.tic.limit; 194 const u32 tic_limit = maxwell3d->regs.tex_header.limit;
195 const u32 tsc_limit = linked_tsc ? tic_limit : maxwell3d->regs.tsc.limit; 195 const u32 tsc_limit = linked_tsc ? tic_limit : maxwell3d->regs.tex_sampler.limit;
196 if (channel_state->graphics_sampler_table.Synchornize(maxwell3d->regs.tsc.Address(), 196 if (channel_state->graphics_sampler_table.Synchornize(maxwell3d->regs.tex_sampler.Address(),
197 tsc_limit)) { 197 tsc_limit)) {
198 channel_state->graphics_sampler_ids.resize(tsc_limit + 1, CORRUPT_ID); 198 channel_state->graphics_sampler_ids.resize(tsc_limit + 1, CORRUPT_ID);
199 } 199 }
200 if (channel_state->graphics_image_table.Synchornize(maxwell3d->regs.tic.Address(), tic_limit)) { 200 if (channel_state->graphics_image_table.Synchornize(maxwell3d->regs.tex_header.Address(),
201 tic_limit)) {
201 channel_state->graphics_image_view_ids.resize(tic_limit + 1, CORRUPT_ID); 202 channel_state->graphics_image_view_ids.resize(tic_limit + 1, CORRUPT_ID);
202 } 203 }
203} 204}
@@ -352,8 +353,8 @@ void TextureCache<P>::UpdateRenderTargets(bool is_clear) {
352 down_shift = Settings::values.resolution_info.down_shift; 353 down_shift = Settings::values.resolution_info.down_shift;
353 } 354 }
354 render_targets.size = Extent2D{ 355 render_targets.size = Extent2D{
355 (maxwell3d->regs.render_area.width * up_scale) >> down_shift, 356 (maxwell3d->regs.surface_clip.width * up_scale) >> down_shift,
356 (maxwell3d->regs.render_area.height * up_scale) >> down_shift, 357 (maxwell3d->regs.surface_clip.height * up_scale) >> down_shift,
357 }; 358 };
358 render_targets.is_rescaled = is_rescaling; 359 render_targets.is_rescaled = is_rescaling;
359 360
@@ -1980,7 +1981,7 @@ bool TextureCache<P>::IsFullClear(ImageViewId id) {
1980 // Images with multiple resources can't be cleared in a single call 1981 // Images with multiple resources can't be cleared in a single call
1981 return false; 1982 return false;
1982 } 1983 }
1983 if (regs.clear_flags.scissor == 0) { 1984 if (regs.clear_control.use_scissor == 0) {
1984 // If scissor testing is disabled, the clear is always full 1985 // If scissor testing is disabled, the clear is always full
1985 return true; 1986 return true;
1986 } 1987 }