Commit Graph

255 Commits

Author SHA1 Message Date
Gregory Hainaut d191ae4aba glsl: use rounding in convert 4 shader
It will avoid texture rouding error with negative number
2015-07-30 18:22:59 +02:00
Gregory Hainaut ae8df002af gsdx-ogl: optimize Cs * As + Cd and Cs * Af + Cd blending
Basically the code does the alpha multiplication in the shader therefore
the blend unit only does a pure addition. This way the multiplication is
accurate and accurate_blending doesn't requires a costly barrier.

This code also avoid variable duplication to make the code more separated.
Hopefully blending can be done in a separated function

It is preliminary work to support fast color clipping with HDR

v2: fix assertion compilation failure

v3: fix regression in not accurate mode

v3: Cs * As/Af is not an accumulation

Those cases don't need the Cd addition and were already optimized anyway

Fix a regression on GoW2
2015-07-30 18:22:59 +02:00
Gregory Hainaut 95c374bbcc glsl: Round 0.95+ to 1 for texel colors
It improves SotC blooming. Suikoden seems to be fine too.
2015-07-30 18:21:01 +02:00
Miguel A. Colón Vélez e4ab71abf3 Add authors comment that suggest public-domain license.
Sourceforge was dead for more than a week therefore add the license
information. I could not find the original TGM source (dead link) so I'm not
even sure if this still applies or if the glsl was totally rewritten. None
of the glsl files have a copyright header so it's hard to tell.
2015-07-27 14:21:29 -04:00
Gregory Hainaut 223b7daa1d gsdx-ogl: fix fbmask regression
I forget to remove an useless 255.0f factor
2015-07-19 23:55:27 +02:00
Gregory Hainaut 5c740ff41e gsdx-ogl: wipeout AlphaStencil & Alpha hack
Accurate options do a better jobs. Technically it can still
be useful for old gpu/driver that doesn't support the GL4.5 extension.

On Windows, you can still rely on Dx

On linux, free driver support it (except Intel)
2015-07-19 22:43:48 +02:00
Gregory Hainaut 38c086008d glsl: round blending as SW renderer
Better tone on God of War with ultra accurate mode
2015-07-18 17:16:46 +02:00
Gregory Hainaut c4e165067d glsl: use signed integer when working with substraction...
It mostly fixes rendering of GoW with ultra blending

Color is still a bit wrong but rounding is likely incorrect
2015-07-18 14:41:03 +02:00
Gregory Hainaut c701ab4368 glsl: don't use normalized value for color range
Globally shader uses less intruction (except blending part)

It would also allow to improve the rounding of color
2015-07-18 14:41:03 +02:00
Gregory Hainaut 57394a03e0 partially revert: glsl: disable computing of extra alpha coeff in SW blending
It generates undefined data in screen. Maybe blending isn't switch off properly.
I need to investigate it.
2015-07-18 14:41:03 +02:00
Gregory Hainaut 036cb229a3 glsl: add various comment for future idea
For example GL4 GPU supports special bit operation
2015-07-18 14:40:57 +02:00
Gregory Hainaut 36e83b42ce glsl: round texture and fragment color as the SW renderer
GS uses integer value and does integer operation too.

This commit trunc the sampled texture, the interpoled fragment color
and the product of the 2.

It impacts negatively the perf of about 3/4% (GPU) but it fixes rendering on
suikoden and potentially some others games too.
2015-07-17 21:08:49 +02:00
Gregory Hainaut 5f247a6e16 glsl: rewrite tfx function to ease future update
No need to put lots of ifdef, compiler will optimize everything
It increases a bit the readability
2015-07-17 21:08:49 +02:00
Gregory Hainaut ea9e608288 gsdx-ogl: fix texture palette mask 2015-07-17 21:08:49 +02:00
Gregory Hainaut b4c04ed00a gsdx-ogl: wipeout subroutine code
Code was completey bitrotten
Code was a partial test (and yet 500 lines already)
Shader is more and more complex and multithreading support greatly
reduce the cost of shader switch
2015-07-17 21:08:49 +02:00
Gregory Hainaut e3751f6cd9 glsl: disable computing of extra alpha coeff in SW blending
Hum, I'm curious of the impact to enable only this code when it is actually used.
2015-07-17 21:08:49 +02:00
Gregory Hainaut 784822a5c2 glsl: redo blending management to use A/B/C/D directly
1/ Code is much more readable
2/ It will allow to round differently the operation in the future
2015-07-17 21:08:49 +02:00
Gregory Hainaut 91fbe6f108 gsdx-ogl: add some code to fix black netting on some renderings
Code is not yet enabled because it requires extensive test

