forked from FWGS/xash3d-fwgs
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #742 from w23/stream-E379-staging
Implements new totally automatic barrier placement. Also, staging is refactored. - [x] image staging - [x] some images are corrupted - ~~[ ] #745~~ -- postponed until next time we'd need to touch images; current code works good enough for now. - [x] use combuf auto barriers everywhere where it makes sense - [x] corrupted geometry in playdemo ... - [x] buffer staging - [x] #743 - [x] track copied staging regions: i.e. staging must know that it has been drained fully - [x] RT-trad dynamic toggle - [x] push-pull staging boundary - [x] frame dependency tracking: automatically free/flip buffers when frame using them is done - [x] replace ALL barriers with combuf ones - [x] buffers in rtx/resources - [x] images - [x] track images sync state inline where possible - [x] find other uses - [x] improve staging - [x] track staging users explicitly - [x] per-user stats: sizes, allocations, etc - [x] push remaining data for stale users - [x] use ring buffer directly, track frame boundaries externally in fctl - [x] crash in `buildBlases()`: 1. load map with rt disabled 2. change to another map 3. enable rt 4. 💥 - [x] suboptimal barrier, see comment #742 (comment) - [x] simplify creating and building TLAS - [x] Run rendering tests - [x] missing emissive toxic waters - Leave as a known problem: it's due to inadvertently skipping some water surfaces when looking for emissive ones, see: - #56 - #752 - [x] slightly different indirect blur - Assuming that this is due to Á-Trous filtering, which could've sneaked through before the gold images were set. Not going to investigate, as we're about to submit a big change to the denoiser.
- Loading branch information
Showing
55 changed files
with
2,217 additions
and
1,671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "arrays.h" | ||
|
||
#include "vk_core.h" // Mem_Malloc | ||
|
||
#include <stddef.h> // NULL | ||
|
||
|
||
void arrayDynamicInit(array_dynamic_t *array, int item_size) { | ||
array->items = NULL; | ||
array->count = 0; | ||
array->capacity = 0; | ||
array->item_size = item_size; | ||
} | ||
|
||
void arrayDynamicDestroy(array_dynamic_t *array) { | ||
if (array->items) | ||
Mem_Free(array->items); | ||
} | ||
|
||
static void arrayDynamicEnsureCapacity(array_dynamic_t *array, int min_capacity) { | ||
if (array->capacity >= min_capacity) | ||
return; | ||
|
||
if (array->capacity == 0) | ||
array->capacity = 2; | ||
|
||
while (array->capacity < min_capacity) | ||
array->capacity = array->capacity * 3 / 2; | ||
|
||
void *new_buffer = Mem_Malloc(vk_core.pool, array->capacity * array->item_size); | ||
if (array->items) { | ||
memcpy(new_buffer, array->items, array->count * array->item_size); | ||
Mem_Free(array->items); | ||
} | ||
array->items = new_buffer; | ||
} | ||
|
||
void arrayDynamicResize(array_dynamic_t *array, int count) { | ||
arrayDynamicEnsureCapacity(array, count); | ||
array->count = count; | ||
} | ||
|
||
void arrayDynamicAppend(array_dynamic_t *array, void *item) { | ||
const int new_count = array->count + 1; | ||
arrayDynamicEnsureCapacity(array, new_count); | ||
|
||
if (item) | ||
memcpy((char*)array->items + array->count * array->item_size, item, array->item_size); | ||
|
||
array->count = new_count; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#pragma once | ||
|
||
#include <stddef.h> // size_t | ||
|
||
#define VIEW_DECLARE_CONST(TYPE, NAME) \ | ||
struct { \ | ||
const TYPE *items; \ | ||
int count; \ | ||
} NAME | ||
|
||
// Array with compile-time maximum size | ||
#define BOUNDED_ARRAY_DECLARE(TYPE, NAME, MAX_SIZE) \ | ||
struct { \ | ||
TYPE items[MAX_SIZE]; \ | ||
int count; \ | ||
} NAME | ||
|
||
#define BOUNDED_ARRAY(TYPE, NAME, MAX_SIZE) \ | ||
BOUNDED_ARRAY_DECLARE(TYPE, NAME, MAX_SIZE) = {0} | ||
|
||
#define BOUNDED_ARRAY_HAS_SPACE(array_, space_) \ | ||
((COUNTOF((array_).items) - (array_).count) >= space_) | ||
|
||
#define BOUNDED_ARRAY_APPEND_UNSAFE(array_) \ | ||
((array_).items[(array_).count++]) | ||
|
||
#define BOUNDED_ARRAY_APPEND_ITEM(var, item) \ | ||
do { \ | ||
ASSERT(BOUNDED_ARRAY_HAS_SPACE(var, 1)); \ | ||
var.items[var.count++] = item; \ | ||
} while(0) | ||
|
||
|
||
// Dynamically-sized array | ||
// I. Type-agnostic | ||
|
||
typedef struct array_dynamic_s { | ||
void *items; | ||
size_t count, capacity; | ||
size_t item_size; | ||
} array_dynamic_t; | ||
|
||
void arrayDynamicInit(array_dynamic_t *array, int item_size); | ||
void arrayDynamicDestroy(array_dynamic_t *array); | ||
|
||
void arrayDynamicReserve(array_dynamic_t *array, int capacity); | ||
void arrayDynamicAppend(array_dynamic_t *array, void *item); | ||
#define arrayDynamicAppendItem(array, item) \ | ||
do { \ | ||
ASSERT((array)->item_size == sizeof(&(item))); \ | ||
arrayDynamicAppend(array, item); \ | ||
} while (0) | ||
/* void *arrayDynamicGet(array_dynamic_t *array, int index); */ | ||
/* #define arrayDynamicAt(array, type, index) \ */ | ||
/* (ASSERT((array)->item_size == sizeof(type)), \ */ | ||
/* ASSERT((array)->count > (index)), \ */ | ||
/* arrayDynamicGet(array, index)) */ | ||
void arrayDynamicResize(array_dynamic_t *array, int count); | ||
//void arrayDynamicErase(array_dynamic_t *array, int begin, int end); | ||
|
||
//void arrayDynamicInsert(array_dynamic_t *array, int before, int count, void *items); | ||
|
||
// II. Type-specific | ||
#define ARRAY_DYNAMIC_DECLARE(TYPE, NAME) \ | ||
struct { \ | ||
TYPE *items; \ | ||
size_t count, capacity; \ | ||
size_t item_size; \ | ||
} NAME | ||
|
||
#define arrayDynamicInitT(array) \ | ||
arrayDynamicInit((array_dynamic_t*)array, sizeof((array)->items[0])) | ||
|
||
#define arrayDynamicDestroyT(array) \ | ||
arrayDynamicDestroy((array_dynamic_t*)array) | ||
|
||
#define arrayDynamicResizeT(array, size) \ | ||
arrayDynamicResize((array_dynamic_t*)(array), (size)) | ||
|
||
#define arrayDynamicAppendT(array, item) \ | ||
arrayDynamicAppend((array_dynamic_t*)(array), (item)) | ||
|
||
#define arrayDynamicInsertT(array, before, count, items) \ | ||
arrayDynamicInsert((array_dynamic_t*)(array), before, count, items) | ||
|
||
#define arrayDynamicAppendManyT(array, items_count, items) \ | ||
arrayDynamicInsert((array_dynamic_t*)(array), (array)->count, items_count, items) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.