surface_params: Make use of designated initializers where applicable

Provides a convenient way to avoid unnecessary zero initializing.
This commit is contained in:
Lioncash 2020-07-21 02:17:53 -04:00
parent bd9545a3a8
commit 82b7e5c8ee

View File

@ -166,27 +166,30 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl
SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) { SurfaceParams SurfaceParams::CreateForDepthBuffer(Core::System& system) {
const auto& regs = system.GPU().Maxwell3D().regs; const auto& regs = system.GPU().Maxwell3D().regs;
SurfaceParams params;
params.is_tiled = regs.zeta.memory_layout.type ==
Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear;
params.srgb_conversion = false;
params.block_width = std::min(regs.zeta.memory_layout.block_width.Value(), 5U);
params.block_height = std::min(regs.zeta.memory_layout.block_height.Value(), 5U);
params.block_depth = std::min(regs.zeta.memory_layout.block_depth.Value(), 5U);
params.tile_width_spacing = 1;
params.pixel_format = PixelFormatFromDepthFormat(regs.zeta.format);
params.type = GetFormatType(params.pixel_format);
params.width = regs.zeta_width;
params.height = regs.zeta_height;
params.pitch = 0;
params.num_levels = 1;
params.emulated_levels = 1;
const bool is_layered = regs.zeta_layers > 1 && params.block_depth == 0; const auto block_depth = std::min(regs.zeta.memory_layout.block_depth.Value(), 5U);
params.is_layered = is_layered; const bool is_layered = regs.zeta_layers > 1 && block_depth == 0;
params.target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D; const auto pixel_format = PixelFormatFromDepthFormat(regs.zeta.format);
params.depth = is_layered ? regs.zeta_layers.Value() : 1U;
return params; return {
.is_tiled = regs.zeta.memory_layout.type ==
Tegra::Engines::Maxwell3D::Regs::InvMemoryLayout::BlockLinear,
.srgb_conversion = false,
.is_layered = is_layered,
.block_width = std::min(regs.zeta.memory_layout.block_width.Value(), 5U),
.block_height = std::min(regs.zeta.memory_layout.block_height.Value(), 5U),
.block_depth = block_depth,
.tile_width_spacing = 1,
.width = regs.zeta_width,
.height = regs.zeta_height,
.depth = is_layered ? regs.zeta_layers.Value() : 1U,
.pitch = 0,
.num_levels = 1,
.emulated_levels = 1,
.pixel_format = pixel_format,
.type = GetFormatType(pixel_format),
.target = is_layered ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D,
};
} }
SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::size_t index) { SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::size_t index) {
@ -232,24 +235,29 @@ SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::siz
SurfaceParams SurfaceParams::CreateForFermiCopySurface( SurfaceParams SurfaceParams::CreateForFermiCopySurface(
const Tegra::Engines::Fermi2D::Regs::Surface& config) { const Tegra::Engines::Fermi2D::Regs::Surface& config) {
SurfaceParams params{}; const bool is_tiled = !config.linear;
params.is_tiled = !config.linear; const auto pixel_format = PixelFormatFromRenderTargetFormat(config.format);
params.srgb_conversion = config.format == Tegra::RenderTargetFormat::B8G8R8A8_SRGB ||
config.format == Tegra::RenderTargetFormat::A8B8G8R8_SRGB; SurfaceParams params{
params.block_width = params.is_tiled ? std::min(config.BlockWidth(), 5U) : 0; .is_tiled = is_tiled,
params.block_height = params.is_tiled ? std::min(config.BlockHeight(), 5U) : 0; .srgb_conversion = config.format == Tegra::RenderTargetFormat::B8G8R8A8_SRGB ||
params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0; config.format == Tegra::RenderTargetFormat::A8B8G8R8_SRGB,
params.tile_width_spacing = 1; .block_width = is_tiled ? std::min(config.BlockWidth(), 5U) : 0U,
params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); .block_height = is_tiled ? std::min(config.BlockHeight(), 5U) : 0U,
params.type = GetFormatType(params.pixel_format); .block_depth = is_tiled ? std::min(config.BlockDepth(), 5U) : 0U,
params.width = config.width; .tile_width_spacing = 1,
params.height = config.height; .width = config.width,
params.pitch = config.pitch; .height = config.height,
// TODO(Rodrigo): Try to guess texture arrays from parameters .depth = 1,
params.target = SurfaceTarget::Texture2D; .pitch = config.pitch,
params.depth = 1; .num_levels = 1,
params.num_levels = 1; .emulated_levels = 1,
params.emulated_levels = 1; .pixel_format = pixel_format,
.type = GetFormatType(pixel_format),
// TODO(Rodrigo): Try to guess texture arrays from parameters
.target = SurfaceTarget::Texture2D,
};
params.is_layered = params.IsLayered(); params.is_layered = params.IsLayered();
return params; return params;
} }