• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 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 #ifndef SRC_VULKAN_BUFFER_BACKED_DESCRIPTOR_H_
16 #define SRC_VULKAN_BUFFER_BACKED_DESCRIPTOR_H_
17 
18 #include <memory>
19 #include <vector>
20 
21 #include "amber/result.h"
22 #include "amber/value.h"
23 #include "amber/vulkan_header.h"
24 #include "src/buffer.h"
25 #include "src/engine.h"
26 #include "src/vulkan/descriptor.h"
27 #include "src/vulkan/resource.h"
28 
29 namespace amber {
30 namespace vulkan {
31 
32 class BufferBackedDescriptor : public Descriptor {
33  public:
34   BufferBackedDescriptor(Buffer* buffer,
35                          DescriptorType type,
36                          Device* device,
37                          uint32_t desc_set,
38                          uint32_t binding);
39   ~BufferBackedDescriptor() override;
40 
CreateResourceIfNeeded()41   Result CreateResourceIfNeeded() override { return {}; }
42   Result RecordCopyDataToResourceIfNeeded(CommandBuffer* command) override;
43   Result RecordCopyDataToHost(CommandBuffer* command) override;
44   Result MoveResourceToBufferOutput() override;
GetDescriptorCount()45   uint32_t GetDescriptorCount() override {
46     return static_cast<uint32_t>(amber_buffers_.size());
47   }
GetAmberBuffers()48   const std::vector<Buffer*>& GetAmberBuffers() const { return amber_buffers_; }
AddAmberBuffer(Buffer * buffer)49   void AddAmberBuffer(Buffer* buffer) { amber_buffers_.push_back(buffer); }
AsBufferBackedDescriptor()50   BufferBackedDescriptor* AsBufferBackedDescriptor() override { return this; }
51   bool IsReadOnly() const;
52 
53  protected:
54   virtual std::vector<Resource*> GetResources() = 0;
55 
56  private:
57   std::vector<Buffer*> amber_buffers_;
58 };
59 
60 }  // namespace vulkan
61 }  // namespace amber
62 
63 #endif  // SRC_VULKAN_BUFFER_BACKED_DESCRIPTOR_H_
64