Skip to content

Commit

Permalink
Collect descriptor set accesses
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Oct 25, 2024
1 parent ee4f87d commit 2154ec4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,8 @@ void kope_d3d12_command_list_queue_buffer_access(kope_g5_command_list *list, kop
list->d3d12.queued_buffer_accesses[list->d3d12.queued_buffer_accesses_count] = access;
list->d3d12.queued_buffer_accesses_count += 1;
}

void kope_d3d12_command_list_queue_descriptor_set_access(kope_g5_command_list *list, kope_d3d12_descriptor_set *descriptor_set) {
list->d3d12.queued_descriptor_set_accesses[list->d3d12.queued_descriptor_set_accesses_count] = descriptor_set;
list->d3d12.queued_descriptor_set_accesses_count += 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ void kope_d3d12_command_list_compute_indirect(kope_g5_command_list *list, kope_g

void kope_d3d12_command_list_queue_buffer_access(kope_g5_command_list *list, kope_g5_buffer *buffer, uint32_t offset, uint32_t size);

void kope_d3d12_command_list_queue_descriptor_set_access(kope_g5_command_list *list, kope_d3d12_descriptor_set *descriptor_set);

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct kope_d3d12_texture;
struct kope_d3d12_compute_pipeline;
struct kope_d3d12_ray_pipeline;
struct kope_d3d12_rendery_pipeline;
struct kope_d3d12_descriptor_set;
struct kope_g5_query_set;

struct ID3D12Fence;
Expand All @@ -26,6 +27,8 @@ struct ID3D12Fence;

#define KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_BUFFER_ACCESSES 256

#define KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_DESCRIPTOR_SET_ACCESSES 256

typedef struct kope_d3d12_buffer_access {
kope_g5_buffer *buffer;
uint64_t offset;
Expand Down Expand Up @@ -68,6 +71,9 @@ typedef struct kope_d3d12_command_list {
kope_d3d12_buffer_access queued_buffer_accesses[KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_BUFFER_ACCESSES];
uint32_t queued_buffer_accesses_count;

struct kope_d3d12_descriptor_set *queued_descriptor_set_accesses[KOPE_D3D12_COMMAND_LIST_MAX_QUEUED_DESCRIPTOR_SET_ACCESSES];
uint32_t queued_descriptor_set_accesses_count;

bool presenting;
} kope_d3d12_command_list;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ typedef struct kope_d3d12_descriptor_set {

oa_allocation_t sampler_allocation;
size_t sampler_count;

uint64_t execution_index;
} kope_d3d12_descriptor_set;

#ifdef __cplusplus
Expand Down
11 changes: 11 additions & 0 deletions Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ void kope_d3d12_device_create_command_list(kope_g5_device *device, kope_g5_comma

list->d3d12.queued_buffer_accesses_count = 0;

list->d3d12.queued_descriptor_set_accesses_count = 0;

list->d3d12.presenting = false;

ID3D12DescriptorHeap *heaps[] = {list->d3d12.device->descriptor_heap, list->d3d12.device->sampler_heap};
Expand Down Expand Up @@ -595,6 +597,13 @@ void kope_d3d12_device_execute_command_list(kope_g5_device *device, kope_g5_comm
}
list->d3d12.queued_buffer_accesses_count = 0;

for (uint32_t set_access_index = 0; set_access_index < list->d3d12.queued_descriptor_set_accesses_count; ++set_access_index) {
kope_d3d12_descriptor_set *set = list->d3d12.queued_descriptor_set_accesses[set_access_index];

set->execution_index = device->d3d12.execution_index;
}
list->d3d12.queued_descriptor_set_accesses_count = 0;

list->d3d12.allocator_execution_index[list->d3d12.current_allocator_index] = device->d3d12.execution_index;

ID3D12CommandList *lists[] = {list->d3d12.list};
Expand Down Expand Up @@ -654,6 +663,8 @@ void kope_d3d12_device_create_descriptor_set(kope_g5_device *device, uint32_t de
oa_allocate(&device->d3d12.sampler_heap_allocator, sampler_count, &set->sampler_allocation);
}
set->sampler_count = sampler_count;

set->execution_index = 0;
}

static D3D12_TEXTURE_ADDRESS_MODE convert_address_mode(kope_g5_address_mode mode) {
Expand Down

0 comments on commit 2154ec4

Please sign in to comment.