I have a common method in hlsli
/// RendererShaderTypes.hlsli
///
static inline float4 OverlayColor(float2 texOverlay, float4 videoColor)
{
float4 texColor = float4(imageMixTexture[4].Sample(imageMixSampler[4], texOverlay));
if (texColor.r == keyColor.r &&
texColor.g == keyColor.g &&
texColor.b == keyColor.b)
{
return videoColor;
}
return lerp(texColor, videoColor, transparency);
}
It's called from more than one hlsl pixel shaders.
#include "RendererShaderTypes.hlsli"
float4 main(PSPosTexOverlay input) : SV_TARGET
{
return OverlayColor(input.texOverlay, backColor);
}
also called to another pixel shader
#include "RendererShaderTypes.hlsli"
float4 main(PSPosVideoTexture input) : SV_TARGET
{
// lookup color of video
float4 mixColor = mul(colorMatrix[0], VideoColor(imageMixSampler[0], imageMixTexture[0], input.texImage));
mixColor.rgb *= mixColor.a;
mixColor.a = 1.0f;
return OverlayColor(input.texOverlay, mixColor);
}
when compiled shows following warning. Any idea why it's showing?
warning X4000: use of potentially uninitialized variable (OverlayColor)
I don't know yet any satisfactory reason but I have solved the issue. Any function that calls a mid-function return statement will show the warning during compilation. I have re-writed one of above like this and the warning went away.
static inline float4 OverlayColor(int texIndex, float2 texOverlay, float4 videoColor)
{
float4 texColor = float4(imageMixTexture[4].Sample(imageMixSampler[4], texOverlay));
float4 overlayColor;
if (texColor.r == keyColor.r &&
texColor.g == keyColor.g &&
texColor.b == keyColor.b)
{
overlayColor = videoColor;
}
else
overlayColor = lerp(texColor, videoColor, transparency);
return overlayColor;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With