vk: avoid calling List::head() in loops
This commit is contained in:
parent
0ef54aa16b
commit
6bfde76514
|
@ -41,7 +41,7 @@ struct List
|
|||
}
|
||||
|
||||
__forceinline
|
||||
T* LastPtr(int n=1)
|
||||
T* LastPtr(int n=1) const
|
||||
{
|
||||
return daty-n;
|
||||
}
|
||||
|
|
|
@ -158,15 +158,17 @@ void BaseDrawer::SetBaseScissor()
|
|||
void BaseDrawer::SetProvokingVertices()
|
||||
{
|
||||
auto setProvokingVertex = [](const List<PolyParam>& list) {
|
||||
for (int i = 0; i < list.used(); i++)
|
||||
u32 *idx_base = pvrrc.idx.head();
|
||||
Vertex *vtx_base = pvrrc.verts.head();
|
||||
const PolyParam *pp_end = list.LastPtr(0);
|
||||
for (const PolyParam *pp = list.head(); pp != pp_end; pp++)
|
||||
{
|
||||
const PolyParam& pp = list.head()[i];
|
||||
if (!pp.pcw.Gouraud && pp.count > 2)
|
||||
if (!pp->pcw.Gouraud && pp->count > 2)
|
||||
{
|
||||
for (int i = 0; i < pp.count - 2; i++)
|
||||
for (int i = 0; i < pp->count - 2; i++)
|
||||
{
|
||||
Vertex *vertex = &pvrrc.verts.head()[pvrrc.idx.head()[pp.first + i]];
|
||||
Vertex *lastVertex = &pvrrc.verts.head()[pvrrc.idx.head()[pp.first + i + 2]];
|
||||
Vertex *vertex = &vtx_base[idx_base[pp->first + i]];
|
||||
Vertex *lastVertex = &vtx_base[idx_base[pp->first + i + 2]];
|
||||
memcpy(vertex->col, lastVertex->col, 4);
|
||||
memcpy(vertex->spc, lastVertex->spc, 4);
|
||||
memcpy(vertex->col1, lastVertex->col1, 4);
|
||||
|
@ -224,19 +226,15 @@ void Drawer::DrawPoly(const vk::CommandBuffer& cmdBuffer, u32 listType, bool sor
|
|||
void Drawer::DrawSorted(const vk::CommandBuffer& cmdBuffer, const std::vector<SortTrigDrawParam>& polys)
|
||||
{
|
||||
for (const SortTrigDrawParam& param : polys)
|
||||
{
|
||||
DrawPoly(cmdBuffer, ListType_Translucent, true, *param.ppid, pvrrc.idx.used() + param.first, param.count);
|
||||
}
|
||||
}
|
||||
|
||||
void Drawer::DrawList(const vk::CommandBuffer& cmdBuffer, u32 listType, bool sortTriangles, const List<PolyParam>& polys, u32 first, u32 last)
|
||||
{
|
||||
for (u32 i = first; i < last; i++)
|
||||
{
|
||||
const PolyParam &pp = polys.head()[i];
|
||||
if (pp.count > 2)
|
||||
DrawPoly(cmdBuffer, listType, sortTriangles, pp, pp.first, pp.count);
|
||||
}
|
||||
const PolyParam *pp_end = polys.head() + last;
|
||||
for (const PolyParam *pp = polys.head() + first; pp != pp_end; pp++)
|
||||
if (pp->count > 2)
|
||||
DrawPoly(cmdBuffer, listType, sortTriangles, *pp, pp->first, pp->count);
|
||||
}
|
||||
|
||||
void Drawer::DrawModVols(const vk::CommandBuffer& cmdBuffer, int first, int count)
|
||||
|
|
|
@ -52,9 +52,7 @@ void OITDrawer::DrawPoly(const vk::CommandBuffer& cmdBuffer, u32 listType, bool
|
|||
},
|
||||
{ poly.tsp.SrcInstr, poly.tsp.DstInstr, 0, 0 },
|
||||
trilinearAlpha,
|
||||
(int)(&poly - (listType == ListType_Opaque ? pvrrc.global_param_op.head()
|
||||
: listType == ListType_Punch_Through ? pvrrc.global_param_pt.head()
|
||||
: pvrrc.global_param_tr.head())),
|
||||
listType == ListType_Translucent ? (int)(&poly - pvrrc.global_param_tr.head()) : 0,
|
||||
};
|
||||
if (twoVolumes)
|
||||
{
|
||||
|
@ -85,12 +83,10 @@ void OITDrawer::DrawPoly(const vk::CommandBuffer& cmdBuffer, u32 listType, bool
|
|||
void OITDrawer::DrawList(const vk::CommandBuffer& cmdBuffer, u32 listType, bool sortTriangles, Pass pass,
|
||||
const List<PolyParam>& polys, u32 first, u32 last)
|
||||
{
|
||||
for (u32 i = first; i < last; i++)
|
||||
{
|
||||
const PolyParam &pp = polys.head()[i];
|
||||
if (pp.count > 2)
|
||||
DrawPoly(cmdBuffer, listType, sortTriangles, pass, pp, pp.first, pp.count);
|
||||
}
|
||||
const PolyParam *pp_end = polys.head() + last;
|
||||
for (const PolyParam *pp = polys.head() + first; pp != pp_end; pp++)
|
||||
if (pp->count > 2)
|
||||
DrawPoly(cmdBuffer, listType, sortTriangles, pass, *pp, pp->first, pp->count);
|
||||
}
|
||||
|
||||
template<bool Translucent>
|
||||
|
@ -222,11 +218,12 @@ void OITDrawer::UploadMainBuffer(const OITDescriptorSets::VertexShaderUniforms&
|
|||
trPolyParams.push_back(0); // makes the validation layers happy
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < pvrrc.global_param_tr.used(); i++)
|
||||
const PolyParam *pp_end = pvrrc.global_param_tr.LastPtr(0);
|
||||
const PolyParam *pp = pvrrc.global_param_tr.head();
|
||||
for (int i = 0; pp != pp_end; i += 2, pp++)
|
||||
{
|
||||
const PolyParam& pp = pvrrc.global_param_tr.head()[i];
|
||||
trPolyParams[i * 2] = (pp.tsp.full & 0xffff00c0) | ((pp.isp.full >> 16) & 0xe400) | ((pp.pcw.full >> 7) & 1);
|
||||
trPolyParams[i * 2 + 1] = pp.tsp1.full;
|
||||
trPolyParams[i] = (pp->tsp.full & 0xffff00c0) | ((pp->isp.full >> 16) & 0xe400) | ((pp->pcw.full >> 7) & 1);
|
||||
trPolyParams[i + 1] = pp->tsp1.full;
|
||||
}
|
||||
}
|
||||
offsets.polyParamsSize = trPolyParams.size() * 4;
|
||||
|
|
Loading…
Reference in New Issue