-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do some D3D12 descriptor set setup work
- Loading branch information
1 parent
28838ae
commit d698c5b
Showing
9 changed files
with
144 additions
and
76 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
2 changes: 2 additions & 0 deletions
2
Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset.cpp
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,2 @@ | ||
#include "descriptorset_functions.h" | ||
#include "descriptorset_structs.h" |
12 changes: 12 additions & 0 deletions
12
Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_functions.h
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,12 @@ | ||
#ifndef KOPE_D3D12_DESCRIPTORSET_FUNCTIONS_HEADER | ||
#define KOPE_D3D12_DESCRIPTORSET_FUNCTIONS_HEADER | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
21 changes: 21 additions & 0 deletions
21
Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_structs.h
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,21 @@ | ||
#ifndef KOPE_D3D12_DESCRIPTORSET_STRUCTS_HEADER | ||
#define KOPE_D3D12_DESCRIPTORSET_STRUCTS_HEADER | ||
|
||
#include "d3d12mini.h" | ||
|
||
#include <kope/util/offalloc/offalloc.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct kope_d3d12_descriptor_set { | ||
oa_allocation_t allocation; | ||
size_t descriptor_count; | ||
} kope_d3d12_descriptor_set; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
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 |
---|---|---|
@@ -1,75 +1,83 @@ | ||
// (C) Sebastian Aaltonen 2023 | ||
// MIT License (see file: LICENSE) | ||
// C99 conversion by Aarni Gratseff | ||
// https://github.com/aarni57/offalloc | ||
|
||
#ifndef OFFALLOC_H | ||
#define OFFALLOC_H | ||
|
||
#include "stdint.h" | ||
|
||
#define OA_NUM_TOP_BINS 32 | ||
#define OA_BINS_PER_LEAF 8 | ||
#define OA_NUM_LEAF_BINS OA_NUM_TOP_BINS * OA_BINS_PER_LEAF | ||
|
||
#define OA_NO_SPACE 0xffffffff | ||
|
||
typedef uint16_t oa_index_t; | ||
#define OA_INVALID_INDEX (oa_index_t)0xffff | ||
#define OA_UNUSED (oa_index_t)0xffff | ||
|
||
typedef struct oa_allocation_t { | ||
uint32_t offset; | ||
oa_index_t index; // internal: node index | ||
} oa_allocation_t; | ||
|
||
typedef struct ao_storage_report_t { | ||
uint32_t total_free_space; | ||
uint32_t largest_free_region; | ||
} oa_storage_report_t; | ||
|
||
typedef struct ao_region_t { | ||
uint32_t size; | ||
uint32_t count; | ||
} oa_region_t; | ||
|
||
typedef struct ao_storage_report_full_t { | ||
oa_region_t free_regions[OA_NUM_LEAF_BINS]; | ||
} oa_storage_report_full_t; | ||
|
||
typedef struct ao_node_t { | ||
uint32_t data_offset; | ||
uint32_t data_size; // 'used' flag stored as high bit | ||
oa_index_t bin_list_prev; | ||
oa_index_t bin_list_next; | ||
oa_index_t neighbor_prev; | ||
oa_index_t neighbor_next; | ||
} oa_node_t; | ||
|
||
typedef struct ao_allocator_t { | ||
uint32_t size; | ||
uint32_t max_allocs; | ||
uint32_t free_storage; | ||
|
||
uint32_t used_bins_top; | ||
uint8_t used_bins[OA_NUM_TOP_BINS]; | ||
oa_index_t bin_indices[OA_NUM_LEAF_BINS]; | ||
|
||
oa_node_t *nodes; | ||
oa_index_t *free_nodes; | ||
uint32_t free_offset; | ||
} oa_allocator_t; | ||
|
||
// | ||
|
||
int oa_create(oa_allocator_t *self, uint32_t size, uint32_t max_allocs); | ||
void oa_destroy(oa_allocator_t *self); | ||
|
||
int oa_allocate(oa_allocator_t *self, uint32_t size, oa_allocation_t *allocation); | ||
void oa_free(oa_allocator_t *self, oa_allocation_t *allocation); | ||
|
||
uint32_t oa_allocation_size(oa_allocator_t *self, const oa_allocation_t *allocation); | ||
void oa_storage_report(const oa_allocator_t *self, oa_storage_report_t *report); | ||
void oa_storage_report_full(const oa_allocator_t *self, oa_storage_report_full_t *report); | ||
|
||
#endif | ||
// (C) Sebastian Aaltonen 2023 | ||
// MIT License (see file: LICENSE) | ||
// C99 conversion by Aarni Gratseff | ||
// https://github.com/aarni57/offalloc | ||
|
||
#ifndef OFFALLOC_H | ||
#define OFFALLOC_H | ||
|
||
#include "stdint.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define OA_NUM_TOP_BINS 32 | ||
#define OA_BINS_PER_LEAF 8 | ||
#define OA_NUM_LEAF_BINS OA_NUM_TOP_BINS *OA_BINS_PER_LEAF | ||
|
||
#define OA_NO_SPACE 0xffffffff | ||
|
||
typedef uint16_t oa_index_t; | ||
#define OA_INVALID_INDEX (oa_index_t)0xffff | ||
#define OA_UNUSED (oa_index_t)0xffff | ||
|
||
typedef struct oa_allocation_t { | ||
uint32_t offset; | ||
oa_index_t index; // internal: node index | ||
} oa_allocation_t; | ||
|
||
typedef struct ao_storage_report_t { | ||
uint32_t total_free_space; | ||
uint32_t largest_free_region; | ||
} oa_storage_report_t; | ||
|
||
typedef struct ao_region_t { | ||
uint32_t size; | ||
uint32_t count; | ||
} oa_region_t; | ||
|
||
typedef struct ao_storage_report_full_t { | ||
oa_region_t free_regions[OA_NUM_LEAF_BINS]; | ||
} oa_storage_report_full_t; | ||
|
||
typedef struct ao_node_t { | ||
uint32_t data_offset; | ||
uint32_t data_size; // 'used' flag stored as high bit | ||
oa_index_t bin_list_prev; | ||
oa_index_t bin_list_next; | ||
oa_index_t neighbor_prev; | ||
oa_index_t neighbor_next; | ||
} oa_node_t; | ||
|
||
typedef struct ao_allocator_t { | ||
uint32_t size; | ||
uint32_t max_allocs; | ||
uint32_t free_storage; | ||
|
||
uint32_t used_bins_top; | ||
uint8_t used_bins[OA_NUM_TOP_BINS]; | ||
oa_index_t bin_indices[OA_NUM_LEAF_BINS]; | ||
|
||
oa_node_t *nodes; | ||
oa_index_t *free_nodes; | ||
uint32_t free_offset; | ||
} oa_allocator_t; | ||
|
||
// | ||
|
||
int oa_create(oa_allocator_t *self, uint32_t size, uint32_t max_allocs); | ||
void oa_destroy(oa_allocator_t *self); | ||
|
||
int oa_allocate(oa_allocator_t *self, uint32_t size, oa_allocation_t *allocation); | ||
void oa_free(oa_allocator_t *self, oa_allocation_t *allocation); | ||
|
||
uint32_t oa_allocation_size(oa_allocator_t *self, const oa_allocation_t *allocation); | ||
void oa_storage_report(const oa_allocator_t *self, oa_storage_report_t *report); | ||
void oa_storage_report_full(const oa_allocator_t *self, oa_storage_report_full_t *report); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
#include "indexallocator.c" | ||
#include "indexallocator.c" | ||
#include "offalloc/offalloc.c" |