mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-27 23:34:18 +01:00
Pica/CommandProcessor: Workaround games not setting the input position's w component.
This commit is contained in:
parent
18a5e888bb
commit
b2d461020d
@ -112,6 +112,10 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||||||
// Initialize data for the current vertex
|
// Initialize data for the current vertex
|
||||||
VertexShader::InputVertex input;
|
VertexShader::InputVertex input;
|
||||||
|
|
||||||
|
// Load a debugging token to check whether this gets loaded by the running
|
||||||
|
// application or not.
|
||||||
|
input.attr[0].w = float24::FromRawFloat24(0x00abcdef);
|
||||||
|
|
||||||
for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
|
for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
|
||||||
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::GetPointer(PAddrToVAddr(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]));
|
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) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// workaround, we force the fourth component to 1.0 if we find this to be the
|
||||||
|
// case.
|
||||||
|
// To do this, we additionally have to assume that the first input attribute
|
||||||
|
// is the vertex position, since there's no information about this other than
|
||||||
|
// the empiric observation that this is usually the case.
|
||||||
|
if (input.attr[0].w == float24::FromRawFloat24(0x00abcdef))
|
||||||
|
input.attr[0].w = float24::FromFloat32(1.0);
|
||||||
|
|
||||||
if (g_debug_context)
|
if (g_debug_context)
|
||||||
g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input);
|
g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user