Commit Graph

239 Commits

Author SHA1 Message Date
Gregory Hainaut 9b69afe541 gsdx-ogl: typo that broke TC offset hack 2015-09-20 22:19:45 +02:00
Gregory Hainaut 78569ee833 gsdx-ogl: redo properly the setup of texture format
* add lengthly comment to explain the format
* Likely reduce the number of shader permutation
* Avoid slow AEM (on GPU)

Expect regressions because TC needs some fixes

v2: fix palette mode
2015-09-11 14:14:22 +02:00
Gregory Hainaut ddc03cbccf gsdx: add a nice enum to replace the hardcoded convert shader 2015-09-08 16:51:24 +02:00
Gregory Hainaut a46c11b088 gsdx-ogl: delete various leftovers 2015-08-22 13:33:32 +02:00
Gregory Hainaut 7002ff3ec3 gsdx-ogl: move texture scale from vs_cb to fs_cb
It avoid useless update of the vs_cb.
2015-08-22 13:33:04 +02:00
Gregory Hainaut 499206f0ea gsdx-ogl: disable advance rendering when drivers don't support it 2015-08-22 12:22:35 +02:00
Gregory Hainaut 37f9bcf9cb gsdx-ogl: reduce state change
* don't dirty aref when a fog color is uploaded
* only set clamp mode in clamp mode (region clamp is handled in shader)

v2: fix SSE2/3 compilation
2015-08-20 23:01:43 +02:00
Gregory Hainaut c5a786ed2c gsdx-ogl: remove support WMS/T == 2 in hardware unit
I think behavior was wrong because only first texel coordinate was clamped.

Beside we can't interpolate if AEM isn't yet applied
2015-08-20 23:01:43 +02:00
Gregory Hainaut 6b84a89b6a gsdx-ogl: remove old ati hack for point sampler
Was never used on openGL

In the future absolute coordinate will be use anyway
2015-08-18 19:09:45 +02:00
Gregory Hainaut 37661f3a86 gsdx-ogl: fix blending regression (VP2)
Negative factor must be disabled in negative accumulation "-Cs*As + Cd"
Shader must output Cs*As and blending unit will do the Cd - C subtraction
2015-08-18 09:14:11 +02:00
Gregory Hainaut 260c12756a gsdx-ogl: accelerate Cd - Cs * Alpha in sw blending
It is similar as Cd + Cs * Alpha except the operator

It would help to emulate other color clipping case correctly in basic
mode at full speed
2015-08-16 18:12:34 +02:00
Jonathan Li 6580f4922f gsdx-ogl: correct fbmask conversion on texture shuffle
Fbmask is RGBA8 and must be converted to RGB5A1
=> bit 31 must be moved to bit 15

Signed-off-by: Gregory Hainaut <gregory.hainaut@gmail.com>
2015-08-16 14:06:10 +02:00
Gregory Hainaut c32f1dfc23 gsdx-ogl: fix blend clear regression
Field selector are very dangerous to use.

Fix #764
2015-08-15 20:06:34 +02:00
Gregory Hainaut 0e3491bd58 gsdx-ogl: always do RW RT check
Jak uses it with triangle rendering.
2015-08-15 20:06:34 +02:00
Gregory Hainaut c7b2f9d1d2 gsdx-ogl: setup fbo to always write to first buffer
GL_NONE was kind of useless because nothing was attached anyway
2015-08-15 20:06:34 +02:00
Gregory Hainaut 87f497af0a gsdx-ogl: remove an useless variable 2015-08-15 20:06:34 +02:00
Gregory Hainaut 6046d6c417 Merge pull request #749 from PCSX2/gsdx-micro-optimization
Gsdx micro optimization
2015-08-12 08:54:36 +02:00
Gregory Hainaut 98c74879bf Merge pull request #718 from PCSX2/depth-color-direct-write
Depth color direct write
2015-08-10 15:50:48 +02:00
Gregory Hainaut 9f92f63194 gsdx-ogl: Use GetAlphaMinMax to limit the scope of FULL accurate blending
Provide a massive speed up in this level.
2015-08-09 13:44:31 +02:00
Gregory Hainaut 61694013a5 gsdx-ogl: compact blending parameter structure
Save 656B of data. It is good for the cache.
2015-08-09 13:44:30 +02:00
Gregory Hainaut df3ade896b gsdx-ogl: use integer for blend factor
Integer argument&comparison might be lighter

