Compare commits

...

2 Commits

Author SHA1 Message Date
bjorn 4719dbdd10 Fix crash with timestamp readback; 2024-03-07 10:26:35 -08:00
bjorn 9068c8daee rm map_remove;
It's no longer used.
2024-03-07 10:13:00 -08:00
3 changed files with 7 additions and 32 deletions

View File

@ -1721,10 +1721,12 @@ void lovrGraphicsSubmit(Pass** passes, uint32_t count) {
gpu_stream* stream = streams[streamCount++] = gpu_stream_begin(NULL);
// Timestamp Readback
BufferView view = getBuffer(GPU_BUFFER_DOWNLOAD, 2 * count * sizeof(uint32_t), 4);
gpu_copy_tally_buffer(stream, state.timestamps, view.buffer, 0, view.offset, 2 * count);
Readback* readback = lovrReadbackCreateTimestamp(times, count, view);
lovrRelease(readback, lovrReadbackDestroy); // It gets freed when it completes
if (state.timingEnabled) {
BufferView view = getBuffer(GPU_BUFFER_DOWNLOAD, 2 * count * sizeof(uint32_t), 4);
gpu_copy_tally_buffer(stream, state.timestamps, view.buffer, 0, view.offset, 2 * count);
Readback* readback = lovrReadbackCreateTimestamp(times, count, view);
lovrRelease(readback, lovrReadbackDestroy); // It gets freed when it completes
}
// OpenXR Swapchain Layout Transitions
for (uint32_t i = 0; i < count; i++) {

View File

@ -129,32 +129,6 @@ void map_set(map_t* map, uint64_t hash, uint64_t value) {
map->values[h] = value;
}
void map_remove(map_t* map, uint64_t hash) {
uint64_t h = map_find(map, hash);
if (map->hashes[h] == MAP_NIL) {
return;
}
uint64_t mask = map->size - 1;
uint64_t i = h;
do {
i = (i + 1) & mask;
uint64_t x = map->hashes[i] & mask;
// Removing a key from an open-addressed hash table is complicated
if ((i > h && (x <= h || x > i)) || (i < h && (x <= h && x > i))) {
map->hashes[h] = map->hashes[i];
map->values[h] = map->values[i];
h = i;
}
} while (map->hashes[i] != MAP_NIL);
map->hashes[i] = MAP_NIL;
map->values[i] = MAP_NIL;
map->used--;
}
// UTF-8
// https://github.com/starwing/luautf8
size_t utf8_decode(const char *s, const char *e, unsigned *pch) {

View File

@ -89,7 +89,7 @@ static inline void _arr_reserve(void** data, size_t n, size_t* capacity, size_t
lovrAssert(*data, "Out of memory");
}
// Hashmap
// Hashmap (does not support removal)
typedef struct {
uint64_t* hashes;
uint64_t* values;
@ -103,7 +103,6 @@ void map_init(map_t* map, uint32_t n);
void map_free(map_t* map);
uint64_t map_get(map_t* map, uint64_t hash);
void map_set(map_t* map, uint64_t hash, uint64_t value);
void map_remove(map_t* map, uint64_t hash);
// UTF-8
size_t utf8_decode(const char *s, const char *e, unsigned *pch);