Bindless shader parameters

- Adding support for bindless resources/samplers. The loose resources have to be wrapped in a macro that generates an index and proxy resource when bindless is enabled. Reflection has to parse these differently from other resources since they're parsed as uint parameters. The runtime also has to bind these differently since they end up needing to find their real resource in the binding data and then update a constant buffer.
- To assist in conversions, the shader compiler will detect if a shader is compiled with both bindless and non-bindless resources/samplers and will emit errors if that is the case.
- Adding support for bindless Uniform Buffer resources/samplers. Because Uniform Buffers aren't per-shader, they'll always update their constants with the bindless indices of their resources.
- Adding more flags to FShaderCodePackedResourceCounts required changing all the array initializations to individual parameters since not all the new flags are used everywhere.
- No shaders have been configured to support bindless resources/samplers. Yet.

#jira UE-139616
#rb zach.bethel, arciel.rekman
#preflight 6282b8ec44349a6581a21a39

[CL 20250348 by christopher waters in ue5-main branch]
This commit is contained in:
christopher waters
2022-05-17 16:30:48 -04:00
parent 7625323945
commit 1e01768e33
23 changed files with 567 additions and 69 deletions
@@ -11,6 +11,8 @@
namespace UE::ShaderCompilerCommon
{
static constexpr const TCHAR* kUniformBufferConstantBufferPrefix = TEXT("UniformBufferConstants_");
static constexpr const TCHAR* kBindlessResourcePrefix = TEXT("BindlessResource_");
static constexpr const TCHAR* kBindlessSamplerPrefix = TEXT("BindlessSampler_");
}
/**
@@ -58,12 +60,16 @@ public:
const FShaderParametersMetadata::FMember* Member = nullptr;
/** Information found about the member when parsing the preprocessed code. */
FString ParsedName;
FString ParsedType;
FString ParsedArraySize;
/** Offset the member should be in the constant buffer. */
int32 ConstantBufferOffset = 0;
/** Records if the parameter was fully moved. */
bool bOriginalParameterErased{};
/* Returns whether the shader parameter has been found when parsing. */
bool IsFound() const
{
@@ -146,7 +152,9 @@ private:
namespace UE::ShaderCompilerCommon
{
extern SHADERCOMPILERCOMMON_API FString RemoveConstantBufferPrefix(const FString& InName);
extern SHADERCOMPILERCOMMON_API FString RemoveConstantBufferPrefix(const FString& InName);
extern SHADERCOMPILERCOMMON_API EShaderParameterType ParseAndRemoveBindlessParameterPrefix(FString& InName);
extern SHADERCOMPILERCOMMON_API bool RemoveBindlessParameterPrefix(FString& InName);
}
extern SHADERCOMPILERCOMMON_API void HandleReflectedGlobalConstantBufferMember(