Skip to content

Commit 9c92f84

Browse files
committed
[Kompjuta] Fill the command buffer
1 parent c0b18b0 commit 9c92f84

4 files changed

Lines changed: 84 additions & 6 deletions

File tree

backends/gpu/kompjuta/includes/kore3/kompjuta/pipeline_structs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ typedef struct kore_kompjuta_render_pipeline_parameters {
196196
} kore_kompjuta_render_pipeline_parameters;
197197

198198
typedef struct kore_kompjuta_render_pipeline {
199-
int nothing;
199+
kore_kompjuta_shader vertex_shader;
200+
kore_kompjuta_shader fragment_shader;
200201
} kore_kompjuta_render_pipeline;
201202

202203
typedef struct kore_kompjuta_compute_pipeline_parameters {

backends/gpu/kompjuta/sources/commandlist.c

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,85 @@ void kore_kompjuta_command_list_destroy(kore_gpu_command_list *list) {}
1515

1616
void kore_kompjuta_command_list_begin_render_pass(kore_gpu_command_list *list, const kore_gpu_render_pass_parameters *parameters) {
1717
assert(list->kompjuta.current_command < list->kompjuta.commands_count);
18+
1819
kompjuta_gpu_command *command = &list->kompjuta.commands[list->kompjuta.current_command];
1920
command->kind = KOMPJUTA_GPU_COMMAND_CLEAR;
2021
command->data.clear.r = parameters->color_attachments[0].clear_value.r;
2122
command->data.clear.g = parameters->color_attachments[0].clear_value.g;
2223
command->data.clear.b = parameters->color_attachments[0].clear_value.b;
2324
command->data.clear.a = parameters->color_attachments[0].clear_value.a;
25+
2426
++list->kompjuta.current_command;
2527
}
2628

2729
void kore_kompjuta_command_list_end_render_pass(kore_gpu_command_list *list) {}
2830

2931
void kore_kompjuta_command_list_present(kore_gpu_command_list *list) {
3032
assert(list->kompjuta.current_command < list->kompjuta.commands_count);
33+
3134
kompjuta_gpu_command *command = &list->kompjuta.commands[list->kompjuta.current_command];
3235
command->kind = KOMPJUTA_GPU_COMMAND_PRESENT;
36+
3337
++list->kompjuta.current_command;
3438
}
3539

36-
void kore_kompjuta_command_list_set_index_buffer(kore_gpu_command_list *list, kore_gpu_buffer *buffer, kore_gpu_index_format index_format, uint64_t offset) {}
40+
void kore_kompjuta_command_list_set_index_buffer(kore_gpu_command_list *list, kore_gpu_buffer *buffer, kore_gpu_index_format index_format, uint64_t offset) {
41+
assert(list->kompjuta.current_command < list->kompjuta.commands_count);
42+
43+
kompjuta_gpu_command *command = &list->kompjuta.commands[list->kompjuta.current_command];
44+
command->kind = KOMPJUTA_GPU_COMMAND_SET_INDEX_BUFFER;
45+
46+
uint8_t *data = (uint8_t *)buffer->kompjuta.data;
47+
command->data.set_index_buffer.data = &data[offset];
48+
49+
command->data.set_index_buffer.index_format = index_format;
50+
51+
++list->kompjuta.current_command;
52+
}
3753

3854
void kore_kompjuta_command_list_set_vertex_buffer(kore_gpu_command_list *list, uint32_t slot, kore_kompjuta_buffer *buffer, uint64_t offset, uint64_t size,
39-
uint64_t stride) {}
55+
uint64_t stride) {
56+
assert(list->kompjuta.current_command < list->kompjuta.commands_count);
57+
58+
kompjuta_gpu_command *command = &list->kompjuta.commands[list->kompjuta.current_command];
59+
command->kind = KOMPJUTA_GPU_COMMAND_SET_VERTEX_BUFFER;
4060

41-
void kore_kompjuta_command_list_set_render_pipeline(kore_gpu_command_list *list, kore_kompjuta_render_pipeline *pipeline) {}
61+
uint8_t *data = (uint8_t *)buffer->data;
62+
command->data.set_vertex_buffer.data = &data[offset];
63+
64+
command->data.set_vertex_buffer.stride = stride;
65+
66+
++list->kompjuta.current_command;
67+
}
68+
69+
void kore_kompjuta_command_list_set_render_pipeline(kore_gpu_command_list *list, kore_kompjuta_render_pipeline *pipeline) {
70+
assert(list->kompjuta.current_command < list->kompjuta.commands_count);
71+
72+
kompjuta_gpu_command *command = &list->kompjuta.commands[list->kompjuta.current_command];
73+
command->kind = KOMPJUTA_GPU_COMMAND_SET_RENDER_PIPELINE;
74+
command->data.set_render_pipeline.vertex_shader = pipeline->vertex_shader.function;
75+
command->data.set_render_pipeline.fragment_shader = pipeline->fragment_shader.function;
76+
77+
++list->kompjuta.current_command;
78+
}
4279

4380
void kore_kompjuta_command_list_draw(kore_gpu_command_list *list, uint32_t vertex_count, uint32_t instance_count, uint32_t first_vertex,
4481
uint32_t first_instance) {}
4582

4683
void kore_kompjuta_command_list_draw_indexed(kore_gpu_command_list *list, uint32_t index_count, uint32_t instance_count, uint32_t first_index,
47-
int32_t base_vertex, uint32_t first_instance) {}
84+
int32_t base_vertex, uint32_t first_instance) {
85+
assert(list->kompjuta.current_command < list->kompjuta.commands_count);
86+
87+
kompjuta_gpu_command *command = &list->kompjuta.commands[list->kompjuta.current_command];
88+
command->kind = KOMPJUTA_GPU_COMMAND_DRAW_INDEXED;
89+
command->data.draw_indexed.index_count = index_count;
90+
command->data.draw_indexed.instance_count = instance_count;
91+
command->data.draw_indexed.first_index = first_index;
92+
command->data.draw_indexed.base_vertex = base_vertex;
93+
command->data.draw_indexed.first_instance = first_instance;
94+
95+
++list->kompjuta.current_command;
96+
}
4897

4998
void kore_kompjuta_command_list_set_bind_group(kore_gpu_command_list *list, uint32_t index, kore_kompjuta_descriptor_set *set, uint32_t dynamic_count,
5099
uint32_t *dynamic_offsets) {}

backends/gpu/kompjuta/sources/pipeline.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
#include <kore3/log.h>
55

66
void kore_kompjuta_render_pipeline_init(kore_kompjuta_device *device, kore_kompjuta_render_pipeline *pipe,
7-
const kore_kompjuta_render_pipeline_parameters *parameters) {}
7+
const kore_kompjuta_render_pipeline_parameters *parameters) {
8+
pipe->vertex_shader = parameters->vertex.shader;
9+
pipe->fragment_shader = parameters->fragment.shader;
10+
}
811

912
void kore_kompjuta_render_pipeline_destroy(kore_kompjuta_render_pipeline *pipe) {}
1013

backends/system/kompjuta/includes/kore3/backend/mmio.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef KOMPJUTA_MMIO_HEADER
22
#define KOMPJUTA_MMIO_HEADER
33

4+
#include <kore3/gpu/commandlist.h>
5+
46
#include <stdint.h>
57

68
#ifdef __cplusplus
@@ -21,6 +23,10 @@ extern "C" {
2123

2224
typedef enum kompjuta_gpu_command_kind {
2325
KOMPJUTA_GPU_COMMAND_CLEAR,
26+
KOMPJUTA_GPU_COMMAND_SET_INDEX_BUFFER,
27+
KOMPJUTA_GPU_COMMAND_SET_VERTEX_BUFFER,
28+
KOMPJUTA_GPU_COMMAND_SET_RENDER_PIPELINE,
29+
KOMPJUTA_GPU_COMMAND_DRAW_INDEXED,
2430
KOMPJUTA_GPU_COMMAND_PRESENT,
2531
} kompjuta_gpu_command_kind;
2632

@@ -33,6 +39,25 @@ typedef struct kompjuta_gpu_command {
3339
float b;
3440
float a;
3541
} clear;
42+
struct {
43+
void *data;
44+
kore_gpu_index_format index_format;
45+
} set_index_buffer;
46+
struct {
47+
void *data;
48+
uint64_t stride;
49+
} set_vertex_buffer;
50+
struct {
51+
void *vertex_shader;
52+
void *fragment_shader;
53+
} set_render_pipeline;
54+
struct {
55+
uint32_t index_count;
56+
uint32_t instance_count;
57+
uint32_t first_index;
58+
int32_t base_vertex;
59+
uint32_t first_instance;
60+
} draw_indexed;
3661
} data;
3762
} kompjuta_gpu_command;
3863

0 commit comments

Comments
 (0)