summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-12-21 03:02:15 +0100
committerGravatar Tony Wasserka2014-12-31 16:32:55 +0100
commitb2d461020d12b9abf06857747ed237c0c3a6647a (patch)
tree51a0e4d3e24c9c82be6e76843dec4473023ca770 /src/video_core
parentGPU: Pseudo-implement horizontal scaling. (diff)
downloadyuzu-b2d461020d12b9abf06857747ed237c0c3a6647a.tar.gz
yuzu-b2d461020d12b9abf06857747ed237c0c3a6647a.tar.xz
yuzu-b2d461020d12b9abf06857747ed237c0c3a6647a.zip
Pica/CommandProcessor: Workaround games not setting the input position's w component.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/command_processor.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index 9e1975ddb..76acdc177 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -112,6 +112,10 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
112 // Initialize data for the current vertex 112 // Initialize data for the current vertex
113 VertexShader::InputVertex input; 113 VertexShader::InputVertex input;
114 114
115 // Load a debugging token to check whether this gets loaded by the running
116 // application or not.
117 input.attr[0].w = float24::FromRawFloat24(0x00abcdef);
118
115 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { 119 for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
116 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { 120 for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
117 const u8* srcdata = Memory::GetPointer(PAddrToVAddr(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i])); 121 const u8* srcdata = Memory::GetPointer(PAddrToVAddr(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]));
@@ -136,6 +140,16 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
136 } 140 }
137 } 141 }
138 142
143 // HACK: Some games do not initialize the vertex position's w component. This leads
144 // to critical issues since it messes up perspective division. As a
145 // workaround, we force the fourth component to 1.0 if we find this to be the
146 // case.
147 // To do this, we additionally have to assume that the first input attribute
148 // is the vertex position, since there's no information about this other than
149 // the empiric observation that this is usually the case.
150 if (input.attr[0].w == float24::FromRawFloat24(0x00abcdef))
151 input.attr[0].w = float24::FromFloat32(1.0);
152
139 if (g_debug_context) 153 if (g_debug_context)
140 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); 154 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input);
141 155