为什么 "Warning X4000: use of potentially uninitialized variable" 显示了多个常用方法的用法?
Why "Warning X4000: use of potentially uninitialized variable" shows for more than one usage of common method?
我在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);
}
它被多个 hlsl 像素着色器调用。
#include "RendererShaderTypes.hlsli"
float4 main(PSPosTexOverlay input) : SV_TARGET
{
return OverlayColor(input.texOverlay, backColor);
}
还调用了另一个像素着色器
#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);
}
编译时显示以下警告。知道它为什么显示吗?
warning X4000: use of potentially uninitialized variable (OverlayColor)
我还不知道任何令人满意的原因,但我已经解决了这个问题。任何调用 mid-function return 语句的函数都会在编译期间显示警告。我有 re-writed 以上之一,警告消失了。
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;
}
我在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);
}
它被多个 hlsl 像素着色器调用。
#include "RendererShaderTypes.hlsli"
float4 main(PSPosTexOverlay input) : SV_TARGET
{
return OverlayColor(input.texOverlay, backColor);
}
还调用了另一个像素着色器
#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);
}
编译时显示以下警告。知道它为什么显示吗?
warning X4000: use of potentially uninitialized variable (OverlayColor)
我还不知道任何令人满意的原因,但我已经解决了这个问题。任何调用 mid-function return 语句的函数都会在编译期间显示警告。我有 re-writed 以上之一,警告消失了。
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;
}