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

VideoCommon: Fix direct normal+tangent+binormal with index3 set #10808

Merged

Conversation

Pokechu22
Copy link
Contributor

Fixes https://bugs.dolphin-emu.org/issues/12952. I haven't tested the ARM change at all other than verifying that it compiles (so it's probably completely broken), but I have tested the x64 change.

@Pokechu22 Pokechu22 marked this pull request as ready for review July 5, 2022 04:24
@Pokechu22
Copy link
Contributor Author

JMC's testing indicates that this works correctly on android, too (quake GX is fixed, while rs2.dff and RogueSquadron3Bumpmapping.dff both render correctly).

@JMC47
Copy link
Contributor

JMC47 commented Jul 5, 2022

I don't think there's any other games that uses this, unfortunately, not even the Rogue Squadron games.

Copy link
Contributor

@JMC47 JMC47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and verified to work on both Android and Desktop

@Pokechu22 Pokechu22 changed the title VideoCommon: Fix direct normal+tangent+binormal with index3 set VideoCommon: Fix direct normal+tangent+binormal with index3 set Jul 6, 2022
@Pokechu22 Pokechu22 requested a review from JosJuice July 6, 2022 23:40
@Pokechu22 Pokechu22 marked this pull request as draft July 14, 2022 22:17
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch 2 times, most recently from 88a71cb to 01eb1f6 Compare July 15, 2022 19:31
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch from 01eb1f6 to 1e52eb1 Compare July 15, 2022 20:26
@Pokechu22 Pokechu22 marked this pull request as ready for review July 15, 2022 20:39
Source/Core/Common/Arm64Emitter.cpp Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VertexLoaderARM64.cpp Outdated Show resolved Hide resolved
Source/Core/VideoCommon/VertexLoaderARM64.cpp Show resolved Hide resolved
@JosJuice
Copy link
Member

AArch64 LGTM other than above nits.

