DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
[SPIR-V] asdouble has invalid return type and failes to compile when targeting SPIRV
When trying to use the asdouble HLSL api SPIR-V emits an invalid return type.
spirv:
DXC_Debug_BUILD/bin/dxc scratch/asdouble_spirv_test.hlsl -T lib_6_8 -spirv -fspv-target-env=universal1.5 -O0
export double4 fn(uint4 p1, uint4 p2) {
return asdouble(p1, p2);
}
fatal error: generated SPIR-V is invalid: OpReturnValue Value <id> '15[%15]'s type does not match OpFunction's return type.
OpReturnValue %15
DXIL:
DXC_Debug_BUILD/bin/dxc scratch/asdouble_spirv_test.hlsl -T lib_6_8 -O0
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
target triple = "dxil-ms-dx"
@dx.nothing.a = internal constant [1 x i32] zeroinitializer
; Function Attrs: nounwind
define <4 x double> @"\01?fn@@YA?AV?$vector@N$03@@V?$vector@I$03@@0@Z"(<4 x i32> %p1, <4 x i32> %p2) #0 {
%1 = extractelement <4 x i32> %p1, i64 0
%2 = extractelement <4 x i32> %p2, i64 0
%3 = call double @dx.op.makeDouble.f64(i32 101, i32 %1, i32 %2) ; MakeDouble(lo,hi)
%4 = insertelement <4 x double> undef, double %3, i64 0
%5 = extractelement <4 x i32> %p1, i64 1
%6 = extractelement <4 x i32> %p2, i64 1
%7 = call double @dx.op.makeDouble.f64(i32 101, i32 %5, i32 %6) ; MakeDouble(lo,hi)
%8 = insertelement <4 x double> %4, double %7, i64 1
%9 = extractelement <4 x i32> %p1, i64 2
%10 = extractelement <4 x i32> %p2, i64 2
%11 = call double @dx.op.makeDouble.f64(i32 101, i32 %9, i32 %10) ; MakeDouble(lo,hi)
%12 = insertelement <4 x double> %8, double %11, i64 2
%13 = extractelement <4 x i32> %p1, i64 3
%14 = extractelement <4 x i32> %p2, i64 3
%15 = call double @dx.op.makeDouble.f64(i32 101, i32 %13, i32 %14) ; MakeDouble(lo,hi)
%16 = insertelement <4 x double> %12, double %15, i64 3
%17 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @dx.nothing.a, i32 0, i32 0)
ret <4 x double> %16
}
; Function Attrs: nounwind readnone
declare double @dx.op.makeDouble.f64(i32, i32, i32) #1
attributes #0 = { nounwind }
attributes #1 = { nounwind readnone }
!llvm.ident = !{!0}
!dx.version = !{!1}
!dx.valver = !{!1}
!dx.shaderModel = !{!2}
!dx.entryPoints = !{!3}
!0 = !{!"dxc(private) 1.8.0.14649 (main, 206133c9e)"}
!1 = !{i32 1, i32 8}
!2 = !{!"lib", i32 6, i32 8}
!3 = !{null, !"", null, null, !4}
!4 = !{i32 0, i64 8388612}
would this work for you?
template<class T, class U>
[[vk::ext_instruction(spv::OpBitcast)]]
T bitcast(U);