Skip to content

Commit

Permalink
Pass buffer sizes and offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Oct 12, 2024
1 parent f689b66 commit b96e2e4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Sources/integrations/kope.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,17 @@ void kope_export(char *directory, api_kind api) {

switch (d.kind) {
case DEFINITION_CONST_CUSTOM:
fprintf(output, "\tkope_d3d12_descriptor_set_prepare_cbv_buffer(list, set->%s);\n", get_name(get_global(d.global)->name));
if (has_attribute(&get_global(d.global)->attributes, add_name("indexed"))) {
fprintf(
output,
"\tkope_d3d12_descriptor_set_prepare_cbv_buffer(list, set->%s, %s_index * align_pow2((int)%i, 256), align_pow2((int)%i, 256));\n",
get_name(get_global(d.global)->name), get_name(get_global(d.global)->name), struct_size(get_global(d.global)->type),
struct_size(get_global(d.global)->type));
}
else {
fprintf(output, "\tkope_d3d12_descriptor_set_prepare_cbv_buffer(list, set->%s, 0, UINT32_MAX);\n",
get_name(get_global(d.global)->name));
}
break;
CASE_TEXTURE: {
attribute *write_attribute = find_attribute(&get_global(d.global)->attributes, add_name("write"));
Expand Down Expand Up @@ -1145,6 +1155,8 @@ void kope_export(char *directory, api_kind api) {

fprintf(output, "\tuint32_t dynamic_offsets[%i];\n", dynamic_count);

fprintf(output, "\tuint32_t dynamic_sizes[%i];\n", dynamic_count);

uint32_t dynamic_index = 0;
for (size_t definition_index = 0; definition_index < set->definitions_count; ++definition_index) {
definition d = set->definitions[definition_index];
Expand All @@ -1154,6 +1166,7 @@ void kope_export(char *directory, api_kind api) {
fprintf(output, "\tdynamic_buffers[%i] = set->%s;\n", dynamic_index, get_name(get_global(d.global)->name));
fprintf(output, "\tdynamic_offsets[%i] = %s_index * align_pow2((int)%i, 256);\n", dynamic_index,
get_name(get_global(d.global)->name), struct_size(get_global(d.global)->type));
fprintf(output, "\tdynamic_sizes[%i] = align_pow2((int)%i, 256);\n", dynamic_index, struct_size(get_global(d.global)->type));
dynamic_index += 1;
}
break;
Expand All @@ -1163,7 +1176,7 @@ void kope_export(char *directory, api_kind api) {

fprintf(output, "\n\tkope_d3d12_command_list_set_descriptor_table(list, %i, &set->set", descriptor_table_index);
if (dynamic_count > 0) {
fprintf(output, ", dynamic_buffers, dynamic_offsets");
fprintf(output, ", dynamic_buffers, dynamic_offsets, dynamic_sizes");
}
else {
fprintf(output, ", NULL, NULL");
Expand Down

0 comments on commit b96e2e4

Please sign in to comment.