Page MenuHome

DRAW Cache: sanitize 'DRW_mesh_batch_cache_dirty_tag'
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Jun 12 2021, 5:02 AM.

Details

Summary

DRW_mesh_batch_cache_dirty_tag relies heavily on the developer to check
all references between batch and buffer in order to discard batches along
with buffers.

This is not safe and makes it difficult to create new tags.

This patch proposes the creation of a series of macros that ensure that
the references between buffer and batch are computed.

These macros create uint32_t maps in the global scope that can be used
to identify batches that have references to the removed buffers in
DRW_mesh_batch_cache_dirty_tag.

To avoid errors, the developer just needs to ensure that MDEPS_ASSERT
and MDEPS_ASSERT_MAP point to the correct variables.
(And correct in case of failures).

Diff Detail

Repository
rB Blender

Event Timeline

Germano Cavalcante (mano-wii) requested review of this revision.Jun 12 2021, 5:02 AM
Germano Cavalcante (mano-wii) created this revision.

Cleanup: Simplify macros

I have no objections adding this. But would like to have feedback from fclem.

  • Fix wrong use of GPU_BATCH_CLEAR_SAFE
  • Cleanup: use DRWBatchFlag type

Dirty but better than nothing.

source/blender/draw/intern/draw_cache_extract.h
230–231

Replace by uint32_t.

270–297

for all of these use 1u.

298

For sanity purpose, you could add a static assert that max value is not overflowing the 32bit uint type. Or maybe at least a comment saying to bump the type to a 64bit one.

This revision is now accepted and ready to land.Jun 15 2021, 8:09 PM
This revision was automatically updated to reflect the committed changes.
Germano Cavalcante (mano-wii) marked 3 inline comments as done.