• 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_IMAGE_DESCRIPTOR_H_
16 #define SRC_VULKAN_IMAGE_DESCRIPTOR_H_
17 
18 #include <memory>
19 #include <vector>
20 
21 #include "src/vulkan/buffer_backed_descriptor.h"
22 #include "src/vulkan/sampler.h"
23 #include "src/vulkan/transfer_image.h"
24 
25 namespace amber {
26 namespace vulkan {
27 
28 class ImageDescriptor : public BufferBackedDescriptor {
29  public:
30   ImageDescriptor(Buffer* buffer,
31                   DescriptorType type,
32                   Device* device,
33                   uint32_t base_mip_level,
34                   uint32_t desc_set,
35                   uint32_t binding);
36   ~ImageDescriptor() override;
37 
38   void UpdateDescriptorSetIfNeeded(VkDescriptorSet descriptor_set) override;
39   Result RecordCopyDataToResourceIfNeeded(CommandBuffer* command) override;
40   Result CreateResourceIfNeeded() override;
41   Result RecordCopyDataToHost(CommandBuffer* command) override;
42   Result MoveResourceToBufferOutput() override;
SetAmberSampler(amber::Sampler * sampler)43   void SetAmberSampler(amber::Sampler* sampler) { amber_sampler_ = sampler; }
44 
45  protected:
46   std::vector<Resource*> GetResources() override;
47 
48  private:
49   uint32_t base_mip_level_ = 0;
50   std::vector<std::unique_ptr<TransferImage>> transfer_images_;
51   amber::Sampler* amber_sampler_ = nullptr;
52   amber::vulkan::Sampler vulkan_sampler_;
53 };
54 
55 }  // namespace vulkan
56 }  // namespace amber
57 
58 #endif  // SRC_VULKAN_IMAGE_DESCRIPTOR_H_
59