oit: poly number/vertex id overflow
Use 17 bits for vertex id but substract first vtx index Use 13 bits for poly number instead of 12 Panzer Front uses more than 4095 tr polys. Issue #616
This commit is contained in:
parent
c348f4ccad
commit
3cc991fa4f
|
@ -129,7 +129,7 @@ VertexOut main(in VertexIn vin)
|
||||||
if (envMapping0 == 1)
|
if (envMapping0 == 1)
|
||||||
computeEnvMap(vo.uv.xy, vnorm);
|
computeEnvMap(vo.uv.xy, vnorm);
|
||||||
#endif
|
#endif
|
||||||
vo.index = (uint(polyNumber) << 18) + vin.vertexId;
|
vo.index = uint(polyNumber) + vin.vertexId;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vo.pos = mul(projMat, vo.pos);
|
vo.pos = mul(projMat, vo.pos);
|
||||||
|
|
|
@ -315,6 +315,7 @@ struct DX11OITRenderer : public DX11Renderer
|
||||||
|
|
||||||
PolyParam* params = &gply.head()[first];
|
PolyParam* params = &gply.head()[first];
|
||||||
|
|
||||||
|
u32 firstVertexIdx = Type == ListType_Translucent ? pvrrc.idx.head()[gply.head()->first] : 0;
|
||||||
while (count-- > 0)
|
while (count-- > 0)
|
||||||
{
|
{
|
||||||
if (params->count > 2)
|
if (params->count > 2)
|
||||||
|
@ -325,7 +326,7 @@ struct DX11OITRenderer : public DX11Renderer
|
||||||
params++;
|
params++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
setRenderState<Type, SortingEnabled, pass>(params, (int)(params - gply.head()));
|
setRenderState<Type, SortingEnabled, pass>(params, (int)((params - gply.head()) << 17) - firstVertexIdx);
|
||||||
deviceContext->DrawIndexed(params->count, params->first, 0);
|
deviceContext->DrawIndexed(params->count, params->first, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ VertexOut main(in VertexIn vin)
|
||||||
#endif
|
#endif
|
||||||
vo.uv = float4(vin.uv * vo.pos.z, 0.f, vo.pos.z);
|
vo.uv = float4(vin.uv * vo.pos.z, 0.f, vo.pos.z);
|
||||||
vo.uv1 = vin.uv1 * vo.pos.z;
|
vo.uv1 = vin.uv1 * vo.pos.z;
|
||||||
vo.index = (uint(polyNumber) << 18) + vin.vertexId;
|
vo.index = uint(polyNumber) + vin.vertexId;
|
||||||
|
|
||||||
vo.pos.w = 1.f;
|
vo.pos.w = 1.f;
|
||||||
vo.pos.z = 0.f;
|
vo.pos.z = 0.f;
|
||||||
|
@ -212,7 +212,7 @@ uint getPolyIndex(in Pixel pixel)
|
||||||
|
|
||||||
uint getPolyNumber(in Pixel pixel)
|
uint getPolyNumber(in Pixel pixel)
|
||||||
{
|
{
|
||||||
return (pixel.seq_num & 0x3FFFFFFFu) >> 18;
|
return (pixel.seq_num & 0x3FFFFFFFu) >> 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHADOW_STENCIL 0x40000000u
|
#define SHADOW_STENCIL 0x40000000u
|
||||||
|
|
|
@ -294,6 +294,7 @@ static void DrawList(const List<PolyParam>& gply, int first, int count)
|
||||||
{
|
{
|
||||||
PolyParam* params = &gply.head()[first];
|
PolyParam* params = &gply.head()[first];
|
||||||
|
|
||||||
|
u32 firstVertexIdx = Type == ListType_Translucent ? pvrrc.idx.head()[gply.head()->first] : 0;
|
||||||
while (count-- > 0)
|
while (count-- > 0)
|
||||||
{
|
{
|
||||||
if (params->count > 2)
|
if (params->count > 2)
|
||||||
|
@ -310,7 +311,7 @@ static void DrawList(const List<PolyParam>& gply, int first, int count)
|
||||||
params++;
|
params++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gl4ShaderUniforms.poly_number = params - gply.head();
|
gl4ShaderUniforms.poly_number = ((params - gply.head()) << 17) - firstVertexIdx;
|
||||||
SetGPState<Type, SortingEnabled, pass>(params);
|
SetGPState<Type, SortingEnabled, pass>(params);
|
||||||
glDrawElements(GL_TRIANGLE_STRIP, params->count, GL_UNSIGNED_INT, (GLvoid*)(sizeof(u32) * params->first)); glCheck();
|
glDrawElements(GL_TRIANGLE_STRIP, params->count, GL_UNSIGNED_INT, (GLvoid*)(sizeof(u32) * params->first)); glCheck();
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ void main()
|
||||||
vtx_base1 = in_base1;
|
vtx_base1 = in_base1;
|
||||||
vtx_offs1 = in_offs1;
|
vtx_offs1 = in_offs1;
|
||||||
vtx_uv1 = in_uv1 * vpos.z;
|
vtx_uv1 = in_uv1 * vpos.z;
|
||||||
vtx_index = (uint(pp_Number) << 18) + uint(gl_VertexID);
|
vtx_index = uint(pp_Number) + uint(gl_VertexID);
|
||||||
#if pp_Gouraud == 1
|
#if pp_Gouraud == 1
|
||||||
vtx_base *= vpos.z;
|
vtx_base *= vpos.z;
|
||||||
vtx_offs *= vpos.z;
|
vtx_offs *= vpos.z;
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct PolyParam { \n\
|
||||||
\n\
|
\n\
|
||||||
#define getShadowEnable(pp) (((pp).tsp_isp_pcw & 1) != 0) \n\
|
#define getShadowEnable(pp) (((pp).tsp_isp_pcw & 1) != 0) \n\
|
||||||
\n\
|
\n\
|
||||||
#define getPolyNumber(pixel) (((pixel).seq_num & 0x3FFFFFFFu) >> 18) \n\
|
#define getPolyNumber(pixel) (((pixel).seq_num & 0x3FFFFFFFu) >> 17) \n\
|
||||||
\n\
|
\n\
|
||||||
#define getPolyIndex(pixel) ((pixel).seq_num & 0x3FFFFFFFu) \n\
|
#define getPolyIndex(pixel) ((pixel).seq_num & 0x3FFFFFFFu) \n\
|
||||||
\n\
|
\n\
|
||||||
|
|
|
@ -126,7 +126,7 @@ void main()
|
||||||
wDivide(vpos);
|
wDivide(vpos);
|
||||||
|
|
||||||
#ifdef OIT_RENDER
|
#ifdef OIT_RENDER
|
||||||
vtx_index = (uint(pp_Number) << 18) + uint(gl_VertexID);
|
vtx_index = uint(pp_Number) + uint(gl_VertexID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gl_Position = vpos;
|
gl_Position = vpos;
|
||||||
|
|
|
@ -105,8 +105,12 @@ protected:
|
||||||
for (const PolyParam& pp : pvrrc.global_param_pt)
|
for (const PolyParam& pp : pvrrc.global_param_pt)
|
||||||
addUniform(pp, 0);
|
addUniform(pp, 0);
|
||||||
size_t trOffset = bufIdx;
|
size_t trOffset = bufIdx;
|
||||||
for (const PolyParam& pp : pvrrc.global_param_tr)
|
if (pvrrc.global_param_tr.used() > 0)
|
||||||
addUniform(pp, &pp - pvrrc.global_param_tr.head());
|
{
|
||||||
|
u32 firstVertexIdx = pvrrc.idx.head()[pvrrc.global_param_tr.head()->first];
|
||||||
|
for (const PolyParam& pp : pvrrc.global_param_tr)
|
||||||
|
addUniform(pp, ((&pp - pvrrc.global_param_tr.head()) << 17) - firstVertexIdx);
|
||||||
|
}
|
||||||
size_t mvOffset = bufIdx;
|
size_t mvOffset = bufIdx;
|
||||||
for (const ModifierVolumeParam& mvp : pvrrc.global_param_mvo)
|
for (const ModifierVolumeParam& mvp : pvrrc.global_param_mvo)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,8 +78,10 @@ void OITDrawer::DrawPoly(const vk::CommandBuffer& cmdBuffer, u32 listType, bool
|
||||||
cmdBuffer.pushConstants<OITDescriptorSets::PushConstants>(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eFragment, 0, pushConstants);
|
cmdBuffer.pushConstants<OITDescriptorSets::PushConstants>(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eFragment, 0, pushConstants);
|
||||||
if (!poly.isNaomi2())
|
if (!poly.isNaomi2())
|
||||||
{
|
{
|
||||||
OITDescriptorSets::VtxPushConstants vtxPushConstants = {
|
OITDescriptorSets::VtxPushConstants vtxPushConstants {};
|
||||||
listType == ListType_Translucent ? (int)(&poly - pvrrc.global_param_tr.head()) : 0
|
if (listType == ListType_Translucent) {
|
||||||
|
u32 firstVertexIdx = pvrrc.idx.head()[pvrrc.global_param_tr.head()->first];
|
||||||
|
vtxPushConstants.polyNumber = (int)((&poly - pvrrc.global_param_tr.head()) << 17) - firstVertexIdx;
|
||||||
};
|
};
|
||||||
cmdBuffer.pushConstants<OITDescriptorSets::VtxPushConstants>(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eVertex,
|
cmdBuffer.pushConstants<OITDescriptorSets::VtxPushConstants>(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eVertex,
|
||||||
sizeof(OITDescriptorSets::PushConstants), vtxPushConstants);
|
sizeof(OITDescriptorSets::PushConstants), vtxPushConstants);
|
||||||
|
|
|
@ -64,7 +64,7 @@ void main()
|
||||||
vtx_base1 *= vpos.z;
|
vtx_base1 *= vpos.z;
|
||||||
vtx_offs1 *= vpos.z;
|
vtx_offs1 *= vpos.z;
|
||||||
#endif
|
#endif
|
||||||
vtx_index = (uint(pushConstants.polyNumber) << 18) + uint(gl_VertexIndex);
|
vtx_index = uint(pushConstants.polyNumber) + uint(gl_VertexIndex);
|
||||||
vpos.w = 1.0;
|
vpos.w = 1.0;
|
||||||
vpos.z = 0.0;
|
vpos.z = 0.0;
|
||||||
gl_Position = vpos;
|
gl_Position = vpos;
|
||||||
|
@ -766,7 +766,7 @@ void main()
|
||||||
|
|
||||||
vpos = n2Uniform.projMat * vpos;
|
vpos = n2Uniform.projMat * vpos;
|
||||||
wDivide(vpos);
|
wDivide(vpos);
|
||||||
vtx_index = (uint(n2Uniform.polyNumber) << 18) + uint(gl_VertexIndex);
|
vtx_index = uint(n2Uniform.polyNumber) + uint(gl_VertexIndex);
|
||||||
|
|
||||||
gl_Position = vpos;
|
gl_Position = vpos;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue