RPCS3 / rpcs3

PS3 emulator/debugger
https://rpcs3.net/
GNU General Public License v2.0
14.55k stars 1.85k forks source link

DX12: Saint Seiya Brave Soldiers - fragment program compile failure #2050

Closed raven02 closed 6 years ago

raven02 commented 7 years ago

DX12 (Stuck at "Now Loading" scene)

E {rsx::thread} RSX: FS build failed:D:\EMU\PS3\RPCS3.V2\FragmentProgram.hlsl(197,12-55): warning X3570: gradient instruction used in a loop with varying iteration, attempting to unroll the loop
D:\EMU\PS3\RPCS3.V2\FragmentProgram.hlsl(188,3-36): error X3511: unable to unroll loop, loop does not appear to terminate in a timely manner (248 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number

F {rsx::thread} class std::runtime_error thrown: fragment program compilation failure
(in file c:\rpcs3\rpcs3\emu\rsx\d3d12\D3D12PipelineState.h:162)

untitled

ikki84 commented 7 years ago

@raven02 OpenGL and Vulkan goes further now (tested with fcb85379) https://ci.appveyor.com/api/buildjobs/bvjdcpmxcq0nb0j2/artifacts/rpcs3-ReleaseLLVM-fcb85379.zip

ssbs2 ssbs3

-The black shadow at the side of the clothes appears to be an attempt to render the model without the clothes... -DX12 still stucks at the loading screen

ikki84 commented 7 years ago

It´s affects (Saint Seiya - Soldier´s Soul [BLES02181]) the same way.

off-topic - the game (Saint Seiya: Sanctuary Battle [BLES-01421]) is running in the last builds (i don´t know since when it start running), and the characters clothes are all kind of white (in OpenGL). Maybe its also related to the issue #2178. Vulkan and DX12 is a totally mess on the screen.

@raven02 @kd-11

raven02 commented 7 years ago

@ikki84 , just wonder which LLEs are required to in-game .

ikki84 commented 7 years ago

I will list here all that are selected:

-libdmux , libdmuxpamf -libfiber -libfont , libfontFT -libfreetype , libfreetypeTT -libresc -libspurs_jq -libsre

*Also fonts files are in "/dev_flash/data/font"

raven02 commented 7 years ago

Thanks @ikki84

ikki84 commented 7 years ago

@raven02 Thank you and all the developers of rpcs3. The emulator is making progress :)

ikki84 commented 7 years ago

I was testing this game again, the last build it was working is:

RPCS3 v0.0.1-3-8454949 Pre-Alpha: https://ci.appveyor.com/api/buildjobs/hb0slyqiyw809da8/artifacts/rpcs3-ReleaseLLVM-8454949e.zip

Since then all the master builds stopped working, using the lle modules that I listed above.

In a build that is not merged yet it became to work again with some regressions:

RPCS3 v0.0.1-3-123f51d Pre-Alpha https://ci.appveyor.com/api/buildjobs/7qol4mha9p7iur94/artifacts/rpcs3-ReleaseLLVM-123f51d5.zip

*The title screen miss the background (looks like the front part its hidding it) and the saint´s clothes are flickering and changing position all the time.

RPCS3 v0.0.1-3-8454949 Pre-Alpha:

title screen rpcs3 v0 0 1-3-8454949 pre-alpha character select rpcs3 v0 0 1-3-8454949 pre-alpha

RPCS3 v0.0.1-3-123f51d Pre-Alpha:

title screen - rpcs3 v0 0 1-3-123f51d pre-alpha character select - 1 rpcs3 v0 0 1-3-123f51d pre-alpha character select -2 rpcs3 v0 0 1-3-123f51d pre-alpha

Logs: log RPCS3 v0.0.1-3-8454949 Pre-Alpha.txt log RPCS3 v0.0.1-3-123f51d Pre-Alpha.txt

@raven02 @kd-11

kd-11 commented 7 years ago

Some bugs here may be fixed now since https://github.com/RPCS3/rpcs3/pull/2237 Missing geometry may be due to previously broken handling of parallel branch instructions. These can be spotted by searching for "jump_position" in the vertex shaders or the log. This is one such case.

SakataGintokiYT commented 7 years ago

@kd-11 much better :)

Fotoszok.pl

E {rsx::thread} RSX: Unimplemented sca_opcode BRB [E {rsx::thread} RSX: Unknown/illegal instruction: 0x3d (forced unit 2)]

*Video: https://m.youtube.com/watch?v=Q4sh0-CM-k8

SakataGintokiYT commented 7 years ago

@kd-11 [9e84804e] Saint Seiya Brave Soldiers:

Log: shaderLog: OpenGL-RenderDoc-Menu: OpenGL-RenderDoc-In game:

kd-11 commented 7 years ago

Wait; so the armor was rendered correcly before (i.e not flashing and misplaced)? If so, I might just have to reorganize the code generation and this might be fixed.

Anyway, the generated shader now has alot of dead code; Not sure if its supposed to be like this.