V2: Forget to change one OMSetBlendState call
2015-08-09 13:44:05 +02:00
Gregory Hainaut 5b57405517 gsdx-ogl: blend management cleanup
* reorder the blend function
* remove OM bsel object
* add a bit to support pabe (miss the glsl part)
2015-08-08 09:18:09 +02:00
Gregory Hainaut 4d12410707 gsdx-ogl: latch constant buffer in rendering object
* Initialization of the object is done once
* Avoid to reupload it when an useless parameter toggle
 => -10% of UBO update
2015-08-08 09:18:09 +02:00
Gregory Hainaut b17803bb34 gsdx-ogl: wipeout of GL_ARB_bindless_texture
Code is completely broken. It doesn't help to improve speed.

Remove 200 lines ;)
2015-08-08 09:16:49 +02:00
Gregory Hainaut b7e16b5989 gsdx-ogl: clean the blending management
Intially GSBlendStateOGL was an alias of the m_blendMapD3D9 array

The object was replaced by an index in the array. Save 2k of memory duplication.
And too much useless code.

v2: push/pop blending state in DATE stuff
v3: remove m_state which is useless now
2015-08-05 22:55:12 +02:00
Gregory Hainaut 717f0fcb4d gsdx-ogl: optimize fbmask setup 2015-08-05 22:55:12 +02:00
Gregory Hainaut 73e2ff6ff6 gsdx-ogl: change PrimitiveOverlap algo from O(n^2) to O(n)
+ only enable this optimization when it is useful (date or sw blending)

Less impact on the perf even for big vertex array
2015-08-05 17:59:55 +02:00
Gregory Hainaut 36554c3375 Merge branch 'hdr-colclip-32bits' 2015-08-04 21:55:40 +02:00
Gregory Hainaut 45bb27d6db gsdx-ogl: extend HDR colclip to 32 bits texture
Unfortunately 16 bits wasn't enough for Castlevania.
2015-08-04 21:54:27 +02:00
Gregory Hainaut c6ff7531fb gsdx-ogl: performance boost on virtuafighter 2015-08-04 21:26:03 +02:00
Gregory Hainaut d80aa0b0bd gsdx-ogl: remove 2 printfs
GL_INS is a better tracing solution
2015-08-04 20:47:02 +02:00
Gregory Hainaut 744f9ebc09 gsdx-ogl: rare corner case when both texture shuffle and date are enabled
In texture shuffle mode the texture data is either RG or BA. It means
that DATE must either checks MSB of G or A.

Close #693
2015-08-04 20:10:44 +02:00
Gregory Hainaut 3784ea768f gsdx: check null pointer when doing a texture clear 2015-08-04 19:26:17 +02:00
Gregory Hainaut 8424c18e9f Merge pull request #688 from PCSX2/hdr-colclip
Hdr colclip
2015-08-02 18:13:28 +02:00
Gregory Hainaut 1f402b1b56 gsdx-ogl: fix bad detection of overlapping
avoid rendering corruption with SW blending
2015-08-01 13:29:25 +02:00
Gregory Hainaut ec007ac8d0 gsdx-ogl: support accurate blending without geometry shader
For the Mesa driver
2015-08-01 13:26:15 +02:00
Gregory Hainaut eb0fa8c7dc gsdx-ogl: fix bad detection of overlapping
avoid rendering corruption with SW blending
2015-08-01 01:27:22 +02:00
Gregory Hainaut 8452d2ccfe gsdx-ogl: fbmask regression! don't use bit operation with integer 2015-07-31 21:10:58 +02:00
Gregory Hainaut fff59f547d gsdx-ogl: fbmask regression! don't use bit operation with integer 2015-07-31 19:43:06 +02:00
Gregory Hainaut a0edcb58af gsdx-ogl: extend cclip blending level with destination alpha blending
The purpose is to emulate correctly destination alpha factor

An alpha channel of 128 is 1.0 in the GS but only ~0.5 in the GPU

I think few draw call use destination alpha so impact on perf must remains small.
2015-07-31 09:45:28 +02:00
Gregory Hainaut 8554f32086 gsdx-ogl: clean the blend table
Remove old shader define
Prefix macro with BLEND_
Add some notes to explain the special symbol
2015-07-31 09:45:28 +02:00
Gregory Hainaut cfd0fd6cc8 gsdx-ogl: remove old colclip algo 2015-07-31 09:45:28 +02:00
Gregory Hainaut 93c47feb7c gsdx-ogl: replace old colclip algo with the HDR algo
Similar speed but more accurate

