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;
596 Graphics::SyncObject* syncObject;
601 std::vector<const TestGraphicsCommandBuffer*> buffers;
602 } executeCommandBuffers;
606 Graphics::CompareOp compareOp;
613 Graphics::StencilOp failOp;
614 Graphics::StencilOp passOp;
615 Graphics::StencilOp depthFailOp;
625 uint32_t compareMask;
626 Graphics::CompareOp compareOp;
642 class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
645 TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
646 ~TestGraphicsCommandBuffer()
650 void BindVertexBuffers(uint32_t firstBinding,
651 std::vector<const Graphics::Buffer*> buffers,
652 std::vector<uint32_t> offsets) override
654 mCommands.emplace_back();
655 mCommands.back().type = CommandType::BIND_VERTEX_BUFFERS;
656 auto& bindings = mCommands.back().data.bindVertexBuffers.vertexBufferBindings;
657 if(bindings.size() < firstBinding + buffers.size())
659 bindings.resize(firstBinding + buffers.size());
660 auto index = firstBinding;
661 for(auto& buf : buffers)
663 bindings[index].buffer = static_cast<const TestGraphicsBuffer*>(buf);
664 bindings[index].offset = offsets[index - firstBinding];
668 mCallStack.PushCall("BindVertexBuffers", "");
671 void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings) override
673 mCommands.emplace_back();
674 auto& cmd = mCommands.back();
675 cmd.type = CommandType::BIND_UNIFORM_BUFFER;
676 auto& bindCmd = cmd.data.bindUniformBuffers;
677 for(const auto& binding : bindings)
681 auto testBuffer = static_cast<const TestGraphicsBuffer*>(binding.buffer);
682 if(testBuffer->IsCPUAllocated()) // standalone uniforms
684 bindCmd.standaloneUniformsBufferBinding.buffer = testBuffer;
685 bindCmd.standaloneUniformsBufferBinding.offset = binding.offset;
686 bindCmd.standaloneUniformsBufferBinding.binding = binding.binding;
687 bindCmd.standaloneUniformsBufferBinding.emulated = true;
689 else // Bind regular UBO
691 // resize binding slots
692 if(binding.binding >= bindCmd.uniformBufferBindings.size())
694 bindCmd.uniformBufferBindings.resize(binding.binding + 1);
696 auto& slot = bindCmd.uniformBufferBindings[binding.binding];
697 slot.buffer = testBuffer;
698 slot.offset = binding.offset;
699 slot.binding = binding.binding;
700 slot.emulated = false;
704 mCallStack.PushCall("BindUniformBuffers", "");
707 void BindPipeline(const Graphics::Pipeline& pipeline) override
709 mCommands.emplace_back();
710 mCommands.back().type = CommandType::BIND_PIPELINE;
711 mCommands.back().data.bindPipeline.pipeline = static_cast<const TestGraphicsPipeline*>(&pipeline);
712 mCallStack.PushCall("BindPipeline", "");
715 void BindTextures(std::vector<Graphics::TextureBinding>& textureBindings) override
717 mCommands.emplace_back();
718 mCommands.back().type = CommandType::BIND_TEXTURES;
719 mCommands.back().data.bindTextures.textureBindings = std::move(textureBindings);
720 mCallStack.PushCall("BindTextures", "");
723 void BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings) override
725 mCommands.emplace_back();
726 mCommands.back().data.bindSamplers.samplerBindings = std::move(samplerBindings);
727 mCallStack.PushCall("BindSamplers", "");
730 void BindPushConstants(void* data,
732 uint32_t binding) override
734 mCallStack.PushCall("BindPushConstants", "");
737 void BindIndexBuffer(const Graphics::Buffer& buffer,
739 Graphics::Format format) override
741 mCommands.emplace_back();
742 mCommands.back().type = CommandType::BIND_INDEX_BUFFER;
743 mCommands.back().data.bindIndexBuffer.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
744 mCommands.back().data.bindIndexBuffer.offset = offset;
745 mCommands.back().data.bindIndexBuffer.format = format;
746 mCallStack.PushCall("BindIndexBuffer", "");
749 void BeginRenderPass(
750 Graphics::RenderPass* renderPass,
751 Graphics::RenderTarget* renderTarget,
752 Graphics::Rect2D renderArea,
753 std::vector<Graphics::ClearValue> clearValues) override
755 mCommands.emplace_back(CommandType::BEGIN_RENDER_PASS);
756 auto& cmd = mCommands.back();
757 cmd.data.beginRenderPass.renderPass = renderPass;
758 cmd.data.beginRenderPass.renderTarget = renderTarget;
759 cmd.data.beginRenderPass.renderArea = renderArea;
760 cmd.data.beginRenderPass.clearValues = clearValues;
762 TraceCallStack::NamedParams namedParams;
763 namedParams["renderPass"] << std::hex << renderPass;
764 namedParams["renderTarget"] << std::hex << renderTarget;
765 namedParams["renderArea"] << renderArea.width << ", " << renderArea.height;
766 mCallStack.PushCall("BeginRenderPass", namedParams.str(), namedParams);
770 * @brief Ends current render pass
772 * This command must be issued in order to finalize the render pass.
773 * It's up to the implementation whether anything has to be done but
774 * the Controller may use end RP marker in order to resolve resource
775 * dependencies (for example, to know when target texture is ready
776 * before passing it to another render pass).
778 void EndRenderPass(Graphics::SyncObject* syncObject) override
780 mCommands.emplace_back(CommandType::END_RENDER_PASS);
781 auto& cmd = mCommands.back();
783 cmd.data.endRenderPass.syncObject = syncObject;
785 TraceCallStack::NamedParams namedParams;
786 namedParams["syncObject"] << std::hex << syncObject;
787 mCallStack.PushCall("EndRenderPass", namedParams.str(), namedParams);
790 void ExecuteCommandBuffers(std::vector<const CommandBuffer*>&& commandBuffers) override
792 mCommands.emplace_back();
793 auto& cmd = mCommands.back();
794 cmd.type = CommandType::EXECUTE_COMMAND_BUFFERS;
795 cmd.data.executeCommandBuffers.buffers.reserve(commandBuffers.size());
796 for(auto&& item : commandBuffers)
798 cmd.data.executeCommandBuffers.buffers.emplace_back(static_cast<const TestGraphicsCommandBuffer*>(item));
800 mCallStack.PushCall("ExecuteCommandBuffers", "");
804 uint32_t vertexCount,
805 uint32_t instanceCount,
806 uint32_t firstVertex,
807 uint32_t firstInstance) override
809 mCommands.emplace_back();
810 mCommands.back().type = CommandType::DRAW;
811 auto& cmd = mCommands.back().data.draw;
812 cmd.type = DrawCallDescriptor::Type::DRAW;
813 cmd.draw.vertexCount = vertexCount;
814 cmd.draw.instanceCount = instanceCount;
815 cmd.draw.firstInstance = firstInstance;
816 cmd.draw.firstVertex = firstVertex;
817 mCallStack.PushCall("Draw", "");
822 uint32_t instanceCount,
824 int32_t vertexOffset,
825 uint32_t firstInstance) override
827 mCommands.emplace_back();
828 mCommands.back().type = CommandType::DRAW_INDEXED;
829 auto& cmd = mCommands.back().data.draw;
830 cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED;
831 cmd.drawIndexed.firstIndex = firstIndex;
832 cmd.drawIndexed.firstInstance = firstInstance;
833 cmd.drawIndexed.indexCount = indexCount;
834 cmd.drawIndexed.vertexOffset = vertexOffset;
835 cmd.drawIndexed.instanceCount = instanceCount;
836 mCallStack.PushCall("DrawIndexed", "");
839 void DrawIndexedIndirect(
840 Graphics::Buffer& buffer,
843 uint32_t stride) override
845 mCommands.emplace_back();
846 mCommands.back().type = CommandType::DRAW_INDEXED_INDIRECT;
847 auto& cmd = mCommands.back().data.draw;
848 cmd.type = DrawCallDescriptor::Type::DRAW_INDEXED_INDIRECT;
849 cmd.drawIndexedIndirect.buffer = static_cast<const TestGraphicsBuffer*>(&buffer);
850 cmd.drawIndexedIndirect.offset = offset;
851 cmd.drawIndexedIndirect.drawCount = drawCount;
852 cmd.drawIndexedIndirect.stride = stride;
853 mCallStack.PushCall("DrawIndexedIndirect", "");
856 void Reset() override
859 mCallStack.PushCall("Reset", "");
862 void SetScissor(Graphics::Rect2D value) override
864 TraceCallStack::NamedParams params;
865 params["x"] << value.x;
866 params["y"] << value.y;
867 params["width"] << value.width;
868 params["height"] << value.height;
869 mCallStack.PushCall("SetScissor", params.str(), params);
871 mCommands.emplace_back();
872 mCommands.back().type = CommandType::SET_SCISSOR;
873 mCommands.back().data.scissor.region = value;
876 void SetScissorTestEnable(bool value) override
878 TraceCallStack::NamedParams params;
879 params["value"] << (value ? "T" : "F");
880 mCallStack.PushCall("SetScissorTestEnable", params.str(), params);
882 mCommands.emplace_back();
883 mCommands.back().type = CommandType::SET_SCISSOR_TEST;
884 mCommands.back().data.scissorTest.enable = value;
887 void SetViewport(Graphics::Viewport value) override
889 TraceCallStack::NamedParams params;
890 params["x"] << value.x;
891 params["y"] << value.y;
892 params["width"] << value.width;
893 params["height"] << value.height;
894 params["minDepth"] << value.minDepth;
895 params["maxDepth"] << value.maxDepth;
896 mCallStack.PushCall("SetViewport", params.str(), params);
898 mCommands.emplace_back();
899 mCommands.back().type = CommandType::SET_VIEWPORT;
900 mCommands.back().data.viewport.region = value;
903 void SetViewportEnable(bool value) override
905 TraceCallStack::NamedParams params;
906 params["value"] << (value ? "T" : "F");
907 mCallStack.PushCall("SetViewportEnable", params.str(), params);
909 mCommands.emplace_back();
910 mCommands.back().type = CommandType::SET_VIEWPORT_TEST;
911 mCommands.back().data.viewportTest.enable = value;
914 void SetColorMask(bool enabled) override
916 TraceCallStack::NamedParams params;
917 params["enabled"] << (enabled ? "T" : "F");
918 mCallStack.PushCall("SetColorMask", params.str(), params);
919 mCommands.emplace_back();
920 mCommands.back().type = CommandType::SET_COLOR_MASK;
921 mCommands.back().data.colorMask.enabled = enabled;
924 void ClearStencilBuffer() override
926 mCallStack.PushCall("SetStencilMask", "");
927 mCommands.emplace_back();
928 mCommands.back().type = CommandType::CLEAR_STENCIL_BUFFER;
931 void SetStencilTestEnable(bool stencilEnable) override
933 TraceCallStack::NamedParams params;
934 params["enabled"] << (stencilEnable ? "T" : "F");
935 mCallStack.PushCall("SetStencilTestEnable", params.str(), params);
936 mCommands.emplace_back();
937 mCommands.back().type = CommandType::SET_STENCIL_TEST_ENABLE;
938 mCommands.back().data.stencilTest.enabled = stencilEnable;
941 void SetStencilWriteMask(uint32_t writeMask) override
943 TraceCallStack::NamedParams params;
944 params["writeMask"] << std::hex << writeMask;
945 mCallStack.PushCall("SetStencilWriteMask", params.str(), params);
946 mCommands.emplace_back();
947 mCommands.back().type = CommandType::SET_STENCIL_WRITE_MASK;
948 mCommands.back().data.stencilWriteMask.mask = writeMask;
951 void SetStencilOp(Graphics::StencilOp failOp,
952 Graphics::StencilOp passOp,
953 Graphics::StencilOp depthFailOp) override
955 TraceCallStack::NamedParams params;
956 params["failOp"] << failOp;
957 params["passOp"] << passOp;
958 params["depthFailOp"] << depthFailOp;
959 mCallStack.PushCall("SetStencilOp", params.str(), params);
960 mCommands.emplace_back();
961 mCommands.back().type = CommandType::SET_STENCIL_OP;
962 mCommands.back().data.stencilOp.failOp = failOp;
963 mCommands.back().data.stencilOp.passOp = passOp;
964 mCommands.back().data.stencilOp.depthFailOp = depthFailOp;
967 void SetStencilFunc(Graphics::CompareOp compareOp,
969 uint32_t compareMask) override
971 TraceCallStack::NamedParams params;
972 params["compareOp"] << compareOp;
973 params["compareMask"] << std::hex << compareMask;
974 params["reference"] << std::hex << reference;
975 mCallStack.PushCall("SetStencilFunc", params.str(), params);
977 mCommands.emplace_back();
978 mCommands.back().type = CommandType::SET_STENCIL_FUNC;
980 mCommands.back().data.stencilFunc.compareOp = compareOp;
981 mCommands.back().data.stencilFunc.compareMask = compareMask;
982 mCommands.back().data.stencilFunc.reference = reference;
985 void SetDepthCompareOp(Graphics::CompareOp compareOp) override
987 TraceCallStack::NamedParams params;
988 params["compareOp"] << compareOp;
989 mCallStack.PushCall("SetDepthCompareOp", params.str(), params);
990 mCommands.emplace_back();
991 mCommands.back().type = CommandType::SET_DEPTH_COMPARE_OP;
992 mCommands.back().data.depth.compareOp = compareOp;
995 void SetDepthTestEnable(bool depthTestEnable) override
997 TraceCallStack::NamedParams params;
998 params["enabled"] << (depthTestEnable ? "T" : "F");
999 mCallStack.PushCall("SetDepthTestEnable", params.str(), params);
1000 mCommands.emplace_back();
1001 mCommands.back().type = CommandType::SET_DEPTH_TEST_ENABLE;
1002 mCommands.back().data.depth.testEnabled = depthTestEnable;
1004 void SetDepthWriteEnable(bool depthWriteEnable) override
1006 TraceCallStack::NamedParams params;
1007 params["enabled"] << (depthWriteEnable ? "T" : "F");
1008 mCallStack.PushCall("SetDepthWriteEnable", params.str(), params);
1009 mCommands.emplace_back();
1010 mCommands.back().type = CommandType::SET_DEPTH_WRITE_ENABLE;
1011 mCommands.back().data.depth.writeEnabled = depthWriteEnable;
1013 void ClearDepthBuffer() override
1015 mCallStack.PushCall("ClearDepthBuffer", "");
1016 mCommands.emplace_back();
1017 mCommands.back().type = CommandType::CLEAR_DEPTH_BUFFER;
1020 [[nodiscard]] const std::vector<Command>& GetCommands() const
1026 * Returns number of draw commands
1029 int GetDrawCallsCount();
1032 * Retrieves state resolve for selected draw call
1033 * @param drawCommandIndex
1035 void GetStateForDrawCall(int drawCallIndex);
1038 * Retrieves commands of specified type
1040 std::vector<const Command*> GetCommandsByType(CommandTypeMask mask) const;
1042 std::vector<const Command*> GetChildCommandsByType(CommandTypeMask mask) const;
1045 TraceCallStack& mCallStack;
1046 TestGlAbstraction& mGlAbstraction;
1048 std::vector<Command> mCommands;
1053 #endif //DALI_TEST_GRAPHICS_COMMAND_BUFFER_H