summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar FernandoS272018-10-08 14:34:55 -0400
committerGravatar FernandoS272018-10-09 21:14:32 -0400
commitaf653906d0cf38556acae1f8e5d3f8968ff7074a (patch)
tree55197afb627984e1756a885a9c4df9b0091d923c /src
parentMerge pull request #1423 from DarkLordZach/romfs-file-exts (diff)
downloadyuzu-af653906d0cf38556acae1f8e5d3f8968ff7074a.tar.gz
yuzu-af653906d0cf38556acae1f8e5d3f8968ff7074a.tar.xz
yuzu-af653906d0cf38556acae1f8e5d3f8968ff7074a.zip
Fixed block height settings for RenderTargets and Depth Buffers, and added block width and block depth
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/fermi_2d.h14
-rw-r--r--src/video_core/engines/maxwell_3d.h12
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp27
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h5
-rw-r--r--src/video_core/textures/texture.h17
5 files changed, 63 insertions, 12 deletions
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h
index 81d15c62a..2a6e8bbbb 100644
--- a/src/video_core/engines/fermi_2d.h
+++ b/src/video_core/engines/fermi_2d.h
@@ -36,9 +36,9 @@ public:
36 RenderTargetFormat format; 36 RenderTargetFormat format;
37 BitField<0, 1, u32> linear; 37 BitField<0, 1, u32> linear;
38 union { 38 union {
39 BitField<0, 4, u32> block_depth; 39 BitField<0, 4, u32> block_width;
40 BitField<4, 4, u32> block_height; 40 BitField<4, 4, u32> block_height;
41 BitField<8, 4, u32> block_width; 41 BitField<8, 4, u32> block_depth;
42 }; 42 };
43 u32 depth; 43 u32 depth;
44 u32 layer; 44 u32 layer;
@@ -53,10 +53,20 @@ public:
53 address_low); 53 address_low);
54 } 54 }
55 55
56 u32 BlockWidth() const {
57 // The block width is stored in log2 format.
58 return 1 << block_width;
59 }
60
56 u32 BlockHeight() const { 61 u32 BlockHeight() const {
57 // The block height is stored in log2 format. 62 // The block height is stored in log2 format.
58 return 1 << block_height; 63 return 1 << block_height;
59 } 64 }
65
66 u32 BlockDepth() const {
67 // The block depth is stored in log2 format.
68 return 1 << block_depth;
69 }
60 }; 70 };
61 static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size"); 71 static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size");
62 72
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 4290da33f..896498b89 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -432,7 +432,11 @@ public:
432 u32 width; 432 u32 width;
433 u32 height; 433 u32 height;
434 Tegra::RenderTargetFormat format; 434 Tegra::RenderTargetFormat format;
435 u32 block_dimensions; 435 union {
436 BitField<0, 3, u32> block_width;
437 BitField<4, 3, u32> block_height;
438 BitField<8, 3, u32> block_depth;
439 } block_dimensions;
436 u32 array_mode; 440 u32 array_mode;
437 u32 layer_stride; 441 u32 layer_stride;
438 u32 base_layer; 442 u32 base_layer;
@@ -548,7 +552,11 @@ public:
548 u32 address_high; 552 u32 address_high;
549 u32 address_low; 553 u32 address_low;
550 Tegra::DepthFormat format; 554 Tegra::DepthFormat format;
551 u32 block_dimensions; 555 union {
556 BitField<0, 4, u32> block_width;
557 BitField<4, 4, u32> block_height;
558 BitField<8, 4, u32> block_depth;
559 } block_dimensions;
552 u32 layer_stride; 560 u32 layer_stride;
553 561
554 GPUVAddr Address() const { 562 GPUVAddr Address() const {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 56ff83eff..433b34b27 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -45,7 +45,9 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) {
45 SurfaceParams params{}; 45 SurfaceParams params{};
46 params.addr = TryGetCpuAddr(config.tic.Address()); 46 params.addr = TryGetCpuAddr(config.tic.Address());
47 params.is_tiled = config.tic.IsTiled(); 47 params.is_tiled = config.tic.IsTiled();
48 params.block_width = params.is_tiled ? config.tic.BlockWidth() : 0,
48 params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0, 49 params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0,
50 params.block_depth = params.is_tiled ? config.tic.BlockDepth() : 0,
49 params.pixel_format = 51 params.pixel_format =
50 PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value()); 52 PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value());
51 params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value()); 53 params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value());
@@ -98,7 +100,9 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) {
98 SurfaceParams params{}; 100 SurfaceParams params{};
99 params.addr = TryGetCpuAddr(config.Address()); 101 params.addr = TryGetCpuAddr(config.Address());
100 params.is_tiled = true; 102 params.is_tiled = true;
101 params.block_height = Tegra::Texture::TICEntry::DefaultBlockHeight; 103 params.block_width = 1 << config.block_dimensions.block_width;
104 params.block_height = 1 << config.block_dimensions.block_height;
105 params.block_depth = 1 << config.block_dimensions.block_depth;
102 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 106 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format);
103 params.component_type = ComponentTypeFromRenderTarget(config.format); 107 params.component_type = ComponentTypeFromRenderTarget(config.format);
104 params.type = GetFormatType(params.pixel_format); 108 params.type = GetFormatType(params.pixel_format);
@@ -122,11 +126,15 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) {
122 126
123/*static*/ SurfaceParams SurfaceParams::CreateForDepthBuffer(u32 zeta_width, u32 zeta_height, 127/*static*/ SurfaceParams SurfaceParams::CreateForDepthBuffer(u32 zeta_width, u32 zeta_height,
124 Tegra::GPUVAddr zeta_address, 128 Tegra::GPUVAddr zeta_address,
125 Tegra::DepthFormat format) { 129 Tegra::DepthFormat format,
130 u32 block_width, u32 block_height,
131 u32 block_depth) {
126 SurfaceParams params{}; 132 SurfaceParams params{};
127 params.addr = TryGetCpuAddr(zeta_address); 133 params.addr = TryGetCpuAddr(zeta_address);
128 params.is_tiled = true; 134 params.is_tiled = true;
129 params.block_height = Tegra::Texture::TICEntry::DefaultBlockHeight; 135 params.block_width = 1 << std::min(block_width, 5U);
136 params.block_height = 1 << std::min(block_height, 5U);
137 params.block_depth = 1 << std::min(block_depth, 5U);
130 params.pixel_format = PixelFormatFromDepthFormat(format); 138 params.pixel_format = PixelFormatFromDepthFormat(format);
131 params.component_type = ComponentTypeFromDepthFormat(format); 139 params.component_type = ComponentTypeFromDepthFormat(format);
132 params.type = GetFormatType(params.pixel_format); 140 params.type = GetFormatType(params.pixel_format);
@@ -148,7 +156,9 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) {
148 SurfaceParams params{}; 156 SurfaceParams params{};
149 params.addr = TryGetCpuAddr(config.Address()); 157 params.addr = TryGetCpuAddr(config.Address());
150 params.is_tiled = !config.linear; 158 params.is_tiled = !config.linear;
151 params.block_height = params.is_tiled ? config.BlockHeight() : 0, 159 params.block_width = params.is_tiled ? std::min(config.BlockWidth(),32U) : 0,
160 params.block_height = params.is_tiled ? std::min(config.BlockHeight(),32U) : 0,
161 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(),32U) : 0,
152 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 162 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format);
153 params.component_type = ComponentTypeFromRenderTarget(config.format); 163 params.component_type = ComponentTypeFromRenderTarget(config.format);
154 params.type = GetFormatType(params.pixel_format); 164 params.type = GetFormatType(params.pixel_format);
@@ -818,6 +828,11 @@ void CachedSurface::LoadGLBuffer() {
818 if (params.is_tiled) { 828 if (params.is_tiled) {
819 gl_buffer.resize(total_size); 829 gl_buffer.resize(total_size);
820 830
831 ASSERT_MSG(params.block_width == 1, "Block width is defined as {} on texture type {}",
832 params.block_width, static_cast<u32>(params.target));
833 ASSERT_MSG(params.block_depth == 1, "Block depth is defined as {} on texture type {}",
834 params.block_depth, static_cast<u32>(params.target));
835
821 // TODO(bunnei): This only unswizzles and copies a 2D texture - we do not yet know how to do 836 // TODO(bunnei): This only unswizzles and copies a 2D texture - we do not yet know how to do
822 // this for 3D textures, etc. 837 // this for 3D textures, etc.
823 switch (params.target) { 838 switch (params.target) {
@@ -989,7 +1004,9 @@ Surface RasterizerCacheOpenGL::GetDepthBufferSurface(bool preserve_contents) {
989 } 1004 }
990 1005
991 SurfaceParams depth_params{SurfaceParams::CreateForDepthBuffer( 1006 SurfaceParams depth_params{SurfaceParams::CreateForDepthBuffer(
992 regs.zeta_width, regs.zeta_height, regs.zeta.Address(), regs.zeta.format)}; 1007 regs.zeta_width, regs.zeta_height, regs.zeta.Address(), regs.zeta.format,
1008 regs.zeta.block_dimensions.block_width, regs.zeta.block_dimensions.block_height,
1009 regs.zeta.block_dimensions.block_depth)};
993 1010
994 return GetSurface(depth_params, preserve_contents); 1011 return GetSurface(depth_params, preserve_contents);
995} 1012}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 0b4940b3c..542886a6f 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -718,7 +718,8 @@ struct SurfaceParams {
718 /// Creates SurfaceParams for a depth buffer configuration 718 /// Creates SurfaceParams for a depth buffer configuration
719 static SurfaceParams CreateForDepthBuffer(u32 zeta_width, u32 zeta_height, 719 static SurfaceParams CreateForDepthBuffer(u32 zeta_width, u32 zeta_height,
720 Tegra::GPUVAddr zeta_address, 720 Tegra::GPUVAddr zeta_address,
721 Tegra::DepthFormat format); 721 Tegra::DepthFormat format, u32 block_width,
722 u32 block_height, u32 block_depth);
722 723
723 /// Creates SurfaceParams for a Fermi2D surface copy 724 /// Creates SurfaceParams for a Fermi2D surface copy
724 static SurfaceParams CreateForFermiCopySurface( 725 static SurfaceParams CreateForFermiCopySurface(
@@ -733,7 +734,9 @@ struct SurfaceParams {
733 734
734 VAddr addr; 735 VAddr addr;
735 bool is_tiled; 736 bool is_tiled;
737 u32 block_width;
736 u32 block_height; 738 u32 block_height;
739 u32 block_depth;
737 PixelFormat pixel_format; 740 PixelFormat pixel_format;
738 ComponentType component_type; 741 ComponentType component_type;
739 SurfaceType type; 742 SurfaceType type;
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index 8f31d825a..58d17abcb 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -161,7 +161,9 @@ struct TICEntry {
161 BitField<21, 3, TICHeaderVersion> header_version; 161 BitField<21, 3, TICHeaderVersion> header_version;
162 }; 162 };
163 union { 163 union {
164 BitField<0, 3, u32> block_width;
164 BitField<3, 3, u32> block_height; 165 BitField<3, 3, u32> block_height;
166 BitField<6, 3, u32> block_depth;
165 167
166 // High 16 bits of the pitch value 168 // High 16 bits of the pitch value
167 BitField<0, 16, u32> pitch_high; 169 BitField<0, 16, u32> pitch_high;
@@ -202,13 +204,24 @@ struct TICEntry {
202 return depth_minus_1 + 1; 204 return depth_minus_1 + 1;
203 } 205 }
204 206
207 u32 BlockWidth() const {
208 ASSERT(IsTiled());
209 // The block height is stored in log2 format.
210 return 1 << block_width;
211 }
212
205 u32 BlockHeight() const { 213 u32 BlockHeight() const {
206 ASSERT(header_version == TICHeaderVersion::BlockLinear || 214 ASSERT(IsTiled());
207 header_version == TICHeaderVersion::BlockLinearColorKey);
208 // The block height is stored in log2 format. 215 // The block height is stored in log2 format.
209 return 1 << block_height; 216 return 1 << block_height;
210 } 217 }
211 218
219 u32 BlockDepth() const {
220 ASSERT(IsTiled());
221 // The block height is stored in log2 format.
222 return 1 << block_depth;
223 }
224
212 bool IsTiled() const { 225 bool IsTiled() const {
213 return header_version == TICHeaderVersion::BlockLinear || 226 return header_version == TICHeaderVersion::BlockLinear ||
214 header_version == TICHeaderVersion::BlockLinearColorKey; 227 header_version == TICHeaderVersion::BlockLinearColorKey;