The idea is to replace point by a 1 pixels sprite with the help of
a geometry shader. In 4x, point will be replaced by a 4x4 sprite.
2015-07-11 14:35:35 +02:00
Gregory Hainaut 5e7ce63ed1 glsl: add a geometry shader to upscale GS_POINT
The purpose is to avoid upscaling issue on POINT rendering (black netting on some FMVs)
2015-07-11 14:35:34 +02:00
Gregory Hainaut 986754bde7 glsl: don't declare gl_FragDepth
Fix compilation issue on Mesa driver

(hope it doesn't break Catalyst)
2015-07-05 18:12:36 +02:00
Gregory Hainaut a9f49ab9ab glsl: fix rounding error for shadow computation
Better shadow on Castlevania/Nemo (others :) )
2015-07-01 09:36:54 +02:00
Gregory Hainaut 6121677aa1 gsdx-tc: use a single shader pass to convert texture in 8 bits format
It might save a couple of fps

Add a define to test the perf if we keep only the blue channel. It brokes
the code in Prince Of Persia that use the Red/Green channel... Maybe the
speed hack :( Or find a way to replace all if with a lookup table

Note: it is only supported on OpenGL currently
2015-07-01 09:36:54 +02:00
Gregory Hainaut e2727f10ba glsl: fix for AMD
I hope :)
2015-07-01 09:36:54 +02:00
Gregory Hainaut d29e375f72 gsdx-tc: GPU accelerate 8 bits texture conversion
Only native is supported currently
2015-07-01 09:36:54 +02:00
Gregory Hainaut db5468afcf glsl: fix shadow on Shin Megami Tensei Nocturne 2015-07-01 09:36:54 +02:00
Gregory Hainaut 839003467e gsdx-ogl: add support of partial frame buffer masking
It might help to fix a bit the color on a couple of games

accurate_fbmask = 1

Code uses GL4.5 extensions. So far it seems the effect is ony used a couple
of time and often in non-overlapping primitive. Speed impact will likely remain small
2015-07-01 09:36:53 +02:00
Gregory Hainaut 82818dab3c gsdx-ogl: make some room in AlphaCoefficient variable
The idea will be to use the remaining int to store the FB mask
2015-07-01 09:36:53 +02:00
Gregory Hainaut 42e911c78f gsdx-ogl: mask alpha channel in depth conversion
Might not work if depth is recasted as a rt (we lost the alpha channel)
2015-07-01 09:30:20 +02:00
refractionpcsx2 af09d7e063 GSdx-DX: Modified shader slightly as some bits were incorrect. 2015-07-01 09:30:20 +02:00
refractionpcsx2 4bc8bfc23e GSdx-DX: Rough port of texture switching from OGL 2015-07-01 09:30:20 +02:00
Gregory Hainaut 58ce7d4bb8 gsdx-ogl: emulate texture shuffle
GS doesn't supports texture shuffle/swizzle so it is emulated in a
complex way.

The idea is to read/write the 32 bits color format as a 16 bit format.
This way, RG (16 lsb bits) or BA (16 msb bits) can be read or written with
square texture that targets pixels 1-8 or pixels 8-16.
However shuffle is limited. For example you can copy the green channel
to either the alpha channel or another green channel.

Note: Partial masking of channel is not yet implemented

V2: improve logging
V3: better support of green channel in shader
V4: improve detection of destination (issue due to rounding)
2015-07-01 09:30:20 +02:00
Gregory Hainaut 8393ba56d6 gsdx-ogl: rework palette texture handling
Redirect the red channel to alpha channel for 8 bits texture.

It avoid special management in the shader
2015-06-24 19:50:09 +02:00
Gregory Hainaut 23f8203a22 gsdx-ogl: add some shaders to convert depth <-> color
I'm afraid of rounding error
2015-06-07 12:39:00 +02:00
Gregory Hainaut 2cbde89084 Merge pull request #555 from PCSX2/real-fb-format
GSdx: better framebuffer format
2015-06-01 11:48:07 +02:00
Gregory Hainaut da0b77e09b gsdx-ogl: new logo
Thanks bmate for the logo.

Close issue #192
2015-05-29 11:05:52 +02:00
Gregory Hainaut 419dfe0544 glsl: redo color/alpha management correction
Please test it!

GS supports 3 formats for the output:

32 bits: normal case
=> no change

