diff options
| author | 2015-05-18 00:44:46 +0200 | |
|---|---|---|
| committer | 2015-05-18 00:44:46 +0200 | |
| commit | 2c721f376498823f1e8929693d84850d4368e411 (patch) | |
| tree | a16ab79b8974dd07f1d1d382f0878e382e76f74a /src | |
| parent | Merge pull request #781 from archshift/delete (diff) | |
| parent | GPU/DefaultAttributes: Clear up a comment in command_processor (diff) | |
| download | yuzu-2c721f376498823f1e8929693d84850d4368e411.tar.gz yuzu-2c721f376498823f1e8929693d84850d4368e411.tar.xz yuzu-2c721f376498823f1e8929693d84850d4368e411.zip | |
Merge pull request #787 from Subv/default_attributes_fallback
GPU/DefaultAttributes: Let the attribute data from the loaders overwrite the default attribs.
Diffstat (limited to 'src')
| -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..6121df8e3 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, this data will be overwritten by the loader data if it's set | ||
| 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 | // Load per-vertex data from the loader arrays |
| 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 | ||