Merge pull request #1931 from EpicGames/fixes_hlsl

HLSL: Add missing `BuiltInLayer` to HLSL backend.
This commit is contained in:
Hans-Kristian Arntzen 2022-04-29 11:32:46 +02:00 committed by GitHub
commit a9d23d7652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -643,6 +643,13 @@ void CompilerHLSL::emit_builtin_outputs_in_struct()
else
SPIRV_CROSS_THROW("Unsupported builtin in HLSL.");
case BuiltInLayer:
if (hlsl_options.shader_model < 50 || get_entry_point().model != ExecutionModelGeometry)
SPIRV_CROSS_THROW("Render target index output is only supported in GS 5.0 or higher.");
type = "uint";
semantic = "SV_RenderTargetIndex";
break;
default:
SPIRV_CROSS_THROW("Unsupported builtin in HLSL.");
}
@ -788,6 +795,13 @@ void CompilerHLSL::emit_builtin_inputs_in_struct()
else
SPIRV_CROSS_THROW("Unsupported builtin in HLSL.");
case BuiltInLayer:
if (hlsl_options.shader_model < 50 || get_entry_point().model != ExecutionModelFragment)
SPIRV_CROSS_THROW("Render target index input is only supported in PS 5.0 or higher.");
type = "uint";
semantic = "SV_RenderTargetIndex";
break;
default:
SPIRV_CROSS_THROW("Unsupported builtin in HLSL.");
}
@ -1147,6 +1161,7 @@ void CompilerHLSL::emit_builtin_variables()
case BuiltInPrimitiveId:
case BuiltInViewIndex:
case BuiltInLayer:
type = "uint";
break;