a0dee4ab2e86ed3b207100e5ff6e9044942ecc04
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-command-buffer.cpp
1 /*
2  * Copyright (c) 2021 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-command-buffer.h"
18
19 namespace Dali
20 {
21 TestGraphicsCommandBuffer::TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction)
22 : mCallStack(callstack),
23   mGlAbstraction(glAbstraction)
24 {
25 }
26
27 void TestGraphicsCommandBuffer::BindVertexBuffers(uint32_t                             firstBinding,
28                                                   std::vector<const Graphics::Buffer*> buffers,
29                                                   std::vector<uint32_t>                offsets)
30 {
31   mVertexBufferBindings.firstBinding = firstBinding;
32   mVertexBufferBindings.buffers      = buffers; // Copy
33   mVertexBufferBindings.offsets      = offsets; // Copy
34   mCallStack.PushCall("BindVertexBuffers", "");
35 }
36
37 void TestGraphicsCommandBuffer::BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings)
38 {
39   mCallStack.PushCall("BindUniformBuffers", "");
40 }
41
42 void TestGraphicsCommandBuffer::BindPipeline(const Graphics::Pipeline& pipeline)
43 {
44   mPipeline = static_cast<TestGraphicsPipeline*>(const_cast<Graphics::Pipeline*>(&pipeline));
45   mCallStack.PushCall("BindPipeline", "");
46 }
47
48 void TestGraphicsCommandBuffer::BindTextures(std::vector<Graphics::TextureBinding>& textureBindings)
49 {
50   mCallStack.PushCall("BindTextures", "");
51   for(auto& binding : textureBindings)
52   {
53     mTextureBindings.push_back(binding);
54   }
55 }
56
57 void TestGraphicsCommandBuffer::BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings)
58 {
59   mCallStack.PushCall("BindSamplers", "");
60 }
61
62 void TestGraphicsCommandBuffer::BindPushConstants(void*    data,
63                                                   uint32_t size,
64                                                   uint32_t binding)
65 {
66   mCallStack.PushCall("BindPushConstants", "");
67 }
68
69 void TestGraphicsCommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer,
70                                                 uint32_t                offset,
71                                                 Graphics::Format        format)
72 {
73   mIndexBufferBinding.buffer = &buffer;
74   mIndexBufferBinding.offset = offset;
75   mIndexBufferBinding.format = format;
76   mCallStack.PushCall("BindIndexBuffer", "");
77 }
78
79 void TestGraphicsCommandBuffer::BeginRenderPass(
80   Graphics::RenderPass&             renderPass,
81   Graphics::RenderTarget&           renderTarget,
82   Graphics::Extent2D                renderArea,
83   std::vector<Graphics::ClearValue> clearValues)
84 {
85   mCallStack.PushCall("BeginRenderPass", "");
86 }
87
88 void TestGraphicsCommandBuffer::EndRenderPass()
89 {
90   mCallStack.PushCall("EndRenderPass", "");
91 }
92
93 void TestGraphicsCommandBuffer::Draw(
94   uint32_t vertexCount,
95   uint32_t instanceCount,
96   uint32_t firstVertex,
97   uint32_t firstInstance)
98 {
99   drawCommand.drawType                      = Draw::DrawType::Unindexed;
100   drawCommand.u.unindexedDraw.vertexCount   = vertexCount;
101   drawCommand.u.unindexedDraw.instanceCount = instanceCount;
102   drawCommand.u.unindexedDraw.firstVertex   = firstVertex;
103   drawCommand.u.unindexedDraw.firstInstance = firstInstance;
104   mCallStack.PushCall("Draw", "");
105 }
106
107 void TestGraphicsCommandBuffer::DrawIndexed(
108   uint32_t indexCount,
109   uint32_t instanceCount,
110   uint32_t firstIndex,
111   int32_t  vertexOffset,
112   uint32_t firstInstance)
113 {
114   drawCommand.drawType                    = TestGraphicsCommandBuffer::Draw::DrawType::Indexed;
115   drawCommand.u.indexedDraw.indexCount    = indexCount;
116   drawCommand.u.indexedDraw.instanceCount = instanceCount;
117   drawCommand.u.indexedDraw.firstIndex    = firstIndex;
118   drawCommand.u.indexedDraw.vertexOffset  = vertexOffset;
119   drawCommand.u.indexedDraw.firstInstance = firstInstance;
120   mCallStack.PushCall("DrawIndexed", "");
121 }
122
123 void TestGraphicsCommandBuffer::DrawIndexedIndirect(
124   Graphics::Buffer& buffer,
125   uint32_t          offset,
126   uint32_t          drawCount,
127   uint32_t          stride)
128 {
129   mCallStack.PushCall("DrawIndexedIndirect", "");
130 }
131
132 void TestGraphicsCommandBuffer::Reset(Graphics::CommandBuffer& commandBuffer)
133 {
134   mCallStack.PushCall("Reset", "");
135 }
136
137 void TestGraphicsCommandBuffer::SetScissor(Graphics::Extent2D value)
138 {
139   mCallStack.PushCall("SetScissor", "");
140 }
141
142 void TestGraphicsCommandBuffer::SetScissorTestEnable(bool value)
143 {
144   mCallStack.PushCall("SetScissorTestEnable", "");
145 }
146
147 void TestGraphicsCommandBuffer::SetViewport(Graphics::Viewport value)
148 {
149   mCallStack.PushCall("SetViewport", "");
150 }
151
152 void TestGraphicsCommandBuffer::SetViewportEnable(bool value)
153 {
154   mCallStack.PushCall("SetViewportEnable", "");
155 }
156
157 } // namespace Dali