Skip to content

Commit

Permalink
vk: begin resource management effort
Browse files Browse the repository at this point in the history
- rename ray_resources to vk_resources
- add agenda and notes
  • Loading branch information
w23 committed May 7, 2024
1 parent f5eb2da commit 0e84265
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 11 deletions.
17 changes: 17 additions & 0 deletions ref/vk/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1160,3 +1160,20 @@ Pro: no special code for shaders/model passing.
Cons: ridiculous texture explosion

5. Hand-patch things that look weird. E.g. for known sprite/beam textures specify how their alphas should be mapped.


# 2024-05-07 E376
## Resource tables
### Types
- `rt_resource_t` [vk_rtx.c]:
- name, `vk_resource_t`, image, refcount, source_index_plus_1
- `vk_resource_t`/`vk_resource_s`/`*vk_resource_p` [ray_resources.h]:
- desc `type`, state `read/write`, desc `value`

### Variables
- `g_rtx.res[]` -- `rt_resource_t`[`MAX_RESOURCES`=32]
- `findResource(name)` / `findResourceOrEmptySlot(name)`
- access by builtin index names like `g_rtx.res[ExternalResource_...]` for both read and write
- `performTracing()` write resource desc values passed from outside on each call
- new resources are added in `reloadMainpipe()`
- resource with zero refcount are destroyed in `cleanupResources()`
6 changes: 6 additions & 0 deletions ref/vk/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
- [ ] Render graph
- [ ] performance profiling and comparison

## 2024-05-07 E376
- [ ] resource manager
- [ ] extract all resource mgmt from vk_rtx into a designated file
- [ ] register all resources in their modules
- [ ] massage resource state tracking (read-write vs write-current; `value` field consistency, etc)

## 2024-04-12 E374
- [x] ~~`-vknort` arg to force-disable RT at init time~~ -- reverted on 2024-04-29

Expand Down
2 changes: 1 addition & 1 deletion ref/vk/ray_pass.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ray_pass.h"
#include "shaders/ray_interop.h" // for SPEC_SBT_RECORD_SIZE_INDEX
#include "ray_resources.h"
#include "vk_resources.h"
#include "vk_pipeline.h"
#include "vk_descriptor.h"
#include "vk_combuf.h"
Expand Down
1 change: 0 additions & 1 deletion ref/vk/vk_meatpipe.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "vk_meatpipe.h"

#include "vk_pipeline.h"
#include "ray_resources.h"

#include "ray_pass.h"
#include "vk_common.h"
Expand Down
5 changes: 1 addition & 4 deletions ref/vk/vk_ray_accel.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#pragma once

#include "vk_core.h"
#include "vk_buffer.h"
#include "vk_math.h"
#include "ray_resources.h"
#include "vk_resources.h"

qboolean RT_VkAccelInit(void);
void RT_VkAccelShutdown(void);
Expand Down
2 changes: 1 addition & 1 deletion ref/vk/ray_resources.c → ref/vk/vk_resources.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ray_resources.h"
#include "vk_resources.h"
#include "vk_core.h"
#include "vk_image.h"
#include "vk_common.h"
Expand Down
2 changes: 0 additions & 2 deletions ref/vk/ray_resources.h → ref/vk/vk_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ typedef struct {
} vk_resources_write_descriptors_args_t;

void R_VkResourcesPrepareDescriptorsValues(VkCommandBuffer cmdbuf, vk_resources_write_descriptors_args_t args);


6 changes: 4 additions & 2 deletions ref/vk/vk_rtx.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "vk_rtx.h"

#include "ray_resources.h"
#include "vk_resources.h"
#include "vk_ray_accel.h"

#include "vk_buffer.h"
Expand Down Expand Up @@ -31,7 +31,7 @@
#define MIN_FRAME_WIDTH 1280
#define MIN_FRAME_HEIGHT 800

// TODO each of these should be registered by the provider of the resource:
// TODO each of these should be registered by the provider of the resource:
#define EXTERNAL_RESOUCES(X) \
X(TLAS, tlas) \
X(Buffer, ubo) \
Expand Down Expand Up @@ -69,7 +69,9 @@ static struct {

// TODO with proper intra-cmdbuf sync we don't really need 2x images
unsigned frame_number;

vk_meatpipe_t *mainpipe;

vk_resource_p *mainpipe_resources;
rt_resource_t *mainpipe_out;

Expand Down

0 comments on commit 0e84265

Please sign in to comment.