From 2f30d220fb3af61359f91c63391eb3e6bd41db28 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 1 Feb 2024 14:10:51 +0100 Subject: [PATCH] Draw: Fix 'draw_resource_id_gen' test The test uses a none points shader to draw points, which is incorrect and asserts when using Vulkan. It also didn't test the gpu part of the pipeline (PassMain). When using PassMain the order of the resources are expected to be different as the draw calls are ordered based on the primitive type and handles. Pull Request: https://projects.blender.org/blender/blender/pulls/117714 --- source/blender/draw/tests/draw_pass_test.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/source/blender/draw/tests/draw_pass_test.cc b/source/blender/draw/tests/draw_pass_test.cc index 439aad60261..67857af2e79 100644 --- a/source/blender/draw/tests/draw_pass_test.cc +++ b/source/blender/draw/tests/draw_pass_test.cc @@ -304,13 +304,12 @@ static void test_draw_resource_id_gen() drw.resource_handle(obmat_2, float3(2), float3(1)); drw.end_sync(); - StringRefNull expected = "2 1 1 1 1 3 3 1 1 1 1 1 3 2 2 2 2 2 2 1 1 1 "; - { /* Computed on CPU. */ PassSimple pass = {"test.resource_id"}; pass.init(); - pass.shader_set(GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE_COLOR)); + pass.shader_set( + GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA)); pass.draw_procedural(GPU_PRIM_TRIS, 1, -1, -1, handle2); pass.draw_procedural(GPU_PRIM_POINTS, 4, -1, -1, handle1); pass.draw_procedural(GPU_PRIM_TRIS, 2, -1, -1, handle3); @@ -326,13 +325,16 @@ static void test_draw_resource_id_gen() result << val << " "; } - EXPECT_EQ(result.str(), expected); + StringRefNull expected_simple = "2 1 1 1 1 3 3 1 1 1 1 1 3 2 2 2 2 2 2 1 1 1 "; + EXPECT_EQ(result.str(), expected_simple); } + { /* Same thing with PassMain (computed on GPU) */ - PassSimple pass = {"test.resource_id"}; + PassMain pass = {"test.resource_id"}; pass.init(); - pass.shader_set(GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE_COLOR)); + pass.shader_set( + GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA)); pass.draw_procedural(GPU_PRIM_TRIS, 1, -1, -1, handle2); pass.draw_procedural(GPU_PRIM_POINTS, 4, -1, -1, handle1); pass.draw_procedural(GPU_PRIM_TRIS, 2, -1, -1, handle3); @@ -348,7 +350,11 @@ static void test_draw_resource_id_gen() result << val << " "; } - EXPECT_EQ(result.str(), expected); + /* When using PassMain the handles are sorted based on their handles and GPUBatches. Different + * primitives use different batches. + */ + StringRefNull expected_main = "2 3 3 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 "; + EXPECT_EQ(result.str(), expected_main); } GPU_render_end();