From 6e6f8dbdf64ea3f76af96395025313a5e58ea265 Mon Sep 17 00:00:00 2001 From: Tex Riddell Date: Wed, 21 Feb 2018 21:50:39 +0000 Subject: [PATCH] Merged PR 24: Require payload/attribute/param structs for ray shaders. (MD CHANGE) Require payload/attribute/param structs for ray shaders. (MD CHANGE) --- include/dxc/HLSL/DxilFunctionProps.h | 9 +- lib/HLSL/DxilMetadataHelper.cpp | 30 ++-- tools/clang/include/clang/AST/HlslTypes.h | 2 + tools/clang/lib/AST/HlslTypes.cpp | 34 ++++ tools/clang/lib/CodeGen/CGHLSLMS.cpp | 146 +++++++++--------- .../quick-test/lib_anyhit_2_payload_attr.hlsl | 20 --- .../quick-test/lib_anyhit_in_payload.hlsl | 12 -- .../quick-test/lib_anyhit_inout_attr.hlsl | 11 -- .../quick-test/lib_anyhit_order.hlsl | 18 --- .../quick-test/lib_anyhit_param.hlsl | 11 -- .../quick-test/lib_callable_in.hlsl | 11 -- .../lib_closesthit_2_payload_attr.hlsl | 22 --- .../quick-test/lib_closesthit_in_payload.hlsl | 11 -- .../quick-test/lib_closesthit_inout_attr.hlsl | 11 -- .../quick-test/lib_closesthit_order.hlsl | 17 -- .../quick-test/lib_closesthit_param.hlsl | 11 -- .../quick-test/lib_miss_2payload.hlsl | 12 -- .../raytracing_anyhit_in_payload.hlsl | 17 ++ .../raytracing_anyhit_inout_attr.hlsl | 16 ++ .../quick-test/raytracing_anyhit_no_attr.hlsl | 12 ++ .../raytracing_anyhit_no_payload.hlsl | 8 + ...it_out.hlsl => raytracing_anyhit_out.hlsl} | 5 +- .../quick-test/raytracing_anyhit_param.hlsl | 23 +++ ...m.hlsl => raytracing_callable_2param.hlsl} | 2 +- .../quick-test/raytracing_callable_in.hlsl | 7 + ..._out.hlsl => raytracing_callable_out.hlsl} | 2 +- ..._ret.hlsl => raytracing_callable_ret.hlsl} | 14 +- .../quick-test/raytracing_callable_udt.hlsl | 15 ++ .../raytracing_closesthit_in_payload.hlsl | 16 ++ .../raytracing_closesthit_inout_attr.hlsl | 16 ++ .../raytracing_closesthit_no_attr.hlsl | 11 ++ .../raytracing_closesthit_no_payload.hlsl | 7 + .../raytracing_closesthit_numeric.hlsl | 24 +++ ...ut.hlsl => raytracing_closesthit_out.hlsl} | 5 +- .../raytracing_closesthit_param.hlsl | 23 +++ ...lsl => raytracing_intersection_param.hlsl} | 2 +- ..._extra.hlsl => raytracing_miss_extra.hlsl} | 2 +- ...b_miss_in.hlsl => raytracing_miss_in.hlsl} | 2 +- .../raytracing_miss_no_payload.hlsl | 6 + ...miss_out.hlsl => raytracing_miss_out.hlsl} | 2 +- ...miss_ret.hlsl => raytracing_miss_ret.hlsl} | 11 +- .../quick-test/raytracing_miss_udt.hlsl | 11 ++ ...aram.hlsl => raytracing_raygen_param.hlsl} | 2 +- 43 files changed, 372 insertions(+), 277 deletions(-) delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_2_payload_attr.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_in_payload.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_inout_attr.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_order.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_param.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_callable_in.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_2_payload_attr.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_in_payload.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_inout_attr.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_order.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_param.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/quick-test/lib_miss_2payload.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_in_payload.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_inout_attr.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_attr.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_payload.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_anyhit_out.hlsl => raytracing_anyhit_out.hlsl} (57%) create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_param.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_callable_2param.hlsl => raytracing_callable_2param.hlsl} (84%) create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_in.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_callable_out.hlsl => raytracing_callable_out.hlsl} (82%) rename tools/clang/test/CodeGenHLSL/quick-test/{lib_callable_ret.hlsl => raytracing_callable_ret.hlsl} (72%) create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_udt.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_in_payload.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_inout_attr.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_attr.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_payload.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_numeric.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_closesthit_out.hlsl => raytracing_closesthit_out.hlsl} (57%) create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_param.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_intersection_param.hlsl => raytracing_intersection_param.hlsl} (84%) rename tools/clang/test/CodeGenHLSL/quick-test/{lib_miss_extra.hlsl => raytracing_miss_extra.hlsl} (84%) rename tools/clang/test/CodeGenHLSL/quick-test/{lib_miss_in.hlsl => raytracing_miss_in.hlsl} (81%) create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_no_payload.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_miss_out.hlsl => raytracing_miss_out.hlsl} (83%) rename tools/clang/test/CodeGenHLSL/quick-test/{lib_miss_ret.hlsl => raytracing_miss_ret.hlsl} (51%) create mode 100644 tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_udt.hlsl rename tools/clang/test/CodeGenHLSL/quick-test/{lib_raygen_param.hlsl => raytracing_raygen_param.hlsl} (83%) diff --git a/include/dxc/HLSL/DxilFunctionProps.h b/include/dxc/HLSL/DxilFunctionProps.h index abe4c967a..47590d159 100644 --- a/include/dxc/HLSL/DxilFunctionProps.h +++ b/include/dxc/HLSL/DxilFunctionProps.h @@ -58,9 +58,12 @@ struct DxilFunctionProps { } PS; // Ray Tracing shaders struct { - unsigned payloadParamCount; - unsigned attributeParamCount; - } AnyHit, ClosestHit; + union { + unsigned payloadSizeInBytes; + unsigned paramSizeInBytes; + }; + unsigned attributeSizeInBytes; + } Ray; } ShaderProps; DXIL::ShaderKind shaderKind; // TODO: Should we have an unmangled name here for ray tracing shaders? diff --git a/lib/HLSL/DxilMetadataHelper.cpp b/lib/HLSL/DxilMetadataHelper.cpp index 043b1c5eb..9f9c39e4e 100644 --- a/lib/HLSL/DxilMetadataHelper.cpp +++ b/lib/HLSL/DxilMetadataHelper.cpp @@ -957,6 +957,7 @@ Function *DxilMDHelper::LoadDxilFunctionProps(MDTuple *pProps, DXIL::ShaderKind shaderKind = static_cast(ConstMDToUint32(pProps->getOperand(idx++))); + bool bRayAttributes = false; props->shaderKind = shaderKind; switch (shaderKind) { case DXIL::ShaderKind::Compute: @@ -1008,16 +1009,16 @@ Function *DxilMDHelper::LoadDxilFunctionProps(MDTuple *pProps, ConstMDToUint32(pProps->getOperand(idx++)); break; case DXIL::ShaderKind::AnyHit: - props->ShaderProps.AnyHit.payloadParamCount = - ConstMDToUint32(pProps->getOperand(idx++)); - props->ShaderProps.AnyHit.attributeParamCount = - ConstMDToUint32(pProps->getOperand(idx++)); - break; case DXIL::ShaderKind::ClosestHit: - props->ShaderProps.ClosestHit.payloadParamCount = - ConstMDToUint32(pProps->getOperand(idx++)); - props->ShaderProps.ClosestHit.attributeParamCount = + bRayAttributes = true; + case DXIL::ShaderKind::Miss: + case DXIL::ShaderKind::Callable: + // payload/params unioned and first: + props->ShaderProps.Ray.payloadSizeInBytes = ConstMDToUint32(pProps->getOperand(idx++)); + if (bRayAttributes) + props->ShaderProps.Ray.attributeSizeInBytes = + ConstMDToUint32(pProps->getOperand(idx++)); break; default: break; @@ -1028,6 +1029,7 @@ Function *DxilMDHelper::LoadDxilFunctionProps(MDTuple *pProps, MDTuple * DxilMDHelper::EmitDxilFunctionProps(const hlsl::DxilFunctionProps *props, Function *F) { + bool bRayAttributes = false; Metadata *MDVals[30]; std::fill(MDVals, MDVals + _countof(MDVals), nullptr); unsigned valIdx = 0; @@ -1071,12 +1073,14 @@ DxilMDHelper::EmitDxilFunctionProps(const hlsl::DxilFunctionProps *props, MDVals[valIdx++] = BoolToConstMD(props->ShaderProps.PS.EarlyDepthStencil); break; case DXIL::ShaderKind::AnyHit: - MDVals[valIdx++] = Uint32ToConstMD(props->ShaderProps.AnyHit.payloadParamCount); - MDVals[valIdx++] = Uint32ToConstMD(props->ShaderProps.AnyHit.attributeParamCount); - break; case DXIL::ShaderKind::ClosestHit: - MDVals[valIdx++] = Uint32ToConstMD(props->ShaderProps.ClosestHit.payloadParamCount); - MDVals[valIdx++] = Uint32ToConstMD(props->ShaderProps.ClosestHit.attributeParamCount); + bRayAttributes = true; + case DXIL::ShaderKind::Miss: + case DXIL::ShaderKind::Callable: + // payload/params unioned and first: + MDVals[valIdx++] = Uint32ToConstMD(props->ShaderProps.Ray.payloadSizeInBytes); + if (bRayAttributes) + MDVals[valIdx++] = Uint32ToConstMD(props->ShaderProps.Ray.attributeSizeInBytes); break; default: break; diff --git a/tools/clang/include/clang/AST/HlslTypes.h b/tools/clang/include/clang/AST/HlslTypes.h index 53f5c9863..3d7c2ea28 100644 --- a/tools/clang/include/clang/AST/HlslTypes.h +++ b/tools/clang/include/clang/AST/HlslTypes.h @@ -371,6 +371,8 @@ bool IsHLSLLineStreamType(clang::QualType type); bool IsHLSLTriangleStreamType(clang::QualType type); bool IsHLSLStreamOutputType(clang::QualType type); bool IsHLSLResourceType(clang::QualType type); +bool IsHLSLNumeric(clang::QualType type); +bool IsHLSLNumericUserDefinedType(clang::QualType type); clang::QualType GetHLSLResourceResultType(clang::QualType type); bool IsIncompleteHLSLResourceArrayType(clang::ASTContext& context, clang::QualType type); clang::QualType GetHLSLInputPatchElementType(clang::QualType type); diff --git a/tools/clang/lib/AST/HlslTypes.cpp b/tools/clang/lib/AST/HlslTypes.cpp index d2de7a70a..5527a135a 100644 --- a/tools/clang/lib/AST/HlslTypes.cpp +++ b/tools/clang/lib/AST/HlslTypes.cpp @@ -90,6 +90,40 @@ bool IsHLSLVecType(clang::QualType type) { return false; } +bool IsHLSLNumeric(clang::QualType type) { + const clang::Type *Ty = type.getCanonicalType().getTypePtr(); + if (isa(Ty)) { + if (IsHLSLVecMatType(type)) + return true; + return IsHLSLNumericUserDefinedType(type); + } else if (type->isArrayType()) { + return IsHLSLNumeric(QualType(type->getArrayElementTypeNoTypeQual(), 0)); + } + return Ty->isBuiltinType(); +} + +bool IsHLSLNumericUserDefinedType(clang::QualType type) { + const clang::Type *Ty = type.getCanonicalType().getTypePtr(); + if (const RecordType *RT = dyn_cast(Ty)) { + const RecordDecl *RD = RT->getDecl(); + if (isa(RD)) { + return false; // UDT are not templates + } + // TODO: avoid check by name + StringRef name = RD->getName(); + if (name == "ByteAddressBuffer" || + name == "RWByteAddressBuffer" || + name == "RaytracingAccelerationStructure") + return false; + for (auto member : RD->fields()) { + if (!IsHLSLNumeric(member->getType())) + return false; + } + return true; + } + return false; +} + /// Checks whether the pAttributes indicate a parameter is inout or out; if /// inout, pIsIn will be set to true. bool IsParamAttributedAsOut(_In_opt_ clang::AttributeList *pAttributes, diff --git a/tools/clang/lib/CodeGen/CGHLSLMS.cpp b/tools/clang/lib/CodeGen/CGHLSLMS.cpp index 2b90c83e9..826cc0d29 100644 --- a/tools/clang/lib/CodeGen/CGHLSLMS.cpp +++ b/tools/clang/lib/CodeGen/CGHLSLMS.cpp @@ -1528,9 +1528,10 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { if (FD->hasAttr()) retTyAnnotation.SetPrecise(); - // flattened parameter count for payload and attributes for AnyHit and ClosestHit shaders: - unsigned payloadParamCount = 0; - unsigned attributeParamCount = 0; + if (isRay) { + funcProps->ShaderProps.Ray.payloadSizeInBytes = 0; + funcProps->ShaderProps.Ray.attributeSizeInBytes = 0; + } for (; ArgNo < F->arg_size(); ++ArgNo, ++ParmIdx) { DxilParameterAnnotation ¶mAnnotation = @@ -1705,13 +1706,6 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { // Validate Ray Tracing function parameter (some validation may be pushed into front end) if (isRay) { - StringRef semanticName; - unsigned int semanticIndex = 0; - if (paramAnnotation.HasSemanticString()) { - Semantic::DecomposeNameAndIndex(paramAnnotation.GetSemanticStringRef(), - &semanticName, &semanticIndex); - } - switch (funcProps->shaderKind) { case DXIL::ShaderKind::RayGeneration: case DXIL::ShaderKind::Intersection: @@ -1723,59 +1717,36 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { break; case DXIL::ShaderKind::AnyHit: case DXIL::ShaderKind::ClosestHit: - // AnyHit & ClosestHit may have zero or one inout SV_RayPayload and - // zero or one in SV_IntersectionAttributes parameters, in that order only. - // Number of flattened elements for each of these is stored - // in payloadParamCount/attributeParamCount. - if (!paramAnnotation.HasSemanticString()) { + if (0 == ArgNo && dxilInputQ != DxilParamInputQual::Inout) { Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( DiagnosticsEngine::Error, - "parameter must have SV_RayPayload or SV_IntersectionAttributes semantic")); - } else { - // compare semantic with allowed names and verify number is 0 - bool bPayload = semanticName.compare_lower("sv_raypayload") == 0; - bool bAttr = semanticName.compare_lower("sv_intersectionattributes") == 0; - if (bPayload || bAttr) { - unsigned int &flattened = - bPayload ? payloadParamCount : attributeParamCount; - if (flattened > 0) { - Diags.Report(paramSemanticLoc, Diags.getCustomDiagID( - DiagnosticsEngine::Error, "only one %0 parameter allowed")) - << (bPayload ? "ray payload" : "intersection attributes"); - } else { - if (bPayload && attributeParamCount) { - Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "ray payload must be before intersection attributes")); - } - // TODO: count flattened elements for parameter - flattened = 1; // FIX THIS - } - if (semanticIndex > 0) { - Diags.Report(paramSemanticLoc, Diags.getCustomDiagID( - DiagnosticsEngine::Error, "semantic index must be 0")); - } - if (bPayload && dxilInputQ != DxilParamInputQual::Inout) { - Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "ray payload parameter must be inout")); - } else if (bAttr && dxilInputQ != DxilParamInputQual::In) { - Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "intersection attributes parameter must be in")); - } - } else { - Diags.Report(paramSemanticLoc, Diags.getCustomDiagID( + "ray payload parameter must be inout")); + } else if (1 == ArgNo && dxilInputQ != DxilParamInputQual::In) { + Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( + DiagnosticsEngine::Error, + "intersection attributes parameter must be in")); + } else if (ArgNo > 1) { + Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( + DiagnosticsEngine::Error, + "too many parameters, expected payload and attributes parameters only.")); + } + if (ArgNo < 2) { + if (!IsHLSLNumericUserDefinedType(parmDecl->getType())) { + Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( DiagnosticsEngine::Error, - "semantic must be SV_RayPayload or SV_IntersectionAttributes")); + "payload and attribute structures must be user defined types with only numeric contents.")); + } else { + DataLayout DL(&this->TheModule); + unsigned size = DL.getTypeAllocSize(F->getFunctionType()->getFunctionParamType(ArgNo)); + if (0 == ArgNo) + funcProps->ShaderProps.Ray.payloadSizeInBytes = size; + else + funcProps->ShaderProps.Ray.attributeSizeInBytes = size; } } break; case DXIL::ShaderKind::Miss: - // Miss shader may have zero or one inout payload param only - // semantic should be SV_RayPayload - // (though we could ignore semantic, leaving it optional) - if (ParmIdx > 0) { + if (ArgNo > 0) { Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( DiagnosticsEngine::Error, "only one parameter (ray payload) allowed for miss shader")); @@ -1784,18 +1755,20 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { DiagnosticsEngine::Error, "ray payload parameter must be declared inout")); } - if (paramAnnotation.HasSemanticString() && - (semanticName.compare_lower("sv_raypayload") != 0 || - semanticIndex != 0)) { - Diags.Report(paramSemanticLoc, Diags.getCustomDiagID( - DiagnosticsEngine::Error, - "semantic must be SV_RayPayload with optional index of 0")); + if (ArgNo < 1) { + if (!IsHLSLNumericUserDefinedType(parmDecl->getType())) { + Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( + DiagnosticsEngine::Error, + "ray payload parameter must be a user defined type with only numeric contents.")); + } else { + DataLayout DL(&this->TheModule); + unsigned size = DL.getTypeAllocSize(F->getFunctionType()->getFunctionParamType(ArgNo)); + funcProps->ShaderProps.Ray.payloadSizeInBytes = size; + } } break; case DXIL::ShaderKind::Callable: - // Callable may have zero or one UDT parameter input - // (ignore semantic if present) - if (ParmIdx > 0) { + if (ArgNo > 0) { Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( DiagnosticsEngine::Error, "only one parameter allowed for callable shader")); @@ -1804,6 +1777,17 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { DiagnosticsEngine::Error, "callable parameter must be declared inout")); } + if (ArgNo < 1) { + if (!IsHLSLNumericUserDefinedType(parmDecl->getType())) { + Diags.Report(parmDecl->getLocation(), Diags.getCustomDiagID( + DiagnosticsEngine::Error, + "callable parameter must be a user defined type with only numeric contents.")); + } else { + DataLayout DL(&this->TheModule); + unsigned size = DL.getTypeAllocSize(F->getFunctionType()->getFunctionParamType(ArgNo)); + funcProps->ShaderProps.Ray.paramSizeInBytes = size; + } + } break; } } @@ -1826,12 +1810,32 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) { Diags.Report(FD->getLocation(), DiagID); } - if (funcProps->IsAnyHit()) { - funcProps->ShaderProps.AnyHit.payloadParamCount = payloadParamCount; - funcProps->ShaderProps.AnyHit.attributeParamCount = attributeParamCount; - } else if (funcProps->IsClosestHit()) { - funcProps->ShaderProps.ClosestHit.payloadParamCount = payloadParamCount; - funcProps->ShaderProps.ClosestHit.attributeParamCount = attributeParamCount; + // If Shader is a ray shader that requires parameters, make sure size is non-zero + if (isRay) { + bool bNeedsAttributes = false; + bool bNeedsPayload = false; + switch (funcProps->shaderKind) { + case DXIL::ShaderKind::AnyHit: + case DXIL::ShaderKind::ClosestHit: + bNeedsAttributes = true; + case DXIL::ShaderKind::Miss: + bNeedsPayload = true; + case DXIL::ShaderKind::Callable: + if (0 == funcProps->ShaderProps.Ray.payloadSizeInBytes) { + unsigned DiagID = bNeedsPayload ? + Diags.getCustomDiagID(DiagnosticsEngine::Error, + "shader must include inout payload structure parameter.") : + Diags.getCustomDiagID(DiagnosticsEngine::Error, + "shader must include inout parameter structure."); + Diags.Report(FD->getLocation(), DiagID); + } + } + if (bNeedsAttributes && + 0 == funcProps->ShaderProps.Ray.attributeSizeInBytes) { + Diags.Report(FD->getLocation(), Diags.getCustomDiagID( + DiagnosticsEngine::Error, + "shader must include attributes structure parameter.")); + } } // Type annotation for parameters and return type. diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_2_payload_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_2_payload_attr.hlsl deleted file mode 100644 index 324f1d57b..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_2_payload_attr.hlsl +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: only one ray payload parameter allowed -// CHECK: error: semantic index must be 0 - -struct MyPayload { - float4 color; - uint2 pos; -}; - -struct MyAttributes { - float2 bary; - uint id; -}; - -[shader("anyhit")] -void anyhit_2_payload_attr( inout MyPayload payload : SV_RayPayload, - inout MyPayload payload2 : SV_RayPayload2, - in MyAttributes attr : SV_IntersectionAttributes, - in MyAttributes attr2 : SV_IntersectionAttributes2 ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_in_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_in_payload.hlsl deleted file mode 100644 index 4837a67f0..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_in_payload.hlsl +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: ray payload parameter must be inout - -struct MyPayload { - float4 color; - uint2 pos; -}; - -[shader("anyhit")] -void anyhit_in_payload( in MyPayload payload : SV_RayPayload ) {} - diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_inout_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_inout_attr.hlsl deleted file mode 100644 index 1d695d5df..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_inout_attr.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: intersection attributes parameter must be in - -struct MyAttributes { - float2 bary; - uint id; -}; - -[shader("anyhit")] -void anyhit_inout_attr( inout MyAttributes attr : SV_IntersectionAttributes ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_order.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_order.hlsl deleted file mode 100644 index ce1a872fe..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_order.hlsl +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: ray payload must be before intersection attributes - -struct MyPayload { - float4 color; - uint2 pos; -}; - -struct MyAttributes { - float2 bary; - uint id; -}; - -[shader("anyhit")] -void anyhit_order( in MyAttributes attr : SV_IntersectionAttributes, - inout MyPayload payload : SV_RayPayload ) {} - diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_param.hlsl deleted file mode 100644 index 625569ccd..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_param.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// Fine. -[shader("anyhit")] -void anyhit_nop() {} - -// CHECK: error: return type for ray tracing shaders must be void -// CHECK: error: parameter must have SV_RayPayload or SV_IntersectionAttributes semantic - -[shader("anyhit")] -float anyhit_param( in float4 extra ) { return extra.x; } diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_in.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_in.hlsl deleted file mode 100644 index 58e6a7aa4..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_in.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: callable parameter must be declared inout - -struct MyParam { - float2 coord; - float4 output; -}; - -[shader("callable")] -void callable_in( in MyParam param ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_2_payload_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_2_payload_attr.hlsl deleted file mode 100644 index ec9a45356..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_2_payload_attr.hlsl +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: only one ray payload parameter allowed -// CHECK: error: semantic index must be 0 -// CHECK: error: only one intersection attributes parameter allowed -// CHECK: error: semantic index must be 0 - -struct MyPayload { - float4 color; - uint2 pos; -}; - -struct MyAttributes { - float2 bary; - uint id; -}; - -[shader("closesthit")] -void closesthit_2_payload_attr( inout MyPayload payload : SV_RayPayload, - inout MyPayload payload2 : SV_RayPayload2, - in MyAttributes attr : SV_IntersectionAttributes, - in MyAttributes attr2 : SV_IntersectionAttributes2 ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_in_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_in_payload.hlsl deleted file mode 100644 index d2d5aa67b..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_in_payload.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: ray payload parameter must be inout - -struct MyPayload { - float4 color; - uint2 pos; -}; - -[shader("closesthit")] -void closesthit_in_payload( in MyPayload payload : SV_RayPayload ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_inout_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_inout_attr.hlsl deleted file mode 100644 index 8bbfb3ad4..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_inout_attr.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: intersection attributes parameter must be in - -struct MyAttributes { - float2 bary; - uint id; -}; - -[shader("closesthit")] -void closesthit_inout_attr( inout MyAttributes attr : SV_IntersectionAttributes ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_order.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_order.hlsl deleted file mode 100644 index d2303c278..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_order.hlsl +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: ray payload must be before intersection attributes - -struct MyPayload { - float4 color; - uint2 pos; -}; - -struct MyAttributes { - float2 bary; - uint id; -}; - -[shader("closesthit")] -void closesthit_order( in MyAttributes attr : SV_IntersectionAttributes, - inout MyPayload payload : SV_RayPayload ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_param.hlsl deleted file mode 100644 index e55db3abf..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_param.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// Fine. -[shader("closesthit")] -void closesthit_nop() {} - -// CHECK: error: return type for ray tracing shaders must be void -// CHECK: error: parameter must have SV_RayPayload or SV_IntersectionAttributes semantic - -[shader("closesthit")] -float closesthit_param( in float4 extra ) { return extra.x; } diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_2payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_2payload.hlsl deleted file mode 100644 index 5ec3e1fce..000000000 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_2payload.hlsl +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// CHECK: error: only one parameter (ray payload) allowed for miss shader - -struct MyPayload { - float4 color; - uint2 pos; -}; - -[shader("miss")] -void miss_2payload( inout MyPayload payload : SV_RayPayload, - inout MyPayload payload2 : SV_RayPayload2) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_in_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_in_payload.hlsl new file mode 100644 index 000000000..26401ed2b --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_in_payload.hlsl @@ -0,0 +1,17 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: ray payload parameter must be inout + +struct MyPayload { + float4 color; + uint2 pos; +}; + +struct MyAttributes { + float2 bary; + uint id; +}; + +[shader("anyhit")] +void anyhit_in_payload( in MyPayload payload, MyAttributes attr ) {} + diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_inout_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_inout_attr.hlsl new file mode 100644 index 000000000..e828c4cbf --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_inout_attr.hlsl @@ -0,0 +1,16 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: intersection attributes parameter must be in + +struct MyPayload { + float4 color; + uint2 pos; +}; + +struct MyAttributes { + float2 bary; + uint id; +}; + +[shader("anyhit")] +void anyhit_inout_attr( inout MyPayload payload, inout MyAttributes attr ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_attr.hlsl new file mode 100644 index 000000000..6c33c2009 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_attr.hlsl @@ -0,0 +1,12 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: shader must include attributes structure parameter + +struct MyPayload { + float4 color; + uint2 pos; +}; + +[shader("anyhit")] +void anyhit_no_attr( inout MyPayload payload ) {} + diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_payload.hlsl new file mode 100644 index 000000000..6db815666 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_no_payload.hlsl @@ -0,0 +1,8 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: shader must include inout payload structure parameter +// CHECK: error: shader must include attributes structure parameter + +[shader("anyhit")] +void anyhit_no_payload() {} + diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_out.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_out.hlsl similarity index 57% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_out.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_out.hlsl index 7f5e31834..9030eca24 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_anyhit_out.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_out.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: ray payload parameter must be inout // CHECK: error: intersection attributes parameter must be in @@ -14,5 +14,4 @@ struct MyAttributes { }; [shader("anyhit")] -void anyhit_out( out MyPayload payload : SV_RayPayload, - out MyAttributes attr : SV_IntersectionAttributes ) {} +void anyhit_out( out MyPayload payload, out MyAttributes attr ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_param.hlsl new file mode 100644 index 000000000..b83c231cb --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_anyhit_param.hlsl @@ -0,0 +1,23 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +struct MyPayload { + float4 color; + uint2 pos; +}; + +struct MyAttributes { + float2 bary; + uint id; +}; + +// Fine. +[shader("anyhit")] +void anyhit_nop( inout MyPayload payload, MyAttributes attr ) {} + +// CHECK: error: return type for ray tracing shaders must be void +// CHECK: error: ray payload parameter must be inout +// CHECK: error: payload and attribute structures must be user defined types with only numeric contents. +// CHECK: error: payload and attribute structures must be user defined types with only numeric contents. + +[shader("anyhit")] +float anyhit_param( in float4 extra, Texture2D tex0 ) { return extra.x; } diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_2param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_2param.hlsl similarity index 84% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_callable_2param.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_2param.hlsl index 620447aca..cd56188b0 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_2param.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_2param.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: only one parameter allowed for callable shader diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_in.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_in.hlsl new file mode 100644 index 000000000..a35ed69af --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_in.hlsl @@ -0,0 +1,7 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: callable parameter must be declared inout +// CHECK: error: callable parameter must be a user defined type with only numeric contents. + +[shader("callable")] +void callable_in( in float4x4 param ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_out.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_out.hlsl similarity index 82% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_callable_out.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_out.hlsl index 0a97cf8a0..e85435c4f 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_out.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_out.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: callable parameter must be declared inout diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_ret.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_ret.hlsl similarity index 72% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_callable_ret.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_ret.hlsl index 5541524ce..30f8999f9 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_callable_ret.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_ret.hlsl @@ -1,15 +1,15 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s - -// Fine. -[shader("callable")] -void callable_nop() {} - -// CHECK: error: return type for ray tracing shaders must be void +// RUN: %dxc -T lib_6_3 %s | FileCheck %s struct MyParam { float2 coord; float4 output; }; +// Fine. +[shader("callable")] +void callable_nop( inout MyParam param ) {} + +// CHECK: error: return type for ray tracing shaders must be void + [shader("callable")] float callable_ret( inout MyParam param ) { return 1.0; } diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_udt.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_udt.hlsl new file mode 100644 index 000000000..879af84a6 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_callable_udt.hlsl @@ -0,0 +1,15 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: callable parameter must be a user defined type with only numeric contents. + +struct Foo { + float4 vec; + RWByteAddressBuffer buf; +}; + +struct MyParams { + Foo foo; +}; + +[shader("callable")] +void callable_udt( inout MyParams param ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_in_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_in_payload.hlsl new file mode 100644 index 000000000..8f8950f07 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_in_payload.hlsl @@ -0,0 +1,16 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: ray payload parameter must be inout + +struct MyPayload { + float4 color; + uint2 pos; +}; + +struct MyAttributes { + float2 bary; + uint id; +}; + +[shader("closesthit")] +void closesthit_in_payload( in MyPayload payload, MyAttributes attr ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_inout_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_inout_attr.hlsl new file mode 100644 index 000000000..e0ccf6c8b --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_inout_attr.hlsl @@ -0,0 +1,16 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: intersection attributes parameter must be in + +struct MyPayload { + float4 color; + uint2 pos; +}; + +struct MyAttributes { + float2 bary; + uint id; +}; + +[shader("closesthit")] +void closesthit_inout_attr( inout MyPayload payload, inout MyAttributes attr ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_attr.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_attr.hlsl new file mode 100644 index 000000000..6a40c5e37 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_attr.hlsl @@ -0,0 +1,11 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: shader must include attributes structure parameter + +struct MyPayload { + float4 color; + uint2 pos; +}; + +[shader("closesthit")] +void closesthit_no_attr( inout MyPayload payload ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_payload.hlsl new file mode 100644 index 000000000..57b998c4f --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_no_payload.hlsl @@ -0,0 +1,7 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: shader must include inout payload structure parameter +// CHECK: error: shader must include attributes structure parameter + +[shader("closesthit")] +void closesthit_no_payload() {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_numeric.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_numeric.hlsl new file mode 100644 index 000000000..0e4b4eaa2 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_numeric.hlsl @@ -0,0 +1,24 @@ +// RUN: %dxc -enable-16bit-types -T lib_6_3 %s | FileCheck %s + +// CHECK: define void @"\01?closesthit_numeric + +struct MyNumericTest { + float f; + int i; + uint u; + half h; + int16_t i16; + float2 f2; + double d; +}; + +struct MyPayload { + MyNumericTest t; +}; + +struct MyAttributes { + MyNumericTest t; +}; + +[shader("closesthit")] +void closesthit_numeric( inout MyPayload payload, MyAttributes attr ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_out.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_out.hlsl similarity index 57% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_out.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_out.hlsl index 3baa42b69..32b7d554a 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_closesthit_out.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_out.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: ray payload parameter must be inout // CHECK: error: intersection attributes parameter must be in @@ -14,5 +14,4 @@ struct MyAttributes { }; [shader("closesthit")] -void closesthit_out( out MyPayload payload : SV_RayPayload, - out MyAttributes attr : SV_IntersectionAttributes ) {} +void closesthit_out( out MyPayload payload, out MyAttributes attr ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_param.hlsl new file mode 100644 index 000000000..757a38a7e --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_closesthit_param.hlsl @@ -0,0 +1,23 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +struct MyPayload { + float4 color; + uint2 pos; +}; + +struct MyAttributes { + float2 bary; + uint id; +}; + +// Fine. +[shader("closesthit")] +void closesthit_nop( inout MyPayload payload, in MyAttributes attr ) {} + +// CHECK: error: return type for ray tracing shaders must be void +// CHECK: error: ray payload parameter must be inout +// CHECK: error: payload and attribute structures must be user defined types with only numeric contents. +// CHECK: error: payload and attribute structures must be user defined types with only numeric contents. + +[shader("closesthit")] +float closesthit_param( in bool extra, RWByteAddressBuffer buf ) { return extra.x; } diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_intersection_param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_intersection_param.hlsl similarity index 84% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_intersection_param.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_intersection_param.hlsl index b00539c95..d1a21c74c 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_intersection_param.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_intersection_param.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: return type for ray tracing shaders must be void // CHECK: error: parameters are not allowed for intersection shader diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_extra.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_extra.hlsl similarity index 84% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_miss_extra.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_extra.hlsl index ff46baac5..c05079f9e 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_extra.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_extra.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: only one parameter (ray payload) allowed for miss shader diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_in.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_in.hlsl similarity index 81% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_miss_in.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_in.hlsl index 489395713..2880a0b60 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_in.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_in.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: ray payload parameter must be declared inout diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_no_payload.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_no_payload.hlsl new file mode 100644 index 000000000..d4f123fbe --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_no_payload.hlsl @@ -0,0 +1,6 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: shader must include inout payload structure parameter + +[shader("miss")] +void miss_no_payload() {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_out.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_out.hlsl similarity index 83% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_miss_out.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_out.hlsl index a57229364..a3a30e6dc 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_out.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_out.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: ray payload parameter must be declared inout diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_ret.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_ret.hlsl similarity index 51% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_miss_ret.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_ret.hlsl index 1b1e24826..c2a632c34 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_miss_ret.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_ret.hlsl @@ -1,10 +1,15 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s -// CHECK: error: return type for ray tracing shaders must be void +struct MyPayload { + float4 color; + uint2 pos; +}; // Fine. [shader("miss")] -void miss_nop() {} +void miss_nop( inout MyPayload payload ) {} + +// CHECK: error: return type for ray tracing shaders must be void [shader("miss")] float miss_ret() { return 1.0; } diff --git a/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_udt.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_udt.hlsl new file mode 100644 index 000000000..2d6ae2760 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_miss_udt.hlsl @@ -0,0 +1,11 @@ +// RUN: %dxc -T lib_6_3 %s | FileCheck %s + +// CHECK: error: ray payload parameter must be a user defined type with only numeric contents. + +struct MyPayload { + float4 color; + uint2 pos; +}; + +[shader("miss")] +void miss_udt( inout PointStream payload ) {} diff --git a/tools/clang/test/CodeGenHLSL/quick-test/lib_raygen_param.hlsl b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_raygen_param.hlsl similarity index 83% rename from tools/clang/test/CodeGenHLSL/quick-test/lib_raygen_param.hlsl rename to tools/clang/test/CodeGenHLSL/quick-test/raytracing_raygen_param.hlsl index 0fb082259..c8a927067 100644 --- a/tools/clang/test/CodeGenHLSL/quick-test/lib_raygen_param.hlsl +++ b/tools/clang/test/CodeGenHLSL/quick-test/raytracing_raygen_param.hlsl @@ -1,4 +1,4 @@ -// RUN: %dxc -T lib_6_1 %s | FileCheck %s +// RUN: %dxc -T lib_6_3 %s | FileCheck %s // CHECK: error: return type for ray tracing shaders must be void // CHECK: error: parameters are not allowed for raygeneration shader