1 #ifndef DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
2 #define DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <dali/graphics-api/graphics-command-buffer-create-info.h>
21 #include <dali/graphics-api/graphics-command-buffer.h>
22 #include <dali/graphics-api/graphics-pipeline.h>
23 #include <dali/graphics-api/graphics-types.h>
26 #include "test-gl-abstraction.h"
27 #include "test-graphics-buffer.h"
28 #include "test-graphics-pipeline.h"
29 #include "test-trace-call-stack.h"
33 class TestGraphicsTexture;
34 class TestGraphicsBuffer;
35 class TestGraphicsCommandBuffer;
36 class TestGraphicsSampler;
37 class TestGraphicsPipeline;
39 enum class CommandType
42 BIND_TEXTURES = 1 << 1,
43 BIND_SAMPLERS = 1 << 2,
44 BIND_VERTEX_BUFFERS = 1 << 3,
45 BIND_INDEX_BUFFER = 1 << 4,
46 BIND_UNIFORM_BUFFER = 1 << 5,
47 BIND_PIPELINE = 1 << 6,
49 DRAW_INDEXED = 1 << 8,
50 DRAW_INDEXED_INDIRECT = 1 << 9,
51 SET_SCISSOR = 1 << 10,
52 SET_SCISSOR_TEST = 1 << 11,
53 SET_VIEWPORT = 1 << 12,
54 SET_VIEWPORT_TEST = 1 << 13,
55 BEGIN_RENDER_PASS = 1 << 14,
56 END_RENDER_PASS = 1 << 15,
57 EXECUTE_COMMAND_BUFFERS = 1 << 16,
58 SET_COLOR_MASK = 1 << 17,
59 CLEAR_STENCIL_BUFFER = 1 << 18,
60 CLEAR_DEPTH_BUFFER = 1 << 19,
61 SET_STENCIL_TEST_ENABLE = 1 << 20,
62 SET_STENCIL_WRITE_MASK = 1 << 21,
63 SET_STENCIL_OP = 1 << 22,
64 SET_STENCIL_FUNC = 1 << 23,
65 SET_DEPTH_COMPARE_OP = 1 << 24,
66 SET_DEPTH_TEST_ENABLE = 1 << 25,
67 SET_DEPTH_WRITE_ENABLE = 1 << 26,
68 DRAW_NATIVE = 1 << 27,
71 std::ostream& operator<<(std::ostream& os, Graphics::StencilOp op);
73 std::ostream& operator<<(std::ostream& os, Graphics::CompareOp op);
75 using CommandTypeMask = uint32_t;
77 inline CommandTypeMask operator|(T flags, CommandType bit)
79 return static_cast<CommandTypeMask>(flags) | static_cast<CommandTypeMask>(bit);
83 * @brief Descriptor of single buffer binding within
86 struct VertexBufferBindingDescriptor
88 const TestGraphicsBuffer* buffer{nullptr};
93 * @brief Descriptor of ix buffer binding within
96 struct IndexBufferBindingDescriptor
98 const TestGraphicsBuffer* buffer{nullptr};
100 Graphics::Format format{};
104 * @brief Descriptor of uniform buffer binding within
107 struct UniformBufferBindingDescriptor
109 const TestGraphicsBuffer* buffer{nullptr};
110 uint32_t binding{0u};
112 bool emulated; ///<true if UBO is emulated for old gfx API
116 * @brief The descriptor of draw call
118 struct DrawCallDescriptor
121 * @brief Enum specifying type of the draw call
127 DRAW_INDEXED_INDIRECT,
131 Type type{}; ///< Type of the draw call
134 * Union contains data for all types of draw calls.
139 * @brief Vertex array draw
143 uint32_t vertexCount;
144 uint32_t instanceCount;
145 uint32_t firstVertex;
146 uint32_t firstInstance;
150 * @brief Indexed draw
155 uint32_t instanceCount;
157 int32_t vertexOffset;
158 uint32_t firstInstance;
162 * @brief Indexed draw indirect
166 const TestGraphicsBuffer* buffer;
170 } drawIndexedIndirect;
174 Graphics::DrawNativeInfo drawNativeInfo;
180 * Command structure allocates memory to store a single command
188 Command(CommandType type)
191 // do non-trivial initialization
194 case CommandType::BEGIN_RENDER_PASS:
196 new(&data.beginRenderPass) CommandData::BeginRenderPassDescriptor();
209 case CommandType::BEGIN_RENDER_PASS:
211 data.beginRenderPass.~BeginRenderPassDescriptor();
222 * @brief Copy constructor
223 * @param[in] rhs Command
225 Command(const Command& rhs)
229 case CommandType::BEGIN_RENDER_PASS:
231 new(&data.beginRenderPass) CommandData::BeginRenderPassDescriptor(rhs.data.beginRenderPass);
234 case CommandType::END_RENDER_PASS:
236 data.endRenderPass = rhs.data.endRenderPass;
239 case CommandType::EXECUTE_COMMAND_BUFFERS:
241 data.executeCommandBuffers = rhs.data.executeCommandBuffers;
245 case CommandType::BIND_VERTEX_BUFFERS:
247 data.bindVertexBuffers = rhs.data.bindVertexBuffers;
250 case CommandType::BIND_INDEX_BUFFER:
252 data.bindIndexBuffer = rhs.data.bindIndexBuffer;
255 case CommandType::BIND_SAMPLERS:
257 data.bindSamplers = rhs.data.bindSamplers;
260 case CommandType::BIND_TEXTURES:
262 data.bindTextures = rhs.data.bindTextures;
265 case CommandType::BIND_PIPELINE:
267 data.bindPipeline = rhs.data.bindPipeline;
270 case CommandType::BIND_UNIFORM_BUFFER:
272 data.bindUniformBuffers = rhs.data.bindUniformBuffers;
275 case CommandType::DRAW_NATIVE:
277 data.draw.type = rhs.data.draw.type;
278 data.draw.drawNative = rhs.data.draw.drawNative;
281 case CommandType::DRAW:
283 data.draw.type = rhs.data.draw.type;
284 data.draw.draw = rhs.data.draw.draw;
287 case CommandType::DRAW_INDEXED:
289 data.draw.type = rhs.data.draw.type;
290 data.draw.drawIndexed = rhs.data.draw.drawIndexed;
293 case CommandType::DRAW_INDEXED_INDIRECT:
295 data.draw.type = rhs.data.draw.type;
296 data.draw.drawIndexedIndirect = rhs.data.draw.drawIndexedIndirect;
299 case CommandType::FLUSH:
304 case CommandType::SET_SCISSOR:
306 data.scissor.region = rhs.data.scissor.region;
309 case CommandType::SET_SCISSOR_TEST:
311 data.scissorTest.enable = rhs.data.scissorTest.enable;
314 case CommandType::SET_VIEWPORT:
316 data.viewport.region = rhs.data.viewport.region;
319 case CommandType::SET_VIEWPORT_TEST:
321 data.viewportTest.enable = rhs.data.viewportTest.enable;
324 case CommandType::SET_COLOR_MASK:
326 data.colorMask.enabled = rhs.data.colorMask.enabled;
329 case CommandType::CLEAR_STENCIL_BUFFER:
333 case CommandType::CLEAR_DEPTH_BUFFER:
337 case CommandType::SET_STENCIL_TEST_ENABLE:
339 data.stencilTest.enabled = rhs.data.stencilTest.enabled;
342 case CommandType::SET_STENCIL_FUNC:
344 data.stencilFunc.compareMask = rhs.data.stencilFunc.compareMask;
345 data.stencilFunc.compareOp = rhs.data.stencilFunc.compareOp;
346 data.stencilFunc.reference = rhs.data.stencilFunc.reference;
349 case CommandType::SET_STENCIL_WRITE_MASK:
351 data.stencilWriteMask.mask = rhs.data.stencilWriteMask.mask;
354 case CommandType::SET_STENCIL_OP:
356 data.stencilOp.failOp = rhs.data.stencilOp.failOp;
357 data.stencilOp.depthFailOp = rhs.data.stencilOp.depthFailOp;
358 data.stencilOp.passOp = rhs.data.stencilOp.passOp;
362 case CommandType::SET_DEPTH_COMPARE_OP:
364 data.depth.compareOp = rhs.data.depth.compareOp;
367 case CommandType::SET_DEPTH_TEST_ENABLE:
369 data.depth.testEnabled = rhs.data.depth.testEnabled;
372 case CommandType::SET_DEPTH_WRITE_ENABLE:
374 data.depth.writeEnabled = rhs.data.depth.writeEnabled;
382 * @brief move constructor
383 * @param[in] rhs Command
385 Command(Command&& rhs) noexcept
389 case CommandType::BEGIN_RENDER_PASS:
391 new(&data.beginRenderPass) CommandData::BeginRenderPassDescriptor(std::move(rhs.data.beginRenderPass));
394 case CommandType::END_RENDER_PASS:
396 data.endRenderPass = std::move(rhs.data.endRenderPass);
399 case CommandType::EXECUTE_COMMAND_BUFFERS:
401 data.executeCommandBuffers = std::move(rhs.data.executeCommandBuffers);
404 case CommandType::BIND_VERTEX_BUFFERS:
406 data.bindVertexBuffers = std::move(rhs.data.bindVertexBuffers);
409 case CommandType::BIND_INDEX_BUFFER:
411 data.bindIndexBuffer = rhs.data.bindIndexBuffer;
414 case CommandType::BIND_UNIFORM_BUFFER:
416 data.bindUniformBuffers = std::move(rhs.data.bindUniformBuffers);
419 case CommandType::BIND_SAMPLERS:
421 data.bindSamplers = std::move(rhs.data.bindSamplers);
424 case CommandType::BIND_TEXTURES:
426 data.bindTextures = std::move(rhs.data.bindTextures);
429 case CommandType::BIND_PIPELINE:
431 data.bindPipeline = rhs.data.bindPipeline;
434 case CommandType::DRAW_NATIVE:
436 data.draw.type = rhs.data.draw.type;
437 data.draw.drawNative = rhs.data.draw.drawNative;
440 case CommandType::DRAW:
442 data.draw.type = rhs.data.draw.type;
443 data.draw.draw = rhs.data.draw.draw;
446 case CommandType::DRAW_INDEXED:
448 data.draw.type = rhs.data.draw.type;
449 data.draw.drawIndexed = rhs.data.draw.drawIndexed;
452 case CommandType::DRAW_INDEXED_INDIRECT:
454 data.draw.type = rhs.data.draw.type;
455 data.draw.drawIndexedIndirect = rhs.data.draw.drawIndexedIndirect;
458 case CommandType::FLUSH:
463 case CommandType::SET_SCISSOR:
465 data.scissor.region = rhs.data.scissor.region;
468 case CommandType::SET_SCISSOR_TEST:
470 data.scissorTest.enable = rhs.data.scissorTest.enable;
473 case CommandType::SET_VIEWPORT:
475 data.viewport.region = rhs.data.viewport.region;
478 case CommandType::SET_VIEWPORT_TEST:
480 data.viewportTest.enable = rhs.data.viewportTest.enable;
484 case CommandType::SET_COLOR_MASK:
486 data.colorMask.enabled = rhs.data.colorMask.enabled;
489 case CommandType::CLEAR_STENCIL_BUFFER:
493 case CommandType::CLEAR_DEPTH_BUFFER:
497 case CommandType::SET_STENCIL_TEST_ENABLE:
499 data.stencilTest.enabled = rhs.data.stencilTest.enabled;
502 case CommandType::SET_STENCIL_WRITE_MASK:
504 data.stencilWriteMask.mask = rhs.data.stencilWriteMask.mask;
507 case CommandType::SET_STENCIL_OP:
509 data.stencilOp.failOp = rhs.data.stencilOp.failOp;
510 data.stencilOp.depthFailOp = rhs.data.stencilOp.depthFailOp;
511 data.stencilOp.passOp = rhs.data.stencilOp.passOp;
514 case CommandType::SET_STENCIL_FUNC:
516 data.stencilFunc.compareMask = rhs.data.stencilFunc.compareMask;
517 data.stencilFunc.compareOp = rhs.data.stencilFunc.compareOp;
518 data.stencilFunc.reference = rhs.data.stencilFunc.reference;
521 case CommandType::SET_DEPTH_COMPARE_OP:
523 data.depth.compareOp = rhs.data.depth.compareOp;
526 case CommandType::SET_DEPTH_TEST_ENABLE:
528 data.depth.testEnabled = rhs.data.depth.testEnabled;
531 case CommandType::SET_DEPTH_WRITE_ENABLE:
533 data.depth.writeEnabled = rhs.data.depth.writeEnabled;
540 CommandType type{CommandType::FLUSH}; ///< Type of command
554 std::vector<Graphics::TextureBinding> textureBindings;
557 // BindSampler command
560 std::vector<Graphics::SamplerBinding> samplerBindings;
565 using Binding = VertexBufferBindingDescriptor;
566 std::vector<Binding> vertexBufferBindings;
569 struct : public IndexBufferBindingDescriptor
575 std::vector<UniformBufferBindingDescriptor> uniformBufferBindings{};
576 UniformBufferBindingDescriptor standaloneUniformsBufferBinding{};
577 } bindUniformBuffers;
581 const TestGraphicsPipeline* pipeline{nullptr};
584 struct : public DrawCallDescriptor
590 Graphics::Rect2D region;
598 Graphics::Viewport region;
605 struct BeginRenderPassDescriptor
607 Graphics::RenderPass* renderPass;
608 Graphics::RenderTarget* renderTarget;
609 Graphics::Rect2D renderArea;
610 std::vector<Graphics::ClearValue> clearValues;
615 Graphics::SyncObject* syncObject;
620 std::vector<const TestGraphicsCommandBuffer*> buffers;
621 } executeCommandBuffers;
625 Graphics::CompareOp compareOp;
632 Graphics::StencilOp failOp;
633 Graphics::StencilOp passOp;
634 Graphics::StencilOp depthFailOp;
644 uint32_t compareMask;
645 Graphics::CompareOp compareOp;
661 class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
664 TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
665 ~TestGraphicsCommandBuffer()
669 void BindVertexBuffers(uint32_t firstBinding,
670 const std::vector<const Graphics::Buffer*>& buffers,
671 const std::vector<uint32_t>& offsets) override
673 mCommands.emplace_back();
674 mCommands.back().type = CommandType::BIND_VERTEX_BUFFERS;
675 auto& bindings = mCommands.back().data.bindVertexBuffers.vertexBufferBindings;
676 if(bindings.size() < firstBinding + buffers.size())
678 bindings.resize(firstBinding + buffers.size());
679 auto index = firstBinding;
680 for(auto& buf : buffers)
682 bindings[index].buffer = static_cast<const TestGraphicsBuffer*>(buf);
683 bindings[index].offset = offsets[index - firstBinding];
687 mCallStack.PushCall("BindVertexBuffers", "");
690 void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings) override
692 mCommands.emplace_back();
693 auto& cmd = mCommands.back();
694 cmd.type = CommandType::BIND_UNIFORM_BUFFER;
695 auto& bindCmd = cmd.data.bindUniformBuffers;
696 for(const auto& binding : bindings)
700 auto testBuffer = static_cast<const TestGraphicsBuffer*>(binding.buffer);
701 if(testBuffer->IsCPUAllocated()) // standalone uniforms
703 bindCmd.standaloneUniformsBufferBinding.buffer = testBuffer;
704 bindCmd.standaloneUniformsBufferBinding.offset = binding.offset;
705 bindCmd.standaloneUniformsBufferBinding.binding = binding.binding;
706 bindCmd.standaloneUniformsBufferBinding.emulated = true;
708 else // Bind regular UBO
710 // resize binding slots
711 if(binding.binding >= bindCmd.uniformBufferBindings.size())
713 bindCmd.uniformBufferBindings.resize(binding.binding + 1);
715 auto& slot = bindCmd.uniformBufferBindings[binding.binding];
716 slot.buffer = testBuffer;
717 slot.offset = binding.offset;
718 slot.binding = binding.binding;
719 slot.emulated = false;
723 mCallStack.PushCall("BindUniformBuffers", "");
726 void BindPipeline(const Graphics::Pipeline& pipeline) override
728 mCommands.emplace_back();
729 mCommands.back().type = CommandType::BIND_PIPELINE;
730 mCommands.back().data.bindPipeline.pipeline = static_cast<const TestGraphicsPipeline*>(&pipeline);
731 mCallStack.PushCall("BindPipeline", "");
734 void BindTextures(const std::vector<Graphics::TextureBinding>& textureBindings) override
736 mCommands.emplace_back();
737 mCommands.back().type = CommandType::BIND_TEXTURES;
738 mCommands.back().data.bindTextures.textureBindings = std::move(textureBindings);
739 mCallStack.PushCall("BindTextures", "");
742 void BindSamplers(const std::vector<Graphics::SamplerBinding>& samplerBindings) override
744 mCommands.emplace_back();
745 mCommands.back().data.bindSamplers.samplerBindings = std::move(samplerBindings);
746 mCallStack.PushCall("BindSamplers", "");
749 void BindPushConstants(void* data,
751 uint32_t binding) override
753 mCallStack.PushCall("BindPushConstants", "");
756 void BindIndexBuffer(const Graphics::Buffer& buffer,
758 Graphics::Format format) override
760 mCommands.emplace_back();
761 mCommands.back().type = CommandType::BIND_INDEX_BUFFER;
762 mCommands.back().data.bindIndexBuffer.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
763 mCommands.back().data.bindIndexBuffer.offset = offset;
764 mCommands.back().data.bindIndexBuffer.format = format;
765 mCallStack.PushCall("BindIndexBuffer", "");
768 void BeginRenderPass(
769 Graphics::RenderPass* renderPass,
770 Graphics::RenderTarget* renderTarget,
771 Graphics::Rect2D renderArea,
772 const std::vector<Graphics::ClearValue>& clearValues) override
774 mCommands.emplace_back(CommandType::BEGIN_RENDER_PASS);
775 auto& cmd = mCommands.back();
776 cmd.data.beginRenderPass.renderPass = renderPass;
777 cmd.data.beginRenderPass.renderTarget = renderTarget;
778 cmd.data.beginRenderPass.renderArea = renderArea;
779 cmd.data.beginRenderPass.clearValues = clearValues;
781 TraceCallStack::NamedParams namedParams;
782 namedParams["renderPass"] << std::hex << renderPass;
783 namedParams["renderTarget"] << std::hex << renderTarget;
784 namedParams["renderArea"] << renderArea.width << ", " << renderArea.height;
785 mCallStack.PushCall("BeginRenderPass", namedParams.str(), namedParams);
789 * @brief Ends current render pass
791 * This command must be issued in order to finalize the render pass.
792 * It's up to the implementation whether anything has to be done but
793 * the Controller may use end RP marker in order to resolve resource
794 * dependencies (for example, to know when target texture is ready
795 * before passing it to another render pass).
797 void EndRenderPass(Graphics::SyncObject* syncObject) override
799 mCommands.emplace_back(CommandType::END_RENDER_PASS);
800 auto& cmd = mCommands.back();
802 cmd.data.endRenderPass.syncObject = syncObject;
804 TraceCallStack::NamedParams namedParams;
805 namedParams["syncObject"] << std::hex << syncObject;
806 mCallStack.PushCall("EndRenderPass", namedParams.str(), namedParams);
809 void ExecuteCommandBuffers(std::vector<const CommandBuffer*>&& commandBuffers) override
811 mCommands.emplace_back();
812 auto& cmd = mCommands.back();
813 cmd.type = CommandType::EXECUTE_COMMAND_BUFFERS;
814 cmd.data.executeCommandBuffers.buffers.reserve(commandBuffers.size());
815 for(auto&& item : commandBuffers)
817 cmd.data.executeCommandBuffers.buffers.emplace_back(static_cast<const TestGraphicsCommandBuffer*>(item));
819 mCallStack.PushCall("ExecuteCommandBuffers", "");
822 void DrawNative(const Graphics::DrawNativeInfo* drawInfo)
824 mCommands.emplace_back();
825 mCommands.back().type = CommandType::DRAW_NATIVE;
826 auto& cmd = mCommands.back().data.draw;
827 cmd.type = DrawCallDescriptor::Type::DRAW_NATIVE;
828 cmd.drawNative.drawNativeInfo = *drawInfo;
829 mCallStack.PushCall("DrawNative", "");
833 uint32_t vertexCount,
834 uint32_t instanceCount,
835 uint32_t firstVertex,
836 uint32_t firstInstance) override
838 mCommands.emplace_back();
839 mCommands.back().type = CommandType::DRAW;
840 auto& cmd = mCommands.back().data.draw;
841 cmd.type = DrawCallDescriptor::Type::DRAW;
842 cmd.draw.vertexCount = vertexCount;
843 cmd.draw.instanceCount = instanceCount;
844 cmd.draw.firstInstance = firstInstance;
845 cmd.draw.firstVertex = firstVertex;
846 mCallStack.PushCall("Draw", "");
851 uint32_t instanceCount,
853 int32_t vertexOffset,
854 uint32_t firstInstance) override
856 mCommands.emplace_back();
857 mCommands.back().type = CommandType::DRAW_INDEXED;
858 auto& cmd = mCommands.back().data.draw;
859 cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED;
860 cmd.drawIndexed.firstIndex = firstIndex;
861 cmd.drawIndexed.firstInstance = firstInstance;
862 cmd.drawIndexed.indexCount = indexCount;
863 cmd.drawIndexed.vertexOffset = vertexOffset;
864 cmd.drawIndexed.instanceCount = instanceCount;
865 mCallStack.PushCall("DrawIndexed", "");
868 void DrawIndexedIndirect(
869 Graphics::Buffer& buffer,
872 uint32_t stride) override
874 mCommands.emplace_back();
875 mCommands.back().type = CommandType::DRAW_INDEXED_INDIRECT;
876 auto& cmd = mCommands.back().data.draw;
877 cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED_INDIRECT;
878 cmd.drawIndexedIndirect.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
879 cmd.drawIndexedIndirect.offset = offset;
880 cmd.drawIndexedIndirect.drawCount = drawCount;
881 cmd.drawIndexedIndirect.stride = stride;
882 mCallStack.PushCall("DrawIndexedIndirect", "");
885 void Reset() override
888 mCallStack.PushCall("Reset", "");
891 void SetScissor(Graphics::Rect2D value) override
893 TraceCallStack::NamedParams params;
894 params["x"] << value.x;
895 params["y"] << value.y;
896 params["width"] << value.width;
897 params["height"] << value.height;
898 mCallStack.PushCall("SetScissor", params.str(), params);
900 mCommands.emplace_back();
901 mCommands.back().type = CommandType::SET_SCISSOR;
902 mCommands.back().data.scissor.region = value;
905 void SetScissorTestEnable(bool value) override
907 TraceCallStack::NamedParams params;
908 params["value"] << (value ? "T" : "F");
909 mCallStack.PushCall("SetScissorTestEnable", params.str(), params);
911 mCommands.emplace_back();
912 mCommands.back().type = CommandType::SET_SCISSOR_TEST;
913 mCommands.back().data.scissorTest.enable = value;
916 void SetViewport(Graphics::Viewport value) override
918 TraceCallStack::NamedParams params;
919 params["x"] << value.x;
920 params["y"] << value.y;
921 params["width"] << value.width;
922 params["height"] << value.height;
923 params["minDepth"] << value.minDepth;
924 params["maxDepth"] << value.maxDepth;
925 mCallStack.PushCall("SetViewport", params.str(), params);
927 mCommands.emplace_back();
928 mCommands.back().type = CommandType::SET_VIEWPORT;
929 mCommands.back().data.viewport.region = value;
932 void SetViewportEnable(bool value) override
934 TraceCallStack::NamedParams params;
935 params["value"] << (value ? "T" : "F");
936 mCallStack.PushCall("SetViewportEnable", params.str(), params);
938 mCommands.emplace_back();
939 mCommands.back().type = CommandType::SET_VIEWPORT_TEST;
940 mCommands.back().data.viewportTest.enable = value;
943 void SetColorMask(bool enabled) override
945 TraceCallStack::NamedParams params;
946 params["enabled"] << (enabled ? "T" : "F");
947 mCallStack.PushCall("SetColorMask", params.str(), params);
948 mCommands.emplace_back();
949 mCommands.back().type = CommandType::SET_COLOR_MASK;
950 mCommands.back().data.colorMask.enabled = enabled;
953 void ClearStencilBuffer() override
955 mCallStack.PushCall("SetStencilMask", "");
956 mCommands.emplace_back();
957 mCommands.back().type = CommandType::CLEAR_STENCIL_BUFFER;
960 void SetStencilTestEnable(bool stencilEnable) override
962 TraceCallStack::NamedParams params;
963 params["enabled"] << (stencilEnable ? "T" : "F");
964 mCallStack.PushCall("SetStencilTestEnable", params.str(), params);
965 mCommands.emplace_back();
966 mCommands.back().type = CommandType::SET_STENCIL_TEST_ENABLE;
967 mCommands.back().data.stencilTest.enabled = stencilEnable;
970 void SetStencilWriteMask(uint32_t writeMask) override
972 TraceCallStack::NamedParams params;
973 params["writeMask"] << std::hex << writeMask;
974 mCallStack.PushCall("SetStencilWriteMask", params.str(), params);
975 mCommands.emplace_back();
976 mCommands.back().type = CommandType::SET_STENCIL_WRITE_MASK;
977 mCommands.back().data.stencilWriteMask.mask = writeMask;
980 void SetStencilOp(Graphics::StencilOp failOp,
981 Graphics::StencilOp passOp,
982 Graphics::StencilOp depthFailOp) override
984 TraceCallStack::NamedParams params;
985 params["failOp"] << failOp;
986 params["passOp"] << passOp;
987 params["depthFailOp"] << depthFailOp;
988 mCallStack.PushCall("SetStencilOp", params.str(), params);
989 mCommands.emplace_back();
990 mCommands.back().type = CommandType::SET_STENCIL_OP;
991 mCommands.back().data.stencilOp.failOp = failOp;
992 mCommands.back().data.stencilOp.passOp = passOp;
993 mCommands.back().data.stencilOp.depthFailOp = depthFailOp;
996 void SetStencilFunc(Graphics::CompareOp compareOp,
998 uint32_t compareMask) override
1000 TraceCallStack::NamedParams params;
1001 params["compareOp"] << compareOp;
1002 params["compareMask"] << std::hex << compareMask;
1003 params["reference"] << std::hex << reference;
1004 mCallStack.PushCall("SetStencilFunc", params.str(), params);
1006 mCommands.emplace_back();
1007 mCommands.back().type = CommandType::SET_STENCIL_FUNC;
1009 mCommands.back().data.stencilFunc.compareOp = compareOp;
1010 mCommands.back().data.stencilFunc.compareMask = compareMask;
1011 mCommands.back().data.stencilFunc.reference = reference;
1014 void SetDepthCompareOp(Graphics::CompareOp compareOp) override
1016 TraceCallStack::NamedParams params;
1017 params["compareOp"] << compareOp;
1018 mCallStack.PushCall("SetDepthCompareOp", params.str(), params);
1019 mCommands.emplace_back();
1020 mCommands.back().type = CommandType::SET_DEPTH_COMPARE_OP;
1021 mCommands.back().data.depth.compareOp = compareOp;
1024 void SetDepthTestEnable(bool depthTestEnable) override
1026 TraceCallStack::NamedParams params;
1027 params["enabled"] << (depthTestEnable ? "T" : "F");
1028 mCallStack.PushCall("SetDepthTestEnable", params.str(), params);
1029 mCommands.emplace_back();
1030 mCommands.back().type = CommandType::SET_DEPTH_TEST_ENABLE;
1031 mCommands.back().data.depth.testEnabled = depthTestEnable;
1033 void SetDepthWriteEnable(bool depthWriteEnable) override
1035 TraceCallStack::NamedParams params;
1036 params["enabled"] << (depthWriteEnable ? "T" : "F");
1037 mCallStack.PushCall("SetDepthWriteEnable", params.str(), params);
1038 mCommands.emplace_back();
1039 mCommands.back().type = CommandType::SET_DEPTH_WRITE_ENABLE;
1040 mCommands.back().data.depth.writeEnabled = depthWriteEnable;
1042 void ClearDepthBuffer() override
1044 mCallStack.PushCall("ClearDepthBuffer", "");
1045 mCommands.emplace_back();
1046 mCommands.back().type = CommandType::CLEAR_DEPTH_BUFFER;
1049 [[nodiscard]] const std::vector<Command>& GetCommands() const
1055 * Returns number of draw commands
1058 int GetDrawCallsCount();
1061 * Retrieves state resolve for selected draw call
1062 * @param drawCommandIndex
1064 void GetStateForDrawCall(int drawCallIndex);
1067 * Retrieves commands of specified type
1069 std::vector<const Command*> GetCommandsByType(CommandTypeMask mask) const;
1071 std::vector<const Command*> GetChildCommandsByType(CommandTypeMask mask) const;
1074 TraceCallStack& mCallStack;
1075 TestGlAbstraction& mGlAbstraction;
1077 std::vector<Command> mCommands;
1082 #endif //DALI_TEST_GRAPHICS_COMMAND_BUFFER_H