@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch 2 times, most recently from 7c9eb69 to c723e99 Compare July 23, 2022 06:25
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch from c723e99 to 267bdf8 Compare July 25, 2022 18:48
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch 3 times, most recently from 48359f0 to 7f20831 Compare August 10, 2022 18:19
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch from 7f20831 to ca44305 Compare August 25, 2022 01:34
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch 2 times, most recently from 4bbfc40 to 5a87989 Compare September 14, 2022 23:05
We have one that does a similar thing, but only to measure speed and uses indices. This one verifies accuracy (and uses the largest possible input size by using direct components).
This currently fails for direct with NormalIndex3 enabled (see https://bugs.dolphin-emu.org/issues/12952). The goal of this test is to be able to confidently say that that bug has been fixed.
Before, unaligned values would be silently ignored in most cases.
The source and destination offsets will always be less than 255, so we can get rid of a lot of the complexity by doing this.
This way it more closely matches VertexLoaderX64, and is in general easier to understand.
…Vertex

This also means that both a register and a vertex are always specified, though right now if the register is scratch1_reg the offset is always 0.
@Pokechu22 Pokechu22 force-pushed the vertex-loader-direct-normals-with-index3 branch from 5a87989 to d80201a Compare September 19, 2022 06:33
@dolphin-emu-bot
Copy link
Contributor

FifoCI detected that this change impacts graphical rendering. Here are the behavior differences detected by the system:

  • quake-gx on ogl-lin-mesa: diff
  • quake-gx on sw-lin-mesa: diff
  • quake-gx on ogl-lin-radeon: diff
  • quake-gx on uberogl-lin-radeon: diff

automated-fifoci-reporter

@JMC47 JMC47 merged commit 3b10bf0 into dolphin-emu:master Sep 19, 2022
11 checks passed
@AdmiralCurtiss
Copy link
Contributor

#11058 (comment) looks more likely related to this PR.

@Pokechu22
Copy link
Contributor Author

That does look like the assertion is being actually violated, so there probably was a bug beforehand that's only being exposed now, but without a stacktrace I can't tell where that number comes from.

@dvessel
Copy link
Contributor

dvessel commented Sep 20, 2022

but without a stacktrace I can't tell where that number comes from.

Will this do?

31:53:683 Common/Arm64Emitter.cpp:537 E[JIT]: Warning: An error occurred.

64-bit load/store must use aligned offset: 1892

  Condition: (imm & 0x7) == 0
  File: /Users/foo/Projects/mac/dolphin/Source/Core/Common/Arm64Emitter.cpp
  Line: 537
  Function: EncodeLoadStoreIndexedInst

Ignore and continue?
Process 31192 stopped
* thread #21, name = 'CPU-GPU thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x101ab59d8)
    frame #0: 0x0000000101ab59d8 Dolphin`Arm64Gen::ARM64XEmitter::EncodeLoadStoreIndexedInst(this=0x0000000128cc8000, op=996, Rt=X25, Rn=X29, imm=1892, size='@') at Arm64Emitter.cpp:537:5
   534
   535 	  if (size == 64)
   536 	  {
-> 537 	    ASSERT_MSG(DYNA_REC, (imm & 0x7) == 0, "64-bit load/store must use aligned offset: {}", imm);
   538 	    imm >>= 3;
   539 	  }
   540 	  else if (size == 32)
Target 0: (Dolphin) stopped.
(lldb) bt
* thread #21, name = 'CPU-GPU thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x101ab59d8)
  * frame #0: 0x0000000101ab59d8 Dolphin`Arm64Gen::ARM64XEmitter::EncodeLoadStoreIndexedInst(this=0x0000000128cc8000, op=996, Rt=X25, Rn=X29, imm=1892, size='@') at Arm64Emitter.cpp:537:5
    frame #1: 0x0000000101abb6e8 Dolphin`Arm64Gen::ARM64XEmitter::STR(this=0x0000000128cc8000, type=Unsigned, Rt=X25, Rn=X29, imm=1892) at Arm64Emitter.cpp:1681:5
    frame #2: 0x0000000100ba5ab8 Dolphin`JitArm64::mfspr(this=0x0000000128cc8000, inst=UGeckoInstruction @ 0x000000015f7ff8ec) at JitArm64_SystemRegisters.cpp:338:5
    frame #3: 0x0000000100ba61f4 Dolphin`JitArm64::mftb(this=0x0000000128cc8000, inst=UGeckoInstruction @ 0x000000015f7ff92c) at JitArm64_SystemRegisters.cpp:408:3
    frame #4: 0x0000000100baabb8 Dolphin`JitArm64::DynaRunTable31(this=0x0000000128cc8000, inst=UGeckoInstruction @ 0x000000015f7ff97c) at JitArm64_Tables.cpp:478:3
    frame #5: 0x0000000100baadd0 Dolphin`JitArm64::CompileInstruction(this=0x0000000128cc8000, op=0x0000000128d500c0) at JitArm64_Tables.cpp:493:3
    frame #6: 0x0000000100b668c8 Dolphin`JitArm64::DoJit(this=0x0000000128cc8000, em_address=2148005684, b=0x0000600003945af8, nextPC=2148005648) at Jit.cpp:961:7
    frame #7: 0x0000000100b6531c Dolphin`JitArm64::Jit(this=0x0000000128cc8000, em_address=2148005684, clear_cache_and_retry_on_failure=true) at Jit.cpp:684:9
    frame #8: 0x0000000100b64f5c Dolphin`JitArm64::Jit(this=0x0000000128cc8000, em_address=2148005684) at Jit.cpp:616:3
    frame #9: 0x0000000100bb5e88 Dolphin`JitTrampoline(jit=0x0000000128cc8000, em_address=2148005684) at JitBase.cpp:22:7
    frame #10: 0x0000000172a090b4

@JosJuice
Copy link
Member

I'll take on this issue.

@shuffle2
Copy link
Contributor

fwiw this PR seems to have broken nightly-generic buildbot https://dolphin.ci/#/builders/23

@delroth
Copy link
Member

delroth commented Jan 12, 2023

More accurately, AFAICT, this PR is missing a generic implementation of the fix it implemented (and added tests for). The newly broken tests just reflect the fact that generic is missing the bug fix.

@Pokechu22
Copy link
Contributor Author

That's weird, as I locally tested it against the generic/non-JIT/software vertex loader, as it was initially not broken.

It looks like what happened is that I tested via defining #define COMPARE_VERTEXLOADERS in VertexLoaderBase, but if the two vertex loaders generate different data, it uses the JIT vertex loader and the error messages don't end up in the test output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
9 participants