From d4442d6a0bbdad8049cdbf7eba832b31e5eb1dff Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 16 May 2015 00:13:56 -0700 Subject: [PATCH] vertex_shader.cpp: Convert giant if block to a switch block --- src/video_core/vertex_shader.cpp | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp index 981d1a356..660b1a0ea 100644 --- a/src/video_core/vertex_shader.cpp +++ b/src/video_core/vertex_shader.cpp @@ -589,23 +589,27 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes) { const auto& attribute_register_map = registers.vs_input_register_map; float24 dummy_register; boost::fill(state.input_register_table, &dummy_register); - - if (num_attributes > 0) state.input_register_table[attribute_register_map.attribute0_register] = &input.attr[0].x; - if (num_attributes > 1) state.input_register_table[attribute_register_map.attribute1_register] = &input.attr[1].x; - if (num_attributes > 2) state.input_register_table[attribute_register_map.attribute2_register] = &input.attr[2].x; - if (num_attributes > 3) state.input_register_table[attribute_register_map.attribute3_register] = &input.attr[3].x; - if (num_attributes > 4) state.input_register_table[attribute_register_map.attribute4_register] = &input.attr[4].x; - if (num_attributes > 5) state.input_register_table[attribute_register_map.attribute5_register] = &input.attr[5].x; - if (num_attributes > 6) state.input_register_table[attribute_register_map.attribute6_register] = &input.attr[6].x; - if (num_attributes > 7) state.input_register_table[attribute_register_map.attribute7_register] = &input.attr[7].x; - if (num_attributes > 8) state.input_register_table[attribute_register_map.attribute8_register] = &input.attr[8].x; - if (num_attributes > 9) state.input_register_table[attribute_register_map.attribute9_register] = &input.attr[9].x; - if (num_attributes > 10) state.input_register_table[attribute_register_map.attribute10_register] = &input.attr[10].x; - if (num_attributes > 11) state.input_register_table[attribute_register_map.attribute11_register] = &input.attr[11].x; - if (num_attributes > 12) state.input_register_table[attribute_register_map.attribute12_register] = &input.attr[12].x; - if (num_attributes > 13) state.input_register_table[attribute_register_map.attribute13_register] = &input.attr[13].x; - if (num_attributes > 14) state.input_register_table[attribute_register_map.attribute14_register] = &input.attr[14].x; - if (num_attributes > 15) state.input_register_table[attribute_register_map.attribute15_register] = &input.attr[15].x; + + // Each case inherits all cases underneath it, so we let them fall through. + switch (num_attributes) { + default: + case 16: state.input_register_table[attribute_register_map.attribute15_register] = &input.attr[15].x; + case 15: state.input_register_table[attribute_register_map.attribute14_register] = &input.attr[14].x; + case 14: state.input_register_table[attribute_register_map.attribute13_register] = &input.attr[13].x; + case 13: state.input_register_table[attribute_register_map.attribute12_register] = &input.attr[12].x; + case 12: state.input_register_table[attribute_register_map.attribute11_register] = &input.attr[11].x; + case 11: state.input_register_table[attribute_register_map.attribute10_register] = &input.attr[10].x; + case 10: state.input_register_table[attribute_register_map.attribute9_register] = &input.attr[9].x; + case 9: state.input_register_table[attribute_register_map.attribute8_register] = &input.attr[8].x; + case 8: state.input_register_table[attribute_register_map.attribute7_register] = &input.attr[7].x; + case 7: state.input_register_table[attribute_register_map.attribute6_register] = &input.attr[6].x; + case 6: state.input_register_table[attribute_register_map.attribute5_register] = &input.attr[5].x; + case 5: state.input_register_table[attribute_register_map.attribute4_register] = &input.attr[4].x; + case 4: state.input_register_table[attribute_register_map.attribute3_register] = &input.attr[3].x; + case 3: state.input_register_table[attribute_register_map.attribute2_register] = &input.attr[2].x; + case 2: state.input_register_table[attribute_register_map.attribute1_register] = &input.attr[1].x; + case 1: state.input_register_table[attribute_register_map.attribute0_register] = &input.attr[0].x; + } state.conditional_code[0] = false; state.conditional_code[1] = false;