summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2020-07-21 02:17:53 -0400
committerGravatar Lioncash2020-07-21 02:27:22 -0400
commit82b7e5c8ee4cbcb3f73e2875970e2218b7443862 (patch)
tree523130b75bab2ab5c40ead006a83c84d3b5a4a34
parentsurface_params: Remove redundant assignment (diff)
downloadyuzu-82b7e5c8ee4cbcb3f73e2875970e2218b7443862.tar.gz
yuzu-82b7e5c8ee4cbcb3f73e2875970e2218b7443862.tar.xz
yuzu-82b7e5c8ee4cbcb3f73e2875970e2218b7443862.zip
surface_params: Make use of designated initializers where applicable
Provides a convenient way to avoid unnecessary zero initializing.
-rw-r--r--src/video_core/texture_cache/surface_params.cpp84
1 files changed, 46 insertions, 38 deletions
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index ebb6b1f56..9a98f0e98 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -166,27 +166,30 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl
166 166
167SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) { 167SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) {
168 const auto& regs = system.GPU().Maxwell3D().regs; 168 const auto& regs = system.GPU().Maxwell3D().regs;
169 SurfaceParams params;
170 params.is_tiled = regs.zeta.memory_layout.type ==
171 Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear;
172 params.srgb_conversion = false;
173 params.block_width = std::min(regs.zeta.memory_layout.block_width.Value(), 5U);
174 params.block_height = std::min(regs.zeta.memory_layout.block_height.Value(), 5U);
175 params.block_depth = std::min(regs.zeta.memory_layout.block_depth.Value(), 5U);
176 params.tile_width_spacing = 1;
177 params.pixel_format = PixelFormatFromDepthFormat(regs.zeta.format);
178 params.type = GetFormatType(params.pixel_format);
179 params.width = regs.zeta_width;
180 params.height = regs.zeta_height;
181 params.pitch = 0;
182 params.num_levels = 1;
183 params.emulated_levels = 1;
184 169
185 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);
186 params.is_layered = is_layered; 171 const bool is_layered = regs.zeta_layers > 1 && block_depth == 0;
187 params.target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D; 172 const auto pixel_format = PixelFormatFromDepthFormat(regs.zeta.format);
188 params.depth = is_layered ? regs.zeta_layers.Value() : 1U; 173
189 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 };
190} 193}
191 194
192SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::size_t index) { 195SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::size_t index) {
@@ -232,24 +235,29 @@ SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::siz
232 235
233SurfaceParams SurfaceParams::CreateForFermiCopySurface( 236SurfaceParams SurfaceParams::CreateForFermiCopySurface(
234 const Tegra::Engines::Fermi2D::Regs::Surface& config) { 237 const Tegra::Engines::Fermi2D::Regs::Surface& config) {
235 SurfaceParams params{}; 238 const bool is_tiled = !config.linear;
236 params.is_tiled = !config.linear; 239 const auto pixel_format = PixelFormatFromRenderTargetFormat(config.format);
237 params.srgb_conversion = config.format == Tegra::RenderTargetFormat::B8G8R8A8_SRGB || 240
238 config.format == Tegra::RenderTargetFormat::A8B8G8R8_SRGB; 241 SurfaceParams params{
239 params.block_width = params.is_tiled ? std::min(config.BlockWidth(), 5U) : 0; 242 .is_tiled = is_tiled,
240 params.block_height = params.is_tiled ? std::min(config.BlockHeight(), 5U) : 0; 243 .srgb_conversion = config.format == Tegra::RenderTargetFormat::B8G8R8A8_SRGB ||
241 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0; 244 config.format == Tegra::RenderTargetFormat::A8B8G8R8_SRGB,
242 params.tile_width_spacing = 1; 245 .block_width = is_tiled ? std::min(config.BlockWidth(), 5U) : 0U,
243 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 246 .block_height = is_tiled ? std::min(config.BlockHeight(), 5U) : 0U,
244 params.type = GetFormatType(params.pixel_format); 247 .block_depth = is_tiled ? std::min(config.BlockDepth(), 5U) : 0U,
245 params.width = config.width; 248 .tile_width_spacing = 1,
246 params.height = config.height; 249 .width = config.width,
247 params.pitch = config.pitch; 250 .height = config.height,
248 // TODO(Rodrigo): Try to guess texture arrays from parameters 251 .depth = 1,
249 params.target = SurfaceTarget::Texture2D; 252 .pitch = config.pitch,
250 params.depth = 1; 253 .num_levels = 1,
251 params.num_levels = 1; 254 .emulated_levels = 1,
252 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
253 params.is_layered = params.IsLayered(); 261 params.is_layered = params.IsLayered();
254 return params; 262 return params;
255} 263}