From 0184419814981fed918037c136b473d006c84d6e Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 9 Dec 2017 20:23:27 -0800 Subject: [PATCH] Shader: Refactor output_mask copy loop to function --- src/video_core/shader/shader.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 2857d28297..f8b7460e04 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -77,13 +77,18 @@ void UnitState::LoadInput(const ShaderRegs& config, const AttributeBuffer& input } } -void UnitState::WriteOutput(const ShaderRegs& config, AttributeBuffer& output) { - unsigned int output_i = 0; - for (unsigned int reg : Common::BitSet(config.output_mask)) { - output.attr[output_i++] = registers.output[reg]; +static void CopyRegistersToOutput(const Math::Vec4* regs, u32 mask, + AttributeBuffer& buffer) { + int output_i = 0; + for (int reg : Common::BitSet(mask)) { + buffer.attr[output_i++] = regs[reg]; } } +void UnitState::WriteOutput(const ShaderRegs& config, AttributeBuffer& output) { + CopyRegistersToOutput(registers.output, config.output_mask, output); +} + UnitState::UnitState(GSEmitter* emitter) : emitter_ptr(emitter) {} GSEmitter::GSEmitter() { @@ -102,10 +107,7 @@ void GSEmitter::Emit(Math::Vec4 (&vertex)[16]) { handlers->winding_setter(); for (size_t i = 0; i < buffer.size(); ++i) { AttributeBuffer output; - unsigned int output_i = 0; - for (unsigned int reg : Common::BitSet(output_mask)) { - output.attr[output_i++] = buffer[i][reg]; - } + CopyRegistersToOutput(buffer[i].data(), output_mask, output); handlers->vertex_handler(output); } }