summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2020-07-29 19:55:44 -0400
committerGravatar GitHub2020-07-29 19:55:44 -0400
commit4c0f6f1bc861cf637093e07d41ae044ca4040b66 (patch)
tree4405e66c5d38ec4c6ad193acd473b8d6139607a9
parentMerge pull request #4372 from Morph1984/remove_context_menu (diff)
parentsurface_params: Make use of designated initializers where applicable (diff)
downloadyuzu-4c0f6f1bc861cf637093e07d41ae044ca4040b66.tar.gz
yuzu-4c0f6f1bc861cf637093e07d41ae044ca4040b66.tar.xz
yuzu-4c0f6f1bc861cf637093e07d41ae044ca4040b66.zip
Merge pull request #4396 from lioncash/comma
surface_params: Replace questionable usages of the comma operator with semicolons
Diffstat (limited to '')
-rw-r--r--src/video_core/texture_cache/surface_params.cpp97
1 files changed, 52 insertions, 45 deletions
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 9e5fe2374..9a98f0e98 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -74,9 +74,9 @@ SurfaceParams SurfaceParams::CreateForTexture(const FormatLookupTable& lookup_ta
74 SurfaceParams params; 74 SurfaceParams params;
75 params.is_tiled = tic.IsTiled(); 75 params.is_tiled = tic.IsTiled();
76 params.srgb_conversion = tic.IsSrgbConversionEnabled(); 76 params.srgb_conversion = tic.IsSrgbConversionEnabled();
77 params.block_width = params.is_tiled ? tic.BlockWidth() : 0, 77 params.block_width = params.is_tiled ? tic.BlockWidth() : 0;
78 params.block_height = params.is_tiled ? tic.BlockHeight() : 0, 78 params.block_height = params.is_tiled ? tic.BlockHeight() : 0;
79 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0, 79 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0;
80 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1; 80 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
81 params.pixel_format = lookup_table.GetPixelFormat( 81 params.pixel_format = lookup_table.GetPixelFormat(
82 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type); 82 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type);
@@ -130,14 +130,13 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl
130 SurfaceParams params; 130 SurfaceParams params;
131 params.is_tiled = tic.IsTiled(); 131 params.is_tiled = tic.IsTiled();
132 params.srgb_conversion = tic.IsSrgbConversionEnabled(); 132 params.srgb_conversion = tic.IsSrgbConversionEnabled();
133 params.block_width = params.is_tiled ? tic.BlockWidth() : 0, 133 params.block_width = params.is_tiled ? tic.BlockWidth() : 0;
134 params.block_height = params.is_tiled ? tic.BlockHeight() : 0, 134 params.block_height = params.is_tiled ? tic.BlockHeight() : 0;
135 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0, 135 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0;
136 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1; 136 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
137 params.pixel_format = lookup_table.GetPixelFormat( 137 params.pixel_format = lookup_table.GetPixelFormat(
138 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type); 138 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type);
139 params.type = GetFormatType(params.pixel_format); 139 params.type = GetFormatType(params.pixel_format);
140 params.type = GetFormatType(params.pixel_format);
141 params.target = ImageTypeToSurfaceTarget(entry.type); 140 params.target = ImageTypeToSurfaceTarget(entry.type);
142 // TODO: on 1DBuffer we should use the tic info. 141 // TODO: on 1DBuffer we should use the tic info.
143 if (tic.IsBuffer()) { 142 if (tic.IsBuffer()) {
@@ -167,27 +166,30 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl
167 166
168SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) { 167SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) {
169 const auto& regs = system.GPU().Maxwell3D().regs; 168 const auto& regs = system.GPU().Maxwell3D().regs;
170 SurfaceParams params;
171 params.is_tiled = regs.zeta.memory_layout.type ==
172 Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear;
173 params.srgb_conversion = false;
174 params.block_width = std::min(regs.zeta.memory_layout.block_width.Value(), 5U);
175 params.block_height = std::min(regs.zeta.memory_layout.block_height.Value(), 5U);
176 params.block_depth = std::min(regs.zeta.memory_layout.block_depth.Value(), 5U);
177 params.tile_width_spacing = 1;
178 params.pixel_format = PixelFormatFromDepthFormat(regs.zeta.format);
179 params.type = GetFormatType(params.pixel_format);
180 params.width = regs.zeta_width;
181 params.height = regs.zeta_height;
182 params.pitch = 0;
183 params.num_levels = 1;
184 params.emulated_levels = 1;
185 169
186 const bool is_layered = regs.zeta_layers > 1 && params.block_depth == 0; 170 const auto block_depth = std::min(regs.zeta.memory_layout.block_depth.Value(), 5U);
187 params.is_layered = is_layered; 171 const bool is_layered = regs.zeta_layers > 1 && block_depth == 0;
188 params.target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D; 172 const auto pixel_format = PixelFormatFromDepthFormat(regs.zeta.format);
189 params.depth = is_layered ? regs.zeta_layers.Value() : 1U; 173
190 return params; 174 return {
175 .is_tiled = regs.zeta.memory_layout.type ==
176 Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear,
177 .srgb_conversion = false,
178 .is_layered = is_layered,
179 .block_width = std::min(regs.zeta.memory_layout.block_width.Value(), 5U),
180 .block_height = std::min(regs.zeta.memory_layout.block_height.Value(), 5U),
181 .block_depth = block_depth,
182 .tile_width_spacing = 1,
183 .width = regs.zeta_width,
184 .height = regs.zeta_height,
185 .depth = is_layered ? regs.zeta_layers.Value() : 1U,
186 .pitch = 0,
187 .num_levels = 1,
188 .emulated_levels = 1,
189 .pixel_format = pixel_format,
190 .type = GetFormatType(pixel_format),
191 .target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D,
192 };
191} 193}
192 194
193SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::size_t index) { 195SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::size_t index) {
@@ -233,24 +235,29 @@ SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::siz
233 235
234SurfaceParams SurfaceParams::CreateForFermiCopySurface( 236SurfaceParams SurfaceParams::CreateForFermiCopySurface(
235 const Tegra::Engines::Fermi2D::Regs::Surface& config) { 237 const Tegra::Engines::Fermi2D::Regs::Surface& config) {
236 SurfaceParams params{}; 238 const bool is_tiled = !config.linear;
237 params.is_tiled = !config.linear; 239 const auto pixel_format = PixelFormatFromRenderTargetFormat(config.format);
238 params.srgb_conversion = config.format == Tegra::RenderTargetFormat::B8G8R8A8_SRGB || 240
239 config.format == Tegra::RenderTargetFormat::A8B8G8R8_SRGB; 241 SurfaceParams params{
240 params.block_width = params.is_tiled ? std::min(config.BlockWidth(), 5U) : 0, 242 .is_tiled = is_tiled,
241 params.block_height = params.is_tiled ? std::min(config.BlockHeight(), 5U) : 0, 243 .srgb_conversion = config.format == Tegra::RenderTargetFormat::B8G8R8A8_SRGB ||
242 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0, 244 config.format == Tegra::RenderTargetFormat::A8B8G8R8_SRGB,
243 params.tile_width_spacing = 1; 245 .block_width = is_tiled ? std::min(config.BlockWidth(), 5U) : 0U,
244 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 246 .block_height = is_tiled ? std::min(config.BlockHeight(), 5U) : 0U,
245 params.type = GetFormatType(params.pixel_format); 247 .block_depth = is_tiled ? std::min(config.BlockDepth(), 5U) : 0U,
246 params.width = config.width; 248 .tile_width_spacing = 1,
247 params.height = config.height; 249 .width = config.width,
248 params.pitch = config.pitch; 250 .height = config.height,
249 // TODO(Rodrigo): Try to guess texture arrays from parameters 251 .depth = 1,
250 params.target = SurfaceTarget::Texture2D; 252 .pitch = config.pitch,
251 params.depth = 1; 253 .num_levels = 1,
252 params.num_levels = 1; 254 .emulated_levels = 1,
253 params.emulated_levels = 1; 255 .pixel_format = pixel_format,
256 .type = GetFormatType(pixel_format),
257 // TODO(Rodrigo): Try to guess texture arrays from parameters
258 .target = SurfaceTarget::Texture2D,
259 };
260
254 params.is_layered = params.IsLayered(); 261 params.is_layered = params.IsLayered();
255 return params; 262 return params;
256} 263}