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 "libANGLE/renderer/d3d/ImageD3D.h" 14 #include "libANGLE/ImageIndex.h" 15 16 #include "common/debug.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 virtual ~Image11(); 35 36 static gl::Error generateMipmap(Image11 *dest, 37 Image11 *src, 38 const Renderer11DeviceCaps &rendererCaps); 39 40 virtual bool isDirty() const; 41 42 virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box ®ion); 43 44 bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) override; 45 46 DXGI_FORMAT getDXGIFormat() const; 47 48 gl::Error loadData(const gl::Box &area, 49 const gl::PixelUnpackState &unpack, 50 GLenum type, 51 const void *input, 52 bool applySkipImages) override; 53 gl::Error loadCompressedData(const gl::Box &area, const void *input) override; 54 55 gl::Error copyFromTexStorage(const gl::ImageIndex &imageIndex, TextureStorage *source) override; 56 gl::Error copyFromFramebuffer(const gl::Offset &destOffset, 57 const gl::Rectangle &sourceArea, 58 const gl::Framebuffer *source) override; 59 60 gl::Error recoverFromAssociatedStorage(); 61 bool isAssociatedStorageValid(TextureStorage11* textureStorage) const; 62 void disassociateStorage(); 63 64 protected: 65 gl::Error map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map); 66 void unmap(); 67 68 private: 69 gl::Error copyWithoutConversion(const gl::Offset &destOffset, 70 const gl::Box &sourceArea, 71 const TextureHelper11 &textureHelper, 72 UINT sourceSubResource); 73 74 gl::Error getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex); 75 gl::Error createStagingTexture(); 76 void releaseStagingTexture(); 77 78 Renderer11 *mRenderer; 79 80 DXGI_FORMAT mDXGIFormat; 81 ID3D11Resource *mStagingTexture; 82 unsigned int mStagingSubresource; 83 84 bool mRecoverFromStorage; 85 TextureStorage11 *mAssociatedStorage; 86 gl::ImageIndex mAssociatedImageIndex; 87 unsigned int mRecoveredFromStorageCount; 88 }; 89 90 } 91 92 #endif // LIBANGLE_RENDERER_D3D_D3D11_IMAGE11_H_ 93