Allow to clean the code
2015-07-31 09:45:28 +02:00
Gregory Hainaut 83f874db93 gsdx-ogl: remove bsel.ps
Just clear bsel.abe to disable blending
2015-07-31 09:45:28 +02:00
Gregory Hainaut 25298c70f7 gsdx-ogl: move blending management into a separate function 2015-07-31 09:45:28 +02:00
Gregory Hainaut 25bd5f5e85 gsdx-ogl: request texture barrier to emulate accurate date
Actually it can partially be done with GL_ARB_shader_image_load_store
extension. However all drivers that support shader_image have
texture barrier too.
2015-07-31 09:45:28 +02:00
Gregory Hainaut 2901e94ebc gsdx-ogl: always bind the RT as input texture
To avoid code duplication
2015-07-31 09:45:28 +02:00
Gregory Hainaut 1fe3e04ce3 gsdx-ogl: don't alias m_env/m_context variable
It is cumbersome to move code
2015-07-31 09:45:28 +02:00
Gregory Hainaut 8f27a5a92b gsdx-ogl: only enable fast accurate colclip in level3
Until we drop the old method
2015-07-31 09:45:05 +02:00
Gregory Hainaut e026f1bac6 gsdx-ogl: implement a fast accurate colclip algo
The idea is to use a floating texture to accumulate the data and
then do a final postprocessing pass to apply the modulo

v2:
* use bounding box to
* fix vertex corruption issue
* use negative number in shader which allow to use half float (+12
  fps@4x)
2015-07-30 18:34:52 +02:00
Gregory Hainaut aa8f5848d1 gsdx-ogl: always issue a barrier when requested
Safer this way
2015-07-30 18:24:36 +02:00
Gregory Hainaut 88bd0996f5 gsdx-ogl: only print same tex/rt message when prims overlaps
Avoid most of the false positive
2015-07-30 18:24:32 +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 12fdc37599 gsdx-ogl: reorganize blending in the renderer
Do DATE algo selection before blending. This way we can detect bad
interaction.

Regroup all blending/colclip in a single block.  Avoid to check abe &&
rt multiple times.

v2: only enable sw blending when abe is true
2015-07-30 18:21:01 +02:00
Gregory Hainaut caadc73e1b gsdx-ogl: add a new level for accurate blending
The updated medium level will run for all sprites. It helps sotc blooming effect and it remains
fast enough to be enabled by default (at least on 3D games)
The new high level will run for all sprites + color clipping
2015-07-30 18:21:01 +02:00
Gregory Hainaut 01a1b1a5e6 gsdx-ogl: add the code to handle point and line in SW blending 2015-07-30 18:21:01 +02:00
Gregory Hainaut a85894e159 gsdx-ogl: move texture shuffle and fbmask into a dedicated function
DrawPrims is really too big now
2015-07-30 18:21:01 +02:00
Gregory Hainaut 5c1b8986c6 gsdx-ogl: use SW blending when no barrier is required
Speed penality is small (only GPU) but it is more accurate
2015-07-30 18:21:00 +02:00
Gregory Hainaut 8c8fe633a5 gsdx-ogl: merge 3 accurate* option into a nice combobox
It is much easier to configure this way
2015-07-30 18:21:00 +02:00
Gregory Hainaut 8da63cf95a gsdx-ogl: try to enable sw blending for sprite rendering
The idea is that sprites are often use for post-processing effect (ofc except 2D games)

Most of the time post-processing supports SW blending with a small speed penality. SW
blending is more accurate so it is better to use it.
2015-07-30 18:21:00 +02:00
Gregory Hainaut cb4af8fe83 gsdx-ogl: small optimization for the GPU
Gain: 1% at 4x on SotC (it partially compensates recent additions)

When the color is constant and equal to 128, the MODULATE mode is
equivalent to the DECAL mode. It saves 5 instructions on the FS.
2015-07-21 08:19:36 +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 88cd333839 gsdx-ogl: don't enable both HW&SW blending 2015-07-18 16:15:52 +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 698dda2310 gsdx-ogl: remove subroutine from the gui too 2015-07-17 22:28:59 +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 a4bad8fdbc gsdx-ogl: avoid a bad conflict between accurate option 2015-07-11 14:35:35 +02:00
Gregory Hainaut 15b934eb2a gsdx-ogl: remove useless colclip message 2015-07-11 14:35:35 +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 2ccf108534 gsdx-ogl: add back a selector for the Geometry Shader 2015-07-11 14:35:34 +02:00
Gregory Hainaut abec4bd760 gsdx-ogl: don't enable aout when using accurate fbmask 2015-07-03 21:21:56 +02:00
Gregory Hainaut 4dbe71cba8 gsdx-ogl: disable SW blending when running DATE GL42
// GL42 interact very badly with sw blending. GL42 uses the primitiveID to find the primitive
// that write the bad alpha value. Sw blending will force the draw to run primitive by primitive
// (therefore primitiveID will be constant to 1)
2015-07-03 20:34:52 +02:00
Gregory Hainaut 0c12f232ca gsdx-ogl: don't write depth in first step of DATE 42
Fix shadows in Fifa
2015-07-02 21:08:47 +02:00
Gregory Hainaut be1403cdc2 gsdx-ogl: support texture shuffling on !FST
Mostly fix "Finding Nemo"

