PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.85k stars 1.63k forks source link

[GSdx] Vertical lines in Marie to Elie no Atelier: Salburg no Renkinjutsushi 1 & 2 #2374

Open orbea opened 6 years ago

orbea commented 6 years ago

PCSX2 version: pcsx2-2018.04.06_1292cd5_master-x86_64-1_git

PCSX2 options: Only occurs with OpenGL and not software and other options do not seem to make a difference.

Plugins used: GSdx (GCC 7.3.0 SSE2/AVX) 1.1.0 [libGSdx] GSdx (GCC 7.3.0, SSE2) 1.0.0 [libGSdx-legacy-1.0.0]

Renderer: OpenGL (Software is not affected) Resolution: Native

Description of the issue: When playing the game Marie to Elie no Atelier: Salburg no Renkinjutsushi 1 & 2 with either the Japanese iso or an iso patched with the new English translation various parts of the game will have vertical lines, these lines can be stationary, mobile or flashing. Most commonly this is seen on every dialogue box and can be seen on the title screen and right after starting the game for easy testing.

I've included two gs dumps showing two examples, the second one is a multiframe gs dump.

http://ks392457.kimsufi.com/orbea/stuff/trace/gsdx_Atelier-marie1.gs.xz http://ks392457.kimsufi.com/orbea/stuff/trace/gsdx_Atelier-marie2.gs.xz

