From 52b78ad9bf99660593c49a8da0bdcec19016ee25 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 31 Jan 2020 08:55:40 -0500 Subject: 64 bit types doc (#1194) * * For integer literals add postfix, and use unsigned/signed output appropriately * Extend GLSL extension handling by type, and for adding 64 bit int extensions * Added tests for int/uint64 types * Add explicit Int/UInt64 emit functions to avoid ambiguity. * Fix uint64_t intrinsics on CUDA/C++. * WIP 64 bit types documentation. * Testing int64 intrinsic support. * Dx12 Dxil sm6.0 does actually support int64_t. --- docs/64bit-type-support.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 docs/64bit-type-support.md (limited to 'docs/64bit-type-support.md') diff --git a/docs/64bit-type-support.md b/docs/64bit-type-support.md new file mode 100644 index 000000000..6b026d3b2 --- /dev/null +++ b/docs/64bit-type-support.md @@ -0,0 +1,78 @@ +Slang 64-bit Type Support +========================= + +The Slang language supports 64 bit built in types. Such as + +* double +* uint64_t +* int64_t + +This also applies to vector and matrix versions of these types. + +Unfortunately if a specific target supports the type or the typical HLSL instrinsic functions (such as sin/cos/max/min etc) depends very much on the target. + +Note this initial testing only tested scalar usage, and not vector or matrix intrinsics. + +Double support +============== + +Target | Compiler/Binary | Double Type | Intrinsics | Notes +---------|------------------|----------------|-----------------------|----------- +CPU | | Yes | Yes | 1 +CUDA | Nvrtx/PTX | Yes | Yes | 1 +D3D12 | DXC/DXIL | Yes | No | 2 +Vulkan | GlSlang/Spir-V | Yes | No | 3 +D3D11 | FXC/DXBC | No | No | +D3D12 | FXC/DXBC | No | No | + +1) CUDA and CPU support most intrinsics, with the notable exception currently of matrix invert +2) Requires SM 6.0 and above https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12 +3) Restriction is described in https://www.khronos.org/registry/spir-v/specs/1.0/GLSL.std.450.html +Note that GlSlang does produce spir-v that contains double intrinsic calls, the failure happens when validating the Spir-V + +``` +Validation: error 0: [ UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object: VK_NULL_HANDLE (Type = 0) | SPIR-V module not valid: GLSL.std.450 Sin: expected Result Type to be a 16 or 32-bit scalar or vector float type + %57 = OpExtInst %double %1 Sin %56 +``` + +D3D12 and VK may have some very limited intrinsic support such as sqrt, rsqrt + +uint64_t Support +================= + +Target | Compiler/Binary | uint64_t Type | Intrinsic support | Notes +---------|------------------|----------------|--------------------|-------- +CPU | | Yes | Yes | +CUDA | Nvrtx/PTX | Yes | Yes | +D3D12 | DXC/DXIL | Yes | Yes | +Vulkan | GlSlang/Spir-V | Yes | Yes | +D3D11 | FXC/DXBC | No | No | 1 +D3D12 | FXC/DXBC | No | No | 1 + +1) uint64_t support requires https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12, so DXBC is not a target. + +The intrinsics available on uint64_t type are `abs`, `min`, `max`, `clamp` and `countbits`. + +int64_t Support +================ + +Target | Compiler/Binary | int64_t Type | Intrinsic support | Notes +---------|------------------|----------------|--------------------|-------- +CPU | | Yes | Yes | +CUDA | Nvrtx/PTX | Yes | Yes | +Vulkan | GlSlang/Spir-V | Yes | Yes | +D3D12 | DXC/DXIL | Yes | Yes | 1 +D3D11 | FXC/DXBC | No | No | 2 +D3D12 | FXC/DXBC | No | No | 2 + +1) The sm6.0 docs (https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12) describe only supports uint64_t, but the dxc compiler page says int64_t is supported in HLSL 2016 (https://github.com/Microsoft/DirectXShaderCompiler/wiki/Language-Versions). Tests show that this is indeed the case. + +2) uint64_t support requires https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12, so DXBC is not a target. + +The intrinsics available on uint64_t type are `abs`, `min`, `max` and `clamp`. + +GLSL +==== + +GLSL/Spir-v based targets do not support 'generated' intrinsics on matrix types. For example 'sin(mat)' will not work on GLSL/Spir-v. + -- cgit v1.2.3