1 #ifndef DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
2 #define DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
5 * Copyright (c) 2021 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,
70 std::ostream& operator<<(std::ostream& os, Graphics::StencilOp op);
72 std::ostream& operator<<(std::ostream& os, Graphics::CompareOp op);
74 using CommandTypeMask = uint32_t;
76 inline CommandTypeMask operator|(T flags, CommandType bit)
78 return static_cast<CommandTypeMask>(flags) | static_cast<CommandTypeMask>(bit);
82 * @brief Descriptor of single buffer binding within
85 struct VertexBufferBindingDescriptor
87 const TestGraphicsBuffer* buffer{nullptr};
92 * @brief Descriptor of ix buffer binding within
95 struct IndexBufferBindingDescriptor
97 const TestGraphicsBuffer* buffer{nullptr};
99 Graphics::Format format{};
103 * @brief Descriptor of uniform buffer binding within
106 struct UniformBufferBindingDescriptor
108 const TestGraphicsBuffer* buffer{nullptr};
109 uint32_t binding{0u};
111 bool emulated; ///<true if UBO is emulated for old gfx API
115 * @brief The descriptor of draw call
117 struct DrawCallDescriptor
120 * @brief Enum specifying type of the draw call
126 DRAW_INDEXED_INDIRECT
129 Type type{}; ///< Type of the draw call
132 * Union contains data for all types of draw calls.
137 * @brief Vertex array draw
141 uint32_t vertexCount;
142 uint32_t instanceCount;
143 uint32_t firstVertex;
144 uint32_t firstInstance;
148 * @brief Indexed draw
153 uint32_t instanceCount;
155 int32_t vertexOffset;
156 uint32_t firstInstance;
160 * @brief Indexed draw indirect
164 const TestGraphicsBuffer* buffer;
168 } drawIndexedIndirect;
173 * Command structure allocates memory to store a single command
181 Command(CommandType type)
184 // do non-trivial initialization
187 case CommandType::BEGIN_RENDER_PASS:
189 new(&data.beginRenderPass) CommandData::BeginRenderPassDescriptor();
202 case CommandType::BEGIN_RENDER_PASS:
204 data.beginRenderPass.~BeginRenderPassDescriptor();
215 * @brief Copy constructor
216 * @param[in] rhs Command
218 Command(const Command& rhs)
222 case CommandType::BEGIN_RENDER_PASS:
224 new(&data.beginRenderPass) CommandData::BeginRenderPassDescriptor(rhs.data.beginRenderPass);
227 case CommandType::END_RENDER_PASS:
229 data.endRenderPass = rhs.data.endRenderPass;
232 case CommandType::EXECUTE_COMMAND_BUFFERS:
234 data.executeCommandBuffers = rhs.data.executeCommandBuffers;
238 case CommandType::BIND_VERTEX_BUFFERS:
240 data.bindVertexBuffers = rhs.data.bindVertexBuffers;
243 case CommandType::BIND_INDEX_BUFFER:
245 data.bindIndexBuffer = rhs.data.bindIndexBuffer;
248 case CommandType::BIND_SAMPLERS:
250 data.bindSamplers = rhs.data.bindSamplers;
253 case CommandType::BIND_TEXTURES:
255 data.bindTextures = rhs.data.bindTextures;
258 case CommandType::BIND_PIPELINE:
260 data.bindPipeline = rhs.data.bindPipeline;
263 case CommandType::BIND_UNIFORM_BUFFER:
265 data.bindUniformBuffers = rhs.data.bindUniformBuffers;
268 case CommandType::DRAW:
270 data.draw.type = rhs.data.draw.type;
271 data.draw.draw = rhs.data.draw.draw;
274 case CommandType::DRAW_INDEXED:
276 data.draw.type = rhs.data.draw.type;
277 data.draw.drawIndexed = rhs.data.draw.drawIndexed;
280 case CommandType::DRAW_INDEXED_INDIRECT:
282 data.draw.type = rhs.data.draw.type;
283 data.draw.drawIndexedIndirect = rhs.data.draw.drawIndexedIndirect;
286 case CommandType::FLUSH:
291 case CommandType::SET_SCISSOR:
293 data.scissor.region = rhs.data.scissor.region;
296 case CommandType::SET_SCISSOR_TEST:
298 data.scissorTest.enable = rhs.data.scissorTest.enable;
301 case CommandType::SET_VIEWPORT:
303 data.viewport.region = rhs.data.viewport.region;
306 case CommandType::SET_VIEWPORT_TEST:
308 data.viewportTest.enable = rhs.data.viewportTest.enable;
311 case CommandType::SET_COLOR_MASK:
313 data.colorMask.enabled = rhs.data.colorMask.enabled;
316 case CommandType::CLEAR_STENCIL_BUFFER:
320 case CommandType::CLEAR_DEPTH_BUFFER:
324 case CommandType::SET_STENCIL_TEST_ENABLE:
326 data.stencilTest.enabled = rhs.data.stencilTest.enabled;
329 case CommandType::SET_STENCIL_FUNC:
331 data.stencilFunc.compareMask = rhs.data.stencilFunc.compareMask;
332 data.stencilFunc.compareOp = rhs.data.stencilFunc.compareOp;
333 data.stencilFunc.reference = rhs.data.stencilFunc.reference;
336 case CommandType::SET_STENCIL_WRITE_MASK:
338 data.stencilWriteMask.mask = rhs.data.stencilWriteMask.mask;
341 case CommandType::SET_STENCIL_OP:
343 data.stencilOp.failOp = rhs.data.stencilOp.failOp;
344 data.stencilOp.depthFailOp = rhs.data.stencilOp.depthFailOp;
345 data.stencilOp.passOp = rhs.data.stencilOp.passOp;
349 case CommandType::SET_DEPTH_COMPARE_OP:
351 data.depth.compareOp = rhs.data.depth.compareOp;
354 case CommandType::SET_DEPTH_TEST_ENABLE:
356 data.depth.testEnabled = rhs.data.depth.testEnabled;
359 case CommandType::SET_DEPTH_WRITE_ENABLE:
361 data.depth.writeEnabled = rhs.data.depth.writeEnabled;
369 * @brief move constructor
370 * @param[in] rhs Command
372 Command(Command&& rhs) noexcept
376 case CommandType::BEGIN_RENDER_PASS:
378 new(&data.beginRenderPass) CommandData::BeginRenderPassDescriptor(std::move(rhs.data.beginRenderPass));
381 case CommandType::END_RENDER_PASS:
383 data.endRenderPass = std::move(rhs.data.endRenderPass);
386 case CommandType::EXECUTE_COMMAND_BUFFERS:
388 data.executeCommandBuffers = std::move(rhs.data.executeCommandBuffers);
391 case CommandType::BIND_VERTEX_BUFFERS:
393 data.bindVertexBuffers = std::move(rhs.data.bindVertexBuffers);
396 case CommandType::BIND_INDEX_BUFFER:
398 data.bindIndexBuffer = rhs.data.bindIndexBuffer;
401 case CommandType::BIND_UNIFORM_BUFFER:
403 data.bindUniformBuffers = std::move(rhs.data.bindUniformBuffers);
406 case CommandType::BIND_SAMPLERS:
408 data.bindSamplers = std::move(rhs.data.bindSamplers);
411 case CommandType::BIND_TEXTURES:
413 data.bindTextures = std::move(rhs.data.bindTextures);
416 case CommandType::BIND_PIPELINE:
418 data.bindPipeline = rhs.data.bindPipeline;
421 case CommandType::DRAW:
423 data.draw.type = rhs.data.draw.type;
424 data.draw.draw = rhs.data.draw.draw;
427 case CommandType::DRAW_INDEXED:
429 data.draw.type = rhs.data.draw.type;
430 data.draw.drawIndexed = rhs.data.draw.drawIndexed;
433 case CommandType::DRAW_INDEXED_INDIRECT:
435 data.draw.type = rhs.data.draw.type;
436 data.draw.drawIndexedIndirect = rhs.data.draw.drawIndexedIndirect;
439 case CommandType::FLUSH:
444 case CommandType::SET_SCISSOR:
446 data.scissor.region = rhs.data.scissor.region;
449 case CommandType::SET_SCISSOR_TEST:
451 data.scissorTest.enable = rhs.data.scissorTest.enable;
454 case CommandType::SET_VIEWPORT:
456 data.viewport.region = rhs.data.viewport.region;
459 case CommandType::SET_VIEWPORT_TEST:
461 data.viewportTest.enable = rhs.data.viewportTest.enable;
465 case CommandType::SET_COLOR_MASK:
467 data.colorMask.enabled = rhs.data.colorMask.enabled;
470 case CommandType::CLEAR_STENCIL_BUFFER:
474 case CommandType::CLEAR_DEPTH_BUFFER:
478 case CommandType::SET_STENCIL_TEST_ENABLE:
480 data.stencilTest.enabled = rhs.data.stencilTest.enabled;
483 case CommandType::SET_STENCIL_WRITE_MASK:
485 data.stencilWriteMask.mask = rhs.data.stencilWriteMask.mask;
488 case CommandType::SET_STENCIL_OP:
490 data.stencilOp.failOp = rhs.data.stencilOp.failOp;
491 data.stencilOp.depthFailOp = rhs.data.stencilOp.depthFailOp;
492 data.stencilOp.passOp = rhs.data.stencilOp.passOp;
495 case CommandType::SET_STENCIL_FUNC:
497 data.stencilFunc.compareMask = rhs.data.stencilFunc.compareMask;
498 data.stencilFunc.compareOp = rhs.data.stencilFunc.compareOp;
499 data.stencilFunc.reference = rhs.data.stencilFunc.reference;
502 case CommandType::SET_DEPTH_COMPARE_OP:
504 data.depth.compareOp = rhs.data.depth.compareOp;
507 case CommandType::SET_DEPTH_TEST_ENABLE:
509 data.depth.testEnabled = rhs.data.depth.testEnabled;
512 case CommandType::SET_DEPTH_WRITE_ENABLE:
514 data.depth.writeEnabled = rhs.data.depth.writeEnabled;
521 CommandType type{CommandType::FLUSH}; ///< Type of command
535 std::vector<Graphics::TextureBinding> textureBindings;
538 // BindSampler command
541 std::vector<Graphics::SamplerBinding> samplerBindings;
546 using Binding = VertexBufferBindingDescriptor;
547 std::vector<Binding> vertexBufferBindings;
550 struct : public IndexBufferBindingDescriptor
556 std::vector<UniformBufferBindingDescriptor> uniformBufferBindings{};
557 UniformBufferBindingDescriptor standaloneUniformsBufferBinding{};
558 } bindUniformBuffers;
562 const TestGraphicsPipeline* pipeline{nullptr};
565 struct : public DrawCallDescriptor
571 Graphics::Rect2D region;
579 Graphics::Viewport region;
586 struct BeginRenderPassDescriptor
588 Graphics::RenderPass* renderPass;
589 Graphics::RenderTarget* renderTarget;
590 Graphics::Rect2D renderArea;
591 std::vector<Graphics::ClearValue> clearValues;
600 std::vector<const TestGraphicsCommandBuffer*> buffers;
601 } executeCommandBuffers;
605 Graphics::CompareOp compareOp;
612 Graphics::StencilOp failOp;
613 Graphics::StencilOp passOp;
614 Graphics::StencilOp depthFailOp;
624 uint32_t compareMask;
625 Graphics::CompareOp compareOp;
641 class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
644 TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
645 ~TestGraphicsCommandBuffer()
649 void BindVertexBuffers(uint32_t firstBinding,
650 std::vector<const Graphics::Buffer*> buffers,
651 std::vector<uint32_t> offsets) override
653 mCommands.emplace_back();
654 mCommands.back().type = CommandType::BIND_VERTEX_BUFFERS;
655 auto& bindings = mCommands.back().data.bindVertexBuffers.vertexBufferBindings;
656 if(bindings.size() < firstBinding + buffers.size())
658 bindings.resize(firstBinding + buffers.size());
659 auto index = firstBinding;
660 for(auto& buf : buffers)
662 bindings[index].buffer = static_cast<const TestGraphicsBuffer*>(buf);
663 bindings[index].offset = offsets[index - firstBinding];
667 mCallStack.PushCall("BindVertexBuffers", "");
670 void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings) override
672 mCommands.emplace_back();
673 auto& cmd = mCommands.back();
674 cmd.type = CommandType::BIND_UNIFORM_BUFFER;
675 auto& bindCmd = cmd.data.bindUniformBuffers;
676 for(const auto& binding : bindings)
680 auto testBuffer = static_cast<const TestGraphicsBuffer*>(binding.buffer);
681 if(testBuffer->IsCPUAllocated()) // standalone uniforms
683 bindCmd.standaloneUniformsBufferBinding.buffer = testBuffer;
684 bindCmd.standaloneUniformsBufferBinding.offset = binding.offset;
685 bindCmd.standaloneUniformsBufferBinding.binding = binding.binding;
686 bindCmd.standaloneUniformsBufferBinding.emulated = true;
688 else // Bind regular UBO
690 // resize binding slots
691 if(binding.binding >= bindCmd.uniformBufferBindings.size())
693 bindCmd.uniformBufferBindings.resize(binding.binding + 1);
695 auto& slot = bindCmd.uniformBufferBindings[binding.binding];
696 slot.buffer = testBuffer;
697 slot.offset = binding.offset;
698 slot.binding = binding.binding;
699 slot.emulated = false;
703 mCallStack.PushCall("BindUniformBuffers", "");
706 void BindPipeline(const Graphics::Pipeline& pipeline) override
708 mCommands.emplace_back();
709 mCommands.back().type = CommandType::BIND_PIPELINE;
710 mCommands.back().data.bindPipeline.pipeline = static_cast<const TestGraphicsPipeline*>(&pipeline);
711 mCallStack.PushCall("BindPipeline", "");
714 void BindTextures(std::vector<Graphics::TextureBinding>& textureBindings) override
716 mCommands.emplace_back();
717 mCommands.back().type = CommandType::BIND_TEXTURES;
718 mCommands.back().data.bindTextures.textureBindings = std::move(textureBindings);
719 mCallStack.PushCall("BindTextures", "");
722 void BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings) override
724 mCommands.emplace_back();
725 mCommands.back().data.bindSamplers.samplerBindings = std::move(samplerBindings);
726 mCallStack.PushCall("BindSamplers", "");
729 void BindPushConstants(void* data,
731 uint32_t binding) override
733 mCallStack.PushCall("BindPushConstants", "");
736 void BindIndexBuffer(const Graphics::Buffer& buffer,
738 Graphics::Format format) override
740 mCommands.emplace_back();
741 mCommands.back().type = CommandType::BIND_INDEX_BUFFER;
742 mCommands.back().data.bindIndexBuffer.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
743 mCommands.back().data.bindIndexBuffer.offset = offset;
744 mCommands.back().data.bindIndexBuffer.format = format;
745 mCallStack.PushCall("BindIndexBuffer", "");
748 void BeginRenderPass(
749 Graphics::RenderPass* renderPass,
750 Graphics::RenderTarget* renderTarget,
751 Graphics::Rect2D renderArea,
752 std::vector<Graphics::ClearValue> clearValues) override
754 mCommands.emplace_back(CommandType::BEGIN_RENDER_PASS);
755 auto& cmd = mCommands.back();
756 cmd.data.beginRenderPass.renderPass = renderPass;
757 cmd.data.beginRenderPass.renderTarget = renderTarget;
758 cmd.data.beginRenderPass.renderArea = renderArea;
759 cmd.data.beginRenderPass.clearValues = clearValues;
761 TraceCallStack::NamedParams namedParams;
762 namedParams["renderPass"] << std::hex << renderPass;
763 namedParams["renderTarget"] << std::hex << renderTarget;
764 namedParams["renderArea"] << renderArea.width << ", " << renderArea.height;
765 mCallStack.PushCall("BeginRenderPass", namedParams.str(), namedParams);
769 * @brief Ends current render pass
771 * This command must be issued in order to finalize the render pass.
772 * It's up to the implementation whether anything has to be done but
773 * the Controller may use end RP marker in order to resolve resource
774 * dependencies (for example, to know when target texture is ready
775 * before passing it to another render pass).
777 void EndRenderPass() override
779 mCallStack.PushCall("EndRenderPass", "");
782 void ExecuteCommandBuffers(std::vector<const CommandBuffer*>&& commandBuffers) override
784 mCommands.emplace_back();
785 auto& cmd = mCommands.back();
786 cmd.type = CommandType::EXECUTE_COMMAND_BUFFERS;
787 cmd.data.executeCommandBuffers.buffers.reserve(commandBuffers.size());
788 for(auto&& item : commandBuffers)
790 cmd.data.executeCommandBuffers.buffers.emplace_back(static_cast<const TestGraphicsCommandBuffer*>(item));
792 mCallStack.PushCall("ExecuteCommandBuffers", "");
796 uint32_t vertexCount,
797 uint32_t instanceCount,
798 uint32_t firstVertex,
799 uint32_t firstInstance) override
801 mCommands.emplace_back();
802 mCommands.back().type = CommandType::DRAW;
803 auto& cmd = mCommands.back().data.draw;
804 cmd.type = DrawCallDescriptor::Type::DRAW;
805 cmd.draw.vertexCount = vertexCount;
806 cmd.draw.instanceCount = instanceCount;
807 cmd.draw.firstInstance = firstInstance;
808 cmd.draw.firstVertex = firstVertex;
809 mCallStack.PushCall("Draw", "");
814 uint32_t instanceCount,
816 int32_t vertexOffset,
817 uint32_t firstInstance) override
819 mCommands.emplace_back();
820 mCommands.back().type = CommandType::DRAW_INDEXED;
821 auto& cmd = mCommands.back().data.draw;
822 cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED;
823 cmd.drawIndexed.firstIndex = firstIndex;
824 cmd.drawIndexed.firstInstance = firstInstance;
825 cmd.drawIndexed.indexCount = indexCount;
826 cmd.drawIndexed.vertexOffset = vertexOffset;
827 cmd.drawIndexed.instanceCount = instanceCount;
828 mCallStack.PushCall("DrawIndexed", "");
831 void DrawIndexedIndirect(
832 Graphics::Buffer& buffer,
835 uint32_t stride) override
837 mCommands.emplace_back();
838 mCommands.back().type = CommandType::DRAW_INDEXED_INDIRECT;
839 auto& cmd = mCommands.back().data.draw;
840 cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED_INDIRECT;
841 cmd.drawIndexedIndirect.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
842 cmd.drawIndexedIndirect.offset = offset;
843 cmd.drawIndexedIndirect.drawCount = drawCount;
844 cmd.drawIndexedIndirect.stride = stride;
845 mCallStack.PushCall("DrawIndexedIndirect", "");
848 void Reset() override
851 mCallStack.PushCall("Reset", "");
854 void SetScissor(Graphics::Rect2D value) override
856 TraceCallStack::NamedParams params;
857 params["x"] << value.x;
858 params["y"] << value.y;
859 params["width"] << value.width;
860 params["height"] << value.height;
861 mCallStack.PushCall("SetScissor", params.str(), params);
863 mCommands.emplace_back();
864 mCommands.back().type = CommandType::SET_SCISSOR;
865 mCommands.back().data.scissor.region = value;
868 void SetScissorTestEnable(bool value) override
870 TraceCallStack::NamedParams params;
871 params["value"] << (value ? "T" : "F");
872 mCallStack.PushCall("SetScissorTestEnable", params.str(), params);
874 mCommands.emplace_back();
875 mCommands.back().type = CommandType::SET_SCISSOR_TEST;
876 mCommands.back().data.scissorTest.enable = value;
879 void SetViewport(Graphics::Viewport value) override
881 TraceCallStack::NamedParams params;
882 params["x"] << value.x;
883 params["y"] << value.y;
884 params["width"] << value.width;
885 params["height"] << value.height;
886 params["minDepth"] << value.minDepth;
887 params["maxDepth"] << value.maxDepth;
888 mCallStack.PushCall("SetViewport", params.str(), params);
890 mCommands.emplace_back();
891 mCommands.back().type = CommandType::SET_VIEWPORT;
892 mCommands.back().data.viewport.region = value;
895 void SetViewportEnable(bool value) override
897 TraceCallStack::NamedParams params;
898 params["value"] << (value ? "T" : "F");
899 mCallStack.PushCall("SetViewportEnable", params.str(), params);
901 mCommands.emplace_back();
902 mCommands.back().type = CommandType::SET_VIEWPORT_TEST;
903 mCommands.back().data.viewportTest.enable = value;
906 void SetColorMask(bool enabled) override
908 TraceCallStack::NamedParams params;
909 params["enabled"] << (enabled ? "T" : "F");
910 mCallStack.PushCall("SetColorMask", params.str(), params);
911 mCommands.emplace_back();
912 mCommands.back().type = CommandType::SET_COLOR_MASK;
913 mCommands.back().data.colorMask.enabled = enabled;
916 void ClearStencilBuffer() override
918 mCallStack.PushCall("SetStencilMask", "");
919 mCommands.emplace_back();
920 mCommands.back().type = CommandType::CLEAR_STENCIL_BUFFER;
923 void SetStencilTestEnable(bool stencilEnable) override
925 TraceCallStack::NamedParams params;
926 params["enabled"] << (stencilEnable ? "T" : "F");
927 mCallStack.PushCall("SetStencilTestEnable", params.str(), params);
928 mCommands.emplace_back();
929 mCommands.back().type = CommandType::SET_STENCIL_TEST_ENABLE;
930 mCommands.back().data.stencilTest.enabled = stencilEnable;
933 void SetStencilWriteMask(uint32_t writeMask) override
935 TraceCallStack::NamedParams params;
936 params["writeMask"] << std::hex << writeMask;
937 mCallStack.PushCall("SetStencilWriteMask", params.str(), params);
938 mCommands.emplace_back();
939 mCommands.back().type = CommandType::SET_STENCIL_WRITE_MASK;
940 mCommands.back().data.stencilWriteMask.mask = writeMask;
943 void SetStencilOp(Graphics::StencilOp failOp,
944 Graphics::StencilOp passOp,
945 Graphics::StencilOp depthFailOp) override
947 TraceCallStack::NamedParams params;
948 params["failOp"] << failOp;
949 params["passOp"] << passOp;
950 params["depthFailOp"] << depthFailOp;
951 mCallStack.PushCall("SetStencilOp", params.str(), params);
952 mCommands.emplace_back();
953 mCommands.back().type = CommandType::SET_STENCIL_OP;
954 mCommands.back().data.stencilOp.failOp = failOp;
955 mCommands.back().data.stencilOp.passOp = passOp;
956 mCommands.back().data.stencilOp.depthFailOp = depthFailOp;
959 void SetStencilFunc(Graphics::CompareOp compareOp,
961 uint32_t compareMask) override
963 TraceCallStack::NamedParams params;
964 params["compareOp"] << compareOp;
965 params["compareMask"] << std::hex << compareMask;
966 params["reference"] << std::hex << reference;
967 mCallStack.PushCall("SetStencilFunc", params.str(), params);
969 mCommands.emplace_back();
970 mCommands.back().type = CommandType::SET_STENCIL_FUNC;
972 mCommands.back().data.stencilFunc.compareOp = compareOp;
973 mCommands.back().data.stencilFunc.compareMask = compareMask;
974 mCommands.back().data.stencilFunc.reference = reference;
977 void SetDepthCompareOp(Graphics::CompareOp compareOp) override
979 TraceCallStack::NamedParams params;
980 params["compareOp"] << compareOp;
981 mCallStack.PushCall("SetDepthCompareOp", params.str(), params);
982 mCommands.emplace_back();
983 mCommands.back().type = CommandType::SET_DEPTH_COMPARE_OP;
984 mCommands.back().data.depth.compareOp = compareOp;
987 void SetDepthTestEnable(bool depthTestEnable) override
989 TraceCallStack::NamedParams params;
990 params["enabled"] << (depthTestEnable ? "T" : "F");
991 mCallStack.PushCall("SetDepthTestEnable", params.str(), params);
992 mCommands.emplace_back();
993 mCommands.back().type = CommandType::SET_DEPTH_TEST_ENABLE;
994 mCommands.back().data.depth.testEnabled = depthTestEnable;
996 void SetDepthWriteEnable(bool depthWriteEnable) override
998 TraceCallStack::NamedParams params;
999 params["enabled"] << (depthWriteEnable ? "T" : "F");
1000 mCallStack.PushCall("SetDepthWriteEnable", params.str(), params);
1001 mCommands.emplace_back();
1002 mCommands.back().type = CommandType::SET_DEPTH_WRITE_ENABLE;
1003 mCommands.back().data.depth.writeEnabled = depthWriteEnable;
1005 void ClearDepthBuffer() override
1007 mCallStack.PushCall("ClearDepthBuffer", "");
1008 mCommands.emplace_back();
1009 mCommands.back().type = CommandType::CLEAR_DEPTH_BUFFER;
1012 [[nodiscard]] const std::vector<Command>& GetCommands() const
1018 * Returns number of draw commands
1021 int GetDrawCallsCount();
1024 * Retrieves state resolve for selected draw call
1025 * @param drawCommandIndex
1027 void GetStateForDrawCall(int drawCallIndex);
1030 * Retrieves commands of specified type
1032 std::vector<const Command*> GetCommandsByType(CommandTypeMask mask) const;
1034 std::vector<const Command*> GetChildCommandsByType(CommandTypeMask mask) const;
1037 TraceCallStack& mCallStack;
1038 TestGlAbstraction& mGlAbstraction;
1040 std::vector<Command> mCommands;
1045 #endif //DALI_TEST_GRAPHICS_COMMAND_BUFFER_H