Fix uninitialized reads in PreparePolygon
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1392
This commit is contained in:
1 parent
4aa4e235a5
commit
3ee2e47724
3 files changed
+94
-42
No files matched your search
@@ -183,14 +183,15 @@ enum EPolyFlags
|
||||
PF_NoDepthTest = 0x00000200, // Disable the depth test mode
|
||||
PF_Invisible = 0x00000400, // Disable write to color buffer
|
||||
PF_Decal = 0x00000800, // Enable polygon offset
|
||||
PF_Modulated = 0x00001000, // Modulation (multiply output with constant ARGB)
|
||||
PF_Modulated = 0x00001000, // Modulation (multiply output with constant RGBA)
|
||||
// When set, pass the color constant into the FSurfaceInfo -> FlatColor
|
||||
PF_NoTexture = 0x00002000, // Disable texture
|
||||
PF_Ripple = 0x00004000, // Water shader effect
|
||||
PF_ColorMapped = 0x00008000, // Surface has "tint" and "fade" colors, which are sent as uniforms to a shader.
|
||||
// 0x00008000
|
||||
PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y
|
||||
PF_ForceWrapX = 0x00020000, // Force repeat texture on X
|
||||
PF_ForceWrapY = 0x00040000, // Force repeat texture on Y
|
||||
PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y
|
||||
PF_Ripple = 0x00100000 // Water ripple effect. The current backend doesn't use it for anything.
|
||||
// 0x20000000
|
||||
// 0x40000000
|
||||
// 0x80000000
|
||||
@@ -208,7 +209,6 @@ enum ETextureFlags
|
||||
|
||||
typedef struct GLMipmap_s FTextureInfo;
|
||||
|
||||
// jimita 14032019
|
||||
struct FLightInfo
|
||||
{
|
||||
FUINT light_level;
|
||||
@@ -225,7 +225,7 @@ struct FSurfaceInfo
|
||||
RGBA_t TintColor;
|
||||
RGBA_t FadeColor;
|
||||
UINT32 LightTableId;
|
||||
FLightInfo LightInfo; // jimita 14032019
|
||||
FLightInfo LightInfo;
|
||||
};
|
||||
typedef struct FSurfaceInfo FSurfaceInfo;
|
||||
|
||||
|
||||
+65
-16
@@ -861,12 +861,17 @@ void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedhei
|
||||
else
|
||||
PolyFlags |= PF_Masked|PF_Modulated;
|
||||
|
||||
if (PolyFlags & PF_Fog)
|
||||
HWD.pfnSetShader(6); // fog shader
|
||||
else if (PolyFlags & PF_Ripple)
|
||||
HWD.pfnSetShader(5); // water shader
|
||||
else
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
if (PolyFlags & PF_Fog)
|
||||
HWD.pfnSetShader(6); // fog shader
|
||||
else if (PolyFlags & PF_Ripple)
|
||||
HWD.pfnSetShader(5); // water shader
|
||||
else
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
|
||||
|
||||
PolyFlags |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, false);
|
||||
|
||||
@@ -1020,7 +1025,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
|
||||
break;
|
||||
}
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, false);
|
||||
}
|
||||
}
|
||||
@@ -1054,7 +1063,11 @@ void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend
|
||||
{
|
||||
HWR_Lighting(pSurf, lightlevel, wallcolormap);
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
|
||||
blendmode |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
// don't draw to color buffer when drawing to stencil
|
||||
if (gl_drawing_stencil)
|
||||
@@ -3251,7 +3264,12 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t
|
||||
else
|
||||
blendmode |= PF_Masked|PF_Modulated;
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
|
||||
blendmode |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, false);
|
||||
}
|
||||
|
||||
@@ -4062,7 +4080,10 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
|
||||
if (sSurf.PolyColor.s.alpha > floorheight/4)
|
||||
{
|
||||
sSurf.PolyColor.s.alpha = (UINT8)(sSurf.PolyColor.s.alpha - floorheight/4);
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 9 : 1); // floor shader
|
||||
}
|
||||
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated, false);
|
||||
}
|
||||
}
|
||||
@@ -4273,6 +4294,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
|
||||
}
|
||||
|
||||
alpha = Surf.PolyColor.s.alpha;
|
||||
|
||||
|
||||
// Start with the lightlevel and colormap from the top of the sprite
|
||||
lightlevel = *list[sector->numlights - 1].lightlevel;
|
||||
@@ -4428,8 +4450,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
|
||||
HWR_Lighting(&Surf, lightlevel, colormap);
|
||||
|
||||
Surf.PolyColor.s.alpha = alpha;
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
blend |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
|
||||
|
||||
top = bot;
|
||||
@@ -4469,7 +4496,12 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
|
||||
|
||||
Surf.PolyColor.s.alpha = alpha;
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
blend |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
|
||||
}
|
||||
|
||||
@@ -4622,7 +4654,12 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
blend |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
|
||||
}
|
||||
}
|
||||
@@ -4716,7 +4753,12 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 3); // sprite shader
|
||||
blend |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, false);
|
||||
}
|
||||
|
||||
@@ -6359,7 +6401,14 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
|
||||
blendmode |= PF_Modulated; // No PF_Occlude means overlapping (incorrect) transparency
|
||||
|
||||
if (!fogwall)
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
|
||||
{
|
||||
if (cv_grshaders.value || gr_shadersavailable)
|
||||
{
|
||||
HWD.pfnSetShader(gr_use_palette_shader ? 10 : 2); // wall shader
|
||||
blendmode |= PF_ColorMapped;
|
||||
}
|
||||
}
|
||||
|
||||
HWD.pfnDrawPolygon(pSurf, wallVerts, 4, blendmode, false);
|
||||
|
||||
#ifdef WALLSPLATS
|
||||
|
||||
@@ -2807,37 +2807,40 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI
|
||||
// PolyColor
|
||||
if (pSurf)
|
||||
{
|
||||
// If Modulated, mix the surface colour to the texture
|
||||
// If modulated, mix the surface colour to the texture
|
||||
if (CurrentPolyFlags & PF_Modulated)
|
||||
{
|
||||
// Poly color
|
||||
poly.red = byte2float[pSurf->PolyColor.s.red];
|
||||
poly.green = byte2float[pSurf->PolyColor.s.green];
|
||||
poly.blue = byte2float[pSurf->PolyColor.s.blue];
|
||||
poly.alpha = byte2float[pSurf->PolyColor.s.alpha];
|
||||
|
||||
pglColor4ubv((GLubyte*)&pSurf->PolyColor.s);
|
||||
}
|
||||
|
||||
// Tint color
|
||||
tint.red = byte2float[pSurf->TintColor.s.red];
|
||||
tint.green = byte2float[pSurf->TintColor.s.green];
|
||||
tint.blue = byte2float[pSurf->TintColor.s.blue];
|
||||
tint.alpha = byte2float[pSurf->TintColor.s.alpha];
|
||||
// If the surface is either modulated or colormapped, or both
|
||||
if (CurrentPolyFlags & (PF_Modulated | PF_ColorMapped))
|
||||
{
|
||||
poly.red = byte2float[pSurf->PolyColor.s.red];
|
||||
poly.green = byte2float[pSurf->PolyColor.s.green];
|
||||
poly.blue = byte2float[pSurf->PolyColor.s.blue];
|
||||
poly.alpha = byte2float[pSurf->PolyColor.s.alpha];
|
||||
}
|
||||
|
||||
// Fade color
|
||||
fade.red = byte2float[pSurf->FadeColor.s.red];
|
||||
fade.green = byte2float[pSurf->FadeColor.s.green];
|
||||
fade.blue = byte2float[pSurf->FadeColor.s.blue];
|
||||
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
|
||||
|
||||
// Only if the surface is colormapped
|
||||
if (CurrentPolyFlags & PF_ColorMapped)
|
||||
{
|
||||
tint.red = byte2float[pSurf->TintColor.s.red];
|
||||
tint.green = byte2float[pSurf->TintColor.s.green];
|
||||
tint.blue = byte2float[pSurf->TintColor.s.blue];
|
||||
tint.alpha = byte2float[pSurf->TintColor.s.alpha];
|
||||
|
||||
fade.red = byte2float[pSurf->FadeColor.s.red];
|
||||
fade.green = byte2float[pSurf->FadeColor.s.green];
|
||||
fade.blue = byte2float[pSurf->FadeColor.s.blue];
|
||||
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
|
||||
}
|
||||
|
||||
if (gl_use_palette_shader && gl_allowshaders)
|
||||
{
|
||||
pglActiveTexture(GL_TEXTURE2);
|
||||
pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId);
|
||||
pglActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Shader_Load(pSurf, &poly, &tint, &fade);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user