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 std::ostream& operator<<(std::ostream& os, Graphics::StencilOp op)
25 case Graphics::StencilOp::KEEP:
28 case Graphics::StencilOp::ZERO:
31 case Graphics::StencilOp::REPLACE:
34 case Graphics::StencilOp::INCREMENT_AND_CLAMP:
35 os << "INCREMENT_AND_CLAMP";
37 case Graphics::StencilOp::DECREMENT_AND_CLAMP:
38 os << "DECREMENT_AND_CLAMP";
40 case Graphics::StencilOp::INVERT:
43 case Graphics::StencilOp::INCREMENT_AND_WRAP:
44 os << "INCREMENT_AND_WRAP";
46 case Graphics::StencilOp::DECREMENT_AND_WRAP:
47 os << "DECREMENT_AND_WRAP";
53 std::ostream& operator<<(std::ostream& os, Graphics::CompareOp op)
57 case Graphics::CompareOp::NEVER:
60 case Graphics::CompareOp::LESS:
63 case Graphics::CompareOp::EQUAL:
66 case Graphics::CompareOp::LESS_OR_EQUAL:
67 os << "LESS_OR_EQUAL";
69 case Graphics::CompareOp::GREATER:
72 case Graphics::CompareOp::NOT_EQUAL:
75 case Graphics::CompareOp::GREATER_OR_EQUAL:
76 os << "GREATER_OR_EQUAL";
78 case Graphics::CompareOp::ALWAYS:
85 TestGraphicsCommandBuffer::TestGraphicsCommandBuffer(TraceCallStack& callstack, TestGlAbstraction& glAbstraction)
86 : mCallStack(callstack),
87 mGlAbstraction(glAbstraction)
91 int TestGraphicsCommandBuffer::GetDrawCallsCount()
94 for(auto& cmd : mCommands)
96 if(cmd.type == CommandType::DRAW ||
97 cmd.type == CommandType::DRAW_INDEXED ||
98 cmd.type == CommandType::DRAW_INDEXED_INDIRECT)
106 void TestGraphicsCommandBuffer::GetStateForDrawCall(int drawCallIndex)
109 std::vector<Command> mCommandStack{};
110 for(auto& cmd : mCommands)
112 mCommandStack.push_back(cmd);
113 if(cmd.type == CommandType::DRAW ||
114 cmd.type == CommandType::DRAW_INDEXED ||
115 cmd.type == CommandType::DRAW_INDEXED_INDIRECT)
117 if(index == drawCallIndex)
121 mCommandStack.clear();
127 std::vector<const Command*> TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask) const
129 std::vector<const Command*> mCommandStack{};
130 for(auto& cmd : mCommands)
132 if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)))
134 mCommandStack.emplace_back(&cmd);
137 return mCommandStack;
140 std::vector<const Command*> TestGraphicsCommandBuffer::GetChildCommandsByType(CommandTypeMask mask) const
142 std::vector<const Command*> mCommandStack{};
143 for(auto& cmd : mCommands)
145 if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)))
147 mCommandStack.emplace_back(&cmd);
149 if(cmd.type == CommandType::EXECUTE_COMMAND_BUFFERS)
151 for(auto secondaryCB : cmd.data.executeCommandBuffers.buffers)
153 for(auto command : secondaryCB->GetChildCommandsByType(mask))
155 mCommandStack.push_back(command);
160 return mCommandStack;