-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
HLSL supports returning values of array type. For example:
typedef uint32_t4 uint32_t8[2];
export uint32_t8 bleh(uint32_t4 A, uint32_t4 B) {
uint32_t8 output = {A, B};
return output;
}In HLSL Arrays are passed by value, and can be returned by value. We should treat an array return type like a structure return type (sret), and pre-allocate the memory for the array and return into the pre-allocated memory.
FXC and DXC disagree about the parsing for these types. DXC supports array return types when the array is either a typedef or using the syntax <type> <function name>(<parameter list>)[<array size>].
FXC requires the use of a typedef and cannot parse the array-ness directly in the function declaration:
Tried here using the C-based syntax DXC supports -> https://shader-playground.timjones.io/4ee7eb08392d718f6c4361d3a4f0a2b8
Tried here using a more sane-seeming syntax -> https://shader-playground.timjones.io/63496da689c53fa78f697e56112f6290
Working with a typedef- > https://shader-playground.timjones.io/7f68b0373dfe7a5c863234c2245659eb
DXC's non-typedef syntax:
typedef uint32_t4 uint32_t8[2];
export uint32_t4 bleh(uint32_t4 A, uint32_t4 B)[2] {
uint32_t4 output[] = {A, B};
return output;
}Metadata
Metadata
Assignees
Labels
Type
Projects
Status