int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bool skip_drawing, bool is_preprocess) { if (!count) return 0; VertexLoaderBase* loader = RefreshLoader(vtx_attr_group, is_preprocess); int size = count * loader->m_VertexSize; if ((int)src.size() < size) return -1; if (skip_drawing || is_preprocess) return size; // If the native vertex format changed, force a flush. if (loader->m_native_vertex_format != s_current_vtx_fmt || loader->m_native_components != g_current_components) { VertexManagerBase::Flush(); } s_current_vtx_fmt = loader->m_native_vertex_format; g_current_components = loader->m_native_components; // if cull mode is CULL_ALL, tell VertexManager to skip triangles and quads. // They still need to go through vertex loading, because we need to calculate a zfreeze refrence // slope. bool cullall = (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5); DataReader dst = VertexManagerBase::PrepareForAdditionalData( primitive, count, loader->m_native_vtx_decl.stride, cullall); count = loader->RunVertices(src, dst, count); IndexGenerator::AddIndices(primitive, count); VertexManagerBase::FlushData(count, loader->m_native_vtx_decl.stride); ADDSTAT(stats.thisFrame.numPrims, count); INCSTAT(stats.thisFrame.numPrimitiveJoins); return size; }
bool RunVertices(int vtx_attr_group, int primitive, int count, size_t buf_size, bool skip_drawing) { if (!count) return true; CPState* state = &g_main_cp_state; VertexLoader* loader = RefreshLoader(vtx_attr_group, state); size_t size = count * loader->GetVertexSize(); if (buf_size < size) return false; if (skip_drawing || (bpmem.genMode.cullmode == GenMode::CULL_ALL && primitive < 5)) { // if cull mode is CULL_ALL, ignore triangles and quads DataSkip((u32)size); return true; } NativeVertexFormat* native = loader->GetNativeVertexFormat(); // If the native vertex format changed, force a flush. if (native != s_current_vtx_fmt) VertexManager::Flush(); s_current_vtx_fmt = native; VertexManager::PrepareForAdditionalData(primitive, count, loader->GetNativeVertexDeclaration().stride); loader->RunVertices(state->vtx_attr[vtx_attr_group], primitive, count); IndexGenerator::AddIndices(primitive, count); ADDSTAT(stats.thisFrame.numPrims, count); INCSTAT(stats.thisFrame.numPrimitiveJoins); return true; }
int GetVertexSize(int vtx_attr_group, bool preprocess) { return RefreshLoader(vtx_attr_group, preprocess ? &g_preprocess_cp_state : &g_main_cp_state)->GetVertexSize(); }