-
|
Is there a way in slang to detect that a parameter is unused in the final shader? #pragma once
SamplerState g_samplerPointClamp;
SamplerState g_samplerPointWrap;
SamplerState g_samplerLinearClamp;
SamplerState g_samplerLinearWrap;and I have a shader including this header: const float3 albedo = g_albedo.SampleLevel(g_samplerLinearClamp, i.uv, 0.0f).rgb;Is it possible to understand that 3 of 4 samplers unused? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
The best way to detect the unused parameters is to get the compiled shader's reflection data using Slang's reflection API, and then use some additional functions, namely Alternatively, for a simple shader, you could probably get away with compiling the shader with |
Beta Was this translation helpful? Give feedback.
The best way to detect the unused parameters is to get the compiled shader's reflection data using Slang's reflection API, and then use some additional functions, namely
IComponentType::getEntryPointMetadata(), to get metadata for the entry points in the reflections, and then you can search that metadata for usages of each parameter, checking withIMetadata::isParameterLocationUsed().See the section "Determining Whether Parameters Are Used" in the chapter "Using the Reflection API" in the user guide for details on how you can do that.
Alternatively, for a simple shader, you could probably get away with compiling the shader with
-reflection-jsonto dump the reflection info to a JSON file,…