Add sampler slots usage and inputs/outputs count to GPU shader program bindings meta

This commit is contained in:
Wojtek Figat
2026-02-26 12:02:52 +01:00
parent ac4526744a
commit 20c9ed27fb
7 changed files with 35 additions and 14 deletions

View File

@@ -112,15 +112,13 @@ bool GPUPipelineState::Init(const Description& desc)
#endif
// Cache shader stages usage flags for pipeline state
_meta.InstructionsCount = 0;
_meta.UsedCBsMask = 0;
_meta.UsedSRsMask = 0;
_meta.UsedUAsMask = 0;
Platform::MemoryClear(&_meta, sizeof(_meta));
#define CHECK_STAGE(stage) \
if (desc.stage) { \
_meta.UsedCBsMask |= desc.stage->GetBindings().UsedCBsMask; \
_meta.UsedSRsMask |= desc.stage->GetBindings().UsedSRsMask; \
_meta.UsedUAsMask |= desc.stage->GetBindings().UsedUAsMask; \
_meta.UsedSamplersMask |= desc.stage->GetBindings().UsedSamplersMask; \
}
CHECK_STAGE(VS);
CHECK_STAGE(HS);

View File

@@ -215,6 +215,14 @@ public:
return _meta.UsedUAsMask;
}
/// <summary>
/// Gets texture samplers mask (each set bit marks usage of the sampler slot at the bit index slot). Combined from all the used shader stages.
/// </summary>
FORCE_INLINE uint32 GetUsedSamplersMask() const
{
return _meta.UsedSamplersMask;
}
public:
/// <summary>
/// Returns true if pipeline state is valid and ready to use

View File

@@ -12,7 +12,7 @@ class GPUShaderProgram;
/// <summary>
/// The runtime version of the shaders cache supported by the all graphics back-ends. The same for all the shader cache formats (easier to sync and validate).
/// </summary>
#define GPU_SHADER_CACHE_VERSION 12
#define GPU_SHADER_CACHE_VERSION 13
/// <summary>
/// The GPU resource with shader programs that can run on the GPU and are able to perform rendering calculation using textures, vertices and other resources.

View File

@@ -21,6 +21,9 @@ struct FLAXENGINE_API ShaderBindings
uint32 UsedCBsMask;
uint32 UsedSRsMask;
uint32 UsedUAsMask;
uint32 UsedSamplersMask;
uint16 InputsCount;
uint16 OutputsCount;
FORCE_INLINE bool IsUsingCB(uint32 slotIndex) const
{
@@ -36,6 +39,11 @@ struct FLAXENGINE_API ShaderBindings
{
return (UsedUAsMask & (1u << slotIndex)) != 0u;
}
FORCE_INLINE bool IsUsingSampler(uint32 slotIndex) const
{
return (UsedSamplersMask & (1u << slotIndex)) != 0u;
}
};
struct GPUShaderProgramInitializer