forked from ShuriZma/suyu
1
0
Fork 0

GPU/DefaultAttributes: Let the attribute data from the loaders overwrite the default attributes, if set.

closes #735
This commit is contained in:
Subv 2015-05-17 11:52:17 -05:00
parent 9fb9750411
commit 658c44af5c
1 changed files with 21 additions and 19 deletions

View File

@ -74,11 +74,11 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
// Information about internal vertex attributes // Information about internal vertex attributes
u32 vertex_attribute_sources[16]; u32 vertex_attribute_sources[16];
boost::fill(vertex_attribute_sources, 0xdeadbeef); boost::fill(vertex_attribute_sources, 0xdeadbeef);
u32 vertex_attribute_strides[16]; u32 vertex_attribute_strides[16] = {};
Regs::VertexAttributeFormat vertex_attribute_formats[16]; Regs::VertexAttributeFormat vertex_attribute_formats[16] = {};
u32 vertex_attribute_elements[16]; u32 vertex_attribute_elements[16] = {};
u32 vertex_attribute_element_size[16]; u32 vertex_attribute_element_size[16] = {};
// Setup attribute data from loaders // Setup attribute data from loaders
for (int loader = 0; loader < 12; ++loader) { for (int loader = 0; loader < 12; ++loader) {
@ -127,13 +127,16 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
input.attr[0].w = debug_token; input.attr[0].w = debug_token;
for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { 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)) { if (attribute_config.IsDefaultAttribute(i)) {
input.attr[i] = VertexShader::GetDefaultAttribute(i); input.attr[i] = VertexShader::GetDefaultAttribute(i);
LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)", LOG_TRACE(HW_GPU, "Loaded default attribute %x for vertex %x (index %x): (%f, %f, %f, %f)",
i, vertex, index, i, vertex, index,
input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(), input.attr[i][0].ToFloat32(), input.attr[i][1].ToFloat32(),
input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32()); input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32());
} else { }
// Overwrite the default data with the loader data if there's any
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { 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 u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]);
@ -151,7 +154,6 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
input.attr[i][comp].ToFloat32()); input.attr[i][comp].ToFloat32());
} }
} }
}
// HACK: Some games do not initialize the vertex position's w component. This leads // HACK: Some games do not initialize the vertex position's w component. This leads
// to critical issues since it messes up perspective division. As a // to critical issues since it messes up perspective division. As a