2 * Copyright (c) 2021 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 UtcDaliFrameBufferGetColorTexture01(void)
556 TestApplication application;
558 unsigned int width(64);
559 unsigned int height(64);
560 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
561 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
562 frameBuffer.AttachColorTexture(texture);
564 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
569 int UtcDaliFrameBufferGetColorTexture02(void)
571 TestApplication application;
573 unsigned int width(64);
574 unsigned int height(64);
575 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
576 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
577 frameBuffer.AttachColorTexture(texture, 0u, 1u);
579 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
584 int UtcDaliFrameBufferGetColorTexture03(void)
585 { // FrameBuffer::GetColorTexture() and GetColorTexture(0) are equivalent
586 TestApplication application;
588 unsigned int width(64);
589 unsigned int height(64);
590 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
591 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
592 frameBuffer.AttachColorTexture(texture, 0u, 1u);
594 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
595 DALI_TEST_EQUALS(DevelFrameBuffer::GetColorTexture(frameBuffer, 0), texture, TEST_LOCATION);
600 int UtcDaliFrameBufferGetColorTexture04(void)
602 TestApplication application;
604 unsigned int width(64);
605 unsigned int height(64);
606 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
607 Texture textures[] = {
608 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
609 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
610 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
611 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
612 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
613 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
614 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
615 Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height),
618 for(auto& t : textures)
620 frameBuffer.AttachColorTexture(t, 0u, 1u);
623 for(unsigned int i = 0; i < std::extent<decltype(textures)>::value; ++i)
625 DALI_TEST_EQUALS(DevelFrameBuffer::GetColorTexture(frameBuffer, i), textures[i], TEST_LOCATION);
631 int UtcDaliFrameBufferGetDepthTexture01(void)
633 TestApplication application;
635 unsigned int width(64);
636 unsigned int height(64);
637 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
638 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
639 frameBuffer.AttachColorTexture(texture);
641 Texture textureDepth = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_FLOAT, width, height);
642 DevelFrameBuffer::AttachDepthTexture(frameBuffer, textureDepth);
644 DALI_TEST_EQUALS(DevelFrameBuffer::GetDepthTexture(frameBuffer), textureDepth, TEST_LOCATION);
649 int UtcDaliFrameBufferGetDepthStencilTexture01(void)
651 TestApplication application;
653 unsigned int width(64);
654 unsigned int height(64);
655 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
656 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
657 frameBuffer.AttachColorTexture(texture);
659 Texture textureStencil = Texture::New(TextureType::TEXTURE_2D, Pixel::DEPTH_STENCIL, width, height);
660 DevelFrameBuffer::AttachDepthStencilTexture(frameBuffer, textureStencil);
662 DALI_TEST_EQUALS(DevelFrameBuffer::GetDepthStencilTexture(frameBuffer), textureStencil, TEST_LOCATION);
667 int UtcDaliFramebufferContextLoss(void)
669 tet_infoline("UtcDaliFramebufferContextLoss\n");
670 TestApplication application;
673 unsigned int width(64);
674 unsigned int height(64);
675 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
676 DALI_TEST_CHECK(texture);
677 FrameBuffer frameBuffer = FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
678 DALI_TEST_CHECK(frameBuffer);
679 frameBuffer.AttachColorTexture(texture, 0u, 1u);
681 Geometry geometry = CreateQuadGeometry();
682 Shader shader = CreateShader();
683 Renderer renderer = Renderer::New(geometry, shader);
685 application.SendNotification();
686 application.Render(16);
688 // Lose & regain context (in render 'thread')
689 application.ResetContext();
690 DALI_TEST_CHECK(frameBuffer);
695 int UtcDaliFrameBufferGetColorTextureNegative(void)
697 TestApplication application;
698 Dali::FrameBuffer instance;
701 instance.GetColorTexture();
702 DALI_TEST_CHECK(false); // Should not get here
706 DALI_TEST_CHECK(true); // We expect an assert
711 int UtcDaliFrameBufferAttachColorTextureNegative01(void)
713 TestApplication application;
714 Dali::FrameBuffer instance;
717 Dali::Texture arg1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 400u, 400u);
718 instance.AttachColorTexture(arg1);
719 DALI_TEST_CHECK(false); // Should not get here
723 DALI_TEST_CHECK(true); // We expect an assert
728 int UtcDaliFrameBufferAttachColorTextureNegative02(void)
730 TestApplication application;
731 Dali::FrameBuffer instance;
734 Dali::Texture arg1 = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 400u, 400u);
735 unsigned int arg2(0u);
736 unsigned int arg3(0u);
737 instance.AttachColorTexture(arg1, arg2, arg3);
738 DALI_TEST_CHECK(false); // Should not get here
742 DALI_TEST_CHECK(true); // We expect an assert