2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/rendering/frame-buffer-devel.h>
20 #include <dali/public-api/dali-core.h>
23 #include <mesh-builder.h>
24 #include <test-actor-utils.h>
26 void framebuffer_set_startup(void)
28 test_return_value = TET_UNDEF;
31 void framebuffer_set_cleanup(void)
33 test_return_value = TET_PASS;
36 RenderTask CreateRenderTask(TestApplication& application,
37 FrameBuffer framebuffer)
39 Actor rootActor = Actor::New();
40 application.GetScene().Add(rootActor);
41 Texture img = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
42 Actor sourceActor = CreateRenderableActor(img);
43 application.GetScene().Add(sourceActor);
45 CameraActor offscreenCameraActor = CameraActor::New(Size(TestApplication::DEFAULT_SURFACE_WIDTH,
46 TestApplication::DEFAULT_SURFACE_HEIGHT));
47 application.GetScene().Add(offscreenCameraActor);
49 // Change main render task to use a different root
50 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
51 taskList.GetTask(0u).SetSourceActor(rootActor);
53 RenderTask newTask = taskList.CreateTask();
54 newTask.SetCameraActor(offscreenCameraActor);
55 newTask.SetSourceActor(sourceActor);
56 newTask.SetInputEnabled(false);
57 newTask.SetClearColor(Vector4(0.f, 0.f, 0.f, 0.f));
58 newTask.SetClearEnabled(true);
59 newTask.SetExclusive(true);
60 newTask.SetFrameBuffer(framebuffer);
65 int UtcDaliFrameBufferNew01(void)
67 TestApplication application;
69 unsigned int width(64);
70 unsigned int height(64);
71 FrameBuffer framebuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
73 DALI_TEST_CHECK(framebuffer);
75 CreateRenderTask(application, framebuffer);
77 application.SendNotification();
80 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
81 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
82 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
87 int UtcDaliFrameBufferNew02(void)
89 TestApplication application;
91 unsigned int width(64);
92 unsigned int height(64);
93 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH);
94 DALI_TEST_CHECK(frameBuffer);
95 Texture depthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_FLOAT, width, height);
96 DevelFrameBuffer::AttachDepthTexture(frameBuffer, depthTexture);
98 CreateRenderTask(application, frameBuffer);
100 application.SendNotification();
101 application.Render();
103 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
104 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
105 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
110 int UtcDaliFrameBufferNew03(void)
112 TestApplication application;
114 unsigned int width(64);
115 unsigned int height(64);
116 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::STENCIL);
117 DALI_TEST_CHECK(frameBuffer);
118 Texture stencilTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
119 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, stencilTexture);
120 CreateRenderTask(application, frameBuffer);
122 application.SendNotification();
123 application.Render();
125 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
126 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
127 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
132 int UtcDaliFrameBufferNew04(void)
134 TestApplication application;
136 unsigned int width(64);
137 unsigned int height(64);
138 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
139 DALI_TEST_CHECK(frameBuffer);
141 Texture stencilTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
142 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, stencilTexture);
143 CreateRenderTask(application, frameBuffer);
145 application.SendNotification();
146 application.Render();
148 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
149 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
150 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
155 int UtcDaliFrameBufferNew05(void)
157 TestApplication application;
158 FrameBuffer frameBuffer;
159 DALI_TEST_CHECK(!frameBuffer);
163 int UtcDaliFrameBufferNew06(void)
165 TestApplication application;
167 unsigned int width(64);
168 unsigned int height(64);
169 FrameBuffer frameBuffer = FrameBuffer::New(width, height, static_cast<FrameBuffer::Attachment::Mask>(FrameBuffer::Attachment::DEPTH | FrameBuffer::Attachment::STENCIL));
170 DALI_TEST_CHECK(frameBuffer);
172 Texture stencilTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
173 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, stencilTexture);
174 CreateRenderTask(application, frameBuffer);
176 application.SendNotification();
177 application.Render();
179 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 0u, TEST_LOCATION);
180 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
181 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
186 int UtcDaliFrameBufferNewWithColor01(void)
188 TestApplication application;
190 uint32_t height = 64;
191 FrameBuffer frameBuffer = FrameBuffer::New(width, height);
193 CreateRenderTask(application, frameBuffer);
194 application.SendNotification();
195 application.Render();
196 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
197 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
198 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
199 // check that texture is not empty handle
200 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
204 int UtcDaliFrameBufferNewWithColor02(void)
206 TestApplication application;
208 uint32_t height = 64;
209 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR);
210 CreateRenderTask(application, frameBuffer);
211 application.SendNotification();
212 application.Render();
213 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
214 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
215 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
216 // check that texture is not empty handle
217 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
221 int UtcDaliFrameBufferNewWithColor03(void)
223 TestApplication application;
225 uint32_t height = 64;
226 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR_DEPTH);
228 Texture depthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_UNSIGNED_INT, width, height);
229 DevelFrameBuffer::AttachDepthTexture(frameBuffer, depthTexture);
230 CreateRenderTask(application, frameBuffer);
232 application.SendNotification();
233 application.Render();
234 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
235 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
236 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
237 // check that texture is not empty handle
238 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
242 int UtcDaliFrameBufferNewWithColor04(void)
244 TestApplication application;
246 uint32_t height = 64;
247 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR_STENCIL);
248 Texture depthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
249 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, depthTexture);
250 CreateRenderTask(application, frameBuffer);
251 application.SendNotification();
252 application.Render();
253 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
254 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
255 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
256 // check that texture is not empty handle
257 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
261 int UtcDaliFrameBufferNewWithColor05(void)
263 TestApplication application;
265 uint32_t height = 64;
267 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::COLOR_DEPTH_STENCIL);
268 Texture depthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
269 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, depthTexture);
270 CreateRenderTask(application, frameBuffer);
272 application.SendNotification();
273 application.Render();
274 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
275 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
276 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
277 // check that texture is not empty handle
278 DALI_TEST_CHECK(frameBuffer.GetColorTexture());
282 int UtcDaliFrameBufferCopyConstructor(void)
284 TestApplication application;
286 unsigned int width(64);
287 unsigned int height(64);
288 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
290 FrameBuffer frameBufferCopy(frameBuffer);
292 DALI_TEST_CHECK(frameBufferCopy);
297 int UtcDaliFrameBufferAssignmentOperator(void)
299 TestApplication application;
301 unsigned int width(64);
302 unsigned int height(64);
303 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
305 FrameBuffer frameBuffer2;
306 DALI_TEST_CHECK(!frameBuffer2);
308 frameBuffer2 = frameBuffer;
309 DALI_TEST_CHECK(frameBuffer2);
314 int UtcDaliFrameBufferMoveConstructor(void)
316 TestApplication application;
319 uint32_t height = 64;
320 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
321 DALI_TEST_CHECK(frameBuffer);
322 DALI_TEST_EQUALS(1, frameBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
324 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
325 frameBuffer.AttachColorTexture(texture);
326 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
328 FrameBuffer move = std::move(frameBuffer);
329 DALI_TEST_CHECK(move);
330 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
331 DALI_TEST_EQUALS(move.GetColorTexture(), texture, TEST_LOCATION);
332 DALI_TEST_CHECK(!frameBuffer);
337 int UtcDaliFrameBufferMoveAssignment(void)
339 TestApplication application;
342 uint32_t height = 64;
343 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
344 DALI_TEST_CHECK(frameBuffer);
345 DALI_TEST_EQUALS(1, frameBuffer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
347 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
348 frameBuffer.AttachColorTexture(texture);
349 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
352 move = std::move(frameBuffer);
353 DALI_TEST_CHECK(move);
354 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
355 DALI_TEST_EQUALS(move.GetColorTexture(), texture, TEST_LOCATION);
356 DALI_TEST_CHECK(!frameBuffer);
361 int UtcDaliFrameBufferDownCast01(void)
363 TestApplication application;
364 unsigned int width(64);
365 unsigned int height(64);
366 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
368 BaseHandle handle(frameBuffer);
369 FrameBuffer frameBuffer2 = FrameBuffer::DownCast(handle);
370 DALI_TEST_CHECK(frameBuffer2);
375 int UtcDaliFrameBufferDownCast02(void)
377 TestApplication application;
379 Handle handle = Handle::New(); // Create a custom object
380 FrameBuffer frameBuffer = FrameBuffer::DownCast(handle);
381 DALI_TEST_CHECK(!frameBuffer);
385 int UtcDaliFrameBufferAttachColorTexture01(void)
387 TestApplication application;
389 unsigned int width(64);
390 unsigned int height(64);
391 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
392 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
393 CreateRenderTask(application, frameBuffer);
394 frameBuffer.AttachColorTexture(texture);
396 Texture depthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
397 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, depthTexture);
398 CreateRenderTask(application, frameBuffer);
400 application.SendNotification();
401 application.Render();
403 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
404 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
405 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
410 int UtcDaliFrameBufferAttachColorTexture02(void)
412 TestApplication application;
414 unsigned int width(64);
415 unsigned int height(64);
416 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
417 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
418 texture.GenerateMipmaps();
421 frameBuffer.AttachColorTexture(texture, 0u, 1u);
422 CreateRenderTask(application, frameBuffer);
424 application.SendNotification();
425 application.Render();
427 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
428 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
429 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
434 int UtcDaliFrameBufferAttachColorTexture03(void)
436 TestApplication application;
438 unsigned int width(64);
439 unsigned int height(64);
440 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
441 Texture texture = Texture::New(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
442 texture.GenerateMipmaps();
444 //Attach NEGATIVE_Y face of the cubemap
445 frameBuffer.AttachColorTexture(texture, 0u, CubeMapLayer::NEGATIVE_Y);
446 CreateRenderTask(application, frameBuffer);
448 application.SendNotification();
449 application.Render();
451 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
452 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
453 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
458 int UtcDaliFrameBufferAttachColorTexture04(void)
460 TestApplication application;
462 unsigned int width(64);
463 unsigned int height(64);
464 FrameBuffer frameBuffer = FrameBuffer::New(width, height, static_cast<FrameBuffer::Attachment::Mask>(FrameBuffer::Attachment::DEPTH | FrameBuffer::Attachment::STENCIL));
465 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
466 frameBuffer.AttachColorTexture(texture);
468 Texture depthTexture = CreateTexture(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
469 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, depthTexture);
470 CreateRenderTask(application, frameBuffer);
472 application.SendNotification();
473 application.Render();
475 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
476 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
477 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
482 int UtcDaliFrameBufferAttachColorTexture05(void)
484 TestApplication application;
486 unsigned int width(64);
487 unsigned int height(64);
488 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
489 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
491 // N.B. it doesn't make sense per se, however the OGL standard doesn't seem to forbid attaching the same texture to different slots.
492 for(int i = 0; i < Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS + 1; ++i)
494 frameBuffer.AttachColorTexture(texture);
496 CreateRenderTask(application, frameBuffer);
497 application.SendNotification();
498 application.Render();
500 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS, TEST_LOCATION);
501 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
502 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
507 int UtcDaliFrameBufferAttachDepthTexture01(void)
509 TestApplication application;
511 unsigned int width(64);
512 unsigned int height(64);
513 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH);
514 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
515 frameBuffer.AttachColorTexture(texture);
517 Texture textureDepth = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_UNSIGNED_INT, width, height);
518 DevelFrameBuffer::AttachDepthTexture(frameBuffer, textureDepth);
519 CreateRenderTask(application, frameBuffer);
520 application.SendNotification();
521 application.Render();
523 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
524 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
525 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
530 int UtcDaliFrameBufferAttachDepthStencilTexture01(void)
532 TestApplication application;
534 unsigned int width(64);
535 unsigned int height(64);
536 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
537 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
538 frameBuffer.AttachColorTexture(texture);
540 Texture textureStencil = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
541 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, textureStencil);
543 CreateRenderTask(application, frameBuffer);
544 application.SendNotification();
545 application.Render();
547 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
548 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
549 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
554 int UtcDaliFrameBufferSetMultiSampingLevel(void)
556 TestApplication application;
558 unsigned int width(64);
559 unsigned int height(64);
560 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::DEPTH_STENCIL);
561 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
562 frameBuffer.AttachColorTexture(texture);
564 DevelFrameBuffer::SetMultiSamplingLevel(frameBuffer, 4u);
566 CreateRenderTask(application, frameBuffer);
567 application.SendNotification();
568 application.Render();
570 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachmentCount(), 1u, TEST_LOCATION);
571 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
572 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
574 // We don't have getter API for multisampling level. No testing.
579 int UtcDaliFrameBufferGetColorTexture01(void)
581 TestApplication application;
583 unsigned int width(64);
584 unsigned int height(64);
585 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
586 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
587 frameBuffer.AttachColorTexture(texture);
589 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
594 int UtcDaliFrameBufferGetColorTexture02(void)
596 TestApplication application;
598 unsigned int width(64);
599 unsigned int height(64);
600 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
601 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
602 frameBuffer.AttachColorTexture(texture, 0u, 1u);
604 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
609 int UtcDaliFrameBufferGetColorTexture03(void)
610 { // FrameBuffer::GetColorTexture() and GetColorTexture(0) are equivalent
611 TestApplication application;
613 unsigned int width(64);
614 unsigned int height(64);
615 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
616 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
617 frameBuffer.AttachColorTexture(texture, 0u, 1u);
619 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
620 DALI_TEST_EQUALS(DevelFrameBuffer::GetColorTexture(frameBuffer, 0), texture, TEST_LOCATION);
625 int UtcDaliFrameBufferGetColorTexture04(void)
627 TestApplication application;
629 unsigned int width(64);
630 unsigned int height(64);
631 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
632 Texture textures[] = {
633 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
634 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
635 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
636 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
637 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
638 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
639 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
640 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
643 for(auto& t : textures)
645 frameBuffer.AttachColorTexture(t, 0u, 1u);
648 for(unsigned int i = 0; i < std::extent<decltype(textures)>::value; ++i)
650 DALI_TEST_EQUALS(DevelFrameBuffer::GetColorTexture(frameBuffer, i), textures[i], TEST_LOCATION);
656 int UtcDaliFrameBufferGetDepthTexture01(void)
658 TestApplication application;
660 unsigned int width(64);
661 unsigned int height(64);
662 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
663 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
664 frameBuffer.AttachColorTexture(texture);
666 Texture textureDepth = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_FLOAT, width, height);
667 DevelFrameBuffer::AttachDepthTexture(frameBuffer, textureDepth);
669 DALI_TEST_EQUALS(DevelFrameBuffer::GetDepthTexture(frameBuffer), textureDepth, TEST_LOCATION);
674 int UtcDaliFrameBufferGetDepthStencilTexture01(void)
676 TestApplication application;
678 unsigned int width(64);
679 unsigned int height(64);
680 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
681 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
682 frameBuffer.AttachColorTexture(texture);
684 Texture textureStencil = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
685 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, textureStencil);
687 DALI_TEST_EQUALS(DevelFrameBuffer::GetDepthStencilTexture(frameBuffer), textureStencil, TEST_LOCATION);
692 int UtcDaliFramebufferContextLoss(void)
694 tet_infoline("UtcDaliFramebufferContextLoss\n");
695 TestApplication application;
698 unsigned int width(64);
699 unsigned int height(64);
700 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
701 DALI_TEST_CHECK(texture);
702 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
703 DALI_TEST_CHECK(frameBuffer);
704 frameBuffer.AttachColorTexture(texture, 0u, 1u);
706 Geometry geometry = CreateQuadGeometry();
707 Shader shader = CreateShader();
708 Renderer renderer = Renderer::New(geometry, shader);
710 application.SendNotification();
711 application.Render(16);
713 // Lose & regain context (in render 'thread')
714 application.ResetContext();
715 DALI_TEST_CHECK(frameBuffer);
720 int UtcDaliFrameBufferGetColorTextureNegative(void)
722 TestApplication application;
723 Dali::FrameBuffer instance;
726 instance.GetColorTexture();
727 DALI_TEST_CHECK(false); // Should not get here
731 DALI_TEST_CHECK(true); // We expect an assert
736 int UtcDaliFrameBufferAttachColorTextureNegative01(void)
738 TestApplication application;
739 Dali::FrameBuffer instance;
742 Dali::Texture arg1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 400u, 400u);
743 instance.AttachColorTexture(arg1);
744 DALI_TEST_CHECK(false); // Should not get here
748 DALI_TEST_CHECK(true); // We expect an assert
753 int UtcDaliFrameBufferAttachColorTextureNegative02(void)
755 TestApplication application;
756 Dali::FrameBuffer instance;
759 Dali::Texture arg1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 400u, 400u);
760 unsigned int arg2(0u);
761 unsigned int arg3(0u);
762 instance.AttachColorTexture(arg1, arg2, arg3);
763 DALI_TEST_CHECK(false); // Should not get here
767 DALI_TEST_CHECK(true); // We expect an assert