Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSX Tricky: Stage select missing foreground graphics #686

Closed
abaire opened this issue Jan 28, 2022 · 7 comments · Fixed by #688
Closed

SSX Tricky: Stage select missing foreground graphics #686

abaire opened this issue Jan 28, 2022 · 7 comments · Fixed by #688
Labels
bug Something isn't working

Comments

@abaire
Copy link
Contributor

abaire commented Jan 28, 2022

Title

https://xemu.app/titles/45410004/#SSX-Tricky

Bug Description

The foreground of the stage select screen is not rendered at all

Screenshot_20220128_083040

Expected Behavior

(Please ignore the glare in the upper left corner, that's an external reflection and not rendered)

ssx_tricky_expected_select

xemu Version

Version: 0.6.2-53-g6b821d2062
Branch: master
Commit: 6b821d2
Date: Mon Jan 24 09:41:21 PM UTC 2022

System Information

OS: Kubuntu 21.04 - 5.11.0-38-generic
CPU: Core i7-6700K @ 4GHz
GPU: NVIDIA GeForce GTX 1070
GPU Driver: 4.6.0 NVIDIA 470.74

Additional Context

No response

@abaire
Copy link
Contributor Author

abaire commented Jan 28, 2022

Capturing with RenderDoc, it looks like the interesting bits start around event ID 7071 (a glDrawElements, indicating that the foreground geometry uses the Inline Elements path)

@abaire
Copy link
Contributor Author

abaire commented Jan 28, 2022

And looking at the mesh, it appears that the output of the vsh is all degenerate triangles for the level indicators.

The inputs to the shader are non-standard. The game enables all 16 attributes, all floats:
v0 is 3 values, presumably vertex position
v1 is 3 values
v2 is 2 values, presumably texcoord0
All other attributes are 4 values, all set to (0, 0, 0, 0)

@abaire
Copy link
Contributor Author

abaire commented Jan 28, 2022

This looks explainable by the shader code itself:

  /* Slot 0: 0x00000000 0x022C401B 0x0836106C 0x3F20E824 */
  MOV(R2,xyzw, v0);
  MOV(oD1,xyz, c[98]); // Irrelevant

  /* Slot 1: 0x00000000 0x00E0161B 0x2436106C 0x20708800 */
  DP4(oPos,x, R2, v11); // v11 - 14 are all vec4(0), so this sets oPos to vec4(0)

  /* Slot 2: 0x00000000 0x00E0181B 0x2436106C 0x20704800 */
  DP4(oPos,y, R2, v12);

  /* Slot 3: 0x00000000 0x00E01A1B 0x2436106C 0x20702800 */
  DP4(oPos,z, R2, v13);

  /* Slot 4: 0x00000000 0x00E01C1B 0x2436106C 0x20701800 */
  DP4(oPos,w, R2, v14);

oPos is not mutated again until the end of the shader:

  MAD(oPos,xyz, R12, R1.x, c[59]);  // R12 == oPos, so vec4(0) * (R1.x, irrelevant) + c[59] = c[59]

resulting in all outputs being the constant passed in slot 59.

Presumably this means there's a problem with how inline elements are being fed to the shader for v12-v14 (maybe they're supposed to default to 1?)

@abaire
Copy link
Contributor Author

abaire commented Jan 30, 2022

I see that it's setting the NV097_SET_VERTEX_DATA_ARRAY_FORMAT for all of the v4 + attributes to have a stride of 0. I'm suspicious that, unlike OpenGL, a stride of 0 might mean to use the first value in the buffer. Glancing at the values for v14, I see that there appears to be one valid entry, followed by 0 entries and potentially unrelated data.

Furthermore, I see that offsets are being set that are exactly attr->size * attr->count apart, meaning the data would all overlap if it really was intended to read beyond the first entry and treat it as tightly packed data.

nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__POS<0x1720> (0xBC204C)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[POSITION{0}] 0xBC204C
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__WEIGHT<0x1724> (0xBC2058)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[WEIGHT{1}] 0xBC2058
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__NORMAL<0x1728> (0xBC2064)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[NORMAL{2}] 0xBC2064
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__DIFFUSE<0x172C> (0x5B23C0)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[DIFFUSE{3}] 0x5B23C0
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__SPECULAR<0x1730> (0x5B23D0)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[SPECULAR{4}] 0x5B23D0
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__FOG_COORD<0x1734> (0x5B23E0)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[FOG{5}] 0x5B23E0
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__POINT_SIZE<0x1738> (0x5B23F0)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[POINT_SIZE{6}] 0x5B23F0
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__BACK_DIFFUSE<0x173C> (0x5B2400)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[BACK_DIFFUSE{7}] 0x5B2400
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__BACK_SPECULAR<0x1740> (0x5B2410)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[BACK_SPECULAR{8}] 0x5B2410
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__TEX0<0x1744> (0x5B2420)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[TEXTURE0{9}] 0x5B2420
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__TEX1<0x1748> (0x5B2430)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[TEXTURE1{10}] 0x5B2430
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__TEX2<0x174C> (0x5B2440)
nv2a: NV097_SET_VERTEX_DATA_ARRAY_OFFSET[TEXTURE2{11}] 0x5B2440
nv2a: pgraph method (0): NV20_KELVIN_PRIMITIVE<0x97> -> NV097_SET_VERTEX_DATA_ARRAY_OFFSET__TEX3<0x1750> (0x5B2450)

@abaire
Copy link
Contributor Author

abaire commented Jan 30, 2022

Did a super quick proof of concept and treating it this way fixes the missing foreground graphics.

@abaire
Copy link
Contributor Author

abaire commented Jan 30, 2022

Also appears to fix #174

@Triticum0
Copy link

@abaire I used a debug build Thousand Land #1026 and it seems to have a simar issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants