blob: 2838f20a75a460b017fecb979c4c71e0713bbad0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <stdlib.h>
#include "ral.h"
#include "types.h"
#include "render_types.h"
#define VULKAN_QUEUES_COUNT 2
const char* queue_names[VULKAN_QUEUES_COUNT] = {
"GRAPHICS", "TRANSFER"
};
typedef struct vulkan_context {
gpu_device device;
VkInstance instance;
} vulkan_context;
static vulkan_context context;
static bool select_physical_device(gpu_device* out_device) {}
bool gpu_device_create(gpu_device* out_device) {
// Physical device
if (!select_physical_device(out_device)) {
return false;
}
INFO("Physical device selected");
// Logical device
VkDeviceQueueCreateInfo queue_create_info[2];
//..
VkDeviceCreateInfo device_create_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
VkResult result = vkCreateDevice();
if (result != VK_SUCCESS) {
FATAL("Error creating logical device with status %u\n", result);
exit(1);
}
INFO("Logical device created");
// Queues
// Create the command pool
}
gpu_renderpass* gpu_renderpass_create() {
// Allocate it
// sets everything up
// return pointer to it
}
void encode_set_pipeline(gpu_cmd_encoder* encoder, pipeline_type kind, gpu_pipeline* pipeline) {
// VK_PIPELINE_BIND_POINT_GRAPHICS, &shader->pipeline);
if (kind== PIPELINE_GRAPHICS) {
// ...
} else {
// ...
}
}
// --- Drawing
inline void encode_draw_indexed(gpu_cmd_encoder* encoder, u64 index_count) {
vkCmdDrawIndexed(encoder->cmd_buffer, index_count, 1, 0, 0, 0);
}
|