• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
AsEntryPoint()61 EntryPointCommand* Command::AsEntryPoint() {
62   return static_cast<EntryPointCommand*>(this);
63 }
64 
AsPatchParameterVertices()65 PatchParameterVerticesCommand* Command::AsPatchParameterVertices() {
66   return static_cast<PatchParameterVerticesCommand*>(this);
67 }
68 
AsProbe()69 ProbeCommand* Command::AsProbe() {
70   return static_cast<ProbeCommand*>(this);
71 }
72 
AsBuffer()73 BufferCommand* Command::AsBuffer() {
74   return static_cast<BufferCommand*>(this);
75 }
76 
AsProbeSSBO()77 ProbeSSBOCommand* Command::AsProbeSSBO() {
78   return static_cast<ProbeSSBOCommand*>(this);
79 }
80 
AsRepeat()81 RepeatCommand* Command::AsRepeat() {
82   return static_cast<RepeatCommand*>(this);
83 }
84 
PipelineCommand(Type type,Pipeline * pipeline)85 PipelineCommand::PipelineCommand(Type type, Pipeline* pipeline)
86     : Command(type), pipeline_(pipeline) {}
87 
88 PipelineCommand::~PipelineCommand() = default;
89 
DrawRectCommand(Pipeline * pipeline,PipelineData data)90 DrawRectCommand::DrawRectCommand(Pipeline* pipeline, PipelineData data)
91     : PipelineCommand(Type::kDrawRect, pipeline), data_(data) {}
92 
93 DrawRectCommand::~DrawRectCommand() = default;
94 
DrawArraysCommand(Pipeline * pipeline,PipelineData data)95 DrawArraysCommand::DrawArraysCommand(Pipeline* pipeline, PipelineData data)
96     : PipelineCommand(Type::kDrawArrays, pipeline), data_(data) {}
97 
98 DrawArraysCommand::~DrawArraysCommand() = default;
99 
CompareBufferCommand(Buffer * buffer_1,Buffer * buffer_2)100 CompareBufferCommand::CompareBufferCommand(Buffer* buffer_1, Buffer* buffer_2)
101     : Command(Type::kCompareBuffer), buffer_1_(buffer_1), buffer_2_(buffer_2) {}
102 
103 CompareBufferCommand::~CompareBufferCommand() = default;
104 
ComputeCommand(Pipeline * pipeline)105 ComputeCommand::ComputeCommand(Pipeline* pipeline)
106     : PipelineCommand(Type::kCompute, pipeline) {}
107 
108 ComputeCommand::~ComputeCommand() = default;
109 
Probe(Type type,Buffer * buffer)110 Probe::Probe(Type type, Buffer* buffer) : Command(type), buffer_(buffer) {}
111 
112 Probe::~Probe() = default;
113 
ProbeCommand(Buffer * buffer)114 ProbeCommand::ProbeCommand(Buffer* buffer) : Probe(Type::kProbe, buffer) {}
115 
116 ProbeCommand::~ProbeCommand() = default;
117 
ProbeSSBOCommand(Buffer * buffer)118 ProbeSSBOCommand::ProbeSSBOCommand(Buffer* buffer)
119     : Probe(Type::kProbeSSBO, buffer) {}
120 
121 ProbeSSBOCommand::~ProbeSSBOCommand() = default;
122 
BufferCommand(BufferType type,Pipeline * pipeline)123 BufferCommand::BufferCommand(BufferType type, Pipeline* pipeline)
124     : PipelineCommand(Type::kBuffer, pipeline), buffer_type_(type) {}
125 
126 BufferCommand::~BufferCommand() = default;
127 
CopyCommand(Buffer * buffer_from,Buffer * buffer_to)128 CopyCommand::CopyCommand(Buffer* buffer_from, Buffer* buffer_to)
129     : Command(Type::kCopy), buffer_from_(buffer_from), buffer_to_(buffer_to) {}
130 
131 CopyCommand::~CopyCommand() = default;
132 
ClearCommand(Pipeline * pipeline)133 ClearCommand::ClearCommand(Pipeline* pipeline)
134     : PipelineCommand(Type::kClear, pipeline) {}
135 
136 ClearCommand::~ClearCommand() = default;
137 
ClearColorCommand(Pipeline * pipeline)138 ClearColorCommand::ClearColorCommand(Pipeline* pipeline)
139     : PipelineCommand(Type::kClearColor, pipeline) {}
140 
141 ClearColorCommand::~ClearColorCommand() = default;
142 
ClearDepthCommand(Pipeline * pipeline)143 ClearDepthCommand::ClearDepthCommand(Pipeline* pipeline)
144     : PipelineCommand(Type::kClearDepth, pipeline) {}
145 
146 ClearDepthCommand::~ClearDepthCommand() = default;
147 
ClearStencilCommand(Pipeline * pipeline)148 ClearStencilCommand::ClearStencilCommand(Pipeline* pipeline)
149     : PipelineCommand(Type::kClearStencil, pipeline) {}
150 
151 ClearStencilCommand::~ClearStencilCommand() = default;
152 
PatchParameterVerticesCommand(Pipeline * pipeline)153 PatchParameterVerticesCommand::PatchParameterVerticesCommand(Pipeline* pipeline)
154     : PipelineCommand(Type::kPatchParameterVertices, pipeline) {}
155 
156 PatchParameterVerticesCommand::~PatchParameterVerticesCommand() = default;
157 
EntryPointCommand(Pipeline * pipeline)158 EntryPointCommand::EntryPointCommand(Pipeline* pipeline)
159     : PipelineCommand(Type::kEntryPoint, pipeline) {}
160 
161 EntryPointCommand::~EntryPointCommand() = default;
162 
RepeatCommand(uint32_t count)163 RepeatCommand::RepeatCommand(uint32_t count)
164     : Command(Type::kRepeat), count_(count) {}
165 
166 RepeatCommand::~RepeatCommand() = default;
167 
168 }  // namespace amber
169