EDIT: After reading https://github.com/RPCS3/rpcs3/issues/2050#issuecomment-255616460 it seems that the flicker already existed before, so not a regression.

kd-11 commented 7 years ago

I suspect the unimplemented branch instruction is what keeps some code from being executed at all, causing the flicker.

kd-11 commented 7 years ago

https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.378 Post the emulator log with this build; It should log the call to the undefined op and give some more information. A renderdoc trace with OGL would be nice too if it runs.

ikki84 commented 7 years ago

@kd-11 Yes, the armor was rendered correcly before.

SakataGintokiYT commented 7 years ago

@kd-11 [6f6d0dca]

Log: shaderLog: OpenGL-RenderDoc-Menu: OpenGL-RenderDoc-character select screen: OpenGL-RenderDoc-In game:

E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C088, d3=0x20401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C088, d3=0x1401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C089, d3=0x61401FFC
E {rsx::thread} RSX: Unknown/illegal instruction: 0x3d (forced unit 2)
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C082, d3=0xA0401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C092, d3=0x40401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x9C6C, d1=0x8840000D, d2=0x8086C093, d3=0xA141FFFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C084, d3=0x20401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C085, d3=0x81401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C084, d3=0x20401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C085, d3=0x81401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C084, d3=0x20401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C085, d3=0x81401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C084, d3=0x20401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C085, d3=0x81401FFC

E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C082, d3=0x401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C082, d3=0x401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unknown/illegal instruction: 0x3d (forced unit 2)
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Unimplemented sca_opcode BRB, d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C086, d3=0xE1401FFC
ikki84 commented 7 years ago

Surely the problem is after pull request #2153 and before #2237.

@SakataGintokiYT @kd-11 @raven02 Could you test it? https://ci.appveyor.com/api/buildjobs/f6pe0p1t4wejeo8c/artifacts/rpcs3-ReleaseLLVM-025e3f04.zip

Merry Christmas.

SakataGintokiYT commented 7 years ago

@ikki84 same

kd-11 commented 7 years ago

As far as I know, BRB is not properly implemented yet. I'll get back to rpcs3 after the holidays. Cheers.

ikki84 commented 7 years ago

@SakataGintokiYT Strange, I am sure it fix the armor and the characters. Could try it again? Just try it using OpenGL. / Vulkan and DX12 will not work.

https://ci.appveyor.com/api/buildjobs/f6pe0p1t4wejeo8c/artifacts/rpcs3-ReleaseLLVM-025e3f04.zip

SakataGintokiYT commented 7 years ago

@ikki84 Still the same issue maybe it's drivers question ? or gpu model...

ikki84 commented 7 years ago

Radeon R7 200.

kd-11 commented 7 years ago

@SakataGintokiYT Retry with this build: https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.379 Attempts to actually implement the opcodes BRB and CLB

MarioSonic2987 commented 7 years ago

@kd-11 GL:

·F {rsx::thread} class gl::glsl::link_exception thrown: linkage failed: 'Vertex info
-----------
0(115) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
0(283) : error C1118: "break" not in loop
0(286) : error C0000: syntax error, unexpected '}' at token "}"
0(301) : error C0000: syntax error, unexpected '(', expecting "::" at token "("

Vulkan:

·E {rsx::thread} RSX: Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
ERROR: 0:116: '$' : unexpected token 
ERROR: 1 compilation errors.  No code generated.

·E {rsx::thread} RSX: 
·F {rsx::thread} class std::runtime_error thrown: Failed to compile vertex shader
(in file C:\rpcs3\rpcs3\Emu\RSX\VK\VKVertexProgram.cpp:391)

Shaderlog Vulkan Shaderlog GL

kd-11 commented 7 years ago

https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.381 I dont expect much progress, just the GL shaderlog will do. This is mainly for experimenting with the code generator and figuring out how jump addresses are supposed to be determined.

MarioSonic2987 commented 7 years ago
F {PPU[0x70000000] Thread (main_thread) [0x0102c0a4]} struct vm::access_violation thrown: Access violation reading address 0x0

Shaderlog GL Log GL

kd-11 commented 7 years ago

https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.383 Should dump the last raw compiled vertex program as vertexprogram.raw (opengl only) so that I can work on the shader code without having the game. Just attach the opengl shaderlog for this one.

MarioSonic2987 commented 7 years ago

Shaderlog3 GL VertexProgram.raw

SakataGintokiYT commented 7 years ago

[17ce61d5]

@kd-11

OpenGL

E {rsx::thread} RSX: Unimplemented sca_opcode BRB d0=0x1F9C6C, d1=0x8800000D, d2=0x8106C081, d3=0x41401FFC
E {rsx::thread} RSX: Failed to compile vertex shader: 0(94) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
0(138) : error C1118: "break" not in loop
0(141) : error C0000: syntax error, unexpected '}' at token "}"
0(156) : error C0000: syntax error, unexpected '(', expecting "::" at token "("

