Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h Source File

Diligent Engine API Reference

TextureBaseD3D11.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
28
29 #include "TextureD3D11.h"
30 #include "RenderDeviceD3D11.h"
31 #include "TextureBase.h"
32 #include "TextureViewD3D11Impl.h"
33
34 namespace Diligent
35 {
36
37 class FixedBlockMemoryAllocator;
38
39 enum class D3D11TextureState
40 {
41 Undefined = 0x0,
42 ShaderResource = 0x1,
43 RenderTarget = 0x2,
44 DepthStencil = 0x4,
45 UnorderedAccess = 0x8,
46 Output = RenderTarget | DepthStencil | UnorderedAccess
47 };
48
50 class TextureBaseD3D11 : public TextureBase<ITextureD3D11, TextureViewD3D11Impl, FixedBlockMemoryAllocator>
51 {
52 public:
53 typedef TextureBase<ITextureD3D11, TextureViewD3D11Impl, FixedBlockMemoryAllocator> TTextureBase;
54
55 TextureBaseD3D11(IReferenceCounters *pRefCounters,
56 FixedBlockMemoryAllocator &TexViewObjAllocator,
57 class RenderDeviceD3D11Impl *pDeviceD3D11,
58 const TextureDesc& TexDesc,
59 const TextureData &InitData = TextureData());
60 ~TextureBaseD3D11();
61
62 virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final;
63
64 virtual void UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override final;
65
66 //virtual void CopyData(CTexture *pSrcTexture, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size);
67 virtual void Map( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData )override final;
68 virtual void Unmap( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags )override final;
69
70 virtual ID3D11Resource* GetD3D11Texture()override final{ return m_pd3d11Texture; }
71
72 virtual void* GetNativeHandle()override final { return GetD3D11Texture(); }
73
74 void CopyData(IDeviceContext *pContext,
75 ITexture *pSrcTexture,
76 Uint32 SrcMipLevel,
77 Uint32 SrcSlice,
78 const Box *pSrcBox,
79 Uint32 DstMipLevel,
80 Uint32 DstSlice,
81 Uint32 DstX,
82 Uint32 DstY,
83 Uint32 DstZ);
84
85 void ResetState(D3D11TextureState State){m_State = static_cast<Uint32>(State);}
86 void AddState(D3D11TextureState State){m_State |= static_cast<Uint32>(State);}
87 void ClearState(D3D11TextureState State){m_State &= ~static_cast<Uint32>(State);}
88 bool CheckState(D3D11TextureState State){return (m_State & static_cast<Uint32>(State)) ? true : false;}
89
90 protected:
91 void CreateViewInternal( const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView )override final;
92 void PrepareD3D11InitData(const TextureData &InitData, Uint32 NumSubresources,
93 std::vector<D3D11_SUBRESOURCE_DATA, STDAllocatorRawMem<D3D11_SUBRESOURCE_DATA> > &D3D11InitData);
94
95 virtual void CreateSRV( TextureViewDesc &SRVDesc, ID3D11ShaderResourceView **ppD3D11SRV ) = 0;
96 virtual void CreateRTV( TextureViewDesc &RTVDesc, ID3D11RenderTargetView **ppD3D11RTV ) = 0;
97 virtual void CreateDSV( TextureViewDesc &DSVDesc, ID3D11DepthStencilView **ppD3D11DSV ) = 0;
98 virtual void CreateUAV( TextureViewDesc &UAVDesc, ID3D11UnorderedAccessView **ppD3D11UAV ) = 0;
99
100 friend class RenderDeviceD3D11Impl;
102 CComPtr<ID3D11Resource> m_pd3d11Texture;
103
104 Uint32 m_State = static_cast<Uint32>(D3D11TextureState::Undefined);
105 };
106
107 }
Diligent::TextureBaseD3D11::QueryInterface
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override final
Queries the specific interface, see IObject::QueryInterface() for details.
Diligent::TextureDesc
Texture description.
Definition: Texture.h:82
Diligent::TextureBaseD3D11
Base implementation of the Diligent::ITextureD3D11 interface.
Definition: TextureBaseD3D11.h:50
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::TextureSubResData
Describes data for one subresource.
Definition: Texture.h:193
Diligent::TextureBaseD3D11::CopyData
void CopyData(IDeviceContext *pContext, ITexture *pSrcTexture, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox, Uint32 DstMipLevel, Uint32 DstSlice, Uint32 DstX, Uint32 DstY, Uint32 DstZ)
Base implementaiton of ITexture::CopyData(); validates input parameters.
Definition: TextureBaseD3D11.cpp:169
Diligent::TextureBaseD3D11::Map
virtual void Map(IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData) override final
Base implementaiton of ITexture::Map()
Definition: TextureBaseD3D11.cpp:202
Diligent::TextureBaseD3D11::CreateViewInternal
void CreateViewInternal(const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView) override final
Pure virtual function that creates texture view for the specific engine implementation.
Definition: TextureBaseD3D11.cpp:44
Diligent::TextureBaseD3D11::m_pd3d11Texture
CComPtr< ID3D11Resource > m_pd3d11Texture
D3D11 texture.
Definition: TextureBaseD3D11.h:102
Diligent::TextureData
Describes the initial data to store in the texture.
Definition: Texture.h:243
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:443
Diligent::TextureBaseD3D11::GetNativeHandle
virtual void * GetNativeHandle() override final
Returns native texture handle specific to the underlying graphics API.
Definition: TextureBaseD3D11.h:72
Diligent::Box
Box.
Definition: GraphicsTypes.h:1005
Diligent::FixedBlockMemoryAllocator
Memory allocator that allocates memory in a fixed-size chunks.
Definition: FixedBlockMemoryAllocator.h:50
Diligent::TextureBaseD3D11::Unmap
virtual void Unmap(IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags) override final
Base implementaiton of ITexture::Unmap()
Definition: TextureBaseD3D11.cpp:226
Diligent::RenderDeviceD3D11Impl
Implementation of the Diligent::IRenderDeviceD3D11 interface.
Definition: RenderDeviceD3D11Impl.h:38
Diligent::TextureBaseD3D11::UpdateData
virtual void UpdateData(IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData) override final
Base implementaiton of ITexture::UpdateData(); validates input parameters.
Definition: TextureBaseD3D11.cpp:145
Diligent::TextureBase
Base implementation of the ITexture interface.
Definition: TextureBase.h:52
Diligent::MAP_TYPE
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:125
Diligent::TextureBaseD3D11::GetD3D11Texture
virtual ID3D11Resource * GetD3D11Texture() override final
Returns a pointer to the ID3D11Resource interface of the internal Direct3D11 object.
Definition: TextureBaseD3D11.h:70
Diligent::ITexture
Texture inteface.
Definition: Texture.h:276