summaryrefslogtreecommitdiff
path: root/chromium/gpu/command_buffer/service/external_vk_image_dawn_representation.h
blob: e605db8e46bdf69544afdb3e133d9f7340b97301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_COMMAND_BUFFER_SERVICE_EXTERNAL_VK_IMAGE_DAWN_REPRESENTATION_H_
#define GPU_COMMAND_BUFFER_SERVICE_EXTERNAL_VK_IMAGE_DAWN_REPRESENTATION_H_

#include "gpu/command_buffer/service/external_vk_image_backing.h"
#include "gpu/command_buffer/service/shared_image_representation.h"

namespace gpu {

class ExternalVkImageDawnRepresentation : public SharedImageRepresentationDawn {
 public:
  ExternalVkImageDawnRepresentation(SharedImageManager* manager,
                                    SharedImageBacking* backing,
                                    MemoryTypeTracker* tracker,
                                    DawnDevice device,
                                    DawnTextureFormat dawn_format,
                                    int memory_fd,
                                    VkDeviceSize allocation_size,
                                    uint32_t memory_type_index);
  ~ExternalVkImageDawnRepresentation() override;

  DawnTexture BeginAccess(DawnTextureUsage usage) override;
  void EndAccess() override;

 private:
  const DawnDevice device_;
  const DawnTextureFormat dawn_format_;
  const int memory_fd_;
  const VkDeviceSize allocation_size_;
  const uint32_t memory_type_index_;

  DawnTexture texture_ = nullptr;

  // TODO(cwallez@chromium.org): Load procs only once when the factory is
  // created and pass a pointer to them around?
  const DawnProcTable dawn_procs_;

  ExternalVkImageBacking* backing_impl() {
    return static_cast<ExternalVkImageBacking*>(backing());
  }

  DISALLOW_COPY_AND_ASSIGN(ExternalVkImageDawnRepresentation);
};

}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_SERVICE_EXTERNAL_VK_IMAGE_DAWN_REPRESENTATION_H_