From be4115b50238d855286c32ffc5e75885e9b54ec1 Mon Sep 17 00:00:00 2001 From: nielsbross Date: Thu, 27 Jun 2024 09:32:25 +0000 Subject: [PATCH] Added constant buffers --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c96fb16..51e5624 100644 --- a/README.md +++ b/README.md @@ -49,13 +49,22 @@ properties { view : float4x4; } ``` -which will be exposed in the compiled result. In the future `properties` can be renamed to a custom/shorter name like +which will be exposed in the compiled result. `properties` can be renamed to a custom/shorter name like ``` p :: properties { ... } ``` +You can also define constant buffers + +``` +camera :: Constant_Buffer { + projection : float4x4; + view : float4x4; +} +``` + ## Jai Usage Example To compile a shader and use the result, you can do the following in jai @@ -95,6 +104,9 @@ A `Shader_Variant_Collection` looks as follows Shader_Variant_Collection :: struct { properties : Properties; + max_constant_buffers :: 16; + cbuffers : Static_Array(Constant_Buffer, max_constant_buffers); + variants : [..]Shader_Variant; } @@ -114,6 +126,16 @@ Shader_Variant :: struct { } } +Constant_Buffer :: struct { + register : int; + + name : string; + + fields : Static_Array(Property_Field, 16); + + buffer_index : u32; +} + Properties :: struct { fields : [..]Property_Field;