From bd501ce33662e87add2dd7cdbb734b9e074a8c05 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Mon, 31 Oct 2022 18:13:26 -0300 Subject: [PATCH] vkd3d-shader/hlsl: Don't produce a parse error on empty buffer_body. --- Makefile.am | 1 + libs/vkd3d-shader/hlsl.y | 2 +- tests/cbuffer.shader_test | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/cbuffer.shader_test diff --git a/Makefile.am b/Makefile.am index 74c45aed..85cd4642 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ vkd3d_shader_tests = \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \ tests/cast-to-uint.shader_test \ + tests/cbuffer.shader_test \ tests/compute.shader_test \ tests/conditional.shader_test \ tests/floor.shader_test \ diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 6461ade5..c1fb003d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3361,7 +3361,7 @@ buffer_type: } declaration_statement_list: - declaration_statement + %empty | declaration_statement_list declaration_statement preproc_directive: diff --git a/tests/cbuffer.shader_test b/tests/cbuffer.shader_test new file mode 100644 index 00000000..07ef18db --- /dev/null +++ b/tests/cbuffer.shader_test @@ -0,0 +1,17 @@ +[pixel shader] +// Test empty constant buffer. +cbuffer Constants : register(b1) +{ +}; + +float4 foo; + +float4 main() : sv_target +{ + return foo; +} + +[test] +uniform 0 float4 1.0 2.0 3.0 4.0 +draw quad +probe all rgba (1.0, 2.0, 3.0, 4.0)