Updated test files to match dali-core Pipeline VtxFmt
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-command-buffer.h
1 #ifndef DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
2 #define DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
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>
24 #include <cstdint>
25 #include <vector>
26 #include "test-gl-abstraction.h"
27 #include "test-graphics-pipeline.h"
28 #include "test-trace-call-stack.h"
29
30 namespace Dali
31 {
32 class TestGraphicsCommandBuffer : public Graphics::CommandBuffer
33 {
34 public:
35   TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction);
36
37   void BindVertexBuffers(uint32_t                             firstBinding,
38                          std::vector<const Graphics::Buffer*> buffers,
39                          std::vector<uint32_t>                offsets);
40
41   void BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings);
42
43   void BindPipeline(const Graphics::Pipeline& pipeline);
44
45   void BindTextures(std::vector<Graphics::TextureBinding>& textureBindings);
46
47   void BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings);
48
49   void BindPushConstants(void*    data,
50                          uint32_t size,
51                          uint32_t binding);
52
53   void BindIndexBuffer(const Graphics::Buffer& buffer,
54                        uint32_t                offset,
55                        Graphics::Format        format);
56
57   void BeginRenderPass(Graphics::RenderPass&             renderPass,
58                        Graphics::RenderTarget&           renderTarget,
59                        Graphics::Extent2D                renderArea,
60                        std::vector<Graphics::ClearValue> clearValues);
61
62   void EndRenderPass();
63
64   void Draw(
65     uint32_t vertexCount,
66     uint32_t instanceCount,
67     uint32_t firstVertex,
68     uint32_t firstInstance);
69
70   void DrawIndexed(
71     uint32_t indexCount,
72     uint32_t instanceCount,
73     uint32_t firstIndex,
74     int32_t  vertexOffset,
75     uint32_t firstInstance);
76
77   void DrawIndexedIndirect(
78     Graphics::Buffer& buffer,
79     uint32_t          offset,
80     uint32_t          drawCount,
81     uint32_t          stride);
82
83   void Reset(Graphics::CommandBuffer& commandBuffer);
84
85   void SetScissor(Graphics::Extent2D value);
86
87   void SetScissorTestEnable(bool value);
88
89   void SetViewport(Graphics::Viewport value);
90
91   void SetViewportEnable(bool value);
92
93 public:
94   TraceCallStack&                       mCallStack;
95   TestGlAbstraction&                    mGlAbstraction;
96   TestGraphicsPipeline*                 mPipeline{nullptr};
97   std::vector<Graphics::TextureBinding> mTextureBindings{};
98
99   struct VertexBuffersBinding
100   {
101     uint32_t                             firstBinding;
102     std::vector<const Graphics::Buffer*> buffers;
103     std::vector<uint32_t>                offsets;
104   };
105   VertexBuffersBinding mVertexBufferBindings{};
106
107   struct IndexBufferBinding
108   {
109     const Graphics::Buffer* buffer;
110     uint32_t                offset;
111     Graphics::Format        format;
112   };
113   IndexBufferBinding mIndexBufferBinding{};
114
115   struct Draw
116   {
117     enum class DrawType
118     {
119       Indexed,
120       Unindexed
121     } drawType;
122     union
123     {
124       struct IndexedDraw
125       {
126         uint32_t indexCount;
127         uint32_t instanceCount;
128         uint32_t firstIndex;
129         int32_t  vertexOffset;
130         uint32_t firstInstance;
131       } indexedDraw;
132       struct UnindexedDraw
133       {
134         uint32_t vertexCount;
135         uint32_t instanceCount;
136         uint32_t firstVertex;
137         uint32_t firstInstance;
138       } unindexedDraw;
139     } u;
140   } drawCommand;
141 };
142
143 } // namespace Dali
144
145 #endif //DALI_TEST_GRAPHICS_COMMAND_BUFFER_H