!(1)[https://i.imgur.com/enG4ckn.png] !(2)[https://i.imgur.com/wHbO9Zf.png]

How to reproduce the issue:

  1. Start the game with OpenGL.
  2. Proceed to the title screen.
  3. Start the game and view the beginning areas for additional examples.

Last known version to work: I went back to commit 5c7d9d08e without any changes in behavior.

PC specifications: OS: Slackware64-current GK110B [GeForce GTX 780 Ti] Linux-4.14.29 mesa-2018.03.24_776e6af_master-x86_64-1_git

gregory38 commented 6 years ago

You should run it from a gsdump. This way behavior is the same (same drawcall number)

lightningterror commented 6 years ago

Another way is to load from a savestate and then enable the raw dump but running gsdump is more efficient here.

gregory38 commented 6 years ago

Gsdump is better because it will always replay the same. Evn between renderer

orbea commented 6 years ago

How do I run it from a gsdump? When I run it with pcsx2_GSReplayLoader it doesn't seem to use any of the GSdx options and doesn't dump any files.

pcsx2_GSReplayLoader /usr/lib/games/PCSX2/libGSdx.so gsdx_Atelier-marie1.gs

I tried lightningterror's suggestion and that seemed to be more successful.

 ls GS_SW_dump32/
00004_context.txt                  00006_f5000_rt0_00000_C_32.png
00004_f5000_itex0_02bc0_P_8.png    00006_f5000_rt1_00000_C_32.png
00004_f5000_itexp_03f80_C_32.png   00006_f5000_rz0_02300_Z_16S.png
00004_f5000_itexraw_02bc0_P_8.png  00006_f5000_rz1_02300_Z_16S.png
00004_f5000_rt0_00000_C_32.png     00007_context.txt
00004_f5000_rt1_00000_C_32.png     00007_f5000_itex0_03020_P_8.png
00004_f5000_rz0_02300_Z_16S.png    00007_f5000_itexp_03f84_C_32.png
00004_f5000_rz1_02300_Z_16S.png    00007_f5000_itexraw_03020_P_8.png
00005_context.txt                  00007_f5000_rt0_00000_C_32.png
00005_f5000_itex0_03020_P_8.png    00007_f5000_rt1_00000_C_32.png
00005_f5000_itexp_03f84_C_32.png   00007_f5000_rz0_02300_Z_16S.png
00005_f5000_itexraw_03020_P_8.png  00007_f5000_rz1_02300_Z_16S.png
00005_f5000_rt0_00000_C_32.png     00008_context.txt
00005_f5000_rt1_00000_C_32.png     00008_f5000_itex0_03fe8_P_4.png
00005_f5000_rz0_02300_Z_16S.png    00008_f5000_itexp_03ff8_C_32.png
00005_f5000_rz1_02300_Z_16S.png    00008_f5000_itexraw_03fe8_P_4.png
00006_context.txt                  00008_f5000_rt0_00000_C_32.png
00006_f5000_itex0_03b80_P_8.png    00008_f5000_rt1_00000_C_32.png
00006_f5000_itexp_03fa4_C_32.png   00008_f5000_rz0_02300_Z_16S.png
00006_f5000_itexraw_03b80_P_8.png  00008_f5000_rz1_02300_Z_16S.png

The relevent images appear to be 00006_f5000_rt0_00000_C_32.png and 00006_f5000_rt1_00000_C_32.png.

rt0 rt0

rt1 rt1

And here is 00006_context.txt.

PRIM
    PRIM:6
    IIP:0
    TME:1
    FGE:0
    ABE:1
    AA1:0
    FST:1
    CTXT:0
    FIX:0

PRMODE (when AC=0)
    _PRIM:6
    IIP:0
    TME:0
    FGE:0
    ABE:0
    AA1:0
    FST:0
    CTXT:0
    FIX:0

PRMODECONT
    AC:1

TEXCLUT
    COU:0
    CBW:0
    COV:0

SCANMSK
    MSK:0

TEXA
    AEM:0
    TA0:128
    TA1:128

FOGCOL
    FCG:0
    FCB:0
    FCR:0

DIMX
    DM22:0
    DM23:0
    DM31:0
    DM02:0
    DM21:0
    DM12:0
    DM03:0
    DM01:0
    DM33:0
    DM30:0
    DM11:0
    DM10:0
    DM20:0
    DM32:0
    DM00:0
    DM13:0

DTHE
    DTHE:0

COLCLAMP
    CLAMP:1

PABE
    PABE:0

BITBLTBUF
    SBW:0
    SBP:0x0
    SPSM:0
    DBW:1
    DPSM:0
    DBP:0x3f84

TRXDIR
    XDIR:0

TRXPOS
    DIRY:0
    SSAY:0
    SSAX:0
    DIRX:0
    DSAX:0
    DSAY:0

TRXREG
    RRH:16
    RRW:16

XYOFFSET
    X:27648
    Y:29184

MIPTBP1
    BP1:0x0
    BW1:0
    BP2:0x0
    BW2:0
    BP3:0x0
    BW3:0

MIPTBP2
    BP4:0x0
    BW4:0
    BP5:0x0
    BW5:0
    BP6:0x0
    BW6:0

TEX0
    TBP0:0x3b80
    TBW:4
    PSM:0x13
    TW:8
    TCC:1
    TFX:0
    CBP:0x3fa4
    CPSM:0x0
    CSM:0
    CSA:0
    CLD:4
    TH:8

TEX1
    LCM:0
    MXL:0
    MMAG:1
    MMIN:1
    MTBA:0
    L:0
    K:0

TEX2
    PSM:0x0
    CBP:0x0
    CPSM:0x0
    CSM:0
    CSA:0
    CLD:0

CLAMP
    WMS:2
    WMT:2
    MINU:0
    MAXU:256
    MAXV:256
    MINV:0

SCISSOR
    X0:0
    X1:639
    Y0:0
    Y1:447

ALPHA
    A:0
    B:1
    C:0
    D:1
    FIX:0
    => (Cs - Cd) * As + Cd

TEST
    ATE:1
    ATST:5
    AREF:128
    AFAIL:3
    DATE:0
    DATM:0
    ZTE:1
    ZTST:2

FBA
    FBA:0

FRAME
    FBP (*32):0x0
    FBW:10
    PSM:0x0
    FBMSK:0x0

ZBUF
    ZBP (*32):0x2300
    PSM:0x3a
    ZMSK:0
gregory38 commented 6 years ago

Not the good draw call. You should have no menu at the bottom on rt0. And the menu should appear on rt1. You can give the ini directory (not ini file) as 3rd options of replayer. Call the replayer without any options to see a mini help message.

orbea commented 6 years ago

That helps, thanks! I think this should be better.

$ pcsx2_GSReplayLoader /usr/lib/games/PCSX2/libGSdx.so gsdx_Atelier-marie1.gs /home/orbea/.config/PCSX2/inis/
$ ls GS_SW_dump32/
00004_context.txt                  00006_f5000_rt0_00000_C_32.png
00004_f5000_itex0_02bc0_P_8.png    00006_f5000_rt1_00000_C_32.png
00004_f5000_itexp_03f80_C_32.png   00006_f5000_rz0_02300_Z_16S.png
00004_f5000_itexraw_02bc0_P_8.png  00006_f5000_rz1_02300_Z_16S.png
00004_f5000_rt0_00000_C_32.png     00007_context.txt
00004_f5000_rt1_00000_C_32.png     00007_f5000_itex0_03020_P_8.png
00004_f5000_rz0_02300_Z_16S.png    00007_f5000_itexp_03f84_C_32.png
00004_f5000_rz1_02300_Z_16S.png    00007_f5000_itexraw_03020_P_8.png
00005_context.txt                  00007_f5000_rt0_00000_C_32.png
00005_f5000_itex0_03020_P_8.png    00007_f5000_rt1_00000_C_32.png
00005_f5000_itexp_03f84_C_32.png   00007_f5000_rz0_02300_Z_16S.png
00005_f5000_itexraw_03020_P_8.png  00007_f5000_rz1_02300_Z_16S.png
00005_f5000_rt0_00000_C_32.png     00008_context.txt
00005_f5000_rt1_00000_C_32.png     00008_f5000_itex0_03fe8_P_4.png
00005_f5000_rz0_02300_Z_16S.png    00008_f5000_itexp_03ff8_C_32.png
00005_f5000_rz1_02300_Z_16S.png    00008_f5000_itexraw_03fe8_P_4.png
00006_context.txt                  00008_f5000_rt0_00000_C_32.png
00006_f5000_itex0_03b80_P_8.png    00008_f5000_rt1_00000_C_32.png
00006_f5000_itexp_03fa4_C_32.png   00008_f5000_rz0_02300_Z_16S.png
00006_f5000_itexraw_03b80_P_8.png  00008_f5000_rz1_02300_Z_16S.png

The relevent images are 00005_f5000_rt0_00000_C_32.png and 00005_f5000_rt1_00000_C_32.png.

rt0 rt0

rt1 rt1

00005_context.txt

PRIM
    PRIM:6
    IIP:0
    TME:1
    FGE:0
    ABE:1
    AA1:0
    FST:1
    CTXT:0
    FIX:0

PRMODE (when AC=0)
    _PRIM:6
    IIP:0
    TME:0
    FGE:0
    ABE:0
    AA1:0
    FST:0
    CTXT:0
    FIX:0

PRMODECONT
    AC:1

TEXCLUT
    COU:0
    CBW:0
    COV:0

SCANMSK
    MSK:0

TEXA
    AEM:0
    TA0:128
    TA1:128

FOGCOL
    FCG:0
    FCB:0
    FCR:0

DIMX
    DM22:0
    DM23:0
    DM31:0
    DM02:0
    DM21:0
    DM12:0
    DM03:0
    DM01:0
    DM33:0
    DM30:0
    DM11:0
    DM10:0
    DM20:0
    DM32:0
    DM00:0
    DM13:0

DTHE
    DTHE:0

COLCLAMP
    CLAMP:1

PABE
    PABE:0

BITBLTBUF
    SBW:0
    SBP:0x0
    SPSM:0
    DBW:1
    DPSM:0
    DBP:0x3f84

TRXDIR
    XDIR:0

TRXPOS
    DIRY:0
    SSAY:0
    SSAX:0
    DIRX:0
    DSAX:0
    DSAY:0

TRXREG
    RRH:16
    RRW:16

XYOFFSET
    X:27648
    Y:29184

MIPTBP1
    BP1:0x0
    BW1:0
    BP2:0x0
    BW2:0
    BP3:0x0
    BW3:0

MIPTBP2
    BP4:0x0
    BW4:0
    BP5:0x0
    BW5:0
    BP6:0x0
    BW6:0

TEX0
    TBP0:0x3020
    TBW:8
    PSM:0x13
    TW:9
    TCC:1
    TFX:0
    CBP:0x3f84
    CPSM:0x0
    CSM:0
    CSA:0
    CLD:4
    TH:9

TEX1
    LCM:0
    MXL:0
    MMAG:0
    MMIN:0
    MTBA:0
    L:0
    K:0

TEX2
    PSM:0x0
    CBP:0x0
    CPSM:0x0
    CSM:0
    CSA:0
    CLD:0

CLAMP
    WMS:2
    WMT:2
    MINU:0
    MAXU:512
    MAXV:512
    MINV:0

SCISSOR
    X0:0
    X1:639
    Y0:0
    Y1:447

ALPHA
    A:0
    B:1
    C:0
    D:1
    FIX:0
    => (Cs - Cd) * As + Cd

TEST
    ATE:1
    ATST:5
    AREF:128
    AFAIL:3
    DATE:0
    DATM:0
    ZTE:1
    ZTST:2

FBA
    FBA:0

FRAME
    FBP (*32):0x0
    FBW:10
    PSM:0x0
    FBMSK:0x0

ZBUF
    ZBP (*32):0x2300
    PSM:0x3a
    ZMSK:0
gregory38 commented 6 years ago

As a side note we should optimize texture clamping.

So you have the renderer menu with SW and HW. Could you check the extreme left and right position (first and last pixel position) of the menu.

orbea commented 6 years ago

Using gimp zoomed in at 800%.

Software:

Left - 20
Right - 612

Hardware

Left - 20
Right - 611
gregory38 commented 6 years ago

What happen if you try to reduce only the X offset on the vertex shader.

p.xy = vec2(i_p) - vec2(0.05f, 0.05f);
p.xy = vec2(i_p) - vec2(0.02f, 0.05f);
p.xy = vec2(i_p) - vec2(0.01f, 0.05f);
p.xy = vec2(i_p) - vec2(0.001f, 0.05f);
orbea commented 6 years ago
p.xy = vec2(i_p) - vec2(0.02f, 0.05f);

Better, both examples shown in the OP are fixed, but it introduces some new vertical lines from different scenes.

p.xy = vec2(i_p) - vec2(0.01f, 0.05f);

Mostly the same as before, but introduces even more new lines without fixing the remaining lines.

p.xy = vec2(i_p) - vec2(0.001f, 0.05f);

Even worse, the new lines are even bigger.

p.xy = vec2(i_p) - vec2(0.03f, 0.05f);

Still fixes the two original examples, but there are still new lines.

p.xy = vec2(i_p) - vec2(0.04f, 0.05f);

No new lines, but doesn't entirely fix the original issue.

p.xy = vec2(i_p) - vec2(0.035f, 0.05f);

Not much difference, no new lines, but still doesn't fix the original issue.

p.xy = vec2(i_p) - vec2(0.031f, 0.05f);

Fixes the original issue, but there are new lines again.

p.xy = vec2(i_p) - vec2(0.033f, 0.05f);

Fixes some of the original lines and introduces some of the new lines...

p.xy = vec2(i_p) - vec2(0.032f, 0.05f);

Fixes the original issue, but there are new lines.

This feels like progress, but there is still something missing.

willkuer commented 6 years ago

Sounds like -pi/100...

gregory38 commented 6 years ago

In the uniform tab, what value do you have for VertexScale and VertexOffset ?

I'm not sure that a correct solution could be found. It could also be related to the rounding of the rasterizer.

orbea commented 6 years ago

In the uniform tab I see VertexScale and VertextOffset in two places under GL_GEOMETRY_SHADER and GL_VERTEX_SHADER, both have the same values.

VertexOffset - [3.69921875, 4.5615234375[
VertexScale - [9.765625145519152e-5, 0.0001220703125]

Could you elaborate on the rounding of the rasterizer?

Also if a Texture Offset of 2 entirely works around this in the PCSX2 hacks menu, would that suggest that there could be a correct solution? Or am I not understanding how that works?

gregory38 commented 6 years ago

When you draw a primitive, you only have the attribute value at the vertices. So you need to compute for each fragment the attribute value. There are multiple way to compute those value GS is based DDA. I'm not sure modern GPU uses the same formulae.

Besides, modern GPU uses 32 bits float (mantis of 24 bits). GS inputs are mostly 16 bits integer. Even float parameter (such as S, T or Q) are likely truncated to use less than 24 bits. It could explain why 296,994 on GS is becoming a bit more of 297,000 on GPU.

Texture offset will move all texture to the left of 0,125 pixels. You might have issue if texture coordinate is 296,1 in this case it will sample 295 instead of 296.

lightningterror commented 6 years ago

@orbea can you retest latest build ? Maybe the latest uv coordinates changes help.

orbea commented 6 years ago

@lightningterror I built commit eb95559 and the issue is still present, the previous workaround of setting Texture Offset to 2 still seems to work as well.

lightningterror commented 3 years ago

Can this be retested if there's a change?

orbea commented 3 years ago

@lightningterror I built commit https://github.com/PCSX2/pcsx2/commit/88983caaba01ad69d90569ca16f1267977219fca and it still occurs, the texture offset of 2 still seems to work around the issue.

marcoluc97 commented 2 years ago

With vulkan?

Mrlinkwii commented 2 years ago

Can someone confirm this is still an issue and provide a new GS Dump ( the linked GS Dump link is dead ) ?

darkxex commented 2 years ago

Can someone confirm this is still an issue and provide a new GS Dump ( the linked GS Dump link is dead ) ?

https://github.com/PCSX2/pcsx2/issues/6324 yes it is still an issue, here new gsdump made by me. gs_20220604010154Atelier Marie Elie - Salburg no Renkinjutsushi 1_2_SLPM-66140.zip

Mrlinkwii commented 2 years ago

@darkxex Thanks :+1: