5#include "testing/testing.h"
30 const float4 clear_color(0.1f, 0.2f, 0.5f, 1.0f);
43GPU_TEST(framebuffer_clear_color_single_attachment);
60 const float4 clear_color(0.1f, 0.2f, 0.5f, 1.0f);
71 uint4 clear_color_uint(1036831949, 1045220557, 1056964608, 1065353216);
81GPU_TEST(framebuffer_clear_color_multiple_attachments);
98 const float4 clear_color[2] = {
float4(0.1f, 0.2f, 0.5f, 1.0f),
float4(0.5f, 0.2f, 0.1f, 1.0f)};
100 framebuffer,
static_cast<const float(*)[4]
>(
static_cast<const void *
>(clear_color)));
119GPU_TEST(framebuffer_clear_multiple_color_multiple_attachments);
132 const float clear_depth = 0.5f;
137 for (
float pixel_depth :
Span<float>(read_data, size.x * size.y)) {
150 const int bar_size = 16;
160 const float4 color1(0.0f);
161 const float4 color2(0.5f);
162 const float4 color3(1.0f);
166 for (
int x = 0; x < size.x; x += 2 * bar_size) {
170 for (
int y = 0; y < size.y; y += 2 * bar_size) {
180 int x = offset % size.x;
181 int y = offset / size.x;
182 int bar_x = x / bar_size;
183 int bar_y = y / bar_size;
185 if (bar_y % 2 == 0) {
189 if (bar_x % 2 == 0) {
215 const float4 clear_colors[6] = {
216 {0.5f, 0.0f, 0.0f, 1.0f},
217 {1.0f, 0.0f, 0.0f, 1.0f},
218 {0.0f, 0.5f, 0.0f, 1.0f},
219 {0.0f, 1.0f, 0.0f, 1.0f},
220 {0.0f, 0.0f, 0.5f, 1.0f},
221 {0.0f, 0.0f, 1.0f, 1.0f},
238 int index = pixel_index + (
SIZE *
SIZE) * side;
239 EXPECT_EQ(clear_colors[side], data[index]);
257 using namespace gpu::shader;
262 GTEST_SKIP() <<
"NVIDIA fails to compile workaround due to reserved names. Gladly it doesn't "
263 "need the workaround.";
269 const int layers = 256;
279 int viewport_rects[16][4];
280 for (
int i = 0; i < 16; i++) {
281 viewport_rects[i][0] = i % 4;
282 viewport_rects[i][1] = i / 4;
283 viewport_rects[i][2] = 1;
284 viewport_rects[i][3] = 1;
288 const float4 clear_color(0.0f);
292 create_info.
vertex_source(
"gpu_framebuffer_layer_viewport_test.glsl");
293 create_info.
fragment_source(
"gpu_framebuffer_layer_viewport_test.glsl");
294 create_info.
builtins(BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER);
298 reinterpret_cast<GPUShaderCreateInfo *
>(&create_info));
309 int tri_count = size.x * size.y * layers;
319 int2 expected_color(layer, viewport);
320 int2 pixel_color = read_data[viewport + layer * 16];
340 using namespace gpu::shader;
357 const float4 clear_color(0.0f);
361 create_info_write.
define(
"WRITE");
362 create_info_write.
vertex_source(
"gpu_framebuffer_subpass_input_test.glsl");
363 create_info_write.
fragment_source(
"gpu_framebuffer_subpass_input_test.glsl");
364 create_info_write.
fragment_out(0, Type::INT,
"out_value", DualBlend::NONE, 0);
367 reinterpret_cast<GPUShaderCreateInfo *
>(&create_info_write));
370 create_info_read.
define(
"READ");
371 create_info_read.
vertex_source(
"gpu_framebuffer_subpass_input_test.glsl");
372 create_info_read.
fragment_source(
"gpu_framebuffer_subpass_input_test.glsl");
373 create_info_read.
subpass_in(0, Type::INT,
"in_value", 0);
374 create_info_read.
fragment_out(1, Type::INT,
"out_value");
377 reinterpret_cast<GPUShaderCreateInfo *
>(&create_info_read));
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
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)
void GPU_batch_draw(blender::gpu::Batch *batch)
void GPU_framebuffer_multi_viewports_set(GPUFrameBuffer *gpu_fb, const int viewport_rects[GPU_MAX_VIEWPORTS][4])
GPUFrameBuffer * GPU_framebuffer_create(const char *name)
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_TEXTURE_CUBEFACE(_texture, _face)
#define GPU_ATTACHMENT_NONE
void GPU_framebuffer_multi_clear(GPUFrameBuffer *framebuffer, const float(*clear_colors)[4])
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_framebuffer_clear_color(GPUFrameBuffer *fb, const float clear_col[4])
#define GPU_framebuffer_ensure_config(_fb,...)
void GPU_framebuffer_clear_depth(GPUFrameBuffer *fb, float clear_depth)
void GPU_framebuffer_free(GPUFrameBuffer *framebuffer)
#define GPU_framebuffer_subpass_transition(_fb,...)
GPUShader * GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
void GPU_shader_free(GPUShader *shader)
void GPU_scissor_test(bool enable)
void GPU_scissor(int x, int y, int width, int height)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, 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)
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
GPUTexture * GPU_texture_create_2d_array(const char *name, int width, int height, int layer_len, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
GPUTexture * GPU_texture_create_cube(const char *name, int width, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
struct GPUShader GPUShader
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
GPUFrameBuffer * framebuffers[FRAMEBUFFER_STACK_DEPTH]
#define GPU_TEST(test_name)
void MEM_freeN(void *vmemh)
static void test_framebuffer_clear_depth()
static void test_framebuffer_clear_color_single_attachment()
static void test_framebuffer_clear_multiple_color_multiple_attachments()
static void test_framebuffer_cube()
static void test_framebuffer_subpass_input()
static void test_framebuffer_scissor_test()
static void test_framebuffer_multi_viewport()
static void test_framebuffer_clear_color_multiple_attachments()
VecBase< float, 4 > float4
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Self & fragment_source(StringRefNull filename)
Self & builtins(BuiltinBits builtin)
Self & fragment_out(int slot, Type type, StringRefNull name, DualBlend blend=DualBlend::NONE, int raster_order_group=-1)
Self & vertex_source(StringRefNull filename)
Self & subpass_in(int slot, Type type, StringRefNull name, int raster_order_group=-1)
Self & define(StringRefNull name, StringRefNull value="")