-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply unsupported blending modes in the shader #6070
Conversation
Potentially we could also try not blitting as described in #3001 (comment), for certain GPUs. -[Unknown] |
We could blit on ES2 on Tegra using NV_framebuffer_blit - but of course, on Tegra we don't need it as we can use gl_LastFragColor. Anyway, we could fake blitting the color buffer fairly easily on plain ES2 too by simply rendering a quad with a pass through shader, although a little more expensive. That's for future pull requests though. I'll merge this once it has received a little bit of testing. |
Right, well, we could replace all the unsupported blits with "BlitFramebuffer_", I guess. -[Unknown] |
The ones that blit (or care about) only the color buffer, yeah. Can't do depth that way. |
What about a GL_DEPTH24_STENCIL8 texture? Can't those be bound too? -[Unknown] |
Not as textures, In unextended ES 2.0, there are no depth textures (although you can write to depth in the shader). There are extensions though so it can work on some chips (maybe quite a lot). |
return true; | ||
|
||
case GE_SRCBLEND_FIXA: | ||
if (funcB == GE_DSTBLEND_FIXB) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you could also filter out the cases where one of the fix colors is 0xFFFFFF or 0x0, as those are already handled correctly by regular blending by replacing them with GL_ONE/GL_ZERO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did it, yeah.
-[Unknown]
Do permit me to do the usual and report back later. Hopefully the hit isn't too bad on my system. |
Well, if it gets used a lot the hit will be bad, but these blending modes are only used in certain games and usually not many times per frame. Here are some of them: http://report.ppsspp.org/logs/kind/353 Hmm, I wonder how this impacts God Eater 2.... demo seems not majorly impacted. -[Unknown] |
Otherwise, the frag shader might be generated accounting for different vertexFullAlpha values, or otherwise won't match up with the id, since we change flags between the two Apply calls.
@unknownbrackets @hrydgard General Observations:-
Conclusion:- Seems like the pull request is good to go. I was expecting a severe performance hit in GEB (since it's a part of the lists http://report.ppsspp.org/logs/kind/353 and http://report.ppsspp.org/logs/kind/83), but it's relatively minor. |
Well, Gods Eater Burst actually loses 4% for me with this (947% -> 910%), but only in areas and conditions where the blend is triggered. It does a blend of 0xfefefe/0x808080, which this currently triggers for (I could probably allow a variance of 0xfefefe though... Anyway, I'm able now to reproduce (without forcing it) a box in the top left when blending, but I can't figure out why. The framebuffer and fbotex are the right size. It's not strongly noticeable, but i don't get what's causing it. You can reproduce as follows:
This occurs for 1x as well as 2x/3x/etc., so it's not something to do with sizing. The buffer is already selected and estimated by the time it hits ApplyDrawState, so it shouldn't be sizing either... I don't get it. -[Unknown] |
if (funcA != GE_SRCBLEND_DSTCOLOR || funcB != GE_DSTBLEND_SRCCOLOR) { | ||
WARN_LOG_REPORT(G3D, "Using MIN blend equation with odd factors: %d, %d", funcA, funcB); | ||
} | ||
WRITE(p, " v.rgb = min(v.rgb, destColor.rgb);\n", srcFactor, dstFactor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think MIN/MAX/ABSDIFF don't need the srcFactor and dstFactor (though no %s and being used in equation)
Dragon Ball Z uses a CLUT on an FBO, which is not supported without the other changes. That's why it's black. -[Unknown] |
Arr yes . I almost forget it has to been used with framebuffer-clut branch. |
texelFetch is not supported on ES 2.0 .Wondering would it be good to fall back to use texture2D though need more work to cope with the screen resolution . |
What is the actual texture it's using absdiff with? Do we have an issue already for it (I don't know the name so can't search)? -[Unknown] |
@unknownbrackets , yep , there is already an issue tracking it though it is closed #1982 I'll check the actual texture when i back home . On our current implemenation for ABSDIFF blending , we are passing GL_MAX to approximate it . |
So, that looks similar (but much worse) to the problem in God Eater 1 and Gods Eater Burst. I don't know what's causing it, but it's rendering at the wrong size somehow. There shouldn't be anything to trigger that here? I tried scaling the params to texelFetch, but that just moves the window up and down.. maybe I did it wrong. Maybe I should not trust abs()? Does it help to change this: To: Also, are any of these games reporting odd blending factors? -[Unknown] |
This handles unsupported fixed color combinations, alpha doubling, etc. Where possible, tries to avoid it - it means using a blit (without the framebuffer fetch extension), which can slow things down a lot with tons of drawcalls.
Was all lies.
Just in case there are problems with decimating it or etc.
Seems from reports that they are indeed ignored, just wanted to verify.
Aha, I think I found it. Scissor affects glBlitFramebuffer()? "When values are written to the draw buffers, blit operations bypass most of the fragment pipeline. The only fragment operations which affect a blit are the pixel ownership test, the scissor test, and sRGB conversion" Well, so it does. Mystery solved, fix upcoming. -[Unknown] |
Ah, nice!! What does the performance impact of this branch look like now? |
@daniel229 how is God Eater 2? @raven02 how is Dai2Ji Super Robot Taisen Z Hakaihen now? @hrydgard I don't know, I'm too tired now to test it, before it was not really that bad but it depends on how many blits it does... it will report "Lots of blits needed for obscure blending: %d per frame, blend %d/%d/%d" on a problem. Could use wider testing, mostly of these: I have not even tried Tactics Ogre yet... -[Unknown] |
Alright, I'll wait for more testing before deciding whether we need a setting, and merging. |
@unknownbrackets I think you mean revert this #6067 and test,because that is hiding issue.Revert it,and God Eater 2 is still fine with this branch. |
Macross Triangle Frontier report this,but I don't where is the problem. Beats, |
Well, it would mainly be during effects, but yeah, probably hard to find... That's a GE_SRCBLEND_DOUBLESRCALPHA / GE_DSTBLEND_INVSRCALPHA / GE_BLENDMODE_MUL_AND_ADD blend. What that means is textures/vertices that don't use full alpha, so we can't just flip it to color doubling. As long as performance was okay, it might be alright. 26 is high but not super bad. Will be worse on slower devices, though... Yeah, I had to revert that change to test it. -[Unknown] |
Let's merge and see how it goes. If there's severe slowdown this merits a setting but it seems for most games it works fine so we'll default to on. |
Apply unsupported blending modes in the shader
This handles unsupported fixed color combinations, alpha doubling, etc.
Where possible, tries to avoid it - it means using a blit (without the framebuffer fetch extension), which can slow things down a lot with tons of drawcalls.
This fixes some effects in games which use doubling blend modes, but I haven't tested all the cases (especially since I don't have all the games.) It also does absdiff blending and mismatched fixed color blending. It will not help GLES2, and requires GLES3+ or OpenGL 3.0+.
I'm worried this might need a setting. Before I made
AlphaToColorDoubling() || CanDoubleSrcBlendMode()
bail, it made Popolocrois severely slower. However, it does allow more accuracy.-[Unknown]