F {rsx::thread} class gl::glsl::link_exception thrown: linkage failed: 'Vertex info
-----------
0(94) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
0(138) : error C1118: "break" not in loop
0(141) : error C0000: syntax error, unexpected '}' at token "}"
0(156) : error C0000: syntax error, unexpected '(', expecting "::" at token "("
(0) : error C2003: incompatible options for link
'

GL-ShaderLog / VertexProgram.raw:

kd-11 commented 7 years ago

I know about the typo, its fixed here: https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.384

kd-11 commented 7 years ago

https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.385 generates better code, although I've yet to see a case where the encapsulated code should be taken.

SakataGintokiYT commented 7 years ago

[21e3f316] @kd-11

Shaderlog: Console dump:

kd-11 commented 7 years ago

I now understand how the BRB instruction is supposed to affect shaders, but the shaderlog is too large for me to find the broken case specifically. @SakataGintokiYT If the game still runs, could you attach the renderdoc trace for the menu? I already located the missing branch op, but I need to know what is generated in its place with my commits.:

image

SakataGintokiYT commented 7 years ago

[21e3f31] @kd-11 Shaderlog: RenderDoc-Menu:

kd-11 commented 7 years ago

Nice. The test is now in the right place, just has the wrong condition. Use https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.386 and attach the trace. It should write more info into the shader itself.

SakataGintokiYT commented 7 years ago

[236d51ed]

@kd-11 Shaderlog: RenderDoc:

kd-11 commented 7 years ago

I think https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.387 should fix this one. From analyzing different instances where the instruction appears, and taking into account known and used bits, it seems bit 25 switches on/off whether the branch will be taken. The shaders given by this game have more than one way to compute position and the branch should determine which path to take. I have considered the possibility that it may be a multi-bit index into a constants register array, but looking at vertex constants, it seems unlikely as they are used for other computations and contain float data.

kd-11 commented 7 years ago

Another alternative would be that we should decode input as a component of vertex input. EDIT: Nope, wouldn't work. If anything I'm even more convinced of the bit flag after going through some of the more complex shaders used.

SakataGintokiYT commented 7 years ago

[4a855794] @kd-11

[Saint Seiya Brave Soldiers] *Video: *Shaderlog: *RenderDoc-In game: *RenderDoc-Menu:


[Saint Seiya: Soldiers' Soul] *Video: *Shaderlog: *RenderDoc-Menu: *RenderDoc-In game:

ikki84 commented 7 years ago

@kd-11 If you revert this pull https://github.com/RPCS3/rpcs3/pull/2206 , and keep the posts pull requests after #2206 The game will render properly. I don´t know exactly which part of the pull make the things flicker and render wrong but my hint is that its related to Persistent mapped buffers.

SakataGintokiYT commented 7 years ago

Same without this commit #2206 / I have Nvidia GPU

ikki84 commented 7 years ago

@SakataGintokiYT I understand it, but I think if @kd-11 examine that pull, he could attempt to fix it for Nvidia users too.

saintseiya1

kd-11 commented 7 years ago

In that case, please test with legacy opengl buffers. If that fixes the flicker, I know why persistent buffers are not operating in an optimal manner. My assumption was that the buffers would be large enough that waits would happen only once every few seconds (there's a flush command in there for god's sake which harms performance). Looking at the renderdoc traces, its obvious that there are very many draw calls per frame and obviously trampling would take place. I shall fix the persistent buffers bug ASAP.

kd-11 commented 7 years ago

Okay, after looking at the renderdoc trace, it seems I messed up the commit. This issue ought to have been fixed; sorry for the confusion.

kd-11 commented 7 years ago

https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.389 should fix the opcode issue. As for the buffer RAW hazard, I expect some corruption but only when persistent mapped buffers are enabled and the issue would not be easy to capture using a trace, manifesting as an unstable render.

MarioSonic2987 commented 7 years ago

Fixed in https://github.com/kd-11/rpcs3/commit/7a758f4a98328e5daefb18e071086bb0ca56aec9! In Vulkan too.

Also, there's a color error in Vulkan

MarioSonic2987 commented 7 years ago

Video: https://youtu.be/JN_RihPI6WI

kd-11 commented 7 years ago

Seems to be another channel remap issue for the colors. I'll clean up the decompiler code and submit for merge into master. The vulkan colors thing should be easy to fix. Can someone please attach the D3D12 shader log? I'll try and fix that compilation error if the broken shader is captured in the logs.

SakataGintokiYT commented 7 years ago

[7a758f4a]

@kd-11

E {rsx::thread} RSX: FS build failed:0000000007192fc0
F {rsx::thread} class std::runtime_error thrown: fragment program compilation failure
(in file c:\rpcs3\rpcs3\emu\rsx\d3d12\D3D12PipelineState.h:162)

D3D12-Shaderlog

kd-11 commented 7 years ago

Check if https://ci.appveyor.com/project/kd-11/rpcs3/build/1.0.390 introduces any regressions to vulkan or opengl. I've changed the BRB implementation a bit.

MarioSonic2987 commented 7 years ago

In https://github.com/kd-11/rpcs3/commit/247fe3d51ac25801d2b61d26ac86684acf1243e2, there's no regression.