Go to the documentation of this file.
65 const Box* pMapRegion);
70 template <
typename EngineImplTraits>
71 class TextureBase :
public DeviceObjectBase<typename EngineImplTraits::TextureInterface, typename EngineImplTraits::RenderDeviceImplType, TextureDesc>
99 bool bIsDeviceInternal =
false) :
101 #ifdef DILIGENT_DEBUG
102 m_dbgTexViewObjAllocator(TexViewObjAllocator),
106 m_pDefaultDSV{
nullptr, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>(TexViewObjAllocator)},
107 m_pDefaultUAV{
nullptr, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>(TexViewObjAllocator)}
134 Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask();
136 "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask,
137 ") correspond to one of ", pDevice->GetCommandQueueCount(),
" available device command queues");
191 std::string ViewName;
197 ViewName =
"Default SRV of texture '";
201 ViewName =
"Default RTV of texture '";
205 ViewName =
"Default DSV of texture '";
211 ViewName =
"Default UAV of texture '";
219 ViewDesc.
Name = ViewName.c_str();
223 VERIFY(pView !=
nullptr,
"Failed to create default view for texture '", this->
m_Desc.
Name,
"'.");
267 VERIFY((State & (State - 1)) == 0,
"Single state is expected");
269 return (this->
m_State & State) == State;
275 return (this->
m_State & States) != 0;
289 default:
UNEXPECTED(
"Unknown view type");
return nullptr;
297 #ifdef DILIGENT_DEBUG
302 std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>>
m_pDefaultSRV;
304 std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>>
m_pDefaultRTV;
306 std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>>
m_pDefaultDSV;
308 std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>>
m_pDefaultUAV;
@ RESOURCE_DIM_TEX_3D
Three-dimensional texture.
Definition: GraphicsTypes.h:264
@ TEXTURE_VIEW_RENDER_TARGET
A texture view will define a render target view that will be used as the target for rendering operati...
Definition: GraphicsTypes.h:285
@ RESOURCE_DIM_TEX_1D
One-dimensional texture.
Definition: GraphicsTypes.h:260
@ RESOURCE_DIM_TEX_1D_ARRAY
One-dimensional texture array.
Definition: GraphicsTypes.h:261
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
@ RESOURCE_DIM_TEX_2D_ARRAY
Two-dimensional texture array.
Definition: GraphicsTypes.h:263
struct TextureDesc TextureDesc
Definition: Texture.h:162
void CreateDefaultViews()
Creates default texture views.
Definition: TextureBase.hpp:177
@ UAV_ACCESS_FLAG_READ_WRITE
Allow read and write operations on the UAV.
Definition: TextureView.h:61
TEXTURE_FORMAT Format
Texture format, see Diligent::TEXTURE_FORMAT.
Definition: Texture.h:68
@ BIND_UNORDERED_ACCESS
A buffer or a texture can be bound as an unordered access view.
Definition: GraphicsTypes.h:127
@ BIND_INPUT_ATTACHMENT
A texture can be used as render pass input attachment.
Definition: GraphicsTypes.h:129
bool IsInKnownState() const
Definition: TextureBase.hpp:260
RESOURCE_STATE m_State
Definition: TextureBase.hpp:310
std::unique_ptr< TextureViewImplType, STDDeleter< TextureViewImplType, TexViewObjAllocatorType > > m_pDefaultDSV
Default DSV addressing the most detailed mip level.
Definition: TextureBase.hpp:306
std::unique_ptr< TextureViewImplType, STDDeleter< TextureViewImplType, TexViewObjAllocatorType > > m_pDefaultSRV
Default SRV addressing the entire texture.
Definition: TextureBase.hpp:302
Uint32 ComputeMipLevelsCount(Uint32 Width)
Definition: GraphicsAccessories.cpp:1252
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
virtual const TextureViewDesc &METHOD() GetDesc() const override=0
Returns the texture view description used to create the object.
virtual ITextureView * GetDefaultView(TEXTURE_VIEW_TYPE ViewType) override
Implementation of ITexture::GetDefaultView().
Definition: TextureBase.hpp:279
#define UNEXPECTED(...)
Definition: DebugUtilities.hpp:77
bool CheckAnyState(RESOURCE_STATE States) const
Definition: TextureBase.hpp:272
MISC_TEXTURE_FLAGS MiscFlags
Miscellaneous flags, see Diligent::MISC_TEXTURE_FLAGS for details.
Definition: Texture.h:93
void ValidateTextureDesc(const TextureDesc &TexDesc) noexcept(false)
Validates texture description and throws an exception in case of an error.
Definition: TextureBase.cpp:38
std::unique_ptr< TextureViewImplType, STDDeleter< TextureViewImplType, TexViewObjAllocatorType > > m_pDefaultRTV
Default RTV addressing the most detailed mip level.
Definition: TextureBase.hpp:304
@ TEXTURE_VIEW_UNORDERED_ACCESS
A texture view will define an unordered access view that will be used for unordered read/write operat...
Definition: GraphicsTypes.h:293
TextureDesc m_Desc
Object description.
Definition: DeviceObjectBase.hpp:182
Texture view interface.
Definition: TextureView.h:202
std::unique_ptr< TextureViewImplType, STDDeleter< TextureViewImplType, TexViewObjAllocatorType > > m_pDefaultUAV
Default UAV addressing the entire texture.
Definition: TextureBase.hpp:308
UAV_ACCESS_FLAG AccessFlags
For an unordered access view, allowed access flags. See Diligent::UAV_ACCESS_FLAG for details.
Definition: TextureView.h:128
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
@ RESOURCE_DIM_TEX_CUBE_ARRAY
Cube-map array texture.
Definition: GraphicsTypes.h:266
TEXTURE_VIEW_TYPE
Texture view type.
Definition: GraphicsTypes.h:274
void ValidateMapTextureParams(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 ArraySlice, MAP_TYPE MapType, Uint32 MapFlags, const Box *pMapRegion)
Validates map texture command paramters.
Definition: TextureBase.cpp:291
void ValidatedAndCorrectTextureViewDesc(const TextureDesc &TexDesc, TextureViewDesc &ViewDesc) noexcept(false)
Validates and corrects texture view description; throws an exception in case of an error.
Definition: TextureBase.cpp:317
virtual void CreateView(const struct TextureViewDesc &ViewDesc, ITextureView **ppView) override
Implementaiton of ITexture::CreateView(); calls CreateViewInternal() virtual function that creates te...
Definition: TextureBase.hpp:151
virtual void CreateViewInternal(const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView)=0
Pure virtual function that creates texture view for the specific engine implementation.
void ValidateUpdateTextureParams(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData)
Validates update texture command paramters.
Definition: TextureBase.cpp:226
TEXTURE_VIEW_TYPE ViewType
Describes the texture view type, see Diligent::TEXTURE_VIEW_TYPE for details.
Definition: TextureView.h:83
Texture description.
Definition: Texture.h:47
@ RESOURCE_DIM_TEX_CUBE
Cube-map texture.
Definition: GraphicsTypes.h:265
TextureBase(IReferenceCounters *pRefCounters, TexViewObjAllocatorType &TexViewObjAllocator, RenderDeviceImplType *pDevice, const TextureDesc &Desc, bool bIsDeviceInternal=false)
Definition: TextureBase.hpp:95
struct Box Box
Definition: GraphicsTypes.h:2440
Uint32 Width
Texture width, in pixels.
Definition: Texture.h:53
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
TEXTURE_VIEW_FLAGS Flags
Texture view flags, see Diligent::TEXTURE_VIEW_FLAGS.
Definition: TextureView.h:131
@ MISC_TEXTURE_FLAG_GENERATE_MIPS
Allow automatic mipmap generation with ITextureView::GenerateMips()
Definition: GraphicsTypes.h:982
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
struct TextureViewDesc TextureViewDesc
Definition: TextureView.h:183
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Uint32 MipLevels
Number of Mip levels in the texture. Multisampled textures can only have 1 Mip level....
Definition: Texture.h:72
Base implementation of the ITexture interface.
Definition: TextureBase.hpp:71
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
@ TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION
Allow automatic mipmap generation for this view. This flag is only allowed for TEXTURE_VIEW_SHADER_RE...
Definition: TextureView.h:74
bool CheckState(RESOURCE_STATE State) const
Definition: TextureBase.hpp:265
Definition: STDAllocator.hpp:182
@ RESOURCE_DIM_TEX_2D
Two-dimensional texture.
Definition: GraphicsTypes.h:262
struct CopyTextureAttribs CopyTextureAttribs
Definition: DeviceContext.h:725
BIND_FLAGS BindFlags
Bind flags, see Diligent::BIND_FLAGS for details. The following bind flags are allowed: Diligent::BI...
Definition: Texture.h:86
typename EngineGLImplTraits ::TexViewObjAllocatorType TexViewObjAllocatorType
Definition: TextureBase.hpp:84
@ BIND_DEPTH_STENCIL
A texture can be bound as a depth-stencil target.
Definition: GraphicsTypes.h:126
@ TEXTURE_VIEW_DEPTH_STENCIL
A texture view will define a depth stencil view that will be used as the target for rendering operati...
Definition: GraphicsTypes.h:289
typename EngineGLImplTraits ::TextureViewImplType TextureViewImplType
Definition: TextureBase.hpp:81
@ COMPONENT_TYPE_UNDEFINED
Undefined component type.
Definition: GraphicsTypes.h:2447
void ValidateCopyTextureParams(const CopyTextureAttribs &CopyAttribs)
Validates copy texture command paramters.
Definition: TextureBase.cpp:264
virtual void SetState(RESOURCE_STATE State) override final
Definition: TextureBase.hpp:250
typename EngineGLImplTraits ::RenderDeviceImplType RenderDeviceImplType
Definition: TextureBase.hpp:78
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
Uint64 CommandQueueMask
Defines which command queues this texture can be used with.
Definition: Texture.h:99
@ BIND_RENDER_TARGET
A texture can be bound as a render target.
Definition: GraphicsTypes.h:125
DeviceObjectBase< BaseInterface, RenderDeviceImplType, TextureDesc > TDeviceObjectBase
Definition: TextureBase.hpp:86
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
RESOURCE_DIMENSION Type
Texture type. See Diligent::RESOURCE_DIMENSION for details.
Definition: Texture.h:50
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:206
struct TextureSubResData TextureSubResData
Definition: Texture.h:218
Texture view description.
Definition: TextureView.h:80
@ TEXTURE_VIEW_UNDEFINED
Undefined view type.
Definition: GraphicsTypes.h:277
const TextureFormatAttribs & GetTextureFormatAttribs(TEXTURE_FORMAT Format)
Returns invariant texture format attributes, see TextureFormatAttribs for details.
Definition: GraphicsAccessories.cpp:250
typename EngineGLImplTraits ::TextureInterface BaseInterface
Definition: TextureBase.hpp:75
@ TEXTURE_VIEW_SHADER_RESOURCE
A texture view will define a shader resource view that will be used as the source for the shader read...
Definition: GraphicsTypes.h:281
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
virtual RESOURCE_STATE GetState() const override final
Definition: TextureBase.hpp:255
Template class implementing base functionality of the device object.
Definition: DeviceObjectBase.hpp:45
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
@ BIND_SHADER_RESOURCE
A buffer or a texture can be bound as a shader resource.
Definition: GraphicsTypes.h:122