MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / VertexKick

Method VertexKick

pcsx2/GS/GSState.cpp:5860–6117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5858
5859template <u32 prim, bool auto_flush>
5860__forceinline void GSState::VertexKick(u32 skip)
5861{
5862 constexpr u32 n = NumIndicesForPrim(prim);
5863 constexpr int primclass = GSUtil::GetPrimClass(prim);
5864 static_assert(n > 0);
5865
5866 pxAssert(m_vertex->tail < m_vertex->maxcount + 3);
5867
5868 if constexpr (prim == GS_INVALID)
5869 {
5870 m_vertex->tail = m_vertex->head;
5871 return;
5872 }
5873
5874 if (CheckOverlapVerts(n))
5875 Flush(CONTEXTCHANGE);
5876
5877 if (auto_flush && skip == 0 && m_index->tail > 0 && ((m_vertex->tail + 1) - m_vertex->head) >= n)
5878 {
5879 HandleAutoFlush<prim>();
5880 }
5881
5882 u32 head = m_vertex->head;
5883 u32 tail = m_vertex->tail;
5884 u32 next = m_vertex->next;
5885 u32 xy_tail = m_vertex->xy_tail;
5886
5887 if (GSIsHardwareRenderer() && GSLocalMemory::m_psm[m_context->ZBUF.PSM].bpp == 32)
5888 {
5889 if (GSConfig.UserHacks_Limit24BitDepth == GSLimit24BitDepth::PrioritizeUpper)
5890 m_v.XYZ.Z = ((m_v.XYZ.Z >> 8) & ~0xFF) | (m_v.XYZ.Z & 0xFF);
5891 else if (GSConfig.UserHacks_Limit24BitDepth == GSLimit24BitDepth::PrioritizeLower)
5892 m_v.XYZ.Z &= 0x00FFFFFF;
5893 }
5894
5895 // callers should write XYZUVF to m_v.m[1] in one piece to have this load store-forwarded, either by the cpu or the compiler when this function is inlined
5896
5897 const GSVector4i new_v0(m_v.m[0]);
5898 const GSVector4i new_v1(m_v.m[1]);
5899
5900 GSVector4i* RESTRICT tailptr = (GSVector4i*)&m_vertex->buff[tail];
5901
5902 tailptr[0] = new_v0;
5903 tailptr[1] = new_v1;
5904
5905 // We maintain the X/Y coordinates for the last 4 vertices, as well as the head for triangle fans, so we can compute
5906 // the min/max, and cull degenerate triangles, which saves draws in some cases. Why 4? Mod 4 is cheaper than Mod 3.
5907 const GSVector4i xy = new_v1.xxxx().u16to32().sub32(m_xyof);
5908 m_vertex->xy[xy_tail & 3] = xy;
5909
5910 // Backup head for triangle fans so we can read it later, otherwise it'll get lost after the 4th vertex.
5911 if (prim == GS_TRIANGLEFAN && tail == head)
5912 m_vertex->xyhead = xy;
5913
5914 m_vertex->tail = ++tail;
5915 m_vertex->xy_tail = ++xy_tail;
5916
5917 const u32 m = tail - head;

Callers

nothing calls this directly

Calls 5

NumIndicesForPrimFunction · 0.85
GSIsHardwareRendererFunction · 0.85
MaxVerticesForPrimFunction · 0.85
GSVector4iClass · 0.70
FlushFunction · 0.50

Tested by

no test coverage detected