summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2015-05-17 11:52:17 -0500
committerGravatar Subv2015-05-17 11:52:17 -0500
commit658c44af5c0ee246413f66e6da27aeeb039c6f41 (patch)
treedd9d0f01b9afd714cfeb5116ba8a35e7345e571d /src
parentMerge pull request #781 from archshift/delete (diff)
downloadyuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.gz
yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.tar.xz
yuzu-658c44af5c0ee246413f66e6da27aeeb039c6f41.zip
GPU/DefaultAttributes: Let the attribute data from the loaders overwrite the default attributes, if set.
closes #735
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_processor.cpp44
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) {
74 // Information about internal vertex attributes 74 // Information about internal vertex attributes
75 u32 vertex_attribute_sources[16]; 75 u32 vertex_attribute_sources[16];
76 boost::fill(vertex_attribute_sources, 0xdeadbeef); 76 boost::fill(vertex_attribute_sources, 0xdeadbeef);
77 u32 vertex_attribute_strides[16]; 77 u32 vertex_attribute_strides[16] = {};
78 Regs::VertexAttributeFormat vertex_attribute_formats[16]; 78 Regs::VertexAttributeFormat vertex_attribute_formats[16] = {};
79 79
80 u32 vertex_attribute_elements[16]; 80 u32 vertex_attribute_elements[16] = {};
81 u32 vertex_attribute_element_size[16]; 81 u32 vertex_attribute_element_size[16] = {};
82 82
83 // Setup attribute data from loaders 83 // Setup attribute data from loaders
84 for (int loader = 0; loader < 12; ++loader) { 84 for (int loader = 0; loader < 12; ++loader) {
@@ -127,29 +127,31 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
127 input.attr[0].w = debug_token; 127 input.attr[0].w = debug_token;
128 128
129 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { 129 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
130 // Load the default attribute if we're configured to do so
130 if (attribute_config.IsDefaultAttribute(i)) { 131 if (attribute_config.IsDefaultAttribute(i)) {
131 input.attr[i] = VertexShader::GetDefaultAttribute(i); 132 input.attr[i] = VertexShader::GetDefaultAttribute(i);
132 LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)", 133 LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)",
133 i, vertex, index, 134 i, vertex, index,
134 input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(), 135 input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(),
135 input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32()); 136 input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32());
136 } else { 137 }
137 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { 138
138 const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]); 139 // Overwrite the default data with the loader data if there's any
139 140 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
140 const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : 141 const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]);
141 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : 142
142 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata : 143 const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata :
143 *(float*)srcdata; 144 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata :
144 145 (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? *(s16*)srcdata :
145 input.attr[i][comp] = float24::FromFloat32(srcval); 146 *(float*)srcdata;
146 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", 147
147 comp, i, vertex, index, 148 input.attr[i][comp] = float24::FromFloat32(srcval);
148 attribute_config.GetPhysicalBaseAddress(), 149 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f",
149 vertex_attribute_sources[i] - base_address, 150 comp, i, vertex, index,
150 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i], 151 attribute_config.GetPhysicalBaseAddress(),
151 input.attr[i][comp].ToFloat32()); 152 vertex_attribute_sources[i] - base_address,
152 } 153 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i],
154 input.attr[i][comp].ToFloat32());
153 } 155 }
154 } 156 }
155 157