-
Notifications
You must be signed in to change notification settings - Fork 303
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
Dual Source Blending Investigation + Feature Proposal #4283
Comments
I find the There is also the fact that currently the index can only be 0 or 1. If we do, I'd propose to use something like |
What about |
From the implementation perspective I think it's a bit neater to explicitly include an attribute on the src0 blend source. Underneath we do need to know for validation and backend shading language generation. If we just had
Which I think is less desirable than:
It's not a huge deal, but I don't see a significant benefit to leaving the src0 attribute implicit and the implementation could be cleaner with the explicit attribute. I have no significant opinion on the naming. |
To collate suggestions on the WGSL syntax (from here and from a google/mozilla discussion), described by what attributes they'd allow:
|
I wanted to see what these really looked like:
|
This comment was marked as outdated.
This comment was marked as outdated.
One angle from which to compare these: when the |
Besides 1, 5 and 7 the others look good to me. |
Same as @teoxoy though small preference for 2 and 3 overall. |
2 and 3 are my favorites. |
Between 2 and 3 (or in 4/6/9), preference to match the spelling of "source"/"src" we use in the API spec. |
GPU Web 2023-11-29 Atlantic-time
|
Overview
Dual-source blending is a feature available on most platforms that allows a developer to specify blending from two fragment shader outputs to a single framebuffer. This feature has some desirable applications and should be considered as an optional post-V1 WebGPU feature.
Usages
This feature was requested previously in issue #391 with some brief discussion of usages.
Additionally, I've pulled these two scenarios from the spec of the similar OpenGL extension:
D3D12
Dual source blending is supported on all D3D12 platforms as a core feature. [MSDN]
When using dual-source blending, writing to other render targets is undefined. [MSDN]
[D3D12_BLEND Enum]
HLSL
To specify the two blend sources in an HLSL shader, you must use
SV_Target0
andSV_Target1
as fragment shader outputs, which correspond to the indices of the dual-source blend. [MSDN]Vulkan
Dual source blending is available on Vulkan as an extension. You must query the
dualSrcBlend
feature to determine if the required enumerations can be used. [Khronos]The
dualSrcBlend
feature is available on 72.6% of devices. This feature is overwhelmingly supported on Windows, Linux, MacOS and iOS devices, however, only 49.5% of Android devices have support. Android devices that do not supportdualSrcBlend
primarily use ARM, ImgTec, and Qualcomm GPUs. [GPUInfo]Vulkan's
maxFragmentDualSrcAttachments
limit is 1 for most platforms.Vulkan specifies that the dual-source blend operation is undefined if the secondary source is not set. [Khronos]
[VkBlendFactor Enum]
SPIR-V
SPIR-V uses the
index n
decoration following alocation n
decoration to specify the blend index of the output. [Khronos]Metal
Dual-source blending appears to be available on all currently supported platforms [Metal Feature Set Tables]
Metal doesn't support multiple render targets when using dual-source blending [Apple Developer]
[MTLBlendFactor Enum]
MSL
Metal Shading Language uses the
index(n)
attribute following acolor(n)
attribute to specify the blend index of the output. [Apple Developer]Proposal
WebGPU:
Because dual source blending is a desirable feature, but is not supported on all platforms, we should add
dual-source-blending
as an optional post-V1 WebGPU feature.dual-source-blending
should add the following enums to GPUBlendFactor:WGSL:
When
dual-source-blending
is enabled, allow the@index
attribute to specify the dual-source blend index when added to a fragment shader output alongside the@location
attribute.An example shader:
Restrictions:
src1
GPUBlendFactors must be restricted to color attachment 0. (Due to HLSL's restricted dual source blend output targets)@index
attribute must be restricted to@location(0)
. (Due to HLSL's restricted dual source blend output targets)The text was updated successfully, but these errors were encountered: