From 7a07c32cd2f5a310318b364a4a09ee5bbb1265fc Mon Sep 17 00:00:00 2001 From: Niels Bross Date: Mon, 1 Jul 2024 08:02:10 +0200 Subject: [PATCH] Fix cbuffer pretty printing. --- Semantic_Analysis.jai | 1 + test/codegen/texture_sample.golden | 29 +++++++++++++++++++++++++++++ test/semant/constant_buffer.golden | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 test/codegen/texture_sample.golden create mode 100644 test/semant/constant_buffer.golden diff --git a/Semantic_Analysis.jai b/Semantic_Analysis.jai index ab60322..e4e7a80 100644 --- a/Semantic_Analysis.jai +++ b/Semantic_Analysis.jai @@ -2019,6 +2019,7 @@ print_type_variable :: (builder : *String_Builder, variable : Type_Variable, che } case .Function; #through; case .Struct; #through; + case .CBuffer; #through; case .Field; { if variable.struct_field_parent { print_to_builder(builder, "%.", variable.struct_field_parent.name); diff --git a/test/codegen/texture_sample.golden b/test/codegen/texture_sample.golden new file mode 100644 index 0000000..ba7961b --- /dev/null +++ b/test/codegen/texture_sample.golden @@ -0,0 +1,29 @@ +struct PS_Input; + +cbuffer __PROPERTIES : register(b0) +{ +} + +Texture2D texture : register(t0); +Sampler sampler : register(s0); + +struct PS_Input +{ + float2 uv; + float4 pos : POSITION; +} + +PS_Input vs_main(float4 pos : POSITION, float2 uv) +{ + PS_Input result; + result.uv = uv; + result.pos = pos; + return result; +} + +float4 ps_main(PS_Input input) : SV_TARGET +{ + float4 color = texture.sample(input.uv, sampler); + return color; +} + diff --git a/test/semant/constant_buffer.golden b/test/semant/constant_buffer.golden new file mode 100644 index 0000000..1f36c81 --- /dev/null +++ b/test/semant/constant_buffer.golden @@ -0,0 +1,15 @@ +scope (global) [ + [pixel__ps_main] : () -> float4 + [vertex__vs_main] : (pos : float4) -> float4 + [camera] : {projection : float4x4, view : float4x4} + scope (camera) [ + [projection] : float4x4 + [view] : float4x4 + ] + scope (vertex__vs_main) [ + [pos] : float4 + [mv] : float4 + [mvp] : float4 + ] + scope (pixel__ps_main) [] +]