2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #4703 from lioncash/desig7

shader/registry: Make use of designated initializers where applicable
This commit is contained in:
bunnei 2020-09-26 15:23:15 -07:00 committed by GitHub
commit 442096298e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 25 deletions

View file

@ -24,44 +24,45 @@ GraphicsInfo MakeGraphicsInfo(ShaderType shader_stage, ConstBufferEngineInterfac
if (shader_stage == ShaderType::Compute) { if (shader_stage == ShaderType::Compute) {
return {}; return {};
} }
auto& graphics = static_cast<Tegra::Engines::Maxwell3D&>(engine);
GraphicsInfo info; auto& graphics = dynamic_cast<Tegra::Engines::Maxwell3D&>(engine);
info.tfb_layouts = graphics.regs.tfb_layouts;
info.tfb_varying_locs = graphics.regs.tfb_varying_locs; return {
info.primitive_topology = graphics.regs.draw.topology; .tfb_layouts = graphics.regs.tfb_layouts,
info.tessellation_primitive = graphics.regs.tess_mode.prim; .tfb_varying_locs = graphics.regs.tfb_varying_locs,
info.tessellation_spacing = graphics.regs.tess_mode.spacing; .primitive_topology = graphics.regs.draw.topology,
info.tfb_enabled = graphics.regs.tfb_enabled; .tessellation_primitive = graphics.regs.tess_mode.prim,
info.tessellation_clockwise = graphics.regs.tess_mode.cw; .tessellation_spacing = graphics.regs.tess_mode.spacing,
return info; .tfb_enabled = graphics.regs.tfb_enabled != 0,
.tessellation_clockwise = graphics.regs.tess_mode.cw.Value() != 0,
};
} }
ComputeInfo MakeComputeInfo(ShaderType shader_stage, ConstBufferEngineInterface& engine) { ComputeInfo MakeComputeInfo(ShaderType shader_stage, ConstBufferEngineInterface& engine) {
if (shader_stage != ShaderType::Compute) { if (shader_stage != ShaderType::Compute) {
return {}; return {};
} }
auto& compute = static_cast<Tegra::Engines::KeplerCompute&>(engine);
auto& compute = dynamic_cast<Tegra::Engines::KeplerCompute&>(engine);
const auto& launch = compute.launch_description; const auto& launch = compute.launch_description;
ComputeInfo info; return {
info.workgroup_size = {launch.block_dim_x, launch.block_dim_y, launch.block_dim_z}; .workgroup_size = {launch.block_dim_x, launch.block_dim_y, launch.block_dim_z},
info.local_memory_size_in_words = launch.local_pos_alloc; .shared_memory_size_in_words = launch.shared_alloc,
info.shared_memory_size_in_words = launch.shared_alloc; .local_memory_size_in_words = launch.local_pos_alloc,
return info; };
} }
} // Anonymous namespace } // Anonymous namespace
Registry::Registry(Tegra::Engines::ShaderType shader_stage, const SerializedRegistryInfo& info) Registry::Registry(ShaderType shader_stage, const SerializedRegistryInfo& info)
: stage{shader_stage}, stored_guest_driver_profile{info.guest_driver_profile}, : stage{shader_stage}, stored_guest_driver_profile{info.guest_driver_profile},
bound_buffer{info.bound_buffer}, graphics_info{info.graphics}, compute_info{info.compute} {} bound_buffer{info.bound_buffer}, graphics_info{info.graphics}, compute_info{info.compute} {}
Registry::Registry(Tegra::Engines::ShaderType shader_stage, Registry::Registry(ShaderType shader_stage, ConstBufferEngineInterface& engine_)
Tegra::Engines::ConstBufferEngineInterface& engine) : stage{shader_stage}, engine{&engine_}, bound_buffer{engine_.GetBoundBuffer()},
: stage{shader_stage}, engine{&engine}, bound_buffer{engine.GetBoundBuffer()}, graphics_info{MakeGraphicsInfo(shader_stage, engine_)}, compute_info{MakeComputeInfo(
graphics_info{MakeGraphicsInfo(shader_stage, engine)}, compute_info{MakeComputeInfo( shader_stage, engine_)} {}
shader_stage, engine)} {}
Registry::~Registry() = default; Registry::~Registry() = default;
@ -113,8 +114,7 @@ std::optional<Tegra::Engines::SamplerDescriptor> Registry::ObtainSeparateSampler
return value; return value;
} }
std::optional<Tegra::Engines::SamplerDescriptor> Registry::ObtainBindlessSampler(u32 buffer, std::optional<SamplerDescriptor> Registry::ObtainBindlessSampler(u32 buffer, u32 offset) {
u32 offset) {
const std::pair key = {buffer, offset}; const std::pair key = {buffer, offset};
const auto iter = bindless_samplers.find(key); const auto iter = bindless_samplers.find(key);
if (iter != bindless_samplers.end()) { if (iter != bindless_samplers.end()) {

View file

@ -94,7 +94,7 @@ public:
explicit Registry(Tegra::Engines::ShaderType shader_stage, const SerializedRegistryInfo& info); explicit Registry(Tegra::Engines::ShaderType shader_stage, const SerializedRegistryInfo& info);
explicit Registry(Tegra::Engines::ShaderType shader_stage, explicit Registry(Tegra::Engines::ShaderType shader_stage,
Tegra::Engines::ConstBufferEngineInterface& engine); Tegra::Engines::ConstBufferEngineInterface& engine_);
~Registry(); ~Registry();