1 // 2 // Copyright 2012 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 // Image11.h: Defines the rx::Image11 class, which acts as the interface to 8 // the actual underlying resources of a Texture 9 10 #ifndef LIBANGLE_RENDERER_D3D_D3D11_IMAGE11_H_ 11 #define LIBANGLE_RENDERER_D3D_D3D11_IMAGE11_H_ 12 13 #include "common/debug.h" 14 #include "libANGLE/ImageIndex.h" 15 #include "libANGLE/renderer/d3d/ImageD3D.h" 16 #include "libANGLE/renderer/d3d/d3d11/MappedSubresourceVerifier11.h" 17 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" 18 19 namespace gl 20 { 21 class Framebuffer; 22 } 23 24 namespace d3d11 25 { 26 template <typename T> 27 class ScopedUnmapper; 28 } // namespace d3d11 29 30 namespace rx 31 { 32 class Renderer11; 33 class TextureHelper11; 34 class TextureStorage11; 35 struct Renderer11DeviceCaps; 36 37 class Image11 : public ImageD3D 38 { 39 public: 40 Image11(Renderer11 *renderer); 41 ~Image11() override; 42 43 static angle::Result GenerateMipmap(const gl::Context *context, 44 Image11 *dest, 45 Image11 *src, 46 const Renderer11DeviceCaps &rendererCaps); 47 static angle::Result CopyImage(const gl::Context *context, 48 Image11 *dest, 49 Image11 *source, 50 const gl::Box &sourceBox, 51 const gl::Offset &destOffset, 52 bool unpackFlipY, 53 bool unpackPremultiplyAlpha, 54 bool unpackUnmultiplyAlpha, 55 const Renderer11DeviceCaps &rendererCaps); 56 57 bool isDirty() const override; 58 59 angle::Result copyToStorage(const gl::Context *context, 60 TextureStorage *storage, 61 const gl::ImageIndex &index, 62 const gl::Box ®ion) override; 63 64 bool redefine(gl::TextureType type, 65 GLenum internalformat, 66 const gl::Extents &size, 67 bool forceRelease) override; 68 69 DXGI_FORMAT getDXGIFormat() const; 70 71 angle::Result loadData(const gl::Context *context, 72 const gl::Box &area, 73 const gl::PixelUnpackState &unpack, 74 GLenum type, 75 const void *input, 76 bool applySkipImages) override; 77 angle::Result loadCompressedData(const gl::Context *context, 78 const gl::Box &area, 79 const void *input) override; 80 81 angle::Result copyFromTexStorage(const gl::Context *context, 82 const gl::ImageIndex &imageIndex, 83 TextureStorage *source) override; 84 angle::Result copyFromFramebuffer(const gl::Context *context, 85 const gl::Offset &destOffset, 86 const gl::Rectangle &sourceArea, 87 const gl::Framebuffer *source) override; 88 89 angle::Result recoverFromAssociatedStorage(const gl::Context *context); 90 void verifyAssociatedStorageValid(TextureStorage11 *textureStorageEXT) const; 91 void disassociateStorage(); 92 93 angle::Result getStagingTexture(const gl::Context *context, 94 const TextureHelper11 **outStagingTexture, 95 unsigned int *outSubresourceIndex); 96 97 protected: 98 template <typename T> 99 friend class d3d11::ScopedUnmapper; 100 angle::Result map(const gl::Context *context, D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map); 101 void unmap(); 102 103 private: 104 angle::Result copyWithoutConversion(const gl::Context *context, 105 const gl::Offset &destOffset, 106 const gl::Box &sourceArea, 107 const TextureHelper11 &textureHelper, 108 UINT sourceSubResource); 109 110 angle::Result createStagingTexture(const gl::Context *context); 111 void releaseStagingTexture(); 112 113 Renderer11 *mRenderer; 114 115 DXGI_FORMAT mDXGIFormat; 116 TextureHelper11 mStagingTexture; 117 unsigned int mStagingSubresource; 118 MappedSubresourceVerifier11 mStagingTextureSubresourceVerifier; 119 120 bool mRecoverFromStorage; 121 TextureStorage11 *mAssociatedStorage; 122 gl::ImageIndex mAssociatedImageIndex; 123 unsigned int mRecoveredFromStorageCount; 124 }; 125 126 } // namespace rx 127 128 #endif // LIBANGLE_RENDERER_D3D_D3D11_IMAGE11_H_ 129