[Bf-blender-cvs] [79a7030da58] temp-vulkan-descriptor-sets: Added compute test case with ssbo buffers.
Jeroen Bakker
noreply at git.blender.org
Mon Feb 6 14:49:20 CET 2023
Commit: 79a7030da58abde0de7f5ceca42dfb3be1957c4a
Author: Jeroen Bakker
Date: Mon Feb 6 14:49:11 2023 +0100
Branches: temp-vulkan-descriptor-sets
https://developer.blender.org/rB79a7030da58abde0de7f5ceca42dfb3be1957c4a
Added compute test case with ssbo buffers.
===================================================================
M source/blender/gpu/CMakeLists.txt
M source/blender/gpu/shaders/infos/gpu_shader_test_info.hh
M source/blender/gpu/tests/gpu_shader_test.cc
A source/blender/gpu/tests/shaders/gpu_compute_ssbo_test.glsl
===================================================================
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 64fb909da68..e614e708874 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -510,6 +510,7 @@ set(GLSL_SRC_TEST
tests/shaders/gpu_compute_1d_test.glsl
tests/shaders/gpu_compute_2d_test.glsl
tests/shaders/gpu_compute_ibo_test.glsl
+ tests/shaders/gpu_compute_ssbo_test.glsl
tests/shaders/gpu_compute_vbo_test.glsl
tests/shaders/gpu_compute_dummy_test.glsl
)
diff --git a/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh
index bf4de62415d..ff13b91de17 100644
--- a/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh
+++ b/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh
@@ -42,6 +42,12 @@ GPU_SHADER_CREATE_INFO(gpu_compute_vbo_test)
.compute_source("gpu_compute_vbo_test.glsl")
.do_static_compilation(true);
+GPU_SHADER_CREATE_INFO(gpu_compute_ssbo_test)
+ .local_group_size(1)
+ .storage_buf(0, Qualifier::WRITE, "int", "data_out[]")
+ .compute_source("gpu_compute_ssbo_test.glsl")
+ .do_static_compilation(true);
+
GPU_SHADER_CREATE_INFO(gpu_compute_ssbo_binding_test)
.local_group_size(1)
.storage_buf(0, Qualifier::WRITE, "int", "data0[]")
diff --git a/source/blender/gpu/tests/gpu_shader_test.cc b/source/blender/gpu/tests/gpu_shader_test.cc
index 00954c10c1a..fa4c2ef1eef 100644
--- a/source/blender/gpu/tests/gpu_shader_test.cc
+++ b/source/blender/gpu/tests/gpu_shader_test.cc
@@ -212,7 +212,7 @@ GPU_TEST(gpu_shader_compute_ibo)
static void test_gpu_shader_compute_ssbo()
{
- if (!GPU_compute_shader_support()) {
+ if (!GPU_compute_shader_support() && !GPU_shader_storage_buffer_objects_support()) {
/* We can't test as a the platform does not support compute shaders. */
std::cout << "Skipping compute shader test: platform not supported";
return;
@@ -221,14 +221,14 @@ static void test_gpu_shader_compute_ssbo()
static constexpr uint SIZE = 128;
/* Build compute shader. */
- GPUShader *shader = GPU_shader_create_from_info_name("gpu_compute_ibo_test");
+ GPUShader *shader = GPU_shader_create_from_info_name("gpu_compute_ssbo_test");
EXPECT_NE(shader, nullptr);
GPU_shader_bind(shader);
/* Construct IBO. */
GPUStorageBuf *ssbo = GPU_storagebuf_create_ex(
SIZE * sizeof(uint32_t), nullptr, GPU_USAGE_DEVICE_ONLY, __func__);
- GPU_storagebuf_bind(ssbo, GPU_shader_get_ssbo(shader, "out_indices"));
+ GPU_storagebuf_bind(ssbo, GPU_shader_get_ssbo(shader, "data_out"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, 1, 1);
@@ -240,7 +240,7 @@ static void test_gpu_shader_compute_ssbo()
uint32_t data[SIZE];
GPU_storagebuf_read(ssbo, data);
for (int index = 0; index < SIZE; index++) {
- uint32_t expected = index;
+ uint32_t expected = index * 4;
EXPECT_EQ(data[index], expected);
}
diff --git a/source/blender/gpu/tests/shaders/gpu_compute_ssbo_test.glsl b/source/blender/gpu/tests/shaders/gpu_compute_ssbo_test.glsl
new file mode 100644
index 00000000000..b7a7390f309
--- /dev/null
+++ b/source/blender/gpu/tests/shaders/gpu_compute_ssbo_test.glsl
@@ -0,0 +1,5 @@
+void main()
+{
+ int store_index = int(gl_GlobalInvocationID.x);
+ data_out[store_index] = store_index * 4;
+}
More information about the Bf-blender-cvs
mailing list