Skip to content

Commit

Permalink
Handle pointer types when getting type cast style
Browse files Browse the repository at this point in the history
Closes #6025
  • Loading branch information
expipiplus1 committed Feb 26, 2025
1 parent f7b9745 commit 651fc8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/slang/slang-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3970,7 +3970,10 @@ static TypeCastStyle _getTypeStyleId(IRType* type)
{
return _getTypeStyleId(matrixType->getElementType());
}
// Try to simplify style if we can, otherwise just handle it unsimplified
auto style = getTypeStyle(type->getOp());
if (style == kIROp_Invalid)
style = type->getOp();
switch (style)
{
case kIROp_IntType:
Expand Down
16 changes: 16 additions & 0 deletions tests/metal/simple-vertex-position.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage vertex -entry vertexMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage vertex -entry vertexMain
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage vertex -entry vertexMain
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage vertex -entry vertexMain

//METAL: position
//METALLIB: @vertexMain

//WGSL: @builtin(position)
//WGSLSPIRV: %vertexMain = OpFunction

// Vertex Shader which writes to position
void vertexMain(out float4 position : SV_Position)
{
position = float4(0.6, 0.1, 0.6, 0.33);
}

0 comments on commit 651fc8b

Please sign in to comment.