How to write dual source blend output in Metal #7960
-
The second blend color for dual source blending is accessed in Metal by writing a variable tagged Texture2D<float4> tex0;
Texture2D<float4> tex1;
SamplerState samp;
struct Output {
[[vk::location(0), vk::index(0)]] float4 col0;
[[vk::location(0), vk::index(1)]] float4 col1;
};
[[shader("fragment")]]
Output main(float2 coord : TEXCOORD0) {
return { tex0.Sample(samp, coord), tex1.Sample(samp, coord) };
} The docs say "The #include <metal_stdlib>
#include <metal_math>
#include <metal_texture>
using namespace metal;
struct Output_0
{
float4 col0_0 [[user(_SLANG_ATTR)]];
float4 col1_0 [[user(_SLANG_ATTR)]];
};
Output_0 Output_x24init_0(float4 col0_1, float4 col1_1)
{
thread Output_0 _S1;
(&_S1)->col0_0 = col0_1;
(&_S1)->col1_0 = col1_1;
return _S1;
}
struct pixelInput_0
{
float2 coord_0 [[user(TEXCOORD)]];
};
struct KernelContext_0
{
texture2d<float, access::sample> tex0_0;
sampler samp_0;
texture2d<float, access::sample> tex1_0;
};
[[fragment]] Output_0 main_0(pixelInput_0 _S2 [[stage_in]], texture2d<float, access::sample> tex0_1 [[texture(0)]], sampler samp_1 [[sampler(0)]], texture2d<float, access::sample> tex1_1 [[texture(1)]])
{
KernelContext_0 kernelContext_0;
(&kernelContext_0)->tex0_0 = tex0_1;
(&kernelContext_0)->samp_0 = samp_1;
(&kernelContext_0)->tex1_0 = tex1_1;
return Output_x24init_0((((&kernelContext_0)->tex0_0).sample(((&kernelContext_0)->samp_0), (_S2.coord_0))), ((tex1_1).sample(((&kernelContext_0)->samp_0), (_S2.coord_0))));
} Both outputs are marked with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I guess this is related to I don't think Slang supports it yet. |
Beta Was this translation helpful? Give feedback.
I guess this is related to
https://registry.khronos.org/OpenGL/extensions/ARB/ARB_blend_func_extended.txt
I don't think Slang supports it yet.
Please create a new "issue" as a new feature request.