1 // Copyright 2018 The Amber Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/command.h"
16 
17 #include "src/pipeline.h"
18 
19 namespace amber {
20 
Command(Type type)21 Command::Command(Type type) : command_type_(type) {}
22 
23 Command::~Command() = default;
24 
AsClear()25 ClearCommand* Command::AsClear() {
26   return static_cast<ClearCommand*>(this);
27 }
28 
AsClearColor()29 ClearColorCommand* Command::AsClearColor() {
30   return static_cast<ClearColorCommand*>(this);
31 }
32 
AsClearDepth()33 ClearDepthCommand* Command::AsClearDepth() {
34   return static_cast<ClearDepthCommand*>(this);
35 }
36 
AsClearStencil()37 ClearStencilCommand* Command::AsClearStencil() {
38   return static_cast<ClearStencilCommand*>(this);
39 }
40 
AsCompareBuffer()41 CompareBufferCommand* Command::AsCompareBuffer() {
42   return static_cast<CompareBufferCommand*>(this);
43 }
44 
AsCompute()45 ComputeCommand* Command::AsCompute() {
46   return static_cast<ComputeCommand*>(this);
47 }
48 
AsCopy()49 CopyCommand* Command::AsCopy() {
50   return static_cast<CopyCommand*>(this);
51 }
52 
AsDrawArrays()53 DrawArraysCommand* Command::AsDrawArrays() {
54   return static_cast<DrawArraysCommand*>(this);
55 }
56 
AsDrawRect()57 DrawRectCommand* Command::AsDrawRect() {
58   return static_cast<DrawRectCommand*>(this);
59 }
60 
AsDrawGrid()61 DrawGridCommand* Command::AsDrawGrid() {
62   return static_cast<DrawGridCommand*>(this);
63 }
64 
AsEntryPoint()65 EntryPointCommand* Command::AsEntryPoint() {
66   return static_cast<EntryPointCommand*>(this);
67 }
68 
AsPatchParameterVertices()69 PatchParameterVerticesCommand* Command::AsPatchParameterVertices() {
70   return static_cast<PatchParameterVerticesCommand*>(this);
71 }
72 
AsProbe()73 ProbeCommand* Command::AsProbe() {
74   return static_cast<ProbeCommand*>(this);
75 }
76 
AsBuffer()77 BufferCommand* Command::AsBuffer() {
78   return static_cast<BufferCommand*>(this);
79 }
80 
AsProbeSSBO()81 ProbeSSBOCommand* Command::AsProbeSSBO() {
82   return static_cast<ProbeSSBOCommand*>(this);
83 }
84 
AsRepeat()85 RepeatCommand* Command::AsRepeat() {
86   return static_cast<RepeatCommand*>(this);
87 }
88 
PipelineCommand(Type type,Pipeline * pipeline)89 PipelineCommand::PipelineCommand(Type type, Pipeline* pipeline)
90     : Command(type), pipeline_(pipeline) {}
91 
92 PipelineCommand::~PipelineCommand() = default;
93 
DrawRectCommand(Pipeline * pipeline,PipelineData data)94 DrawRectCommand::DrawRectCommand(Pipeline* pipeline, PipelineData data)
95     : PipelineCommand(Type::kDrawRect, pipeline), data_(data) {}
96 
97 DrawRectCommand::~DrawRectCommand() = default;
98 
DrawGridCommand(Pipeline * pipeline,PipelineData data)99 DrawGridCommand::DrawGridCommand(Pipeline* pipeline, PipelineData data)
100     : PipelineCommand(Type::kDrawGrid, pipeline), data_(data) {}
101 
102 DrawGridCommand::~DrawGridCommand() = default;
103 
DrawArraysCommand(Pipeline * pipeline,PipelineData data)104 DrawArraysCommand::DrawArraysCommand(Pipeline* pipeline, PipelineData data)
105     : PipelineCommand(Type::kDrawArrays, pipeline), data_(data) {}
106 
107 DrawArraysCommand::~DrawArraysCommand() = default;
108 
CompareBufferCommand(Buffer * buffer_1,Buffer * buffer_2)109 CompareBufferCommand::CompareBufferCommand(Buffer* buffer_1, Buffer* buffer_2)
110     : Command(Type::kCompareBuffer), buffer_1_(buffer_1), buffer_2_(buffer_2) {}
111 
112 CompareBufferCommand::~CompareBufferCommand() = default;
113 
ComputeCommand(Pipeline * pipeline)114 ComputeCommand::ComputeCommand(Pipeline* pipeline)
115     : PipelineCommand(Type::kCompute, pipeline) {}
116 
117 ComputeCommand::~ComputeCommand() = default;
118 
Probe(Type type,Buffer * buffer)119 Probe::Probe(Type type, Buffer* buffer) : Command(type), buffer_(buffer) {}
120 
121 Probe::~Probe() = default;
122 
ProbeCommand(Buffer * buffer)123 ProbeCommand::ProbeCommand(Buffer* buffer) : Probe(Type::kProbe, buffer) {}
124 
125 ProbeCommand::~ProbeCommand() = default;
126 
ProbeSSBOCommand(Buffer * buffer)127 ProbeSSBOCommand::ProbeSSBOCommand(Buffer* buffer)
128     : Probe(Type::kProbeSSBO, buffer) {}
129 
130 ProbeSSBOCommand::~ProbeSSBOCommand() = default;
131 
BindableResourceCommand(Type type,Pipeline * pipeline)132 BindableResourceCommand::BindableResourceCommand(Type type, Pipeline* pipeline)
133     : PipelineCommand(type, pipeline) {}
134 
135 BindableResourceCommand::~BindableResourceCommand() = default;
136 
BufferCommand(BufferType type,Pipeline * pipeline)137 BufferCommand::BufferCommand(BufferType type, Pipeline* pipeline)
138     : BindableResourceCommand(Type::kBuffer, pipeline), buffer_type_(type) {}
139 
140 BufferCommand::~BufferCommand() = default;
141 
SamplerCommand(Pipeline * pipeline)142 SamplerCommand::SamplerCommand(Pipeline* pipeline)
143     : BindableResourceCommand(Type::kSampler, pipeline) {}
144 
145 SamplerCommand::~SamplerCommand() = default;
146 
CopyCommand(Buffer * buffer_from,Buffer * buffer_to)147 CopyCommand::CopyCommand(Buffer* buffer_from, Buffer* buffer_to)
148     : Command(Type::kCopy), buffer_from_(buffer_from), buffer_to_(buffer_to) {}
149 
150 CopyCommand::~CopyCommand() = default;
151 
ClearCommand(Pipeline * pipeline)152 ClearCommand::ClearCommand(Pipeline* pipeline)
153     : PipelineCommand(Type::kClear, pipeline) {}
154 
155 ClearCommand::~ClearCommand() = default;
156 
ClearColorCommand(Pipeline * pipeline)157 ClearColorCommand::ClearColorCommand(Pipeline* pipeline)
158     : PipelineCommand(Type::kClearColor, pipeline) {}
159 
160 ClearColorCommand::~ClearColorCommand() = default;
161 
ClearDepthCommand(Pipeline * pipeline)162 ClearDepthCommand::ClearDepthCommand(Pipeline* pipeline)
163     : PipelineCommand(Type::kClearDepth, pipeline) {}
164 
165 ClearDepthCommand::~ClearDepthCommand() = default;
166 
ClearStencilCommand(Pipeline * pipeline)167 ClearStencilCommand::ClearStencilCommand(Pipeline* pipeline)
168     : PipelineCommand(Type::kClearStencil, pipeline) {}
169 
170 ClearStencilCommand::~ClearStencilCommand() = default;
171 
PatchParameterVerticesCommand(Pipeline * pipeline)172 PatchParameterVerticesCommand::PatchParameterVerticesCommand(Pipeline* pipeline)
173     : PipelineCommand(Type::kPatchParameterVertices, pipeline) {}
174 
175 PatchParameterVerticesCommand::~PatchParameterVerticesCommand() = default;
176 
EntryPointCommand(Pipeline * pipeline)177 EntryPointCommand::EntryPointCommand(Pipeline* pipeline)
178     : PipelineCommand(Type::kEntryPoint, pipeline) {}
179 
180 EntryPointCommand::~EntryPointCommand() = default;
181 
RepeatCommand(uint32_t count)182 RepeatCommand::RepeatCommand(uint32_t count)
183     : Command(Type::kRepeat), count_(count) {}
184 
185 RepeatCommand::~RepeatCommand() = default;
186 
187 }  // namespace amber
188