Deprecate properties. Use hinted cbuffers instead. This opens up to use a structured buffer in that way as well if you want instead.

This commit is contained in:
2025-09-17 12:31:37 +02:00
parent 7fefe0ecf6
commit 607a6a0bed
27 changed files with 518 additions and 629 deletions

View File

@@ -113,23 +113,10 @@ Entry_Point :: struct {
return_value : Field;
}
Property_Field :: struct {
base_field : Field;
// @Incomplete(nb): Editor information, min max, etc.
// This should also be compiled out for ship
}
Properties :: struct {
fields : [..]Property_Field;
buffer_index : u32;
}
Constant_Buffer :: struct {
name : string;
fields : Static_Array(Property_Field, 16);
fields : Static_Array(Field, 16);
hints : [..]Field_Hint;
@@ -157,8 +144,6 @@ Compiler_Context :: struct {
scope_stack : Scope_Stack;
type_variables : [..]Type_Variable;
property_name : string;
vertex_entry_point : struct {
node : *AST_Node;
name : string;
@@ -171,8 +156,6 @@ Compiler_Context :: struct {
return_value : Field;
}
properties : Properties; //@Note(niels): We'll deprecate this in favor of just marking a constant buffer with a hint on how you'd want to use it
max_constant_buffers :: 16;
cbuffers : Static_Array(Constant_Buffer, max_constant_buffers);
@@ -254,7 +237,7 @@ Min_Field_Name :: 10;
pretty_print_field :: (builder : *String_Builder, field : *Field) {
if field.name.count > 0 {
print_to_builder(builder, "% ", field.name);
append(builder, "- ");
append(builder, ": ");
} else {
append(builder, "return - ");
}
@@ -283,10 +266,17 @@ pretty_print_field :: (builder : *String_Builder, field : *Field) {
case .Struct; {
print_to_builder(builder, "struct : % {", type.name);
newline_after := type.children.count / 4;
for *child : type.children {
pretty_print_field(builder, child);
if it_index < type.children.count - 1 {
append(builder, " ");
append(builder, ", ");
}
if it_index % newline_after == 0 {
append(builder, "\n");
indent(builder, 4);
}
}
@@ -433,11 +423,11 @@ generate_output_data :: (ctx : *Compiler_Context) {
variable := from_handle(ctx.type_variables, buffer_variable);
cb := array_add(*ctx.cbuffers);
cb.name = variable.name;
for i : 0..variable.children.count - 1 {
child := variable.children[i];
field : Property_Field;
field.base_field = type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
field : Field = type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
array_add(*cb.fields, field);
}
@@ -451,20 +441,6 @@ generate_output_data :: (ctx : *Compiler_Context) {
}
}
find_result := find_symbol(*ctx.scope_stack, ctx.property_name, xx 1);
if find_result {
property_variable := from_handle(ctx.type_variables, find_result.type_variable);
for i : 0..property_variable.children.count - 1 {
child := property_variable.children[i];
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
prop_field : Property_Field;
prop_field.base_field = field;
array_add(*ctx.properties.fields, prop_field);
}
ctx.properties.buffer_index = property_variable.resource_index;
}
if ctx.pixel_entry_point.node {
ctx.pixel_entry_point.name = ctx.pixel_entry_point.node.name;