MCPcopy Create free account
hub / github.com/defold/defold / FrustumCulling

Function FrustumCulling

engine/render/src/render/render.cpp:755–808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753 }
754
755 static void FrustumCulling(HRenderContext context, const dmIntersection::Frustum& frustum, uint32_t frustum_hash)
756 {
757 DM_PROFILE("FrustumCulling");
758
759 uint32_t num_entries = context->m_RenderList.Size();
760 if (num_entries == 0)
761 return;
762
763 BatchIterator<RenderListEntry*> iter(num_entries, context->m_RenderList.Begin(), RenderListEntryEqFn);
764 while(iter.Next())
765 {
766 RenderListEntry* batch_start = iter.Begin();
767 uint32_t batch_length = iter.Length();
768
769 const RenderListDispatch* d = &context->m_RenderListDispatch[batch_start->m_Dispatch];
770 if (!d->m_VisibilityFn)
771 {
772 SetVisibility(batch_length, batch_start, dmRender::VISIBILITY_FULL, FRUSTUM_HASH_UNINITIALIZED);
773 }
774 else
775 {
776 RenderListVisibilityParams params;
777 params.m_Frustum = &frustum;
778 params.m_UserData = d->m_UserData;
779
780 uint32_t i =0;
781 while(i < batch_length)
782 {
783 // Skip over already calculated entries
784 while(i < batch_length && batch_start[i].m_FrustumHash == frustum_hash)
785 {
786 i++;
787 }
788
789 // Calculate start/end of entries to calculate culling for
790 uint32_t sub_batch_start = i;
791 while(i < batch_length && batch_start[i].m_FrustumHash != frustum_hash)
792 {
793 // Update hash here since we are already looping over the entries
794 batch_start[i].m_FrustumHash = frustum_hash;
795 i++;
796 }
797
798 // Execute culling for this sub-batch if > 0
799 params.m_Entries = batch_start + sub_batch_start;
800 params.m_NumEntries = i - sub_batch_start;
801 if (params.m_NumEntries > 0)
802 {
803 d->m_VisibilityFn(params);
804 }
805 }
806 }
807 }
808 }
809
810 void SetTextureBindingByHash(dmRender::HRenderContext render_context, dmhash_t sampler_hash, dmGraphics::HTexture texture)
811 {

Callers 1

DrawRenderListFunction · 0.85

Calls 5

SetVisibilityFunction · 0.85
SizeMethod · 0.45
BeginMethod · 0.45
NextMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected