In OpenCL, the default dst output layer is set to a varying layer.
In the code, @dst accepts float and float4, but not float2 or float3. Honestly, I'm really curious why.
But accepting float4 as the output still makes dst a monolayer, even though it's a varying layer. There probably is some meaning to this, but what?
OpenCL and Varying Layer
154 1 0-
- Gaalvk
- Member
- 24 posts
- Joined: March 2025
- Offline
-
- jlait
- Staff
- 6826 posts
- Joined: July 2005
- Offline
@dst accepts only float4, but OpenCL will widen float -> float4 for you. It doesn't widen the others.
Varying Layer means the real type of the output will not have to be strictly float4.
The problem is we want to write a gamma kernel, but not have to write a float, float2, float3, and float4 versions of it. So we write only the float4 version, and let COPs throw away the extra data when we write to @dst. Likewise, when we read from the source layer we implicitly widen.
This does mean we are doing extra computation; but as the time seems to be dominated with the memory costs we bear with it...
If using #bind to set up the signature, the varying is created with the float? type. The size for outputs will then be determined by the first menu of the "Metadata" option on the signature page. By default this is "First Input", which means all the varying writeable layers will match your first input, which usually is a good guess.
You can alternatively set it to "Match Name" so the source of the same name will be used, if it exists, or specify a specific input to copy the size from.
Varying Layer means the real type of the output will not have to be strictly float4.
The problem is we want to write a gamma kernel, but not have to write a float, float2, float3, and float4 versions of it. So we write only the float4 version, and let COPs throw away the extra data when we write to @dst. Likewise, when we read from the source layer we implicitly widen.
This does mean we are doing extra computation; but as the time seems to be dominated with the memory costs we bear with it...
If using #bind to set up the signature, the varying is created with the float? type. The size for outputs will then be determined by the first menu of the "Metadata" option on the signature page. By default this is "First Input", which means all the varying writeable layers will match your first input, which usually is a good guess.
You can alternatively set it to "Match Name" so the source of the same name will be used, if it exists, or specify a specific input to copy the size from.
-
- Quick Links

