forked from blender/blender
main sync #3
@ -809,10 +809,11 @@ if(WITH_GTESTS)
|
|||||||
set(TEST_SRC
|
set(TEST_SRC
|
||||||
tests/gpu_testing.cc
|
tests/gpu_testing.cc
|
||||||
|
|
||||||
tests/gpu_index_buffer_test.cc
|
tests/index_buffer_test.cc
|
||||||
tests/gpu_push_constants_test.cc
|
tests/push_constants_test.cc
|
||||||
tests/gpu_shader_test.cc
|
tests/shader_test.cc
|
||||||
tests/gpu_storage_buffer_test.cc
|
tests/storage_buffer_test.cc
|
||||||
|
tests/texture_test.cc
|
||||||
|
|
||||||
tests/gpu_testing.hh
|
tests/gpu_testing.hh
|
||||||
)
|
)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace blender::gpu::tests {
|
namespace blender::gpu::tests {
|
||||||
|
|
||||||
static void test_gpu_index_buffer_subbuilders()
|
static void test_index_buffer_subbuilders()
|
||||||
{
|
{
|
||||||
const uint num_subbuilders = 10;
|
const uint num_subbuilders = 10;
|
||||||
const uint verts_per_subbuilders = 100;
|
const uint verts_per_subbuilders = 100;
|
||||||
@ -44,6 +44,6 @@ static void test_gpu_index_buffer_subbuilders()
|
|||||||
GPU_INDEXBUF_DISCARD_SAFE(index_buffer);
|
GPU_INDEXBUF_DISCARD_SAFE(index_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU_TEST(gpu_index_buffer_subbuilders)
|
GPU_TEST(index_buffer_subbuilders)
|
||||||
|
|
||||||
} // namespace blender::gpu::tests
|
} // namespace blender::gpu::tests
|
@ -33,7 +33,7 @@ static void test_shader_compile_statically_defined()
|
|||||||
}
|
}
|
||||||
GPU_TEST(shader_compile_statically_defined)
|
GPU_TEST(shader_compile_statically_defined)
|
||||||
|
|
||||||
static void test_gpu_shader_compute_2d()
|
static void test_shader_compute_2d()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!GPU_compute_shader_support()) {
|
if (!GPU_compute_shader_support()) {
|
||||||
@ -77,9 +77,9 @@ static void test_gpu_shader_compute_2d()
|
|||||||
GPU_texture_free(texture);
|
GPU_texture_free(texture);
|
||||||
GPU_shader_free(shader);
|
GPU_shader_free(shader);
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_shader_compute_2d)
|
GPU_TEST(shader_compute_2d)
|
||||||
|
|
||||||
static void test_gpu_shader_compute_1d()
|
static void test_shader_compute_1d()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!GPU_compute_shader_support()) {
|
if (!GPU_compute_shader_support()) {
|
||||||
@ -126,9 +126,9 @@ static void test_gpu_shader_compute_1d()
|
|||||||
GPU_texture_free(texture);
|
GPU_texture_free(texture);
|
||||||
GPU_shader_free(shader);
|
GPU_shader_free(shader);
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_shader_compute_1d)
|
GPU_TEST(shader_compute_1d)
|
||||||
|
|
||||||
static void test_gpu_shader_compute_vbo()
|
static void test_shader_compute_vbo()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!GPU_compute_shader_support()) {
|
if (!GPU_compute_shader_support()) {
|
||||||
@ -173,9 +173,9 @@ static void test_gpu_shader_compute_vbo()
|
|||||||
GPU_vertbuf_discard(vbo);
|
GPU_vertbuf_discard(vbo);
|
||||||
GPU_shader_free(shader);
|
GPU_shader_free(shader);
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_shader_compute_vbo)
|
GPU_TEST(shader_compute_vbo)
|
||||||
|
|
||||||
static void test_gpu_shader_compute_ibo()
|
static void test_shader_compute_ibo()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!GPU_compute_shader_support()) {
|
if (!GPU_compute_shader_support()) {
|
||||||
@ -214,9 +214,9 @@ static void test_gpu_shader_compute_ibo()
|
|||||||
GPU_indexbuf_discard(ibo);
|
GPU_indexbuf_discard(ibo);
|
||||||
GPU_shader_free(shader);
|
GPU_shader_free(shader);
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_shader_compute_ibo)
|
GPU_TEST(shader_compute_ibo)
|
||||||
|
|
||||||
static void test_gpu_shader_compute_ssbo()
|
static void test_shader_compute_ssbo()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!GPU_compute_shader_support() && !GPU_shader_storage_buffer_objects_support()) {
|
if (!GPU_compute_shader_support() && !GPU_shader_storage_buffer_objects_support()) {
|
||||||
@ -256,9 +256,9 @@ static void test_gpu_shader_compute_ssbo()
|
|||||||
GPU_storagebuf_free(ssbo);
|
GPU_storagebuf_free(ssbo);
|
||||||
GPU_shader_free(shader);
|
GPU_shader_free(shader);
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_shader_compute_ssbo)
|
GPU_TEST(shader_compute_ssbo)
|
||||||
|
|
||||||
static void test_gpu_shader_ssbo_binding()
|
static void test_shader_ssbo_binding()
|
||||||
{
|
{
|
||||||
if (!GPU_compute_shader_support()) {
|
if (!GPU_compute_shader_support()) {
|
||||||
/* We can't test as a the platform does not support compute shaders. */
|
/* We can't test as a the platform does not support compute shaders. */
|
||||||
@ -269,7 +269,7 @@ static void test_gpu_shader_ssbo_binding()
|
|||||||
/* Build compute shader. */
|
/* Build compute shader. */
|
||||||
GPUShader *shader = GPU_shader_create_from_info_name("gpu_compute_ssbo_binding_test");
|
GPUShader *shader = GPU_shader_create_from_info_name("gpu_compute_ssbo_binding_test");
|
||||||
EXPECT_NE(shader, nullptr);
|
EXPECT_NE(shader, nullptr);
|
||||||
|
|
||||||
/* Perform tests. */
|
/* Perform tests. */
|
||||||
EXPECT_EQ(0, GPU_shader_get_ssbo_binding(shader, "data0"));
|
EXPECT_EQ(0, GPU_shader_get_ssbo_binding(shader, "data0"));
|
||||||
EXPECT_EQ(1, GPU_shader_get_ssbo_binding(shader, "data1"));
|
EXPECT_EQ(1, GPU_shader_get_ssbo_binding(shader, "data1"));
|
||||||
@ -277,44 +277,7 @@ static void test_gpu_shader_ssbo_binding()
|
|||||||
/* Cleanup. */
|
/* Cleanup. */
|
||||||
GPU_shader_free(shader);
|
GPU_shader_free(shader);
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_shader_ssbo_binding)
|
GPU_TEST(shader_ssbo_binding)
|
||||||
|
|
||||||
static void test_gpu_texture_read()
|
|
||||||
{
|
|
||||||
GPU_render_begin();
|
|
||||||
|
|
||||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ;
|
|
||||||
GPUTexture *rgba32u = GPU_texture_create_2d("rgba32u", 1, 1, 1, GPU_RGBA32UI, usage, nullptr);
|
|
||||||
GPUTexture *rgba16u = GPU_texture_create_2d("rgba16u", 1, 1, 1, GPU_RGBA16UI, usage, nullptr);
|
|
||||||
GPUTexture *rgba32f = GPU_texture_create_2d("rgba32f", 1, 1, 1, GPU_RGBA32F, usage, nullptr);
|
|
||||||
|
|
||||||
const float4 fcol = {0.0f, 1.3f, -231.0f, 1000.0f};
|
|
||||||
const uint4 ucol = {0, 1, 2, 12223};
|
|
||||||
GPU_texture_clear(rgba32u, GPU_DATA_UINT, ucol);
|
|
||||||
GPU_texture_clear(rgba16u, GPU_DATA_UINT, ucol);
|
|
||||||
GPU_texture_clear(rgba32f, GPU_DATA_FLOAT, fcol);
|
|
||||||
|
|
||||||
GPU_memory_barrier(GPU_BARRIER_TEXTURE_UPDATE);
|
|
||||||
|
|
||||||
uint4 *rgba32u_data = (uint4 *)GPU_texture_read(rgba32u, GPU_DATA_UINT, 0);
|
|
||||||
uint4 *rgba16u_data = (uint4 *)GPU_texture_read(rgba16u, GPU_DATA_UINT, 0);
|
|
||||||
float4 *rgba32f_data = (float4 *)GPU_texture_read(rgba32f, GPU_DATA_FLOAT, 0);
|
|
||||||
|
|
||||||
EXPECT_EQ(ucol, *rgba32u_data);
|
|
||||||
EXPECT_EQ(ucol, *rgba16u_data);
|
|
||||||
EXPECT_EQ(fcol, *rgba32f_data);
|
|
||||||
|
|
||||||
MEM_freeN(rgba32u_data);
|
|
||||||
MEM_freeN(rgba16u_data);
|
|
||||||
MEM_freeN(rgba32f_data);
|
|
||||||
|
|
||||||
GPU_texture_free(rgba32u);
|
|
||||||
GPU_texture_free(rgba16u);
|
|
||||||
GPU_texture_free(rgba32f);
|
|
||||||
|
|
||||||
GPU_render_end();
|
|
||||||
}
|
|
||||||
GPU_TEST(gpu_texture_read)
|
|
||||||
|
|
||||||
static std::string print_test_data(const TestOutputRawData &raw, TestType type)
|
static std::string print_test_data(const TestOutputRawData &raw, TestType type)
|
||||||
{
|
{
|
||||||
@ -487,11 +450,11 @@ static void gpu_shader_lib_test(const char *test_src_name, const char *additiona
|
|||||||
GPU_render_end();
|
GPU_render_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_gpu_math_lib()
|
static void test_math_lib()
|
||||||
{
|
{
|
||||||
gpu_shader_lib_test("gpu_math_test.glsl");
|
gpu_shader_lib_test("gpu_math_test.glsl");
|
||||||
}
|
}
|
||||||
GPU_TEST(gpu_math_lib)
|
GPU_TEST(math_lib)
|
||||||
|
|
||||||
static void test_eevee_lib()
|
static void test_eevee_lib()
|
||||||
{
|
{
|
@ -22,7 +22,7 @@ static Vector<int32_t> test_data()
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_gpu_storage_buffer_create_update_read()
|
static void test_storage_buffer_create_update_read()
|
||||||
{
|
{
|
||||||
GPUStorageBuf *ssbo = GPU_storagebuf_create_ex(
|
GPUStorageBuf *ssbo = GPU_storagebuf_create_ex(
|
||||||
SIZE_IN_BYTES, nullptr, GPU_USAGE_STATIC, __func__);
|
SIZE_IN_BYTES, nullptr, GPU_USAGE_STATIC, __func__);
|
||||||
@ -45,6 +45,6 @@ static void test_gpu_storage_buffer_create_update_read()
|
|||||||
GPU_storagebuf_free(ssbo);
|
GPU_storagebuf_free(ssbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU_TEST(gpu_storage_buffer_create_update_read);
|
GPU_TEST(storage_buffer_create_update_read);
|
||||||
|
|
||||||
} // namespace blender::gpu::tests
|
} // namespace blender::gpu::tests
|
49
source/blender/gpu/tests/texture_test.cc
Normal file
49
source/blender/gpu/tests/texture_test.cc
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "gpu_testing.hh"
|
||||||
|
|
||||||
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "BLI_math_vector.hh"
|
||||||
|
|
||||||
|
#include "GPU_context.h"
|
||||||
|
#include "GPU_texture.h"
|
||||||
|
|
||||||
|
namespace blender::gpu::tests {
|
||||||
|
|
||||||
|
static void test_texture_read()
|
||||||
|
{
|
||||||
|
GPU_render_begin();
|
||||||
|
|
||||||
|
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_HOST_READ;
|
||||||
|
GPUTexture *rgba32u = GPU_texture_create_2d("rgba32u", 1, 1, 1, GPU_RGBA32UI, usage, nullptr);
|
||||||
|
GPUTexture *rgba16u = GPU_texture_create_2d("rgba16u", 1, 1, 1, GPU_RGBA16UI, usage, nullptr);
|
||||||
|
GPUTexture *rgba32f = GPU_texture_create_2d("rgba32f", 1, 1, 1, GPU_RGBA32F, usage, nullptr);
|
||||||
|
|
||||||
|
const float4 fcol = {0.0f, 1.3f, -231.0f, 1000.0f};
|
||||||
|
const uint4 ucol = {0, 1, 2, 12223};
|
||||||
|
GPU_texture_clear(rgba32u, GPU_DATA_UINT, ucol);
|
||||||
|
GPU_texture_clear(rgba16u, GPU_DATA_UINT, ucol);
|
||||||
|
GPU_texture_clear(rgba32f, GPU_DATA_FLOAT, fcol);
|
||||||
|
|
||||||
|
GPU_memory_barrier(GPU_BARRIER_TEXTURE_UPDATE);
|
||||||
|
|
||||||
|
uint4 *rgba32u_data = (uint4 *)GPU_texture_read(rgba32u, GPU_DATA_UINT, 0);
|
||||||
|
uint4 *rgba16u_data = (uint4 *)GPU_texture_read(rgba16u, GPU_DATA_UINT, 0);
|
||||||
|
float4 *rgba32f_data = (float4 *)GPU_texture_read(rgba32f, GPU_DATA_FLOAT, 0);
|
||||||
|
|
||||||
|
EXPECT_EQ(ucol, *rgba32u_data);
|
||||||
|
EXPECT_EQ(ucol, *rgba16u_data);
|
||||||
|
EXPECT_EQ(fcol, *rgba32f_data);
|
||||||
|
|
||||||
|
MEM_freeN(rgba32u_data);
|
||||||
|
MEM_freeN(rgba16u_data);
|
||||||
|
MEM_freeN(rgba32f_data);
|
||||||
|
|
||||||
|
GPU_texture_free(rgba32u);
|
||||||
|
GPU_texture_free(rgba16u);
|
||||||
|
GPU_texture_free(rgba32f);
|
||||||
|
|
||||||
|
GPU_render_end();
|
||||||
|
}
|
||||||
|
GPU_TEST(texture_read)
|
||||||
|
|
||||||
|
} // namespace blender::gpu::tests
|
Loading…
Reference in New Issue
Block a user