• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // TextureStorage.h: Defines the abstract rx::TextureStorage class.
8 
9 #ifndef LIBANGLE_RENDERER_D3D_TEXTURESTORAGE_H_
10 #define LIBANGLE_RENDERER_D3D_TEXTURESTORAGE_H_
11 
12 #include "common/debug.h"
13 #include "libANGLE/angletypes.h"
14 
15 #include <GLES2/gl2.h>
16 #include <stdint.h>
17 
18 namespace gl
19 {
20 class Context;
21 class ImageIndex;
22 struct Box;
23 struct PixelUnpackState;
24 }  // namespace gl
25 
26 namespace angle
27 {
28 class Subject;
29 }  // namespace angle
30 
31 namespace rx
32 {
33 class SwapChainD3D;
34 class RenderTargetD3D;
35 class ImageD3D;
36 
37 // Dirty bit messages from TextureStorage
38 constexpr size_t kTextureStorageObserverMessageIndex = 0;
39 
40 class TextureStorage : public angle::Subject
41 {
42   public:
TextureStorage(const std::string & label)43     TextureStorage(const std::string &label) : mTextureLabel(label) {}
~TextureStorage()44     ~TextureStorage() override {}
45 
46     virtual angle::Result onDestroy(const gl::Context *context);
47 
48     virtual int getTopLevel() const                   = 0;
49     virtual bool isRenderTarget() const               = 0;
50     virtual bool isManaged() const                    = 0;
51     virtual bool supportsNativeMipmapFunction() const = 0;
52     virtual int getLevelCount() const                 = 0;
53 
54     virtual angle::Result findRenderTarget(const gl::Context *context,
55                                            const gl::ImageIndex &index,
56                                            GLsizei samples,
57                                            RenderTargetD3D **outRT) const = 0;
58     virtual angle::Result getRenderTarget(const gl::Context *context,
59                                           const gl::ImageIndex &index,
60                                           GLsizei samples,
61                                           RenderTargetD3D **outRT)        = 0;
62     virtual angle::Result generateMipmap(const gl::Context *context,
63                                          const gl::ImageIndex &sourceIndex,
64                                          const gl::ImageIndex &destIndex) = 0;
65 
66     virtual angle::Result copyToStorage(const gl::Context *context,
67                                         TextureStorage *destStorage) = 0;
68     virtual angle::Result setData(const gl::Context *context,
69                                   const gl::ImageIndex &index,
70                                   ImageD3D *image,
71                                   const gl::Box *destBox,
72                                   GLenum type,
73                                   const gl::PixelUnpackState &unpack,
74                                   const uint8_t *pixelData)          = 0;
75 
76     // This is a no-op for most implementations of TextureStorage. Some (e.g. TextureStorage11_2D)
77     // might override it.
78     virtual angle::Result useLevelZeroWorkaroundTexture(const gl::Context *context,
79                                                         bool useLevelZeroTexture);
80 
invalidateTextures()81     virtual void invalidateTextures() {}
82 
83     // RenderToTexture methods
84     virtual angle::Result releaseMultisampledTexStorageForLevel(size_t level);
85     virtual angle::Result resolveTexture(const gl::Context *context);
86     virtual GLsizei getRenderToTextureSamples() const;
87 
onLabelUpdate()88     virtual void onLabelUpdate() {}
89 
90   protected:
91     const angle::Subject *mSubject;
92     const std::string &mTextureLabel;
93 };
94 
onDestroy(const gl::Context * context)95 inline angle::Result TextureStorage::onDestroy(const gl::Context *context)
96 {
97     return angle::Result::Continue;
98 }
99 
useLevelZeroWorkaroundTexture(const gl::Context * context,bool useLevelZeroTexture)100 inline angle::Result TextureStorage::useLevelZeroWorkaroundTexture(const gl::Context *context,
101                                                                    bool useLevelZeroTexture)
102 {
103     return angle::Result::Continue;
104 }
105 
releaseMultisampledTexStorageForLevel(size_t level)106 inline angle::Result TextureStorage::releaseMultisampledTexStorageForLevel(size_t level)
107 {
108     return angle::Result::Continue;
109 }
110 
resolveTexture(const gl::Context * context)111 inline angle::Result TextureStorage::resolveTexture(const gl::Context *context)
112 {
113     return angle::Result::Continue;
114 }
115 
getRenderToTextureSamples()116 inline GLsizei TextureStorage::getRenderToTextureSamples() const
117 {
118     return 0;
119 }
120 
121 using TexStoragePointer = angle::UniqueObjectPointer<TextureStorage, gl::Context>;
122 
123 }  // namespace rx
124 
125 #endif  // LIBANGLE_RENDERER_D3D_TEXTURESTORAGE_H_
126