diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 211 | ||||
| -rw-r--r-- | source/slang/hlsl.meta.slang.h | 211 | ||||
| -rw-r--r-- | source/slang/slang-profile-defs.h | 9 |
3 files changed, 431 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 41a69382d..f8ae340bc 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -1847,3 +1847,214 @@ float3x4 WorldToObject() { return WorldToObject3x4(); } // 10.4.4 - Hit Specific System values __target_intrinsic(glsl, "(gl_HitKindNV)") uint HitKind(); + +// Pre-defined hit kinds (not documented explicitly) +static const uint HIT_KIND_TRIANGLE_FRONT_FACE = 254; +static const uint HIT_KIND_TRIANGLE_BACK_FACE = 255; + +// +// Shader Model 6.4 +// + +// Treats `left` and `right` as 4-component vectors of `UInt8` and computes `dot(left, right) + acc` +uint dot4add_u8packed(uint left, uint right, uint acc); + +// Treats `left` and `right` as 4-component vectors of `Int8` and computes `dot(left, right) + acc` +int dot4add_i8packed(uint left, uint right, int acc); + +// Computes `dot(left, right) + acc`. +// +// May not produce infinities or NaNs for intermediate results that overflow the range of `half` +float dot2add(float2 left, float2 right, float acc); + +// +// Mesh Shaders +// + +// Set the number of output vertices and primitives for a mesh shader invocation. +void SetMeshOutputCounts(uint vertexCount, uint primitiveCount); + +// Specify the number of downstream mesh shader thread groups to invoke from an amplification shader, +// and provide the values for per-mesh payload parameters. +// +void DispatchMesh<P>(uint threadGroupCountX, uint threadGroupCountY, uint threadGroupCountZ, P meshPayload); + +// +// TODO: "Sampler feedback" types `FeedbackTexture2D` and `FeedbackTexture2DArray`. +// + +// +// DXR 1.1 and `TraceRayInline` support +// + +// Status of whether a (closest) hit has been committed in a `RayQuery`. +typedef uint COMMITTED_STATUS; + +// No hit committed. +static const COMMITTED_STATUS COMMITTED_NOTHING = 0; + +// Closest hit is a triangle. +// +// This could be an opaque triangle hit found by the fixed-function +// traversal and intersection implementation, or a non-opaque +// triangle hit committed by user code with `RayQuery.CommitNonOpaqueTriangleHit` +// +static const COMMITTED_STATUS COMMITTED_TRIANGLE_HIT = 1; + +// Closest hit is a procedural primitive. +// +// A procedural hit primitive is committed using `RayQuery.CommitProceduralPrimitiveHit`. +static const COMMITTED_STATUS COMMITTED_PROCEDURAL_PRIMITIVE_HIT = 2; + +// Type of candidate hit that a `RayQuery` is pausing at. +// +// A `RayQuery` can automatically commit hits with opaque triangles, +// but yields to user code for other hits to allow them to be +// dismissed or committed. +// +typedef uint CANDIDATE_TYPE; + +// Candidate hit is a non-opaque triangle. +static const CANDIDATE_TYPE CANDIDATE_NON_OPAQUE_TRIANGLE = 0; + +// Candidate hit is a procedural primitive. +static const CANDIDATE_TYPE CANDIDATE_PROCEDURAL_PRIMITIVE = 1; + +// Handle to state of an in-progress ray-tracing query. +// +// The ray query is effectively a coroutine that user shader +// code can resume to continue tracing the ray, and which yields +// back to the user code at interesting events along the ray. +// +struct RayQuery<let rayFlags : RAY_FLAG = RAY_FLAG_NONE> +{ + // Initialize a ray-tracing query. + // + // This method may be called on a "fresh" ray query, or + // on one that is already tracing a ray. In the latter + // case any state related to the ray previously being + // traced is overwritten. + // + // The `rayFlags` here will be bitwise ORed with + // the `rayFlags` passed as a generic argument to + // `RayQuery` to get the effective ray flags, which + // must obey any API-imposed restrictions. + // + void TraceRayInline(RaytracingAccelerationStructure accelerationStructure, RAY_FLAG rayFlags, uint instanceInclusionMask, RayDesc ray); + + // Resume the ray query coroutine. + // + // If the coroutine suspends because of encountering + // a candidate hit that cannot be resolved with fixed-funciton + // logic, this function returns `true`, and the `Candidate*()` + // functions should be used by application code to resolve + // the candidate hit (by either committing or ignoring it). + // + // If the coroutine terminates because traversal is + // complete (or has been aborted), this function returns + // `false`, and application code should use the `Committed*()` + // functions to appropriately handle the closest hit (it any) + // that was found. + // + bool Proceed(); + + // Causes the ray query to terminate. + // + // This function cases the ray query to act as if + // traversal has terminated, so that subsequent + // `Proceed()` calls will return `false`. + // + void Abort(); + + // Get the type of candidate hit being considered. + // + // The ray query coroutine will suspend when it encounters + // a hit that cannot be resolved with fixed-function logic + // (either a non-opaque triangle or a procedural primitive). + // In either of those cases, `CandidateType()` will return + // the kind of candidate hit that must be resolved by + // user code. + // + CANDIDATE_TYPE CandidateType(); + + // Access properties of a candidate hit. + // + float3x4 CandidateObjectToWorld3x4(); + float4x3 CandidateObjectToWorld4x3(); + float3x4 CandidateWorldToObject3x4(); + float4x3 CandidateWorldToObject4x3(); + uint CandidateInstanceIndex(); + uint CandidateInstanceID(); + uint CandidateGeometryIndex(); + uint CandidatePrimitiveIndex(); + uint CandidateInstanceContributionToHitGroupIndex(); + + // Access properties of the ray being traced + // in the object space of a candidate hit. + // + float3 CandidateObjectRayOrigin(); + float3 CandidateObjectRayDirection(); + + // Access properties of a candidate procedural primitive hit. + // + bool CandidateProceduralPrimitiveNonOpaque(); + + // Access properties of a candidate no-opaque triangle hit. + // + bool CandidateTriangleFrontFace(); + float2 CandidateTriangleBarycentrics(); + float CandidateTriangleRayT(); + + // Commit the current non-opaque triangle hit. + void CommitNonOpaqueTriangleHit(); + + // Commit the current procedural primitive hit, with hit time `t`. + void CommitProceduralPrimitiveHit(float t); + + // Get the status of the committed (closest) hit, if any. + COMMITTED_STATUS CommittedStatus(); + + // Access properties of the committed hit. + // + float3x4 CommittedObjectToWorld3x4(); + float4x3 CommittedObjectToWorld4x3(); + float3x4 CommittedWorldToObject3x4(); + float4x3 CommittedWorldToObject4x3(); + float CommittedRayT(); + uint CommittedInstanceIndex(); + uint CommittedInstanceID(); + uint CommittedGeometryIndex(); + uint CommittedPrimitiveIndex(); + uint CommittedInstanceContributionToHitGroupIndex(); + + // Access properties of the ray being traced + // in the object space of a committed hit. + // + float3 CommittedObjectRayOrigin(); + float3 CommittedObjectRayDirection(); + + // Access properties of a committed triangle hit. + // + bool CommittedTriangleFrontFace(); + float2 CommittedTriangleBarycentrics(); + + // Access properties of the ray being traced. + uint RayFlags(); + float3 WorldRayOrigin(); + float3 WorldRayDirection(); + float RayTMin(); +} + +// +// Vulkan/SPIR-V specific features +// + +struct VkSubpassInput<T> +{ + T SubpassLoad(); +} + +struct VkSubpassInputMS<T> +{ + T SubpassLoad(int sampleIndex); +} diff --git a/source/slang/hlsl.meta.slang.h b/source/slang/hlsl.meta.slang.h index 6721d4a28..215d18670 100644 --- a/source/slang/hlsl.meta.slang.h +++ b/source/slang/hlsl.meta.slang.h @@ -1927,3 +1927,214 @@ SLANG_RAW("\n") SLANG_RAW("// 10.4.4 - Hit Specific System values\n") SLANG_RAW("__target_intrinsic(glsl, \"(gl_HitKindNV)\")\n") SLANG_RAW("uint HitKind();\n") +SLANG_RAW("\n") +SLANG_RAW("// Pre-defined hit kinds (not documented explicitly)\n") +SLANG_RAW("static const uint HIT_KIND_TRIANGLE_FRONT_FACE = 254;\n") +SLANG_RAW("static const uint HIT_KIND_TRIANGLE_BACK_FACE = 255;\n") +SLANG_RAW("\n") +SLANG_RAW("//\n") +SLANG_RAW("// Shader Model 6.4\n") +SLANG_RAW("//\n") +SLANG_RAW("\n") +SLANG_RAW("// Treats `left` and `right` as 4-component vectors of `UInt8` and computes `dot(left, right) + acc`\n") +SLANG_RAW("uint dot4add_u8packed(uint left, uint right, uint acc);\n") +SLANG_RAW("\n") +SLANG_RAW("// Treats `left` and `right` as 4-component vectors of `Int8` and computes `dot(left, right) + acc`\n") +SLANG_RAW("int dot4add_i8packed(uint left, uint right, int acc);\n") +SLANG_RAW("\n") +SLANG_RAW("// Computes `dot(left, right) + acc`.\n") +SLANG_RAW("//\n") +SLANG_RAW("// May not produce infinities or NaNs for intermediate results that overflow the range of `half`\n") +SLANG_RAW("float dot2add(float2 left, float2 right, float acc);\n") +SLANG_RAW("\n") +SLANG_RAW("//\n") +SLANG_RAW("// Mesh Shaders\n") +SLANG_RAW("//\n") +SLANG_RAW("\n") +SLANG_RAW("// Set the number of output vertices and primitives for a mesh shader invocation.\n") +SLANG_RAW("void SetMeshOutputCounts(uint vertexCount, uint primitiveCount);\n") +SLANG_RAW("\n") +SLANG_RAW("// Specify the number of downstream mesh shader thread groups to invoke from an amplification shader,\n") +SLANG_RAW("// and provide the values for per-mesh payload parameters.\n") +SLANG_RAW("//\n") +SLANG_RAW("void DispatchMesh<P>(uint threadGroupCountX, uint threadGroupCountY, uint threadGroupCountZ, P meshPayload);\n") +SLANG_RAW("\n") +SLANG_RAW("//\n") +SLANG_RAW("// TODO: \"Sampler feedback\" types `FeedbackTexture2D` and `FeedbackTexture2DArray`.\n") +SLANG_RAW("//\n") +SLANG_RAW("\n") +SLANG_RAW("//\n") +SLANG_RAW("// DXR 1.1 and `TraceRayInline` support\n") +SLANG_RAW("//\n") +SLANG_RAW("\n") +SLANG_RAW("// Status of whether a (closest) hit has been committed in a `RayQuery`.\n") +SLANG_RAW("typedef uint COMMITTED_STATUS;\n") +SLANG_RAW("\n") +SLANG_RAW("// No hit committed.\n") +SLANG_RAW("static const COMMITTED_STATUS COMMITTED_NOTHING = 0;\n") +SLANG_RAW("\n") +SLANG_RAW("// Closest hit is a triangle.\n") +SLANG_RAW("//\n") +SLANG_RAW("// This could be an opaque triangle hit found by the fixed-function\n") +SLANG_RAW("// traversal and intersection implementation, or a non-opaque\n") +SLANG_RAW("// triangle hit committed by user code with `RayQuery.CommitNonOpaqueTriangleHit`\n") +SLANG_RAW("//\n") +SLANG_RAW("static const COMMITTED_STATUS COMMITTED_TRIANGLE_HIT = 1;\n") +SLANG_RAW("\n") +SLANG_RAW("// Closest hit is a procedural primitive.\n") +SLANG_RAW("//\n") +SLANG_RAW("// A procedural hit primitive is committed using `RayQuery.CommitProceduralPrimitiveHit`.\n") +SLANG_RAW("static const COMMITTED_STATUS COMMITTED_PROCEDURAL_PRIMITIVE_HIT = 2;\n") +SLANG_RAW("\n") +SLANG_RAW("// Type of candidate hit that a `RayQuery` is pausing at.\n") +SLANG_RAW("//\n") +SLANG_RAW("// A `RayQuery` can automatically commit hits with opaque triangles,\n") +SLANG_RAW("// but yields to user code for other hits to allow them to be\n") +SLANG_RAW("// dismissed or committed.\n") +SLANG_RAW("//\n") +SLANG_RAW("typedef uint CANDIDATE_TYPE;\n") +SLANG_RAW("\n") +SLANG_RAW("// Candidate hit is a non-opaque triangle.\n") +SLANG_RAW("static const CANDIDATE_TYPE CANDIDATE_NON_OPAQUE_TRIANGLE = 0;\n") +SLANG_RAW("\n") +SLANG_RAW("// Candidate hit is a procedural primitive.\n") +SLANG_RAW("static const CANDIDATE_TYPE CANDIDATE_PROCEDURAL_PRIMITIVE = 1;\n") +SLANG_RAW("\n") +SLANG_RAW("// Handle to state of an in-progress ray-tracing query.\n") +SLANG_RAW("//\n") +SLANG_RAW("// The ray query is effectively a coroutine that user shader\n") +SLANG_RAW("// code can resume to continue tracing the ray, and which yields\n") +SLANG_RAW("// back to the user code at interesting events along the ray.\n") +SLANG_RAW("//\n") +SLANG_RAW("struct RayQuery<let rayFlags : RAY_FLAG = RAY_FLAG_NONE>\n") +SLANG_RAW("{\n") +SLANG_RAW(" // Initialize a ray-tracing query.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" // This method may be called on a \"fresh\" ray query, or\n") +SLANG_RAW(" // on one that is already tracing a ray. In the latter\n") +SLANG_RAW(" // case any state related to the ray previously being\n") +SLANG_RAW(" // traced is overwritten.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" // The `rayFlags` here will be bitwise ORed with\n") +SLANG_RAW(" // the `rayFlags` passed as a generic argument to\n") +SLANG_RAW(" // `RayQuery` to get the effective ray flags, which\n") +SLANG_RAW(" // must obey any API-imposed restrictions.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" void TraceRayInline(RaytracingAccelerationStructure accelerationStructure, RAY_FLAG rayFlags, uint instanceInclusionMask, RayDesc ray);\n") +SLANG_RAW("\n") +SLANG_RAW(" // Resume the ray query coroutine.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" // If the coroutine suspends because of encountering\n") +SLANG_RAW(" // a candidate hit that cannot be resolved with fixed-funciton\n") +SLANG_RAW(" // logic, this function returns `true`, and the `Candidate*()`\n") +SLANG_RAW(" // functions should be used by application code to resolve\n") +SLANG_RAW(" // the candidate hit (by either committing or ignoring it).\n") +SLANG_RAW(" //\n") +SLANG_RAW(" // If the coroutine terminates because traversal is\n") +SLANG_RAW(" // complete (or has been aborted), this function returns\n") +SLANG_RAW(" // `false`, and application code should use the `Committed*()`\n") +SLANG_RAW(" // functions to appropriately handle the closest hit (it any)\n") +SLANG_RAW(" // that was found.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" bool Proceed();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Causes the ray query to terminate.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" // This function cases the ray query to act as if\n") +SLANG_RAW(" // traversal has terminated, so that subsequent\n") +SLANG_RAW(" // `Proceed()` calls will return `false`.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" void Abort();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Get the type of candidate hit being considered.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" // The ray query coroutine will suspend when it encounters\n") +SLANG_RAW(" // a hit that cannot be resolved with fixed-function logic\n") +SLANG_RAW(" // (either a non-opaque triangle or a procedural primitive).\n") +SLANG_RAW(" // In either of those cases, `CandidateType()` will return\n") +SLANG_RAW(" // the kind of candidate hit that must be resolved by\n") +SLANG_RAW(" // user code.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" CANDIDATE_TYPE CandidateType();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of a candidate hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" float3x4 CandidateObjectToWorld3x4();\n") +SLANG_RAW(" float4x3 CandidateObjectToWorld4x3();\n") +SLANG_RAW(" float3x4 CandidateWorldToObject3x4();\n") +SLANG_RAW(" float4x3 CandidateWorldToObject4x3();\n") +SLANG_RAW(" uint CandidateInstanceIndex();\n") +SLANG_RAW(" uint CandidateInstanceID();\n") +SLANG_RAW(" uint CandidateGeometryIndex();\n") +SLANG_RAW(" uint CandidatePrimitiveIndex();\n") +SLANG_RAW(" uint CandidateInstanceContributionToHitGroupIndex();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of the ray being traced\n") +SLANG_RAW(" // in the object space of a candidate hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" float3 CandidateObjectRayOrigin();\n") +SLANG_RAW(" float3 CandidateObjectRayDirection();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of a candidate procedural primitive hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" bool CandidateProceduralPrimitiveNonOpaque();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of a candidate no-opaque triangle hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" bool CandidateTriangleFrontFace();\n") +SLANG_RAW(" float2 CandidateTriangleBarycentrics();\n") +SLANG_RAW(" float CandidateTriangleRayT();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Commit the current non-opaque triangle hit.\n") +SLANG_RAW(" void CommitNonOpaqueTriangleHit();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Commit the current procedural primitive hit, with hit time `t`.\n") +SLANG_RAW(" void CommitProceduralPrimitiveHit(float t);\n") +SLANG_RAW("\n") +SLANG_RAW(" // Get the status of the committed (closest) hit, if any.\n") +SLANG_RAW(" COMMITTED_STATUS CommittedStatus();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of the committed hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" float3x4 CommittedObjectToWorld3x4();\n") +SLANG_RAW(" float4x3 CommittedObjectToWorld4x3();\n") +SLANG_RAW(" float3x4 CommittedWorldToObject3x4();\n") +SLANG_RAW(" float4x3 CommittedWorldToObject4x3();\n") +SLANG_RAW(" float CommittedRayT();\n") +SLANG_RAW(" uint CommittedInstanceIndex();\n") +SLANG_RAW(" uint CommittedInstanceID();\n") +SLANG_RAW(" uint CommittedGeometryIndex();\n") +SLANG_RAW(" uint CommittedPrimitiveIndex();\n") +SLANG_RAW(" uint CommittedInstanceContributionToHitGroupIndex();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of the ray being traced\n") +SLANG_RAW(" // in the object space of a committed hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" float3 CommittedObjectRayOrigin();\n") +SLANG_RAW(" float3 CommittedObjectRayDirection();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of a committed triangle hit.\n") +SLANG_RAW(" //\n") +SLANG_RAW(" bool CommittedTriangleFrontFace();\n") +SLANG_RAW(" float2 CommittedTriangleBarycentrics();\n") +SLANG_RAW("\n") +SLANG_RAW(" // Access properties of the ray being traced.\n") +SLANG_RAW(" uint RayFlags();\n") +SLANG_RAW(" float3 WorldRayOrigin();\n") +SLANG_RAW(" float3 WorldRayDirection();\n") +SLANG_RAW(" float RayTMin();\n") +SLANG_RAW("}\n") +SLANG_RAW("\n") +SLANG_RAW("//\n") +SLANG_RAW("// Vulkan/SPIR-V specific features\n") +SLANG_RAW("//\n") +SLANG_RAW("\n") +SLANG_RAW("struct VkSubpassInput<T>\n") +SLANG_RAW("{\n") +SLANG_RAW(" T SubpassLoad();\n") +SLANG_RAW("}\n") +SLANG_RAW("\n") +SLANG_RAW("struct VkSubpassInputMS<T>\n") +SLANG_RAW("{\n") +SLANG_RAW(" T SubpassLoad(int sampleIndex);\n") +SLANG_RAW("}\n") diff --git a/source/slang/slang-profile-defs.h b/source/slang/slang-profile-defs.h index 50e1750ac..fc2722160 100644 --- a/source/slang/slang-profile-defs.h +++ b/source/slang/slang-profile-defs.h @@ -69,6 +69,9 @@ PROFILE_STAGE(ClosestHit, closesthit, SLANG_STAGE_CLOSEST_HIT) PROFILE_STAGE(Miss, miss, SLANG_STAGE_MISS) PROFILE_STAGE(Callable, callable, SLANG_STAGE_CALLABLE) +PROFILE_STAGE(Mesh, mesh, SLANG_STAGE_MESH) +PROFILE_STAGE(Amplification, amplification, SLANG_STAGE_AMPLIFICATION) + // Note: HLSL and Direct3D convention erroneously uses the term "Pixel Shader" // for the thing that shades *fragments*. Slang strives to treat the more correct @@ -98,6 +101,8 @@ PROFILE_VERSION(DX_6_0, DX) PROFILE_VERSION(DX_6_1, DX) PROFILE_VERSION(DX_6_2, DX) PROFILE_VERSION(DX_6_3, DX) +PROFILE_VERSION(DX_6_4, DX) +PROFILE_VERSION(DX_6_5, DX) PROFILE_VERSION(GLSL_110, GLSL) PROFILE_VERSION(GLSL_120, GLSL) @@ -199,10 +204,14 @@ PROFILE(DX_None_6_0, sm_6_0, Unknown, DX_6_0) PROFILE(DX_Lib_6_1, lib_6_1, Unknown, DX_6_1) PROFILE(DX_Lib_6_2, lib_6_2, Unknown, DX_6_2) PROFILE(DX_Lib_6_3, lib_6_3, Unknown, DX_6_3) +PROFILE(DX_Lib_6_4, lib_6_4, Unknown, DX_6_4) +PROFILE(DX_Lib_6_5, lib_6_5, Unknown, DX_6_5) PROFILE_ALIAS(DX_None_6_1, DX_Lib_6_1, sm_6_1) PROFILE_ALIAS(DX_None_6_2, DX_Lib_6_2, sm_6_2) PROFILE_ALIAS(DX_None_6_3, DX_Lib_6_3, sm_6_3) +PROFILE_ALIAS(DX_None_6_4, DX_Lib_6_4, sm_6_4) +PROFILE_ALIAS(DX_None_6_5, DX_Lib_6_5, sm_6_5) // Define all the GLSL profiles |
