2D: Switch to VBOs for instance data

- Add support for vertex bindings and UMA vertex buffers in D3D12.
- Simplify 2D instance params and move more into per-batch data to save
  bandwidth

Co-authored-by: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com>
Co-authored-by: Clay John <claynjohn@gmail.com>
Co-authored-by: A Thousand Ships <96648715+athousandships@users.noreply.github.com>
This commit is contained in:
Stuart Carnie 2025-11-07 05:50:02 +11:00
parent bad1287b62
commit 90c0e6acca
25 changed files with 893 additions and 256 deletions

View file

@ -71,6 +71,7 @@ public:
static constexpr uint32_t MIN_CAPACITY_INDEX = 2; // Use a prime.
static constexpr float MAX_OCCUPANCY = 0.75;
static constexpr uint32_t EMPTY_HASH = 0;
using KV = KeyValue<TKey, TValue>; // Type alias for easier access to KeyValue.
private:
HashMapElement<TKey, TValue> **_elements = nullptr;
@ -590,6 +591,22 @@ public:
}
}
HashMap(HashMap &&p_other) {
_elements = p_other._elements;
_hashes = p_other._hashes;
_head_element = p_other._head_element;
_tail_element = p_other._tail_element;
_capacity_idx = p_other._capacity_idx;
_size = p_other._size;
p_other._elements = nullptr;
p_other._hashes = nullptr;
p_other._head_element = nullptr;
p_other._tail_element = nullptr;
p_other._capacity_idx = MIN_CAPACITY_INDEX;
p_other._size = 0;
}
void operator=(const HashMap &p_other) {
if (this == &p_other) {
return; // Ignore self assignment.
@ -609,6 +626,36 @@ public:
}
}
HashMap &operator=(HashMap &&p_other) {
if (this == &p_other) {
return *this;
}
if (_size != 0) {
clear();
}
if (_elements != nullptr) {
Memory::free_static(_elements);
Memory::free_static(_hashes);
}
_elements = p_other._elements;
_hashes = p_other._hashes;
_head_element = p_other._head_element;
_tail_element = p_other._tail_element;
_capacity_idx = p_other._capacity_idx;
_size = p_other._size;
p_other._elements = nullptr;
p_other._hashes = nullptr;
p_other._head_element = nullptr;
p_other._tail_element = nullptr;
p_other._capacity_idx = MIN_CAPACITY_INDEX;
p_other._size = 0;
return *this;
}
HashMap(uint32_t p_initial_capacity) {
// Capacity can't be 0.
_capacity_idx = 0;