1 // 2 // Copyright (c) 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/renderer11_utils.h" 17 18 namespace gl 19 { 20 class Framebuffer; 21 } 22 23 namespace rx 24 { 25 class Renderer11; 26 class TextureHelper11; 27 class TextureStorage11; 28 struct Renderer11DeviceCaps; 29 30 class Image11 : public ImageD3D 31 { 32 public: 33 Image11(Renderer11 *renderer); 34 ~Image11() override; 35 36 static gl::Error GenerateMipmap(const gl::Context *context, 37 Image11 *dest, 38 Image11 *src, 39 const Renderer11DeviceCaps &rendererCaps); 40 static gl::Error CopyImage(const gl::Context *context, 41 Image11 *dest, 42 Image11 *source, 43 const gl::Rectangle &sourceRect, 44 const gl::Offset &destOffset, 45 bool unpackFlipY, 46 bool unpackPremultiplyAlpha, 47 bool unpackUnmultiplyAlpha, 48 const Renderer11DeviceCaps &rendererCaps); 49 50 bool isDirty() const override; 51 52 gl::Error copyToStorage(const gl::Context *context, 53 TextureStorage *storage, 54 const gl::ImageIndex &index, 55 const gl::Box ®ion) override; 56 57 bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) override; 58 59 DXGI_FORMAT getDXGIFormat() const; 60 61 gl::Error loadData(const gl::Context *context, 62 const gl::Box &area, 63 const gl::PixelUnpackState &unpack, 64 GLenum type, 65 const void *input, 66 bool applySkipImages) override; 67 gl::Error loadCompressedData(const gl::Context *context, 68 const gl::Box &area, 69 const void *input) override; 70 71 gl::Error copyFromTexStorage(const gl::Context *context, 72 const gl::ImageIndex &imageIndex, 73 TextureStorage *source) override; 74 gl::Error copyFromFramebuffer(const gl::Context *context, 75 const gl::Offset &destOffset, 76 const gl::Rectangle &sourceArea, 77 const gl::Framebuffer *source) override; 78 79 gl::Error recoverFromAssociatedStorage(const gl::Context *context); 80 void verifyAssociatedStorageValid(TextureStorage11 *textureStorage) const; 81 void disassociateStorage(); 82 83 protected: 84 gl::Error map(const gl::Context *context, D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map); 85 void unmap(); 86 87 private: 88 gl::Error copyWithoutConversion(const gl::Offset &destOffset, 89 const gl::Box &sourceArea, 90 const TextureHelper11 &textureHelper, 91 UINT sourceSubResource); 92 93 gl::Error getStagingTexture(const TextureHelper11 **outStagingTexture, 94 unsigned int *outSubresourceIndex); 95 gl::Error createStagingTexture(); 96 void releaseStagingTexture(); 97 98 Renderer11 *mRenderer; 99 100 DXGI_FORMAT mDXGIFormat; 101 TextureHelper11 mStagingTexture; 102 unsigned int mStagingSubresource; 103 104 bool mRecoverFromStorage; 105 TextureStorage11 *mAssociatedStorage; 106 gl::ImageIndex mAssociatedImageIndex; 107 unsigned int mRecoveredFromStorageCount; 108 }; 109 110 } 111 112 #endif // LIBANGLE_RENDERER_D3D_D3D11_IMAGE11_H_ 113