It remains a shadows issue when you enable accurate_fbmask and depth
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 3b127f663b gsdx-tc: trace the texture format to detect texture shuffling
It fixes games that uses 16 bits RT (like snow engine games)
2015-07-01 09:36:53 +02:00
Gregory Hainaut 05c72980fc gsdx: avoid to detect PSMT8H as 16 bits 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 35081f922a gsdx: GS kinds of support draw without framebuffer
Gow uses 24 bits buffer, so only color is updated but blending is configured as Cd
so it is a NOP

In this case, we don't lookup the target in the texture cache. It reduces the complexity
to handle depth which can be located at same address as RT

Note: please test DX renderer
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 c1d39a5f57 gsdx-ogl: drop UserHacks_DateGL4
Initial goal was to avoid slowdown in buggy driver
2015-06-16 09:57:45 +02:00
Gregory Hainaut 4e82073bfc gsdx-ogl: improve setting bilinear of palette
Instead to disable it, uses GS settings
2015-06-09 09:53:50 +02:00
Gregory Hainaut 2503d9698c gsdx-ogl: re enable bilinear fitlering on palette for paltex mode
However keep it disabled for StarOcean 3 use cases
2015-06-08 21:01:18 +02:00
Gregory Hainaut c3c29945b2 gsdx-ogl: only set a cst blend factor when Ad is used
Fix GT4 and potentially FFX
2015-06-07 16:10:59 +02:00
Gregory Hainaut 0518aaedc9 gsdx-ogl: unattach palette to avoid noise in debug 2015-06-07 12:39:15 +02:00
Gregory Hainaut c2e851b3a5 gsdx-ogl: don't use slow SW blend for nothing
When A == B, coeff is 0 so <= 1
When C == 2, just check the value of coeff

Barely faster in accurate_blend = 2
2015-06-04 18:18:47 +02:00
Gregory Hainaut 3dd3bf6e2b gsdx-ogl: new hidden option accurate_blend = 2
Debug option to emulate all blending draw call in the shader

Of course it is slow but it is very accurate
2015-06-03 09:56:07 +02:00
Gregory Hainaut 995ae51bf4 gsdx-ogl: disable a log message
Too verbose and code was fixed anyway
2015-06-02 09:28:35 +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 d301848848 gsdx-ogl: fix paltex on opengl
RT uses as palette must use the alpha channel

Palette texture uses the red channel
2015-05-30 19:01:09 +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 9ee3a173d0 gsdx-ogl: use a local ALPHA register
It would allow to easy tune the parameter to support 24 bits format
2015-05-26 15:36:48 +02:00
Gregory Hainaut d31bd97d59 gsdx-ogl: add a variable to select FB output
Either 32bits/24bits/16bits
2015-05-26 14:59:07 +02:00
Gregory Hainaut 3be5a6036b gsdx-ogl: remove assertion + debug message
opengl use a different object to compute the vertex count
2015-05-26 11:03:59 +02:00
Gregory Hainaut 580d177951 gsdx: improve commit 11708486d8
This time linear filtering is disabled only for the bad draw call
(RT used as a palette texture).
2015-05-25 09:46:51 +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 7f614401a6 gsdx-ogl: set accurate_blend as default
Rendering is better and I think speed impact remains small.
2015-05-23 15:10:04 +02:00
Gregory Hainaut b884e0c0c0 gsdx-debug: improve debug experience
* Dump context before the increase of s_n
  => aligned with the global call number
* Don't print colclip not supported when it is optimized away
* dettach the input texture when it is useless
  => avoid to show a wrong texture in the debugger
2015-05-23 12:23:05 +02:00
Gregory Hainaut 183af4ece6 gsdx-ogl: don't enable SW blending when there is no blending
Mostly to avoid useless message
2015-05-20 09:36:01 +02:00