5#include "testing/testing.h"
32using namespace blender::gpu::shader;
41 EXPECT_NE(
shader,
nullptr);
57 EXPECT_NE(
data,
nullptr);
58 for (
int index = 0; index <
SIZE *
SIZE; index++) {
59 EXPECT_FLOAT_EQ(
data[index * 4 + 0], 1.0f);
60 EXPECT_FLOAT_EQ(
data[index * 4 + 1], 0.5f);
61 EXPECT_FLOAT_EQ(
data[index * 4 + 2], 0.2f);
62 EXPECT_FLOAT_EQ(
data[index * 4 + 3], 1.0f);
80 EXPECT_NE(
shader,
nullptr);
98 EXPECT_NE(
data,
nullptr);
99 for (
int index = 0; index <
SIZE; index++) {
100 float expected_value = index;
101 EXPECT_FLOAT_EQ(
data[index * 4 + 0], expected_value);
102 EXPECT_FLOAT_EQ(
data[index * 4 + 1], expected_value);
103 EXPECT_FLOAT_EQ(
data[index * 4 + 2], expected_value);
104 EXPECT_FLOAT_EQ(
data[index * 4 + 3], expected_value);
122 EXPECT_NE(
shader,
nullptr);
141 for (
int index = 0; index <
SIZE; index++) {
142 float expected_value = index;
143 EXPECT_FLOAT_EQ(
data[index * 4 + 0], expected_value);
144 EXPECT_FLOAT_EQ(
data[index * 4 + 1], expected_value);
145 EXPECT_FLOAT_EQ(
data[index * 4 + 2], expected_value);
146 EXPECT_FLOAT_EQ(
data[index * 4 + 3], expected_value);
162 EXPECT_NE(
shader,
nullptr);
178 for (
int index = 0; index <
SIZE; index++) {
179 uint32_t expected = index;
196 EXPECT_NE(
shader,
nullptr);
213 for (
int index = 0; index <
SIZE; index++) {
214 uint32_t expected = index * 4;
229 EXPECT_NE(
shader,
nullptr);
242 std::stringstream ss;
246 ss << *reinterpret_cast<const uint *>(&raw);
249 ss << *reinterpret_cast<const int *>(&raw);
252 ss << *reinterpret_cast<const float *>(&raw);
255 ss << *reinterpret_cast<const int2 *>(&raw);
258 ss << *reinterpret_cast<const int3 *>(&raw);
261 ss << *reinterpret_cast<const int4 *>(&raw);
264 ss << *reinterpret_cast<const uint2 *>(&raw);
267 ss << *reinterpret_cast<const uint3 *>(&raw);
270 ss << *reinterpret_cast<const uint4 *>(&raw);
273 ss << *reinterpret_cast<const float2 *>(&raw);
276 ss << *reinterpret_cast<const float3 *>(&raw);
279 ss << *reinterpret_cast<const float4 *>(&raw);
282 ss << *reinterpret_cast<const float2x2 *>(&raw);
285 ss << *reinterpret_cast<const float2x3 *>(&raw);
288 ss << *reinterpret_cast<const float2x4 *>(&raw);
291 ss << *reinterpret_cast<const float3x2 *>(&raw);
294 ss << *reinterpret_cast<const float3x3 *>(&raw);
297 ss << *reinterpret_cast<const float3x4 *>(&raw);
300 ss << *reinterpret_cast<const float4x2 *>(&raw);
303 ss << *reinterpret_cast<const float4x3 *>(&raw);
306 ss << *reinterpret_cast<const float4x4 *>(&raw);
309 ss << *reinterpret_cast<const MatBase<uint, 4, 4> *>(&raw);
321 while ((
pos = test_src.
find(
'\n',
pos)) != std::string::npos) {
322 if (line == test_line) {
323 return test_src.
substr(last_pos,
pos - last_pos);
341 if (additional_info) {
348 reinterpret_cast<GPUShaderCreateInfo *
>(&create_info));
354 while ((
pos = test_src.
find(target,
pos)) != std::string::npos) {
356 pos +=
sizeof(
"EXPECT_");
363 "tx", test_output_px_len, test_count, 1,
GPU_RGBA32UI, usage,
nullptr);
390 ADD_FAILURE_AT(test_src_name, test.line)
#define BLI_assert_unreachable()
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
MINLINE uint divide_ceil_u(uint a, uint b)
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
void GPU_batch_discard(blender::gpu::Batch *batch)
void GPU_batch_draw_advanced(blender::gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
void GPU_batch_set_shader(blender::gpu::Batch *batch, GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_compute_dispatch(GPUShader *shader, uint groups_x_len, uint groups_y_len, uint groups_z_len, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
GPUFrameBuffer * GPU_framebuffer_create(const char *name)
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
void GPU_framebuffer_free(GPUFrameBuffer *fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
#define GPU_framebuffer_ensure_config(_fb,...)
void GPU_indexbuf_discard(blender::gpu::IndexBuf *elem)
blender::gpu::IndexBuf * GPU_indexbuf_build_on_device(uint index_len)
void GPU_indexbuf_bind_as_ssbo(blender::gpu::IndexBuf *elem, int binding)
void GPU_indexbuf_read(blender::gpu::IndexBuf *elem, uint32_t *data)
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
GPUShader * GPU_shader_create_from_info_name(const char *info_name)
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
GPUShader * GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
void GPU_shader_free(GPUShader *shader)
void GPU_memory_barrier(eGPUBarrier barrier)
@ GPU_BARRIER_BUFFER_UPDATE
@ GPU_BARRIER_TEXTURE_UPDATE
void GPU_storagebuf_bind(GPUStorageBuf *ssbo, int slot)
GPUStorageBuf * GPU_storagebuf_create_ex(size_t size, const void *data, GPUUsageType usage, const char *name)
void GPU_storagebuf_free(GPUStorageBuf *ssbo)
void GPU_storagebuf_read(GPUStorageBuf *ssbo, void *data)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
GPUTexture * GPU_texture_create_1d(const char *name, int width, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
void * GPU_texture_read(GPUTexture *texture, eGPUDataFormat data_format, int mip_level)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_GENERAL
void GPU_texture_image_bind(GPUTexture *texture, int unit)
#define GPU_vertbuf_create_with_format(format)
blender::gpu::VertBuf * GPU_vertbuf_create_with_format_ex(const GPUVertFormat &format, GPUUsageType usage)
void GPU_vertbuf_read(const blender::gpu::VertBuf *verts, void *data)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_bind_as_ssbo(blender::gpu::VertBuf *verts, int binding)
void GPU_vertbuf_discard(blender::gpu::VertBuf *)
Read Guarded memory(de)allocation.
BMesh const char void * data
constexpr int64_t find(char c, int64_t pos=0) const
constexpr StringRef substr(int64_t start, int64_t size) const
struct @242053044010324116347033273112253060004051364061::@051143074301336237271216303350234260141112266062 batch
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
#define GPU_TEST(test_name)
BLI_INLINE float fb(float length, float L)
void MEM_freeN(void *vmemh)
StringRefNull gpu_shader_dependency_get_source(const StringRefNull shader_source_name)
static void test_shader_compute_2d()
static void test_shader_compute_ssbo()
static std::string print_test_data(const TestOutputRawData &raw, TestType type)
static Vector< int32_t > test_data()
static void test_eevee_lib()
static void test_shader_compute_vbo()
static void gpu_shader_lib_test(const char *test_src_name, const char *additional_info=nullptr)
static void test_math_lib()
static void test_shader_ssbo_binding()
static void test_shader_compute_1d()
static StringRef print_test_line(StringRefNull test_src, int64_t test_line)
static void test_shader_compute_ibo()
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Self & fragment_source(StringRefNull filename)
Self & additional_info(StringRefNull info_name)