Closed
Labels
feature requestA request for a new GPU feature exposed in the API
Milestone
Description
Add the blend modes: "src1-color", "one-minus-src1-color", "src1-alpha", "one-minus-src1-alpha", "src1-alpha-saturated". Each of these has a direct analogue in Vulkan, Metal and Direct3D12.
Dual source blending provides for applications that blend in multiple ways (for example to support the Porter-Duff blend modes) can significantly reduce pipeline state object changes and open the door to applications for more flexible blending.
I am advocating for this feature as part 1.0 release and not as an extension.
Reacted by Dzmitry Malyshau
Metadata
Metadata
Assignees
Labels
feature requestA request for a new GPU feature exposed in the API
Activity
kainino0x commentedon Aug 8, 2019
This feature is optional in Vulkan, and not available on some ARM/Qualcomm/Imagination GPUs:
http://vulkan.gpuinfo.org/listreports.php?feature=dualSrcBlend&option=not
It's not clear to me exactly why some of these do not support it; I can find an Adreno 530 which supports it and an Adreno 540 which does not. Probably driver version related?
kainino0x commentedon Aug 8, 2019
Also, there seem to be NO ARM and Imagination GPUs that support it.
magcius commentedon Aug 8, 2019
DSB usage is quite rare, and I remember having enough problems with driver support and bugs back when that when I was trying to implement subpixel text rendering, I just chose to make the text a single color and use blend-color instead.
I would prefer if it was an extension. And as we've seen, some hardware doesn't have support for it.
krogovin commentedon Aug 8, 2019
Let's mark the support as optional then. From what I know of Imaginations Technology GPU's I am pretty sure it could be implemented, but they would need to have a business case to do so. Another chicken-egg fiasco.
Lets make it optional but I would prefer at 1.0 instead of an extension as a way to prod ISV's to support it and to support it well.
litherum commentedon Sep 15, 2019
What’s the motivation for this feature? What use-cases does it make possible?
It strikes me that WebGPU app developers could implement this themselves if they could do programmable blending.
krogovin commentedon Sep 16, 2019
If programmable blending, i.e. framebuffer fetch is available, then yes, a WebGPU app can do dual source blending itself.
However, if framebuffer fetch is not available (or another means of doing programmable blending), then dual source blending not only opens up additional blending possibilities but also gives applications a possibility to cut down on the number of blend states needed. Indeed, to implement all 12 PorterDuff modes requires only three distinct blend modes. Direct3D has had dual source blending for a long time as has desktop OpenGL.
But to reiterate, for me, the preference order is:
kvark commentedon Sep 16, 2019
@litherum WebRender relies on DSB for rendering subpixel AA text without doing multiple passes.
I think, exposing dual-source blending is attractive, as an extension, because it's clearly defined and it requires only a tiny API to be added (a few blend factor variants).
magcius commentedon Sep 16, 2019
Even Metal doesn't have programmable blending on desktop platforms. It's something that's much trickier to do on non-tilers.
krogovin commentedon Sep 17, 2019
This is why I advocate framebuffer fetch and interlock to be available as extensions.
krogovin commentedon May 20, 2020
Something that I should have mentioned quite some time ago, but I did not. Without dual-source blending, it is nearly impossible to directly support all of the Porter-Duff blend modes with a shader computing a partial coverage value.
Indeed, for Skia, without dual source blending, for a number of blend modes, it issues a glCopyTexImage2D for some of the blend modes. Ironically, this is needed for kSrc (but not kSrcOver).
So please, do not let this be forgotten.
Now to beg/ask in the correct place for GL_EXT_blend_func_extended in WebGL/WebGL2
Break gen_listings dep on ts-node / fast-glob. Add src_dir/out_dir ar…
teoxoy commentedon Aug 11, 2023
Some additional info on this:
When dual-source blending, you can't write to multiple render targets (only the one at index 0). References:
D3D12_BLEND_OPlinks to Output-Merger Stage which has a section on "Dual-Source Color Blending" indicating that it's not possible to bind multiple render attachments.maxFragmentDualSrcAttachmentslimit is always 1 in practice.GL_MAX_DUAL_SOURCE_DRAW_BUFFERSis also 1 in practice.You have to at least declare the 2nd blend src in the shader due to at least Vulkan.
from https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap30.html#framebuffer-dsb
You shouldn't declare/write to any other locations due to at least DX12.
from https://learn.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage#dual-source-color-blending
bjjones commentedon Sep 7, 2023
I just opened a formal investigation and proposal for this feature at #4283. This comes after recently completing a prototype implementation of the feature in Chromium/Dawn.
Additionally, @teoxoy, I appreciate you documenting many of the specific native API restrictions, which I've used in my proposal.
Kangz commentedon Sep 26, 2023
Closing in favor of #4283 that links to this issue and has a proposal.