5#include "testing/testing.h"
32using namespace blender::gpu::shader;
41 EXPECT_NE(
shader,
nullptr);
48 TextureFormat::SFLOAT_32_32_32_32,
62 EXPECT_NE(
data,
nullptr);
63 for (
int index = 0; index <
SIZE *
SIZE; index++) {
64 EXPECT_FLOAT_EQ(
data[index * 4 + 0], 1.0f);
65 EXPECT_FLOAT_EQ(
data[index * 4 + 1], 0.5f);
66 EXPECT_FLOAT_EQ(
data[index * 4 + 2], 0.2f);
67 EXPECT_FLOAT_EQ(
data[index * 4 + 3], 1.0f);
85 EXPECT_NE(
shader,
nullptr);
91 TextureFormat::SFLOAT_32_32_32_32,
107 EXPECT_NE(
data,
nullptr);
108 for (
int index = 0; index <
SIZE; index++) {
109 float expected_value = index;
110 EXPECT_FLOAT_EQ(
data[index * 4 + 0], expected_value);
111 EXPECT_FLOAT_EQ(
data[index * 4 + 1], expected_value);
112 EXPECT_FLOAT_EQ(
data[index * 4 + 2], expected_value);
113 EXPECT_FLOAT_EQ(
data[index * 4 + 3], expected_value);
131 EXPECT_NE(
shader,
nullptr);
150 for (
int index = 0; index <
SIZE; index++) {
151 float expected_value = index;
152 EXPECT_FLOAT_EQ(
data[index * 4 + 0], expected_value);
153 EXPECT_FLOAT_EQ(
data[index * 4 + 1], expected_value);
154 EXPECT_FLOAT_EQ(
data[index * 4 + 2], expected_value);
155 EXPECT_FLOAT_EQ(
data[index * 4 + 3], expected_value);
171 EXPECT_NE(
shader,
nullptr);
187 for (
int index = 0; index <
SIZE; index++) {
188 uint32_t expected = index;
205 EXPECT_NE(
shader,
nullptr);
222 for (
int index = 0; index <
SIZE; index++) {
223 uint32_t expected = index * 4;
238 EXPECT_NE(
shader,
nullptr);
251 std::stringstream ss;
255 ss << *reinterpret_cast<const uint *>(&raw);
258 ss << *reinterpret_cast<const int *>(&raw);
261 ss << *reinterpret_cast<const float *>(&raw);
264 ss << *reinterpret_cast<const int2 *>(&raw);
267 ss << *reinterpret_cast<const int3 *>(&raw);
270 ss << *reinterpret_cast<const int4 *>(&raw);
273 ss << *reinterpret_cast<const uint2 *>(&raw);
276 ss << *reinterpret_cast<const uint3 *>(&raw);
279 ss << *reinterpret_cast<const uint4 *>(&raw);
282 ss << *reinterpret_cast<const float2 *>(&raw);
285 ss << *reinterpret_cast<const float3 *>(&raw);
288 ss << *reinterpret_cast<const float4 *>(&raw);
291 ss << *reinterpret_cast<const float2x2 *>(&raw);
294 ss << *reinterpret_cast<const float2x3 *>(&raw);
297 ss << *reinterpret_cast<const float2x4 *>(&raw);
300 ss << *reinterpret_cast<const float3x2 *>(&raw);
303 ss << *reinterpret_cast<const float3x3 *>(&raw);
306 ss << *reinterpret_cast<const float3x4 *>(&raw);
309 ss << *reinterpret_cast<const float4x2 *>(&raw);
312 ss << *reinterpret_cast<const float4x3 *>(&raw);
315 ss << *reinterpret_cast<const float4x4 *>(&raw);
318 ss << *reinterpret_cast<const MatBase<uint, 4, 4> *>(&raw);
331 while ((
pos = test_src.
find(
'\n',
pos)) != std::string::npos) {
332 if (line == test_line) {
333 return test_src.
substr(last_pos,
pos - last_pos);
351 if (additional_info) {
358 reinterpret_cast<GPUShaderCreateInfo *
>(&create_info));
364 while ((
pos = test_src.
find(target,
pos)) != std::string::npos) {
366 pos +=
sizeof(
"EXPECT_");
373 "tx", test_output_px_len, test_count, 1, TextureFormat::UINT_32_32_32_32, usage,
nullptr);
395 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)
void GPU_batch_discard(blender::gpu::Batch *batch)
void GPU_batch_draw(blender::gpu::Batch *batch)
blender::gpu::Batch * GPU_batch_create_procedural(GPUPrimType primitive_type, int32_t vertex_count)
void GPU_batch_set_shader(blender::gpu::Batch *batch, blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_compute_dispatch(blender::gpu::Shader *shader, uint groups_x_len, uint groups_y_len, uint groups_z_len, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
blender::gpu::FrameBuffer * GPU_framebuffer_create(const char *name)
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
void GPU_framebuffer_free(blender::gpu::FrameBuffer *fb)
#define GPU_framebuffer_ensure_config(_fb,...)
void GPU_framebuffer_bind(blender::gpu::FrameBuffer *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)
void GPU_shader_free(blender::gpu::Shader *shader)
blender::gpu::Shader * GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
int GPU_shader_get_sampler_binding(blender::gpu::Shader *shader, const char *name)
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
int GPU_shader_get_ssbo_binding(blender::gpu::Shader *shader, const char *name)
blender::gpu::Shader * GPU_shader_create_from_info_name(const char *info_name)
@ GPU_BARRIER_BUFFER_UPDATE
@ GPU_BARRIER_TEXTURE_UPDATE
void GPU_memory_barrier(GPUBarrier barrier)
void GPU_storagebuf_free(blender::gpu::StorageBuf *ssbo)
blender::gpu::StorageBuf * GPU_storagebuf_create_ex(size_t size, const void *data, GPUUsageType usage, const char *name)
void GPU_storagebuf_bind(blender::gpu::StorageBuf *ssbo, int slot)
void GPU_storagebuf_read(blender::gpu::StorageBuf *ssbo, void *data)
void GPU_texture_unbind(blender::gpu::Texture *texture)
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_GENERAL
void * GPU_texture_read(blender::gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
void GPU_texture_image_bind(blender::gpu::Texture *texture, int unit)
blender::gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(blender::gpu::Texture *texture)
blender::gpu::Texture * GPU_texture_create_1d(const char *name, int width, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
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 @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 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)