From b7a48c422aa7293525909ac7b32575bce8575bde Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 21 Dec 2014 02:49:45 +0100 Subject: Pica/CommandProcessor: Add support for integer uniforms. --- src/video_core/command_processor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 9602779f4..9e1975ddb 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -173,6 +173,19 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { break; + case PICA_REG_INDEX_WORKAROUND(vs_int_uniforms[0], 0x2b1): + case PICA_REG_INDEX_WORKAROUND(vs_int_uniforms[1], 0x2b2): + case PICA_REG_INDEX_WORKAROUND(vs_int_uniforms[2], 0x2b3): + case PICA_REG_INDEX_WORKAROUND(vs_int_uniforms[3], 0x2b4): + { + int index = (id - PICA_REG_INDEX_WORKAROUND(vs_int_uniforms[0], 0x2b1)); + auto values = registers.vs_int_uniforms[index]; + VertexShader::GetIntUniform(index) = Math::Vec4(values.x, values.y, values.z, values.w); + LOG_ERROR(HW_GPU, "Set integer uniform %d to %02x %02x %02x %02x", + index, values.x.Value(), values.y.Value(), values.z.Value(), values.w.Value()); + break; + } + case PICA_REG_INDEX_WORKAROUND(vs_uniform_setup.set_value[0], 0x2c1): case PICA_REG_INDEX_WORKAROUND(vs_uniform_setup.set_value[1], 0x2c2): case PICA_REG_INDEX_WORKAROUND(vs_uniform_setup.set_value[2], 0x2c3): -- cgit v1.2.3 From b2d461020d12b9abf06857747ed237c0c3a6647a Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 21 Dec 2014 03:02:15 +0100 Subject: Pica/CommandProcessor: Workaround games not setting the input position's w component. --- src/video_core/command_processor.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/video_core/command_processor.cpp') 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) { // Initialize data for the current vertex 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 (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])); @@ -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) g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); -- cgit v1.2.3 From 323a56f89835714f0973cf808b7b59b2589012d8 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Wed, 31 Dec 2014 15:01:50 +0100 Subject: Pica/CommandProcessor: Cleanups. --- src/video_core/command_processor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 76acdc177..0d9f4ba66 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -114,7 +114,8 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { // Load a debugging token to check whether this gets loaded by the running // application or not. - input.attr[0].w = float24::FromRawFloat24(0x00abcdef); + static const float24 debug_token = float24::FromRawFloat24(0x00abcdef); + input.attr[0].w = debug_token; for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { @@ -147,7 +148,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { // 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)) + if (input.attr[0].w == debug_token) input.attr[0].w = float24::FromFloat32(1.0); if (g_debug_context) @@ -195,7 +196,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { int index = (id - PICA_REG_INDEX_WORKAROUND(vs_int_uniforms[0], 0x2b1)); auto values = registers.vs_int_uniforms[index]; VertexShader::GetIntUniform(index) = Math::Vec4(values.x, values.y, values.z, values.w); - LOG_ERROR(HW_GPU, "Set integer uniform %d to %02x %02x %02x %02x", + LOG_TRACE(HW_GPU, "Set integer uniform %d to %02x %02x %02x %02x", index, values.x.Value(), values.y.Value(), values.z.Value(), values.w.Value()); break; } -- cgit v1.2.3