Updated visuals to use VisualRenderer
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-controller.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "test-graphics-controller.h"
18
19 #include "test-graphics-buffer.h"
20 #include "test-graphics-command-buffer.h"
21 #include "test-graphics-framebuffer.h"
22 #include "test-graphics-reflection.h"
23 #include "test-graphics-render-pass.h"
24 #include "test-graphics-render-target.h"
25 #include "test-graphics-sampler.h"
26 #include "test-graphics-shader.h"
27 #include "test-graphics-sync-object.h"
28 #include "test-graphics-texture.h"
29
30 #include <dali/integration-api/gl-defines.h>
31 #include <cstdio>
32 #include <iostream>
33 #include <sstream>
34
35 namespace Dali
36 {
37 std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo)
38 {
39   return o << "usage:" << std::hex << bufferCreateInfo.usage << ", size:" << std::dec << bufferCreateInfo.size;
40 }
41
42 std::ostream& operator<<(std::ostream& o, const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo)
43 {
44   return o << "level:" << (commandBufferCreateInfo.level == Graphics::CommandBufferLevel::PRIMARY ? "PRIMARY" : "SECONDARY")
45            << ", fixedCapacity:" << std::dec << commandBufferCreateInfo.fixedCapacity;
46 }
47
48 std::ostream& operator<<(std::ostream& o, const Graphics::TextureType& textureType)
49 {
50   switch(textureType)
51   {
52     case Graphics::TextureType::TEXTURE_2D:
53       o << "TEXTURE_2D";
54       break;
55     case Graphics::TextureType::TEXTURE_3D:
56       o << "TEXTURE_3D";
57       break;
58     case Graphics::TextureType::TEXTURE_CUBEMAP:
59       o << "TEXTURE_CUBEMAP";
60       break;
61   }
62   return o;
63 }
64
65 std::ostream& operator<<(std::ostream& o, const Graphics::Extent2D extent)
66 {
67   o << "width:" << extent.width << ", height:" << extent.height;
68   return o;
69 }
70
71 std::ostream& operator<<(std::ostream& o, const Graphics::TextureCreateInfo& createInfo)
72 {
73   o << "textureType:" << createInfo.textureType
74     << " size:" << createInfo.size
75     << " format:" << static_cast<uint32_t>(createInfo.format)
76     << " mipMapFlag:" << createInfo.mipMapFlag
77     << " layout:" << (createInfo.layout == Graphics::TextureLayout::LINEAR ? "LINEAR" : "OPTIMAL")
78     << " usageFlags:" << std::hex << createInfo.usageFlags
79     << " data:" << std::hex << createInfo.data
80     << " dataSize:" << std::dec << createInfo.dataSize
81     << " nativeImagePtr:" << std::hex << createInfo.nativeImagePtr.Get();
82   return o;
83 }
84
85 std::ostream& operator<<(std::ostream& o, Graphics::SamplerAddressMode addressMode)
86 {
87   switch(addressMode)
88   {
89     case Graphics::SamplerAddressMode::REPEAT:
90       o << "REPEAT";
91       break;
92     case Graphics::SamplerAddressMode::MIRRORED_REPEAT:
93       o << "MIRRORED_REPEAT";
94       break;
95     case Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
96       o << "CLAMP_TO_EDGE";
97       break;
98     case Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
99       o << "CLAMP_TO_BORDER";
100       break;
101     case Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
102       o << "MIRROR_CLAMP_TO_EDGE";
103       break;
104   }
105   return o;
106 }
107
108 std::ostream& operator<<(std::ostream& o, Graphics::SamplerFilter filterMode)
109 {
110   switch(filterMode)
111   {
112     case Graphics::SamplerFilter::LINEAR:
113       o << "LINEAR";
114       break;
115     case Graphics::SamplerFilter::NEAREST:
116       o << "NEAREST";
117       break;
118   }
119   return o;
120 }
121
122 std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode)
123 {
124   switch(mipmapMode)
125   {
126     case Graphics::SamplerMipmapMode::NONE:
127       o << "NONE";
128       break;
129     case Graphics::SamplerMipmapMode::LINEAR:
130       o << "LINEAR";
131       break;
132     case Graphics::SamplerMipmapMode::NEAREST:
133       o << "NEAREST";
134       break;
135   }
136   return o;
137 }
138
139 std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo)
140 {
141   o << "minFilter:" << createInfo.minFilter
142     << " magFilter:" << createInfo.magFilter
143     << " wrapModeU:" << createInfo.addressModeU
144     << " wrapModeV:" << createInfo.addressModeV
145     << " wrapModeW:" << createInfo.addressModeW
146     << " mipMapMode:" << createInfo.mipMapMode;
147   return o;
148 }
149
150 std::ostream& operator<<(std::ostream& o, const Graphics::ColorAttachment& colorAttachment)
151 {
152   o << "attachmentId:" << colorAttachment.attachmentId
153     << " layerId:" << colorAttachment.layerId
154     << " levelId:" << colorAttachment.levelId
155     << " texture:" << colorAttachment.texture;
156   return o;
157 }
158
159 std::ostream& operator<<(std::ostream& o, const Graphics::DepthStencilAttachment& depthStencilAttachment)
160 {
161   o << "depthTexture:" << depthStencilAttachment.depthTexture
162     << "depthLevel:" << depthStencilAttachment.depthLevel
163     << "stencilTexture:" << depthStencilAttachment.stencilTexture
164     << "stencilLevel:" << depthStencilAttachment.stencilLevel;
165   return o;
166 }
167
168 std::ostream& operator<<(std::ostream& o, const Graphics::FramebufferCreateInfo& createInfo)
169 {
170   o << "colorAttachments:";
171   for(auto i = 0u; i < createInfo.colorAttachments.size(); ++i)
172   {
173     o << "[" << i << "]=" << createInfo.colorAttachments[i] << "  ";
174   }
175   o << "depthStencilAttachment:" << createInfo.depthStencilAttachment;
176   o << "size: " << createInfo.size;
177   return o;
178 }
179
180 int GetNumComponents(Graphics::VertexInputFormat vertexFormat)
181 {
182   switch(vertexFormat)
183   {
184     case Graphics::VertexInputFormat::UNDEFINED:
185     case Graphics::VertexInputFormat::FLOAT:
186     case Graphics::VertexInputFormat::INTEGER:
187       return 1;
188     case Graphics::VertexInputFormat::IVECTOR2:
189     case Graphics::VertexInputFormat::FVECTOR2:
190       return 2;
191     case Graphics::VertexInputFormat::IVECTOR3:
192     case Graphics::VertexInputFormat::FVECTOR3:
193       return 3;
194     case Graphics::VertexInputFormat::FVECTOR4:
195     case Graphics::VertexInputFormat::IVECTOR4:
196       return 4;
197   }
198   return 1;
199 }
200
201 GLint GetSize(Graphics::VertexInputFormat vertexFormat)
202 {
203   switch(vertexFormat)
204   {
205     case Graphics::VertexInputFormat::UNDEFINED:
206       return 1u;
207     case Graphics::VertexInputFormat::INTEGER:
208     case Graphics::VertexInputFormat::IVECTOR2:
209     case Graphics::VertexInputFormat::IVECTOR3:
210     case Graphics::VertexInputFormat::IVECTOR4:
211       return 2u;
212     case Graphics::VertexInputFormat::FLOAT:
213     case Graphics::VertexInputFormat::FVECTOR2:
214     case Graphics::VertexInputFormat::FVECTOR3:
215     case Graphics::VertexInputFormat::FVECTOR4:
216       return 4u;
217   }
218   return 1u;
219 }
220
221 GLint GetGlType(Graphics::VertexInputFormat vertexFormat)
222 {
223   switch(vertexFormat)
224   {
225     case Graphics::VertexInputFormat::UNDEFINED:
226       return GL_BYTE;
227     case Graphics::VertexInputFormat::INTEGER:
228     case Graphics::VertexInputFormat::IVECTOR2:
229     case Graphics::VertexInputFormat::IVECTOR3:
230     case Graphics::VertexInputFormat::IVECTOR4:
231       return GL_SHORT;
232     case Graphics::VertexInputFormat::FLOAT:
233     case Graphics::VertexInputFormat::FVECTOR2:
234     case Graphics::VertexInputFormat::FVECTOR3:
235     case Graphics::VertexInputFormat::FVECTOR4:
236       return GL_FLOAT;
237   }
238   return GL_BYTE;
239 }
240
241 GLenum GetTopology(Graphics::PrimitiveTopology topology)
242 {
243   switch(topology)
244   {
245     case Graphics::PrimitiveTopology::POINT_LIST:
246       return GL_POINTS;
247
248     case Graphics::PrimitiveTopology::LINE_LIST:
249       return GL_LINES;
250
251     case Graphics::PrimitiveTopology::LINE_LOOP:
252       return GL_LINE_LOOP;
253
254     case Graphics::PrimitiveTopology::LINE_STRIP:
255       return GL_LINE_STRIP;
256
257     case Graphics::PrimitiveTopology::TRIANGLE_LIST:
258       return GL_TRIANGLES;
259
260     case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
261       return GL_TRIANGLE_STRIP;
262
263     case Graphics::PrimitiveTopology::TRIANGLE_FAN:
264       return GL_TRIANGLE_FAN;
265   }
266   return GL_TRIANGLES;
267 }
268
269 GLenum GetCullFace(Graphics::CullMode cullMode)
270 {
271   switch(cullMode)
272   {
273     case Graphics::CullMode::NONE:
274       return GL_NONE;
275     case Graphics::CullMode::FRONT:
276       return GL_FRONT;
277     case Graphics::CullMode::BACK:
278       return GL_BACK;
279     case Graphics::CullMode::FRONT_AND_BACK:
280       return GL_FRONT_AND_BACK;
281   }
282   return GL_NONE;
283 }
284
285 GLenum GetFrontFace(Graphics::FrontFace frontFace)
286 {
287   if(frontFace == Graphics::FrontFace::CLOCKWISE)
288   {
289     return GL_CW;
290   }
291   return GL_CCW;
292 }
293
294 GLenum GetBlendFactor(Graphics::BlendFactor blendFactor)
295 {
296   GLenum glFactor = GL_ZERO;
297
298   switch(blendFactor)
299   {
300     case Graphics::BlendFactor::ZERO:
301       glFactor = GL_ZERO;
302       break;
303     case Graphics::BlendFactor::ONE:
304       glFactor = GL_ONE;
305       break;
306     case Graphics::BlendFactor::SRC_COLOR:
307       glFactor = GL_SRC_COLOR;
308       break;
309     case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
310       glFactor = GL_ONE_MINUS_SRC_COLOR;
311       break;
312     case Graphics::BlendFactor::DST_COLOR:
313       glFactor = GL_DST_COLOR;
314       break;
315     case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
316       glFactor = GL_ONE_MINUS_DST_COLOR;
317       break;
318     case Graphics::BlendFactor::SRC_ALPHA:
319       glFactor = GL_SRC_ALPHA;
320       break;
321     case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
322       glFactor = GL_ONE_MINUS_SRC_ALPHA;
323       break;
324     case Graphics::BlendFactor::DST_ALPHA:
325       glFactor = GL_DST_ALPHA;
326       break;
327     case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
328       glFactor = GL_ONE_MINUS_DST_ALPHA;
329       break;
330     case Graphics::BlendFactor::CONSTANT_COLOR:
331       glFactor = GL_CONSTANT_COLOR;
332       break;
333     case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
334       glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
335       break;
336     case Graphics::BlendFactor::CONSTANT_ALPHA:
337       glFactor = GL_CONSTANT_ALPHA;
338       break;
339     case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
340       glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
341       break;
342     case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
343       glFactor = GL_SRC_ALPHA_SATURATE;
344       break;
345       // GLES doesn't appear to have dual source blending.
346     case Graphics::BlendFactor::SRC1_COLOR:
347       glFactor = GL_SRC_COLOR;
348       break;
349     case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
350       glFactor = GL_ONE_MINUS_SRC_COLOR;
351       break;
352     case Graphics::BlendFactor::SRC1_ALPHA:
353       glFactor = GL_SRC_ALPHA;
354       break;
355     case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
356       glFactor = GL_ONE_MINUS_SRC_ALPHA;
357       break;
358   }
359   return glFactor;
360 }
361
362 GLenum GetBlendOp(Graphics::BlendOp blendOp)
363 {
364   GLenum op = GL_FUNC_ADD;
365   switch(blendOp)
366   {
367     case Graphics::BlendOp::ADD:
368       op = GL_FUNC_ADD;
369       break;
370     case Graphics::BlendOp::SUBTRACT:
371       op = GL_FUNC_SUBTRACT;
372       break;
373     case Graphics::BlendOp::REVERSE_SUBTRACT:
374       op = GL_FUNC_REVERSE_SUBTRACT;
375       break;
376     case Graphics::BlendOp::MIN:
377       op = GL_MIN;
378       break;
379     case Graphics::BlendOp::MAX:
380       op = GL_MAX;
381       break;
382     case Graphics::BlendOp::MULTIPLY:
383     {
384       op = GL_MULTIPLY;
385       break;
386     }
387     case Graphics::BlendOp::SCREEN:
388     {
389       op = GL_SCREEN;
390       break;
391     }
392     case Graphics::BlendOp::OVERLAY:
393     {
394       op = GL_OVERLAY;
395       break;
396     }
397     case Graphics::BlendOp::DARKEN:
398     {
399       op = GL_DARKEN;
400       break;
401     }
402     case Graphics::BlendOp::LIGHTEN:
403     {
404       op = GL_LIGHTEN;
405       break;
406     }
407     case Graphics::BlendOp::COLOR_DODGE:
408     {
409       op = GL_COLORDODGE;
410       break;
411     }
412     case Graphics::BlendOp::COLOR_BURN:
413     {
414       op = GL_COLORBURN;
415       break;
416     }
417     case Graphics::BlendOp::HARD_LIGHT:
418     {
419       op = GL_HARDLIGHT;
420       break;
421     }
422     case Graphics::BlendOp::SOFT_LIGHT:
423     {
424       op = GL_SOFTLIGHT;
425       break;
426     }
427     case Graphics::BlendOp::DIFFERENCE:
428     {
429       op = GL_DIFFERENCE;
430       break;
431     }
432     case Graphics::BlendOp::EXCLUSION:
433     {
434       op = GL_EXCLUSION;
435       break;
436     }
437     case Graphics::BlendOp::HUE:
438     {
439       op = GL_HSL_HUE;
440       break;
441     }
442     case Graphics::BlendOp::SATURATION:
443     {
444       op = GL_HSL_SATURATION;
445       break;
446     }
447     case Graphics::BlendOp::COLOR:
448     {
449       op = GL_HSL_COLOR;
450       break;
451     }
452     case Graphics::BlendOp::LUMINOSITY:
453     {
454       op = GL_HSL_LUMINOSITY;
455       break;
456     }
457   }
458   return op;
459 }
460
461 struct GLCompareOp
462 {
463   constexpr explicit GLCompareOp(Graphics::CompareOp compareOp)
464   {
465     switch(compareOp)
466     {
467       case Graphics::CompareOp::NEVER:
468         op = GL_NEVER;
469         break;
470       case Graphics::CompareOp::LESS:
471         op = GL_LESS;
472         break;
473       case Graphics::CompareOp::EQUAL:
474         op = GL_EQUAL;
475         break;
476       case Graphics::CompareOp::LESS_OR_EQUAL:
477         op = GL_LEQUAL;
478         break;
479       case Graphics::CompareOp::GREATER:
480         op = GL_GREATER;
481         break;
482       case Graphics::CompareOp::NOT_EQUAL:
483         op = GL_NOTEQUAL;
484         break;
485       case Graphics::CompareOp::GREATER_OR_EQUAL:
486         op = GL_GEQUAL;
487         break;
488       case Graphics::CompareOp::ALWAYS:
489         op = GL_ALWAYS;
490         break;
491     }
492   }
493   GLenum op{GL_LESS};
494 };
495
496 struct GLStencilOp
497 {
498   constexpr explicit GLStencilOp(Graphics::StencilOp stencilOp)
499   {
500     switch(stencilOp)
501     {
502       case Graphics::StencilOp::KEEP:
503         op = GL_KEEP;
504         break;
505       case Graphics::StencilOp::ZERO:
506         op = GL_ZERO;
507         break;
508       case Graphics::StencilOp::REPLACE:
509         op = GL_REPLACE;
510         break;
511       case Graphics::StencilOp::INCREMENT_AND_CLAMP:
512         op = GL_INCR;
513         break;
514       case Graphics::StencilOp::DECREMENT_AND_CLAMP:
515         op = GL_DECR;
516         break;
517       case Graphics::StencilOp::INVERT:
518         op = GL_INVERT;
519         break;
520       case Graphics::StencilOp::INCREMENT_AND_WRAP:
521         op = GL_INCR_WRAP;
522         break;
523       case Graphics::StencilOp::DECREMENT_AND_WRAP:
524         op = GL_DECR_WRAP;
525         break;
526     }
527   }
528   GLenum op{GL_KEEP};
529 };
530
531 class TestGraphicsMemory : public Graphics::Memory
532 {
533 public:
534   TestGraphicsMemory(TraceCallStack& callStack, TestGraphicsBuffer& buffer, uint32_t mappedOffset, uint32_t mappedSize)
535   : mCallStack(callStack),
536     mBuffer(buffer),
537     mMappedOffset(mappedOffset),
538     mMappedSize(mappedSize),
539     mLockedOffset(0u),
540     mLockedSize(0u)
541   {
542   }
543
544   void* LockRegion(uint32_t offset, uint32_t size) override
545   {
546     std::ostringstream o;
547     o << offset << ", " << size;
548     mCallStack.PushCall("Memory::LockRegion", o.str());
549
550     if(offset > mMappedOffset + mMappedSize ||
551        size + offset > mMappedOffset + mMappedSize)
552     {
553       fprintf(stderr, "TestGraphics.Memory::LockRegion() Out of bounds");
554       mBuffer.memory.resize(mMappedOffset + offset + size); // Grow to prevent memcpy from crashing
555     }
556     mLockedOffset = offset;
557     mLockedSize   = size;
558     return &mBuffer.memory[mMappedOffset + offset];
559   }
560
561   void Unlock(bool flush) override
562   {
563     mCallStack.PushCall("Memory::Unlock", (flush ? "Flush" : "NoFlush"));
564     if(flush)
565     {
566       Flush();
567     }
568   }
569
570   void Flush() override
571   {
572     mCallStack.PushCall("Memory::Flush", "");
573     mBuffer.Bind();
574     mBuffer.Upload(mMappedOffset + mLockedOffset, mLockedSize);
575     mBuffer.Unbind();
576   }
577
578   TraceCallStack&     mCallStack;
579   TestGraphicsBuffer& mBuffer;
580   uint32_t            mMappedOffset;
581   uint32_t            mMappedSize;
582   uint32_t            mLockedOffset;
583   uint32_t            mLockedSize;
584 };
585
586 TestGraphicsController::TestGraphicsController()
587 : mCallStack(false, "TestGraphicsController."),
588   mCommandBufferCallStack(false, "TestCommandBuffer."),
589   mFrameBufferCallStack(false, "TestFrameBuffer.")
590 {
591   mCallStack.Enable(true);
592   mCommandBufferCallStack.Enable(true);
593   auto& trace = mGl.GetTextureTrace();
594   trace.Enable(true);
595   trace.EnableLogging(false);
596 }
597
598 void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
599 {
600   TraceCallStack::NamedParams namedParams;
601   namedParams["submitInfo"] << "cmdBuffer[" << submitInfo.cmdBuffer.size()
602                             << "], flags:" << std::hex << submitInfo.flags;
603
604   mCallStack.PushCall("SubmitCommandBuffers", "", namedParams);
605
606   mSubmitStack.emplace_back(submitInfo);
607
608   for(auto& graphicsCommandBuffer : submitInfo.cmdBuffer)
609   {
610     auto commandBuffer = Uncast<TestGraphicsCommandBuffer>(graphicsCommandBuffer);
611     ProcessCommandBuffer(*commandBuffer);
612   }
613 }
614
615 void TestGraphicsController::ProcessCommandBuffer(TestGraphicsCommandBuffer& commandBuffer)
616 {
617   bool                     scissorEnabled = false;
618   TestGraphicsFramebuffer* currentFramebuffer{nullptr};
619   TestGraphicsPipeline*    currentPipeline{nullptr};
620
621   for(auto& cmd : commandBuffer.GetCommands())
622   {
623     // process command
624     switch(cmd.type)
625     {
626       case CommandType::FLUSH:
627       {
628         // Nothing to do here
629         break;
630       }
631       case CommandType::BIND_TEXTURES:
632       {
633         for(auto& binding : cmd.data.bindTextures.textureBindings)
634         {
635           if(binding.texture)
636           {
637             auto texture = Uncast<TestGraphicsTexture>(binding.texture);
638             texture->Bind(binding.binding);
639
640             if(binding.sampler)
641             {
642               auto sampler = Uncast<TestGraphicsSampler>(binding.sampler);
643               if(sampler)
644               {
645                 sampler->Apply(texture->GetTarget());
646               }
647             }
648
649             texture->Prepare(); // Ensure native texture is ready
650           }
651         }
652         break;
653       }
654       case CommandType::BIND_VERTEX_BUFFERS:
655       {
656         for(auto& binding : cmd.data.bindVertexBuffers.vertexBufferBindings)
657         {
658           auto graphicsBuffer = binding.buffer;
659           auto vertexBuffer   = Uncast<TestGraphicsBuffer>(graphicsBuffer);
660           vertexBuffer->Bind();
661         }
662         break;
663       }
664       case CommandType::BIND_INDEX_BUFFER:
665       {
666         auto& indexBufferBinding = cmd.data.bindIndexBuffer;
667         if(indexBufferBinding.buffer)
668         {
669           auto buffer = Uncast<TestGraphicsBuffer>(indexBufferBinding.buffer);
670           buffer->Bind();
671         }
672         break;
673       }
674       case CommandType::BIND_UNIFORM_BUFFER:
675       {
676         if(currentPipeline)
677         {
678           auto& bindings = cmd.data.bindUniformBuffers;
679           auto  buffer   = bindings.standaloneUniformsBufferBinding;
680
681           // based on reflection, issue gl calls
682           buffer.buffer->BindAsUniformBuffer(static_cast<const TestGraphicsProgram*>(currentPipeline->programState.program), bindings.standaloneUniformsBufferBinding);
683         }
684         break;
685       }
686       case CommandType::BIND_SAMPLERS:
687       {
688         break;
689       }
690       case CommandType::BIND_PIPELINE:
691       {
692         currentPipeline = Uncast<TestGraphicsPipeline>(cmd.data.bindPipeline.pipeline);
693         BindPipeline(currentPipeline);
694         break;
695       }
696       case CommandType::DRAW:
697       {
698         if(currentPipeline)
699         {
700           mGl.DrawArrays(GetTopology(currentPipeline->inputAssemblyState.topology),
701                          0,
702                          cmd.data.draw.draw.vertexCount);
703         }
704         break;
705       }
706       case CommandType::DRAW_INDEXED:
707       {
708         if(currentPipeline)
709         {
710           mGl.DrawElements(GetTopology(currentPipeline->inputAssemblyState.topology),
711                            static_cast<GLsizei>(cmd.data.draw.drawIndexed.indexCount),
712                            GL_UNSIGNED_SHORT,
713                            reinterpret_cast<void*>(cmd.data.draw.drawIndexed.firstIndex));
714         }
715         break;
716       }
717       case CommandType::DRAW_INDEXED_INDIRECT:
718       {
719         if(currentPipeline)
720         {
721           mGl.DrawElements(GetTopology(currentPipeline->inputAssemblyState.topology),
722                            static_cast<GLsizei>(cmd.data.draw.drawIndexed.indexCount),
723                            GL_UNSIGNED_SHORT,
724                            reinterpret_cast<void*>(cmd.data.draw.drawIndexed.firstIndex));
725         }
726         break;
727       }
728       case CommandType::SET_SCISSOR:
729       {
730         if(scissorEnabled)
731         {
732           auto& rect = cmd.data.scissor.region;
733           mGl.Scissor(rect.x, rect.y, rect.width, rect.height);
734         }
735         break;
736       }
737       case CommandType::SET_SCISSOR_TEST:
738       {
739         if(cmd.data.scissorTest.enable)
740         {
741           mGl.Enable(GL_SCISSOR_TEST);
742           scissorEnabled = true;
743         }
744         else
745         {
746           mGl.Disable(GL_SCISSOR_TEST);
747           scissorEnabled = false;
748         }
749         break;
750       }
751       case CommandType::SET_VIEWPORT_TEST:
752       {
753         break;
754       }
755       case CommandType::SET_VIEWPORT: // @todo Consider correcting for orientation here?
756       {
757         auto& rect = cmd.data.viewport.region;
758         mGl.Viewport(rect.x, rect.y, rect.width, rect.height);
759         break;
760       }
761
762       case CommandType::SET_COLOR_MASK:
763       {
764         // Set all channels to the same mask
765         const bool mask = cmd.data.colorMask.enabled;
766         mGl.ColorMask(mask, mask, mask, mask);
767         break;
768       }
769       case CommandType::CLEAR_STENCIL_BUFFER:
770       {
771         mGl.Clear(GL_STENCIL_BUFFER_BIT);
772         break;
773       }
774       case CommandType::CLEAR_DEPTH_BUFFER:
775       {
776         mGl.Clear(GL_DEPTH_BUFFER_BIT);
777         break;
778       }
779
780       case CommandType::SET_STENCIL_TEST_ENABLE:
781       {
782         if(cmd.data.stencilTest.enabled)
783         {
784           mGl.Enable(GL_STENCIL_TEST);
785         }
786         else
787         {
788           mGl.Disable(GL_STENCIL_TEST);
789         }
790         break;
791       }
792
793       case CommandType::SET_STENCIL_FUNC:
794       {
795         mGl.StencilFunc(GLCompareOp(cmd.data.stencilFunc.compareOp).op,
796                         cmd.data.stencilFunc.reference,
797                         cmd.data.stencilFunc.compareMask);
798         break;
799       }
800
801       case CommandType::SET_STENCIL_WRITE_MASK:
802       {
803         mGl.StencilMask(cmd.data.stencilWriteMask.mask);
804         break;
805       }
806       case CommandType::SET_STENCIL_OP:
807       {
808         mGl.StencilOp(GLStencilOp(cmd.data.stencilOp.failOp).op,
809                       GLStencilOp(cmd.data.stencilOp.depthFailOp).op,
810                       GLStencilOp(cmd.data.stencilOp.passOp).op);
811         break;
812       }
813
814       case CommandType::SET_DEPTH_COMPARE_OP:
815       {
816         mGl.DepthFunc(GLCompareOp(cmd.data.depth.compareOp).op);
817         break;
818       }
819       case CommandType::SET_DEPTH_TEST_ENABLE:
820       {
821         if(cmd.data.depth.testEnabled)
822         {
823           mGl.Enable(GL_DEPTH_TEST);
824         }
825         else
826         {
827           mGl.Disable(GL_DEPTH_TEST);
828         }
829         break;
830       }
831       case CommandType::SET_DEPTH_WRITE_ENABLE:
832       {
833         mGl.DepthMask(cmd.data.depth.writeEnabled);
834         break;
835       }
836
837       case CommandType::EXECUTE_COMMAND_BUFFERS:
838       {
839         // Process secondary command buffers
840         for(auto& buf : cmd.data.executeCommandBuffers.buffers)
841         {
842           ProcessCommandBuffer(*Uncast<TestGraphicsCommandBuffer>(buf));
843         }
844         break;
845       }
846       case CommandType::BEGIN_RENDER_PASS:
847       {
848         auto renderTarget = Uncast<TestGraphicsRenderTarget>(cmd.data.beginRenderPass.renderTarget);
849
850         if(renderTarget)
851         {
852           auto fb = renderTarget->mCreateInfo.framebuffer;
853           if(fb)
854           {
855             if(currentFramebuffer != fb)
856             {
857               currentFramebuffer = Uncast<TestGraphicsFramebuffer>(fb);
858               currentFramebuffer->Bind();
859             }
860           }
861           else
862           {
863             mGl.BindFramebuffer(GL_FRAMEBUFFER, 0);
864           }
865         }
866         else
867         {
868           mGl.BindFramebuffer(GL_FRAMEBUFFER, 0);
869         }
870
871         auto& clearValues = cmd.data.beginRenderPass.clearValues;
872         if(clearValues.size() > 0)
873         {
874           const auto renderPass = static_cast<TestGraphicsRenderPass*>(cmd.data.beginRenderPass.renderPass);
875           if(renderPass)
876           {
877             const auto& color0 = renderPass->attachments[0];
878             GLuint      mask   = 0;
879             if(color0.loadOp == Graphics::AttachmentLoadOp::CLEAR)
880             {
881               mask |= GL_COLOR_BUFFER_BIT;
882
883               // Set clear color (todo: cache it!)
884               // Something goes wrong here if Alpha mask is GL_TRUE
885               mGl.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
886               mGl.ClearColor(clearValues[0].color.r,
887                              clearValues[0].color.g,
888                              clearValues[0].color.b,
889                              clearValues[0].color.a);
890             }
891
892             // check for depth stencil
893             if(renderPass->attachments.size() > 1)
894             {
895               const auto& depthStencil = renderPass->attachments.back();
896               if(depthStencil.loadOp == Graphics::AttachmentLoadOp::CLEAR)
897               {
898                 mGl.DepthMask(true);
899                 uint32_t depthClearColor = 0u;
900                 if(clearValues.size() == renderPass->attachments.size())
901                 {
902                   depthClearColor = clearValues.back().depthStencil.depth;
903                 }
904                 mGl.ClearDepthf(depthClearColor);
905                 mask |= GL_DEPTH_BUFFER_BIT;
906               }
907               if(depthStencil.stencilLoadOp == Graphics::AttachmentLoadOp::CLEAR)
908               {
909                 uint32_t stencilClearColor = 0u;
910                 if(clearValues.size() == renderPass->attachments.size())
911                 {
912                   stencilClearColor = clearValues.back().depthStencil.stencil;
913                 }
914                 mGl.ClearStencil(stencilClearColor);
915                 mGl.StencilMask(0xFF); // Clear all the bitplanes (assume 8)
916                 mask |= GL_STENCIL_BUFFER_BIT;
917               }
918             }
919
920             if(mask != 0)
921             {
922               // Test scissor area and RT size
923               const auto& area = cmd.data.beginRenderPass.renderArea;
924               if(area.x == 0 &&
925                  area.y == 0 &&
926                  renderTarget &&
927                  area.width == renderTarget->mCreateInfo.extent.width &&
928                  area.height == renderTarget->mCreateInfo.extent.height)
929               {
930                 mGl.Disable(GL_SCISSOR_TEST);
931                 mGl.Clear(mask);
932               }
933               else
934               {
935                 mGl.Enable(GL_SCISSOR_TEST);
936                 mGl.Scissor(cmd.data.beginRenderPass.renderArea.x, cmd.data.beginRenderPass.renderArea.y, cmd.data.beginRenderPass.renderArea.width, cmd.data.beginRenderPass.renderArea.height);
937                 mGl.Clear(mask);
938                 mGl.Disable(GL_SCISSOR_TEST);
939               }
940             }
941           }
942           else
943           {
944             DALI_ASSERT_DEBUG(0 && "BeginRenderPass has no render pass");
945           }
946         }
947         break;
948       }
949       case CommandType::END_RENDER_PASS:
950       {
951         if(cmd.data.endRenderPass.syncObject != nullptr)
952         {
953           auto syncObject = Uncast<TestGraphicsSyncObject>(cmd.data.endRenderPass.syncObject);
954           syncObject->InitializeResource(); // create the sync object.
955         }
956         break;
957       }
958     }
959   }
960 }
961
962 void TestGraphicsController::BindPipeline(TestGraphicsPipeline* pipeline)
963 {
964   auto& vi = pipeline->vertexInputState;
965   for(auto& attribute : vi.attributes)
966   {
967     mGl.EnableVertexAttribArray(attribute.location);
968     uint32_t attributeOffset = attribute.offset;
969     GLsizei  stride          = vi.bufferBindings[attribute.binding].stride;
970
971     mGl.VertexAttribPointer(attribute.location,
972                             GetNumComponents(attribute.format),
973                             GetGlType(attribute.format),
974                             GL_FALSE, // Not normalized
975                             stride,
976                             reinterpret_cast<void*>(attributeOffset));
977   }
978
979   // Cull face setup
980   auto& rasterizationState = pipeline->rasterizationState;
981   if(rasterizationState.cullMode == Graphics::CullMode::NONE)
982   {
983     mGl.Disable(GL_CULL_FACE);
984   }
985   else
986   {
987     mGl.Enable(GL_CULL_FACE);
988     mGl.CullFace(GetCullFace(rasterizationState.cullMode));
989   }
990
991   mGl.FrontFace(GetFrontFace(rasterizationState.frontFace));
992
993   // Blending setup
994   auto& colorBlendState = pipeline->colorBlendState;
995   if(colorBlendState.blendEnable)
996   {
997     mGl.Enable(GL_BLEND);
998
999     mGl.BlendFuncSeparate(GetBlendFactor(colorBlendState.srcColorBlendFactor),
1000                           GetBlendFactor(colorBlendState.dstColorBlendFactor),
1001                           GetBlendFactor(colorBlendState.srcAlphaBlendFactor),
1002                           GetBlendFactor(colorBlendState.dstAlphaBlendFactor));
1003     if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
1004     {
1005       mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp));
1006     }
1007     else
1008     {
1009       mGl.BlendEquation(GetBlendOp(colorBlendState.colorBlendOp));
1010     }
1011     mGl.BlendColor(colorBlendState.blendConstants[0],
1012                    colorBlendState.blendConstants[1],
1013                    colorBlendState.blendConstants[2],
1014                    colorBlendState.blendConstants[3]);
1015   }
1016   else
1017   {
1018     mGl.Disable(GL_BLEND);
1019   }
1020
1021   auto* program = static_cast<const TestGraphicsProgram*>(pipeline->programState.program);
1022   mGl.UseProgram(program->mImpl->mId);
1023 }
1024
1025 /**
1026  * @brief Presents render target
1027  * @param renderTarget render target to present
1028  */
1029 void TestGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget)
1030 {
1031   auto*                       rt = static_cast<const TestGraphicsRenderTarget*>(renderTarget);
1032   TraceCallStack::NamedParams namedParams;
1033   namedParams["renderTarget"] << std::hex << renderTarget;
1034   namedParams["surface"] << std::hex << rt->mCreateInfo.surface;
1035   mCallStack.PushCall("PresentRenderTarget", namedParams.str(), namedParams);
1036 }
1037
1038 /**
1039  * @brief Waits until the GPU is idle
1040  */
1041 void TestGraphicsController::WaitIdle()
1042 {
1043   mCallStack.PushCall("WaitIdle", "");
1044 }
1045
1046 /**
1047  * @brief Lifecycle pause event
1048  */
1049 void TestGraphicsController::Pause()
1050 {
1051   mCallStack.PushCall("Pause", "");
1052 }
1053
1054 /**
1055  * @brief Lifecycle resume event
1056  */
1057 void TestGraphicsController::Resume()
1058 {
1059   mCallStack.PushCall("Resume", "");
1060 }
1061
1062 void TestGraphicsController::Shutdown()
1063 {
1064   mCallStack.PushCall("Shutdown", "");
1065 }
1066
1067 void TestGraphicsController::Destroy()
1068 {
1069   mCallStack.PushCall("Destroy", "");
1070 }
1071
1072 void TestGraphicsController::UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>&       updateInfoList,
1073                                             const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList)
1074 {
1075   TraceCallStack::NamedParams namedParams;
1076   namedParams["updateInfoList"] << "[" << updateInfoList.size() << "]:";
1077   namedParams["sourceList"] << "[" << sourceList.size() << "]:";
1078
1079   mCallStack.PushCall("UpdateTextures", "", namedParams);
1080
1081   // Call either TexImage2D or TexSubImage2D
1082   for(unsigned int i = 0; i < updateInfoList.size(); ++i)
1083   {
1084     auto& updateInfo = updateInfoList[i];
1085     auto& source     = sourceList[i];
1086
1087     auto texture = static_cast<TestGraphicsTexture*>(updateInfo.dstTexture);
1088     texture->Bind(0); // Use first texture unit during resource update
1089     texture->Update(updateInfo, source);
1090   }
1091 }
1092
1093 void TestGraphicsController::GenerateTextureMipmaps(const Graphics::Texture& texture)
1094 {
1095   mCallStack.PushCall("GenerateTextureMipmaps", "");
1096
1097   auto gfxTexture = Uncast<TestGraphicsTexture>(&texture);
1098   mGl.BindTexture(gfxTexture->GetTarget(), 0);
1099   mGl.GenerateMipmap(gfxTexture->GetTarget());
1100 }
1101
1102 bool TestGraphicsController::EnableDepthStencilBuffer(bool enableDepth, bool enableStencil)
1103 {
1104   TraceCallStack::NamedParams namedParams;
1105   namedParams["enableDepth"] << (enableDepth ? "T" : "F");
1106   namedParams["enableStencil"] << (enableStencil ? "T" : "F");
1107   mCallStack.PushCall("EnableDepthStencilBuffer", "", namedParams);
1108   return false;
1109 }
1110
1111 void TestGraphicsController::RunGarbageCollector(size_t numberOfDiscardedRenderers)
1112 {
1113   TraceCallStack::NamedParams namedParams;
1114   namedParams["numberOfDiscardedRenderers"] << numberOfDiscardedRenderers;
1115   mCallStack.PushCall("RunGarbageCollector", "", namedParams);
1116 }
1117
1118 void TestGraphicsController::DiscardUnusedResources()
1119 {
1120   mCallStack.PushCall("DiscardUnusedResources", "");
1121 }
1122
1123 bool TestGraphicsController::IsDiscardQueueEmpty()
1124 {
1125   mCallStack.PushCall("IsDiscardQueueEmpty", "");
1126   return isDiscardQueueEmptyResult;
1127 }
1128
1129 /**
1130  * @brief Test if the graphics subsystem has resumed & should force a draw
1131  *
1132  * @return true if the graphics subsystem requires a re-draw
1133  */
1134 bool TestGraphicsController::IsDrawOnResumeRequired()
1135 {
1136   mCallStack.PushCall("IsDrawOnResumeRequired", "");
1137   return isDrawOnResumeRequiredResult;
1138 }
1139
1140 Graphics::UniquePtr<Graphics::Buffer> TestGraphicsController::CreateBuffer(const Graphics::BufferCreateInfo& createInfo, Graphics::UniquePtr<Graphics::Buffer>&& oldBuffer)
1141 {
1142   std::ostringstream oss;
1143   oss << "bufferCreateInfo:" << createInfo;
1144   mCallStack.PushCall("CreateBuffer", oss.str());
1145   return Graphics::MakeUnique<TestGraphicsBuffer>(mCallStack, mGl, createInfo.size, createInfo.usage);
1146 }
1147
1148 Graphics::UniquePtr<Graphics::CommandBuffer> TestGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer)
1149 {
1150   std::ostringstream oss;
1151   oss << "commandBufferCreateInfo:" << commandBufferCreateInfo;
1152   mCallStack.PushCall("CreateCommandBuffer", oss.str());
1153   return Graphics::MakeUnique<TestGraphicsCommandBuffer>(mCommandBufferCallStack, mGl);
1154 }
1155
1156 Graphics::UniquePtr<Graphics::RenderPass> TestGraphicsController::CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<Graphics::RenderPass>&& oldRenderPass)
1157 {
1158   mCallStack.PushCall("CreateRenderPass", "");
1159   return Graphics::MakeUnique<TestGraphicsRenderPass>(mGl, renderPassCreateInfo);
1160 }
1161
1162 Graphics::UniquePtr<Graphics::Texture> TestGraphicsController::CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Graphics::Texture>&& oldTexture)
1163 {
1164   TraceCallStack::NamedParams namedParams;
1165   namedParams["textureCreateInfo"] << textureCreateInfo;
1166   mCallStack.PushCall("CreateTexture", namedParams.str(), namedParams);
1167
1168   return Graphics::MakeUnique<TestGraphicsTexture>(mGl, textureCreateInfo);
1169 }
1170
1171 Graphics::UniquePtr<Graphics::Framebuffer> TestGraphicsController::CreateFramebuffer(
1172   const Graphics::FramebufferCreateInfo&       createInfo,
1173   Graphics::UniquePtr<Graphics::Framebuffer>&& oldFramebuffer)
1174 {
1175   TraceCallStack::NamedParams namedParams;
1176   namedParams["framebufferCreateInfo"] << createInfo;
1177   mCallStack.PushCall("Controller::CreateFramebuffer", namedParams.str(), namedParams);
1178
1179   return Graphics::MakeUnique<TestGraphicsFramebuffer>(mFrameBufferCallStack, mGl, createInfo);
1180 }
1181
1182 Graphics::UniquePtr<Graphics::Pipeline> TestGraphicsController::CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
1183 {
1184   mCallStack.PushCall("CreatePipeline", "");
1185   return std::make_unique<TestGraphicsPipeline>(mGl, pipelineCreateInfo);
1186 }
1187
1188 Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(const Graphics::ProgramCreateInfo& programCreateInfo, Graphics::UniquePtr<Graphics::Program>&& oldProgram)
1189 {
1190   mCallStack.PushCall("CreateProgram", "");
1191
1192   for(auto cacheEntry : mProgramCache)
1193   {
1194     bool found = true;
1195     for(auto& shader : *(programCreateInfo.shaderState))
1196     {
1197       auto                 graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
1198       std::vector<uint8_t> source;
1199       source.resize(graphicsShader->mCreateInfo.sourceSize);
1200       memcpy(&source[0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
1201
1202       if(!std::equal(source.begin(), source.end(), cacheEntry.shaders[shader.pipelineStage].begin()))
1203       {
1204         found = false;
1205         break;
1206       }
1207     }
1208     if(found)
1209     {
1210       return Graphics::MakeUnique<TestGraphicsProgram>(cacheEntry.programImpl);
1211     }
1212   }
1213
1214   mProgramCache.emplace_back();
1215   mProgramCache.back().programImpl = new TestGraphicsProgramImpl(mGl, programCreateInfo, mVertexFormats, mCustomUniforms);
1216   for(auto& shader : *(programCreateInfo.shaderState))
1217   {
1218     auto graphicsShader = Uncast<TestGraphicsShader>(shader.shader);
1219     mProgramCache.back().shaders[shader.pipelineStage].resize(graphicsShader->mCreateInfo.sourceSize);
1220     memcpy(&mProgramCache.back().shaders[shader.pipelineStage][0], graphicsShader->mCreateInfo.sourceData, graphicsShader->mCreateInfo.sourceSize);
1221   }
1222   return Graphics::MakeUnique<TestGraphicsProgram>(mProgramCache.back().programImpl);
1223 }
1224
1225 Graphics::UniquePtr<Graphics::Shader> TestGraphicsController::CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Graphics::Shader>&& oldShader)
1226 {
1227   mCallStack.PushCall("CreateShader", "");
1228   return Graphics::MakeUnique<TestGraphicsShader>(mGl, shaderCreateInfo);
1229 }
1230
1231 Graphics::UniquePtr<Graphics::Sampler> TestGraphicsController::CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Graphics::Sampler>&& oldSampler)
1232 {
1233   TraceCallStack::NamedParams namedParams;
1234   namedParams["samplerCreateInfo"] << samplerCreateInfo;
1235   mCallStack.PushCall("CreateSampler", namedParams.str(), namedParams);
1236
1237   return Graphics::MakeUnique<TestGraphicsSampler>(mGl, samplerCreateInfo);
1238 }
1239
1240 Graphics::UniquePtr<Graphics::RenderTarget> TestGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget)
1241 {
1242   TraceCallStack::NamedParams namedParams;
1243   namedParams["surface"] << std::hex << renderTargetCreateInfo.surface;
1244   mCallStack.PushCall("CreateRenderTarget", namedParams.str(), namedParams);
1245
1246   return Graphics::MakeUnique<TestGraphicsRenderTarget>(mGl, renderTargetCreateInfo);
1247 }
1248
1249 Graphics::UniquePtr<Graphics::SyncObject> TestGraphicsController::CreateSyncObject(
1250   const Graphics::SyncObjectCreateInfo&       syncObjectCreateInfo,
1251   Graphics::UniquePtr<Graphics::SyncObject>&& oldSyncObject)
1252 {
1253   mCallStack.PushCall("CreateSyncObject", "");
1254   return Graphics::MakeUnique<TestGraphicsSyncObject>(mGraphicsSyncImpl, syncObjectCreateInfo);
1255 }
1256
1257 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapBufferRange(const Graphics::MapBufferInfo& mapInfo)
1258 {
1259   mCallStack.PushCall("MapBufferRange", "");
1260
1261   auto buffer = static_cast<TestGraphicsBuffer*>(mapInfo.buffer);
1262   buffer->memory.resize(mapInfo.offset + mapInfo.size); // For initial testing, allow writes past capacity
1263
1264   return std::make_unique<TestGraphicsMemory>(mCallStack, *buffer, mapInfo.offset, mapInfo.size);
1265 }
1266
1267 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapTextureRange(const Graphics::MapTextureInfo& mapInfo)
1268 {
1269   mCallStack.PushCall("MapTextureRange", "");
1270   return nullptr;
1271 }
1272
1273 void TestGraphicsController::UnmapMemory(Graphics::UniquePtr<Graphics::Memory> memory)
1274 {
1275   mCallStack.PushCall("UnmapMemory", "");
1276 }
1277
1278 Graphics::MemoryRequirements TestGraphicsController::GetTextureMemoryRequirements(Graphics::Texture& texture) const
1279 {
1280   mCallStack.PushCall("GetTextureMemoryRequirements", "");
1281   return Graphics::MemoryRequirements{};
1282 }
1283
1284 Graphics::MemoryRequirements TestGraphicsController::GetBufferMemoryRequirements(Graphics::Buffer& buffer) const
1285 {
1286   mCallStack.PushCall("GetBufferMemoryRequirements", "");
1287   return Graphics::MemoryRequirements{};
1288 }
1289
1290 const Graphics::TextureProperties& TestGraphicsController::GetTextureProperties(const Graphics::Texture& texture)
1291 {
1292   static Graphics::TextureProperties textureProperties{};
1293   mCallStack.PushCall("GetTextureProperties", "");
1294
1295   return textureProperties;
1296 }
1297
1298 const Graphics::Reflection& TestGraphicsController::GetProgramReflection(const Graphics::Program& program)
1299 {
1300   mCallStack.PushCall("GetProgramReflection", "");
1301
1302   return static_cast<const TestGraphicsProgram*>(&program)->GetReflection();
1303 }
1304
1305 bool TestGraphicsController::PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const
1306 {
1307   mCallStack.PushCall("PipelineEquals", "");
1308   return false;
1309 }
1310
1311 bool TestGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData)
1312 {
1313   mCallStack.PushCall("GetProgramParameter", "");
1314   auto graphicsProgram = Uncast<TestGraphicsProgram>(&program);
1315   return graphicsProgram->GetParameter(parameterId, outData);
1316 }
1317
1318 } // namespace Dali