24 bits: like 32 bits but without alpha channel
=> mask alpha channel (ie don't write it anymore)
=> Always uses 1.0f as blending coefficient

16 bits: RGB5A1, emulated by a 32 bits openGL texture. I think it will be more correct to use
a real 16 bits GL texture. Unfortunately it would cost several (slow) target conversions.
Anyway as a current solution
=>  apply a mask of 0xF8 on color when SW blending is used (improve Castlevania shadow)
unfortunately normal blending mode still uses the full range of colors!

This commit also corrects a couple of blending factor. 128/255 is equivalent to 1.0f in PS2, whereas GPU uses 1.0f. So the blending factor must be 255/128 instead of 2

Note: disable CRC hack and enable accurate_colclip to see Castlevania shadow ^^
(issue #380).
Note2: SW renderer is darker on Castlevania. I don't know why maybe linked to the 16 bits format poorly emulated
2015-05-26 16:49:43 +02:00
Gregory Hainaut b0af54d33e gsdx-ogl: better support of palette
The purpose of the code is to support alpha channel
of RT uses as an index for a palette texure.

I'm afraid that code will likely break pure palette texture. Only used
if paltex is enabled

It fixes missing shadow in Star Ocean 3 (issue #374) in Native resolution
with filter = 0  (no filtering) or = 2 (normal fitering)

Rendering explanation:
The game emulates a stencil buffer with the alpha channel

The alpha channel of the RT can contains a palette texture index (format 4HH)
The idea is to have a gradient of value in the palette (16/32/48/...).
This way you can implement a +16/-16 and even wrap the alpha value every time
you hit the pixel.

Bilinear filtering breaks the rendering because it interpolates between counts
so you doesn't have the exact count

Upscaling breaks the rendering because the RT is reused as an input texture. It means
that we need to scale it down which again create some interpolations.
2015-05-24 18:07:16 +02:00
Gregory Hainaut a70c3bf5de glsl: correct the alternate implementation of ps_main1
Still not yet enabled by default

Potentially it can be optimized with the dot product but special care
need to be taken to ensure float accuracy.

Bonus: it could work on old GPU (aka DX9)
2015-05-24 13:43:36 +02:00
Gregory Hainaut 3d35e4f8ec gsdx-ogl: implement all blends mode in shader
+ 250 lines !!!
2015-05-20 09:11:36 +02:00
Gregory Hainaut 8d3e3e6c5b gsdx-ogl: more blend rework to support accurate_colclip
So far few blending equations are implemented in PS. It is only
for test the behavior on GoW
2015-05-20 08:00:40 +02:00
Gregory Hainaut c5341a2711 gsdx-ogl: update blending management
This way it will allow to implement all blendings operartion in FS.

Of course it will be slow, but it would be nice for debug and quickly check
game error rendering.
2015-05-20 00:12:52 +02:00
Gregory Hainaut 358e0d445b gsdx-ogl: add a shader to convert depth texture into uint 2015-05-19 18:56:32 +02:00
Gregory Hainaut ec45090358 glsl: implement an alternative of convert 1 shader
Code not yet enabled. Quick test show no heavy regression but I need
to carefully validate it.
2015-05-19 13:14:18 +02:00
Gregory Hainaut 51ed3e63e9 glsl: oups forget to remove a line 2015-05-10 10:39:23 +02:00
Gregory Hainaut 5565544ba6 gsdx-ogl: DATE with texture barrier
Much faster for small batch that write the alpha value. Code can
be enabled with accurate_date option.

Here a summary of all DATE possibilities:
1/ no overlap of primitive
    => texture barrier (pro no setup of stencil and single draw)

2/ alpha written
    => small batch => texture barrier (primitive by primitive). Done in N-primitive draw calls.
    (based on GL_ARB_texture_barrier)

    => bigger batch => compute the first good primitive, slow but only 2 draw calls.
    (based on GL_ARB_shader_image_load_store)

    => Otherwise there is the UserHacks_AlphaStencil but it is a hack!

3/ alpha written
    => full setup of stencil ( 2 draw calls)
2015-05-09 19:54:01 +02:00
Gregory Hainaut 7fac25edb0 glsl: add shader implementation of impossible blend
Issue: I don't know if destination alpha value must be multiplied by 2.0f
2015-05-09 15:02:34 +02:00
Gregory Hainaut f029e4763f gsdx-ogl: add the alpha value in a constant buffer 2015-05-09 15:02:34 +02:00
Gregory Hainaut 9023f5f0db glsl: drop useless ifndef
I often mix them with the real value...
.
2015-05-08 19:28:17 +02:00
Gregory Hainaut 1addae1993 gsdx-ogl: don't use extra shader for sprite hack
Atst == 2 && sprite_hack is equivalent to Atst == 1

It frees a bit in the shader selector, and reduces shader combinations.
2015-05-08 19:28:16 +02:00
Gregory Hainaut 530e4ce776 gsdx-ogl: drop hack that rescale primitive (to avoid upscale glitch)
Rendering is bad. It renders sprites at native resolution.
2015-05-06 19:09:13 +02:00