Always access args.uniforms directly instead of first creating a TriUniforms variable

This commit is contained in:
Magnus Norddahl 2016-11-26 07:35:04 +01:00
parent 62188d1ea5
commit 70181f4146
5 changed files with 33 additions and 46 deletions

View file

@ -70,33 +70,32 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, particle_t *partic
// int color = (particle->color >> 24) & 0xff; // pal index, I think
bool fullbrightSprite = particle->bright != 0;
TriUniforms uniforms;
PolyDrawArgs args;
if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap)
{
uniforms.light = 256;
uniforms.flags = TriUniforms::fixed_light;
args.uniforms.light = 256;
args.uniforms.flags = TriUniforms::fixed_light;
}
else
{
uniforms.light = (uint32_t)((sub->sector->lightlevel + actualextralight) / 255.0f * 256.0f);
uniforms.flags = 0;
args.uniforms.light = (uint32_t)((sub->sector->lightlevel + actualextralight) / 255.0f * 256.0f);
args.uniforms.flags = 0;
}
uniforms.subsectorDepth = subsectorDepth;
args.uniforms.subsectorDepth = subsectorDepth;
if (r_swtruecolor)
{
uint32_t alpha = particle->trans;
uniforms.color = (alpha << 24) | (particle->color & 0xffffff);
args.uniforms.color = (alpha << 24) | (particle->color & 0xffffff);
}
else
{
uniforms.color = ((uint32_t)particle->color) >> 24;
uniforms.srcalpha = particle->trans;
uniforms.destalpha = 255 - particle->trans;
args.uniforms.color = ((uint32_t)particle->color) >> 24;
args.uniforms.srcalpha = particle->trans;
args.uniforms.destalpha = 255 - particle->trans;
}
PolyDrawArgs args;
args.uniforms = uniforms;
args.objectToClip = &worldToClip;
args.vinput = vertices;
args.vcount = 4;

View file

@ -103,12 +103,12 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s
lightlevel = *light->p_lightlevel;
}
TriUniforms uniforms;
uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f);
PolyDrawArgs args;
args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f);
if (fixedlightlev >= 0 || fixedcolormap)
uniforms.light = 256;
uniforms.flags = 0;
uniforms.subsectorDepth = subsectorDepth;
args.uniforms.light = 256;
args.uniforms.flags = 0;
args.uniforms.subsectorDepth = subsectorDepth;
TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines);
if (!vertices)
@ -131,8 +131,6 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, subsector_t *s
}
}
PolyDrawArgs args;
args.uniforms = uniforms;
args.objectToClip = &worldToClip;
args.vinput = vertices;
args.vcount = sub->numlines;
@ -217,12 +215,12 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin
bool isSky = picnum == skyflatnum;
TriUniforms uniforms;
uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
PolyDrawArgs args;
args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
if (fixedlightlev >= 0 || fixedcolormap)
uniforms.light = 256;
uniforms.flags = 0;
uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth;
args.uniforms.light = 256;
args.uniforms.flags = 0;
args.uniforms.subsectorDepth = isSky ? RenderPolyPortal::SkySubsectorDepth : subsectorDepth;
TriVertex *vertices = PolyVertexBuffer::GetVertices(sub->numlines);
if (!vertices)
@ -245,8 +243,6 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, subsector_t *sub, uin
}
}
PolyDrawArgs args;
args.uniforms = uniforms;
args.objectToClip = &worldToClip;
args.vinput = vertices;
args.vcount = sub->numlines;

View file

@ -50,15 +50,12 @@ void PolySkyDome::Render(const TriMatrix &worldToClip)
TriMatrix objectToWorld = TriMatrix::translate((float)ViewPos.X, (float)ViewPos.Y, (float)ViewPos.Z);
objectToClip = worldToClip * objectToWorld;
TriUniforms uniforms;
uniforms.light = 256;
uniforms.flags = 0;
uniforms.subsectorDepth = RenderPolyPortal::SkySubsectorDepth;
int rc = mRows + 1;
PolyDrawArgs args;
args.uniforms = uniforms;
args.uniforms.light = 256;
args.uniforms.flags = 0;
args.uniforms.subsectorDepth = RenderPolyPortal::SkySubsectorDepth;
args.objectToClip = &objectToClip;
args.stenciltestvalue = 255;
args.stencilwritevalue = 255;

View file

@ -239,13 +239,10 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip)
ClampHeight(vertices[1], vertices[2]);
}
TriUniforms uniforms;
uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f);
uniforms.flags = 0;
uniforms.subsectorDepth = SubsectorDepth;
PolyDrawArgs args;
args.uniforms = uniforms;
args.uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f);
args.uniforms.flags = 0;
args.uniforms.subsectorDepth = SubsectorDepth;
args.objectToClip = &worldToClip;
args.vinput = vertices;
args.vcount = 4;

View file

@ -98,21 +98,19 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, AActor *thing, s
bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
TriUniforms uniforms;
PolyDrawArgs args;
if (fullbrightSprite || fixedlightlev >= 0 || fixedcolormap)
{
uniforms.light = 256;
uniforms.flags = TriUniforms::fixed_light;
args.uniforms.light = 256;
args.uniforms.flags = TriUniforms::fixed_light;
}
else
{
uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f);
uniforms.flags = 0;
args.uniforms.light = (uint32_t)((thing->Sector->lightlevel + actualextralight) / 255.0f * 256.0f);
args.uniforms.flags = 0;
}
uniforms.subsectorDepth = subsectorDepth;
args.uniforms.subsectorDepth = subsectorDepth;
PolyDrawArgs args;
args.uniforms = uniforms;
args.objectToClip = &worldToClip;
args.vinput = vertices;
args.vcount = 4;