summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Henrik Rydgard2016-04-28 18:07:34 +0200
committerGravatar Henrik Rydgard2016-04-28 18:07:34 +0200
commit0cf15f64efe0c2dff67d27aac41def4dbcf44262 (patch)
treeaeb88b643449670c7e7d1fa6005130cd9d086c99 /src
parentMerge pull request #1576 from smspillaz/fix-build-errors-03272016 (diff)
downloadyuzu-0cf15f64efe0c2dff67d27aac41def4dbcf44262.tar.gz
yuzu-0cf15f64efe0c2dff67d27aac41def4dbcf44262.tar.xz
yuzu-0cf15f64efe0c2dff67d27aac41def4dbcf44262.zip
Remove late accesses to attribute_config
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_processor.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index 3abe79c09..8030d17a7 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -198,6 +198,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
198 198
199 const auto& attribute_config = regs.vertex_attributes; 199 const auto& attribute_config = regs.vertex_attributes;
200 const u32 base_address = attribute_config.GetPhysicalBaseAddress(); 200 const u32 base_address = attribute_config.GetPhysicalBaseAddress();
201 int num_total_attributes = attribute_config.GetNumTotalAttributes();
201 202
202 // Information about internal vertex attributes 203 // Information about internal vertex attributes
203 u32 vertex_attribute_sources[16]; 204 u32 vertex_attribute_sources[16];
@@ -207,7 +208,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
207 208
208 u32 vertex_attribute_elements[16] = {}; 209 u32 vertex_attribute_elements[16] = {};
209 u32 vertex_attribute_element_size[16] = {}; 210 u32 vertex_attribute_element_size[16] = {};
210 211 bool vertex_attribute_default[16] = {};
211 // Setup attribute data from loaders 212 // Setup attribute data from loaders
212 for (int loader = 0; loader < 12; ++loader) { 213 for (int loader = 0; loader < 12; ++loader) {
213 const auto& loader_config = attribute_config.attribute_loaders[loader]; 214 const auto& loader_config = attribute_config.attribute_loaders[loader];
@@ -230,6 +231,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
230 vertex_attribute_formats[attribute_index] = attribute_config.GetFormat(attribute_index); 231 vertex_attribute_formats[attribute_index] = attribute_config.GetFormat(attribute_index);
231 vertex_attribute_elements[attribute_index] = attribute_config.GetNumElements(attribute_index); 232 vertex_attribute_elements[attribute_index] = attribute_config.GetNumElements(attribute_index);
232 vertex_attribute_element_size[attribute_index] = element_size; 233 vertex_attribute_element_size[attribute_index] = element_size;
234 vertex_attribute_default[attribute_index] = attribute_config.IsDefaultAttribute(attribute_index);
233 offset += attribute_config.GetStride(attribute_index); 235 offset += attribute_config.GetStride(attribute_index);
234 } else if (attribute_index < 16) { 236 } else if (attribute_index < 16) {
235 // Attribute ids 12, 13, 14 and 15 signify 4, 8, 12 and 16-byte paddings, respectively 237 // Attribute ids 12, 13, 14 and 15 signify 4, 8, 12 and 16-byte paddings, respectively
@@ -333,7 +335,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
333 // Initialize data for the current vertex 335 // Initialize data for the current vertex
334 Shader::InputVertex input; 336 Shader::InputVertex input;
335 337
336 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { 338 for (int i = 0; i < num_total_attributes; ++i) {
337 if (vertex_attribute_elements[i] != 0) { 339 if (vertex_attribute_elements[i] != 0) {
338 // Default attribute values set if array elements have < 4 components. This 340 // Default attribute values set if array elements have < 4 components. This
339 // is *not* carried over from the default attribute settings even if they're 341 // is *not* carried over from the default attribute settings even if they're
@@ -362,12 +364,12 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
362 input.attr[i][comp] = float24::FromFloat32(srcval); 364 input.attr[i][comp] = float24::FromFloat32(srcval);
363 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08x + 0x%04x: %f", 365 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08x + 0x%04x: %f",
364 comp, i, vertex, index, 366 comp, i, vertex, index,
365 attribute_config.GetPhysicalBaseAddress(), 367 base_address,
366 vertex_attribute_sources[i] - base_address, 368 vertex_attribute_sources[i] - base_address,
367 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i], 369 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i],
368 input.attr[i][comp].ToFloat32()); 370 input.attr[i][comp].ToFloat32());
369 } 371 }
370 } else if (attribute_config.IsDefaultAttribute(i)) { 372 } else if (vertex_attribute_default[i]) {
371 // Load the default attribute if we're configured to do so 373 // Load the default attribute if we're configured to do so
372 input.attr[i] = g_state.vs.default_attributes[i]; 374 input.attr[i] = g_state.vs.default_attributes[i];
373 LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)", 375 LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)",
@@ -385,7 +387,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
385 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); 387 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input);
386 388
387 // Send to vertex shader 389 // Send to vertex shader
388 output = Shader::Run(shader_unit, input, attribute_config.GetNumTotalAttributes()); 390 output = Shader::Run(shader_unit, input, num_total_attributes);
389 391
390 if (is_indexed) { 392 if (is_indexed) {
391 vertex_cache[vertex_cache_pos] = output; 393 vertex_cache[vertex_cache_pos] = output;