Commit Graph

223 Commits

Author SHA1 Message Date
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
Gregory Hainaut ae70344fbc gsdx-ogl: fix 2 passes DATE with GL42 (override_GL_ARB_shader_image_load_store = 1)
It fixes shadows issue with Persona 3
2015-05-02 16:56:18 +02:00
Gregory Hainaut 73d04e33e9 gsdx ogl: clean various comment and old code 2015-05-01 20:04:23 +02:00
Gregory Hainaut 335695bd0e purge GLES from GSdx !
mobile will use vulkan (or any new API) anyway
2015-05-01 20:02:17 +02:00
Gregory Hainaut 71e517108d gsdx-ogl: fix colclip
Sotc shadow and likely various games :)

Thanks to pseudo
2015-04-30 23:08:05 +02:00
Gregory Hainaut b65a62096f gsdx-ogl: drop support of ENABLE_OGL_DEBUG
Stencil can be read by GL debugger due to correct mask configuration
2015-04-30 20:02:51 +02:00
Gregory Hainaut eaa0dae305 glsl: drop invariant qualifier
Fix issue #510 and potentially it allows the compiler to  better optimize the code
2015-04-27 18:52:55 +02:00
Gregory Hainaut 46ff4dc3d3 gsdx-ogl: hardware unit only support normalization of 4 bytes...
(At least on recent AMD GPU)
2015-04-27 18:51:59 +02:00
Gregory Hainaut 301fe869c7 glsl: improve the logz handling
This way only 0 and 1 will conflict
2015-04-26 17:51:33 +02:00
Gregory Hainaut 6a3250cad2 gsdx-ogl: fix logz management (FFXII)
The issue is that z+1 overflow if z is UINT max
log2(z) overflow if z is 0

So let's use an or 1 to avoid both overflow
2015-04-25 20:23:26 +02:00
Gregory Hainaut 15ae9996bb glsl: format white space + comment 2015-04-25 12:50:12 +02:00
Gregory Hainaut 36514bd95f glsl: fog is a single byte
Give a chance to the driver to optimize if possible
2015-04-24 21:37:37 +02:00
Gregory Hainaut c207632e49 gsdx-ogl: improve date performance for GL45
If there is no overlap, it is allowed to directly read from the render target.

On SotC testcase with 6x scaling: 30fps -> 40fps

Note: it requires GL_ARB_texture_barrier extension so be sure to have a recent driver

Note2: it requires a lots of testing too

Open question: in case of complex date (written alpha)
Will it be faster to split the draw call into multiple call with no
primitive overlap
2015-04-24 21:12:33 +02:00
Gregory Hainaut 795ae50ecd gsdx-ogl: fix the recently broken advance date feature
Now it is really working with a 2 stages shaders but it is still slow.
2015-04-24 20:13:38 +02:00
Gregory Hainaut 89d5e5637c glsl: use an explicit cast insead of notEqual function
If the compiler didn't optimize the code, it will be a bit faster
2015-04-24 18:01:25 +02:00
Gregory Hainaut 56836561f4 glsl: replace runtime condition by preprocessor condition
It might be an easier work for the compiler

I didn't replace all occurences to keep readability
2015-04-24 17:51:29 +02:00
Gregory Hainaut 62489f42f1 gsdx-ogl: add an optimization note for later
Only 1 byte of fog is useful
2015-04-20 07:18:09 +02:00
Gregory Hainaut 6d253c0b8f glsl: fix debugging of tex coordinate in apitrace 2015-04-20 07:18:08 +02:00
Gregory Hainaut 31f8c065db gsdx-ogl: implement a new hack UserHacks_UnscaleSprite for opengl
UserHacks_UnscaleSprite = 1 will unscale flat sprites
UserHacks_UnscaleSprite = 2 will unscale all  sprites (don't work well so far)

The idea of the hack is to redo the interpolation of texture coordinate
based on the non-upscaled pixel position.

It avoids various glitches but sprites aren't upscaled anymore (so no
more anti-aliasing, potentially a coefficient can be added).
2015-04-20 07:18:08 +02:00
Gregory Hainaut 16e6d0d305 glsl: move shader into a separate directory
Only keep glsl_source.h for clarity
2015-04-19 18:49:02 +02:00
Gregory Hainaut 55fdf26898 glsl: remove the older file tfx.glsl 2015-04-19 18:49:02 +02:00
Gregory Hainaut 15264c6c63 glsl: split the main shader
* separate VS/GS and FS
* separate subroutine part of the FS

It already complex enough without subroutine stuff. Besides I'm not sure
we will keep subroutine on the future.
2015-04-19 18:49:02 +02:00
Gregory Hainaut 418f2e69a8 gsdx-ogl: implement the wildhack on the GPU
Likely much faster for opengl and much easier to implement

Note: hopefully UserHacks_round_sprite_offset will replace it
2015-04-13 22:14:36 +02:00
Gregory Hainaut 05eb1641f2 gsdx: add glsl debug capabilities
Useful to debug bad texture sampling
2015-04-08 10:15:25 +02:00
Gregory Hainaut e40a26be19 gsdx: add some helper to debug openGL renderer 2015-04-03 20:28:44 +02:00
Gregory Hainaut 29a14f5667 sed -i -e 's/seperately/separately/'
Thanks micove again
2014-12-07 12:46:16 +01:00
Gregory Hainaut 16284d0a59 gsdx: fix a couple of typo
From @micove
2014-12-07 12:12:53 +01:00
Gregory Hainaut 070dce4c83 Merge pull request #356 from PCSX2/issue-fixes
various bug-tracker fixes
2014-12-06 19:48:13 +01:00
gabest11 b9b02cf749 implemented opencl program caching on disk under the system default temp folder, needs some additional work on linux 2014-12-02 00:16:35 +01:00
gabest11 e3ba15de94 opencl device selection in settings dialog 2014-12-02 00:16:34 +01:00
gabest11 6f5cd1cd4d joined some tfx kernel calls, general speed up in most games 2014-12-02 00:16:34 +01:00
gabest11 3d2b0e3766 minor opencl kernel optimizations 2014-12-02 00:16:34 +01:00
gabest11 72cfc6a6ef 3rdparty/opencl 2014-12-02 00:16:34 +01:00