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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
gpu / command_buffer / service / shared_image / external_vk_image_gl_representation.h [blame]
// Copyright 2019 The Chromium Authors
// 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_SHARED_IMAGE_EXTERNAL_VK_IMAGE_GL_REPRESENTATION_H_
#define GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_EXTERNAL_VK_IMAGE_GL_REPRESENTATION_H_
#include "base/memory/raw_ptr.h"
#include "gpu/command_buffer/service/external_semaphore.h"
#include "gpu/command_buffer/service/shared_image/external_vk_image_backing.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
namespace gpu {
// ExternalVkImageGLRepresentationShared implements BeginAccess and EndAccess
// methods for ExternalVkImageGLRepresentation and
// ExternalVkImageGLPassthroughRepresentation.
class ExternalVkImageGLRepresentationShared {
public:
static void AcquireTexture(ExternalSemaphore* semaphore,
const std::vector<GLuint>& texture_ids,
const std::vector<GLenum>& src_layouts);
static ExternalSemaphore ReleaseTexture(
ExternalSemaphorePool* pool,
const std::vector<GLuint>& texture_ids,
const std::vector<GLenum>& dst_layouts);
ExternalVkImageGLRepresentationShared(
SharedImageBacking* backing,
std::vector<GLuint> texture_service_ids);
ExternalVkImageGLRepresentationShared(
const ExternalVkImageGLRepresentationShared&) = delete;
ExternalVkImageGLRepresentationShared& operator=(
const ExternalVkImageGLRepresentationShared&) = delete;
~ExternalVkImageGLRepresentationShared();
bool BeginAccess(GLenum mode);
void EndAccess();
ExternalVkImageBacking* backing_impl() const { return backing_; }
private:
viz::VulkanContextProvider* context_provider() const {
return backing_impl()->context_provider();
}
const raw_ptr<ExternalVkImageBacking> backing_;
const std::vector<GLuint> texture_service_ids_;
GLenum current_access_mode_ = 0;
std::vector<ExternalSemaphore> begin_access_semaphores_;
};
class ExternalVkImageGLRepresentation : public GLTextureImageRepresentation {
public:
ExternalVkImageGLRepresentation(
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker,
std::vector<raw_ptr<gles2::Texture, VectorExperimental>> textures);
ExternalVkImageGLRepresentation(const ExternalVkImageGLRepresentation&) =
delete;
ExternalVkImageGLRepresentation& operator=(
const ExternalVkImageGLRepresentation&) = delete;
~ExternalVkImageGLRepresentation() override;
// GLTextureImageRepresentation implementation.
gles2::Texture* GetTexture(int plane_index) override;
bool BeginAccess(GLenum mode) override;
void EndAccess() override;
private:
std::vector<raw_ptr<gles2::Texture, VectorExperimental>> textures_;
ExternalVkImageGLRepresentationShared representation_shared_;
};
class ExternalVkImageGLPassthroughRepresentation
: public GLTexturePassthroughImageRepresentation {
public:
ExternalVkImageGLPassthroughRepresentation(
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker,
std::vector<scoped_refptr<gles2::TexturePassthrough>> texture);
ExternalVkImageGLPassthroughRepresentation(
const ExternalVkImageGLPassthroughRepresentation&) = delete;
ExternalVkImageGLPassthroughRepresentation& operator=(
const ExternalVkImageGLPassthroughRepresentation&) = delete;
~ExternalVkImageGLPassthroughRepresentation() override;
// GLTexturePassthroughImageRepresentation implementation.
const scoped_refptr<gles2::TexturePassthrough>& GetTexturePassthrough(
int plane_index) override;
bool BeginAccess(GLenum mode) override;
void EndAccess() override;
private:
std::vector<scoped_refptr<gles2::TexturePassthrough>> textures_;
ExternalVkImageGLRepresentationShared representation_shared_;
};
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_EXTERNAL_VK_IMAGE_GL_REPRESENTATION_H_