Skip to content

Commit

Permalink
Implement query-set creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 29, 2024
1 parent 6a989b9 commit eef34d5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,15 @@ void kope_d3d12_device_create_raytracing_hierarchy(kope_g5_device *device, kope_
kope_g5_device_create_buffer(device, &as_params, &hierarchy->d3d12.acceleration_structure);
}

void kope_d3d12_device_create_query_set(kope_g5_device *device, const kope_g5_query_set_parameters *parameters, kope_g5_query_set *query_set) {
D3D12_QUERY_HEAP_DESC desc = {};
desc.Type = parameters->type == KOPE_G5_QUERY_TYPE_OCCLUSION ? D3D12_QUERY_HEAP_TYPE_OCCLUSION : D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
desc.Count = parameters->count;
desc.NodeMask = 0;

device->d3d12.device->CreateQueryHeap(&desc, IID_GRAPHICS_PPV_ARGS(&query_set->d3d12.query_heap));
}

uint32_t kope_d3d12_device_align_texture_row_bytes(kope_g5_device *device, uint32_t row_bytes) {
return (uint32_t)align_pow2((int)row_bytes, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void kope_d3d12_device_create_raytracing_volume(kope_g5_device *device, kope_g5_
void kope_d3d12_device_create_raytracing_hierarchy(kope_g5_device *device, kope_g5_raytracing_volume **volumes, kinc_matrix4x4_t *volume_transforms,
uint32_t volumes_count, kope_g5_raytracing_hierarchy *hierarchy);

void kope_d3d12_device_create_query_set(kope_g5_device *device, const kope_g5_query_set_parameters *parameters, kope_g5_query_set *query_set);

uint32_t kope_d3d12_device_align_texture_row_bytes(kope_g5_device *device, uint32_t row_bytes);

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C" {

struct ID3D12CommandAllocator;
struct ID3D12DescriptorHeap;
struct ID3D12QueryHeap;

#define KOPE_D3D12_FRAME_COUNT 2

Expand Down Expand Up @@ -48,6 +49,10 @@ typedef struct kope_d3d12_device {
kope_g5_command_list management_list;
} kope_d3d12_device;

typedef struct kope_d3d12_query_set {
struct ID3D12QueryHeap *query_heap;
} kope_d3d12_query_set;

typedef struct kope_d3d12_raytracing_volume {
kope_g5_buffer *vertex_buffer;
uint64_t vertex_count;
Expand Down
4 changes: 4 additions & 0 deletions Sources/kope/graphics5/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ kope_g5_texture *kope_g5_device_get_framebuffer(kope_g5_device *device) {
return KOPE_G5_CALL1(device_get_framebuffer, device);
}

void kope_g5_device_create_query_set(kope_g5_device *device, const kope_g5_query_set_parameters *parameters, kope_g5_query_set *query_set) {
KOPE_G5_CALL3(device_create_query_set, device, parameters, query_set);
}

void kope_g5_device_execute_command_list(kope_g5_device *device, kope_g5_command_list *list) {
KOPE_G5_CALL2(device_execute_command_list, device, list);
}
Expand Down
13 changes: 12 additions & 1 deletion Sources/kope/graphics5/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ KOPE_FUNC void kope_g5_device_create_sampler(kope_g5_device *device, const kope_

KOPE_FUNC void kope_g5_device_create_command_list(kope_g5_device *device, kope_g5_command_list *list);

KOPE_FUNC void kope_g5_device_create_query_set(void *descriptor);
typedef struct kope_g5_query_set {
KOPE_G5_IMPL(query_set);
} kope_g5_query_set;

typedef enum kope_g5_query_type { KOPE_G5_QUERY_TYPE_OCCLUSION, KOPE_G5_QUERY_TYPE_TIMESTAMP } kope_g5_query_type;

typedef struct kope_g5_query_set_parameters {
kope_g5_query_type type;
uint32_t count;
} kope_g5_query_set_parameters;

KOPE_FUNC void kope_g5_device_create_query_set(kope_g5_device *device, const kope_g5_query_set_parameters *parameters, kope_g5_query_set *query_set);

KOPE_FUNC void kope_g5_device_execute_command_list(kope_g5_device *device, kope_g5_command_list *list);

Expand Down

0 comments on commit eef34d5

Please sign in to comment.