2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "test-graphics-command-buffer.h"
21 TestGraphicsCommandBuffer::TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction)
22 : mCallStack(callstack),
23 mGlAbstraction(glAbstraction)
27 void TestGraphicsCommandBuffer::BindVertexBuffers(uint32_t firstBinding,
28 std::vector<const Graphics::Buffer*> buffers,
29 std::vector<uint32_t> offsets)
31 mVertexBufferBindings.firstBinding = firstBinding;
32 mVertexBufferBindings.buffers = buffers; // Copy
33 mVertexBufferBindings.offsets = offsets; // Copy
34 mCallStack.PushCall("BindVertexBuffers", "");
37 void TestGraphicsCommandBuffer::BindUniformBuffers(const std::vector<Graphics::UniformBufferBinding>& bindings)
39 mCallStack.PushCall("BindUniformBuffers", "");
42 void TestGraphicsCommandBuffer::BindPipeline(const Graphics::Pipeline& pipeline)
44 mPipeline = static_cast<TestGraphicsPipeline*>(const_cast<Graphics::Pipeline*>(&pipeline));
45 mCallStack.PushCall("BindPipeline", "");
48 void TestGraphicsCommandBuffer::BindTextures(std::vector<Graphics::TextureBinding>& textureBindings)
50 mCallStack.PushCall("BindTextures", "");
51 for(auto& binding : textureBindings)
53 mTextureBindings.push_back(binding);
57 void TestGraphicsCommandBuffer::BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings)
59 mCallStack.PushCall("BindSamplers", "");
62 void TestGraphicsCommandBuffer::BindPushConstants(void* data,
66 mCallStack.PushCall("BindPushConstants", "");
69 void TestGraphicsCommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer,
71 Graphics::Format format)
73 mIndexBufferBinding.buffer = &buffer;
74 mIndexBufferBinding.offset = offset;
75 mIndexBufferBinding.format = format;
76 mCallStack.PushCall("BindIndexBuffer", "");
79 void TestGraphicsCommandBuffer::BeginRenderPass(
80 Graphics::RenderPass& renderPass,
81 Graphics::RenderTarget& renderTarget,
82 Graphics::Extent2D renderArea,
83 std::vector<Graphics::ClearValue> clearValues)
85 mCallStack.PushCall("BeginRenderPass", "");
88 void TestGraphicsCommandBuffer::EndRenderPass()
90 mCallStack.PushCall("EndRenderPass", "");
93 void TestGraphicsCommandBuffer::Draw(
95 uint32_t instanceCount,
97 uint32_t firstInstance)
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", "");
107 void TestGraphicsCommandBuffer::DrawIndexed(
109 uint32_t instanceCount,
111 int32_t vertexOffset,
112 uint32_t firstInstance)
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", "");
123 void TestGraphicsCommandBuffer::DrawIndexedIndirect(
124 Graphics::Buffer& buffer,
129 mCallStack.PushCall("DrawIndexedIndirect", "");
132 void TestGraphicsCommandBuffer::Reset(Graphics::CommandBuffer& commandBuffer)
134 mCallStack.PushCall("Reset", "");
137 void TestGraphicsCommandBuffer::SetScissor(Graphics::Extent2D value)
139 mCallStack.PushCall("SetScissor", "");
142 void TestGraphicsCommandBuffer::SetScissorTestEnable(bool value)
144 mCallStack.PushCall("SetScissorTestEnable", "");
147 void TestGraphicsCommandBuffer::SetViewport(Graphics::Viewport value)
149 mCallStack.PushCall("SetViewport", "");
152 void TestGraphicsCommandBuffer::SetViewportEnable(bool value)
154 mCallStack.PushCall("SetViewportEnable", "");