summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-12-07 00:25:51 +0100
committerGravatar Tony Wasserka2014-12-20 18:06:54 +0100
commit1e960e9ee280eff2e94873bfc6f888a1ccbc30a4 (patch)
treeaf4a10939e73df3f67dcc84c60e1d6b3208e0362 /src
parentAdd support for a ridiculous number of texture formats. (diff)
downloadyuzu-1e960e9ee280eff2e94873bfc6f888a1ccbc30a4.tar.gz
yuzu-1e960e9ee280eff2e94873bfc6f888a1ccbc30a4.tar.xz
yuzu-1e960e9ee280eff2e94873bfc6f888a1ccbc30a4.zip
Pica/CommandProcessor: Fix vertex decoding if multiple memory areas are accessed for different attributes.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/command_processor.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index 3d06ac7e6..d4559fad6 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -56,10 +56,11 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
56 g_debug_context->OnEvent(DebugContext::Event::IncomingPrimitiveBatch, nullptr); 56 g_debug_context->OnEvent(DebugContext::Event::IncomingPrimitiveBatch, nullptr);
57 57
58 const auto& attribute_config = registers.vertex_attributes; 58 const auto& attribute_config = registers.vertex_attributes;
59 const u8* const base_address = Memory::GetPointer(PAddrToVAddr(attribute_config.GetPhysicalBaseAddress())); 59 const u32 base_address = attribute_config.GetPhysicalBaseAddress();
60 60
61 // Information about internal vertex attributes 61 // Information about internal vertex attributes
62 const u8* vertex_attribute_sources[16]; 62 u32 vertex_attribute_sources[16];
63 std::fill(vertex_attribute_sources, &vertex_attribute_sources[16], 0xdeadbeef);
63 u32 vertex_attribute_strides[16]; 64 u32 vertex_attribute_strides[16];
64 u32 vertex_attribute_formats[16]; 65 u32 vertex_attribute_formats[16];
65 u32 vertex_attribute_elements[16]; 66 u32 vertex_attribute_elements[16];
@@ -69,7 +70,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
69 for (int loader = 0; loader < 12; ++loader) { 70 for (int loader = 0; loader < 12; ++loader) {
70 const auto& loader_config = attribute_config.attribute_loaders[loader]; 71 const auto& loader_config = attribute_config.attribute_loaders[loader];
71 72
72 const u8* load_address = base_address + loader_config.data_offset; 73 u32 load_address = base_address + loader_config.data_offset;
73 74
74 // TODO: What happens if a loader overwrites a previous one's data? 75 // TODO: What happens if a loader overwrites a previous one's data?
75 for (unsigned component = 0; component < loader_config.component_count; ++component) { 76 for (unsigned component = 0; component < loader_config.component_count; ++component) {
@@ -87,7 +88,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
87 bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); 88 bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed));
88 89
89 const auto& index_info = registers.index_array; 90 const auto& index_info = registers.index_array;
90 const u8* index_address_8 = (u8*)base_address + index_info.offset; 91 const u8* index_address_8 = Memory::GetPointer(PAddrToVAddr(base_address + index_info.offset));
91 const u16* index_address_16 = (u16*)index_address_8; 92 const u16* index_address_16 = (u16*)index_address_8;
92 bool index_u16 = (bool)index_info.format; 93 bool index_u16 = (bool)index_info.format;
93 94
@@ -108,7 +109,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
108 109
109 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { 110 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
110 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { 111 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
111 const u8* srcdata = vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]; 112 const u8* srcdata = Memory::GetPointer(PAddrToVAddr(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]));
112 const float srcval = (vertex_attribute_formats[i] == 0) ? *(s8*)srcdata : 113 const float srcval = (vertex_attribute_formats[i] == 0) ? *(s8*)srcdata :
113 (vertex_attribute_formats[i] == 1) ? *(u8*)srcdata : 114 (vertex_attribute_formats[i] == 1) ? *(u8*)srcdata :
114 (vertex_attribute_formats[i] == 2) ? *(s16*)srcdata : 115 (vertex_attribute_formats[i] == 2) ? *(s16*)srcdata :
@@ -116,9 +117,9 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
116 input.attr[i][comp] = float24::FromFloat32(srcval); 117 input.attr[i][comp] = float24::FromFloat32(srcval);
117 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", 118 LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f",
118 comp, i, vertex, index, 119 comp, i, vertex, index,
119 PAddrToVAddr(attribute_config.GetPhysicalBaseAddress()), 120 attribute_config.GetPhysicalBaseAddress(),
120 vertex_attribute_sources[i] - base_address, 121 vertex_attribute_sources[i] - base_address,
121 srcdata - vertex_attribute_sources[i], 122 vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i],
122 input.attr[i][comp].ToFloat32()); 123 input.attr[i][comp].ToFloat32());
123 } 124 }
124 } 125 }