From e4d6832d315791f2d973a20443cd5f3c01ec01c8 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Sat, 17 Aug 2024 15:55:29 +0100 Subject: [PATCH] [*] SM3.0 fixes --- spirv_hlsl.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/spirv_hlsl.cpp b/spirv_hlsl.cpp index 46fc1768..031b4d44 100644 --- a/spirv_hlsl.cpp +++ b/spirv_hlsl.cpp @@ -783,6 +783,9 @@ void CompilerHLSL::emit_builtin_inputs_in_struct() break; case BuiltInPrimitiveId: + if (legacy) + SPIRV_CROSS_THROW("Primitive ID not supported in SM 3.0 or lower."); + type = "uint"; semantic = "SV_PrimitiveID"; break; @@ -830,8 +833,16 @@ void CompilerHLSL::emit_builtin_inputs_in_struct() break; case BuiltInFrontFacing: - type = "bool"; - semantic = "SV_IsFrontFace"; + if (legacy) + { + type = "float"; + semantic = "VFACE"; + } + else + { + type = "bool"; + semantic = "SV_IsFrontFace"; + } break; case BuiltInViewIndex: @@ -3146,6 +3157,20 @@ void CompilerHLSL::emit_hlsl_entry_point() } break; + + + case BuiltInFrontFacing: + { + if (legacy) + statement(builtin, " = bool(stage_input.", builtin, " > 0.0 ? true : false);"); + else + { + statement(builtin, " = int(stage_input.", builtin, ");"); + } + break; + } + + case BuiltInVertexId: case BuiltInVertexIndex: case BuiltInInstanceIndex: