diff options
author | Subv <subv2112@gmail.com> | 2015-05-17 18:52:17 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2015-05-17 18:52:17 +0200 |
commit | 658c44af5c0ee246413f66e6da27aeeb039c6f41 (patch) | |
tree | dd9d0f01b9afd714cfeb5116ba8a35e7345e571d | |
parent | Merge pull request #781 from archshift/delete (diff) | |
download | yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.gz yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.bz2 yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.lz yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.xz yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.zst yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.zip |
-rw-r--r-- | src/video_core/command_processor.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 1ea7cad07..f24c09733 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -74,11 +74,11 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { // Information about internal vertex attributes u32 vertex_attribute_sources[16]; boost::fill(vertex_attribute_sources, 0xdeadbeef); - u32 vertex_attribute_strides[16]; - Regs::VertexAttributeFormat vertex_attribute_formats[16]; + u32 vertex_attribute_strides[16] = {}; + Regs::VertexAttributeFormat vertex_attribute_formats[16] = {}; - u32 vertex_attribute_elements[16]; - u32 vertex_attribute_element_size[16]; + u32 vertex_attribute_elements[16] = {}; + u32 vertex_attribute_element_size[16] = {}; // Setup attribute data from loaders for (int loader = 0; loader < 12; ++loader) { @@ -127,29 +127,31 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { input.attr[0].w = debug_token; for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { + // Load the default attribute if we're configured to do so if (attribute_config.IsDefaultAttribute(i)) { input.attr[i] = VertexShader::GetDefaultAttribute(i); LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)", i, vertex, index, input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(), input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32()); - } else { - for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { - const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]); - - const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : - (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : - (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata : - *(float*)srcdata; - - input.attr[i][comp] = float24::FromFloat32(srcval); - LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", - comp, i, vertex, index, - attribute_config.GetPhysicalBaseAddress(), - vertex_attribute_sources[i] - base_address, - vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i], - input.attr[i][comp].ToFloat32()); - } + } + + // Overwrite the default data with the loader data if there's any + for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { + const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]); + + const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : + (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : + (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata : + *(float*)srcdata; + + input.attr[i][comp] = float24::FromFloat32(srcval); + LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", + comp, i, vertex, index, + attribute_config.GetPhysicalBaseAddress(), + vertex_attribute_sources[i] - base_address, + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i], + input.attr[i][comp].ToFloat32()); } } |