From 71f1ad60962386b6dc3e6dd6f1a7da598ce63965 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 26 Aug 2018 14:13:55 -0700 Subject: Implemented raw buffers (fixed https://github.com/DiligentGraphics/DiligentCore/issues/18). --- Graphics/GraphicsEngine/include/BufferBase.h | 69 ++++++++++---- Graphics/GraphicsEngine/include/TextureBase.h | 12 +++ Graphics/GraphicsEngine/interface/Buffer.h | 108 ++++++---------------- Graphics/GraphicsEngine/interface/BufferView.h | 59 +++++++----- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 60 +++++------- 5 files changed, 152 insertions(+), 156 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/BufferBase.h b/Graphics/GraphicsEngine/include/BufferBase.h index b841d0b1..40e251f4 100644 --- a/Graphics/GraphicsEngine/include/BufferBase.h +++ b/Graphics/GraphicsEngine/include/BufferBase.h @@ -95,17 +95,13 @@ public: (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE) ) { VERIFY_BUFFER( this->m_Desc.Mode > BUFFER_MODE_UNDEFINED && this->m_Desc.Mode < BUFFER_MODE_NUM_MODES, "Buffer mode (", this->m_Desc.Mode, ") is not correct" ); - if( this->m_Desc.Mode == BUFFER_MODE_STRUCTURED ) + if (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_FORMATTED) { - VERIFY_BUFFER( this->m_Desc.ElementByteStride != 0, "Element stride cannot be zero for structured buffer" ); + VERIFY_BUFFER( this->m_Desc.ElementByteStride != 0, "Element stride cannot be zero for structured and formatted buffers" ); } - - if( this->m_Desc.Mode == BUFFER_MODE_FORMATTED ) + else if (this->m_Desc.Mode == BUFFER_MODE_RAW) { - VERIFY_BUFFER( this->m_Desc.Format.ValueType != VT_UNDEFINED, "Value type is not specified for a formatted buffer" ); - VERIFY_BUFFER( this->m_Desc.Format.NumComponents != 0, "Num components cannot be zero in a formatted buffer" ); - if( this->m_Desc.ElementByteStride == 0 ) - this->m_Desc.ElementByteStride = static_cast(GetValueSize( this->m_Desc.Format.ValueType )) * this->m_Desc.Format.NumComponents; + } } } @@ -225,25 +221,61 @@ void BufferBase void BufferBase :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView ) { + DEV_CHECK_ERR(ViewDesc.ViewType != BUFFER_VIEW_UNDEFINED, "Buffer view type is not specified"); + if (ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE) + DEV_CHECK_ERR(this->m_Desc.BindFlags & BIND_SHADER_RESOURCE, "Attempting to create SRV for buffer '", this->m_Desc.Name, "' that was not created with BIND_SHADER_RESOURCE flag"); + else if (ViewDesc.ViewType == BUFFER_VIEW_UNORDERED_ACCESS) + DEV_CHECK_ERR(this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS, "Attempting to create UAV for buffer '", this->m_Desc.Name, "' that was not created with BIND_UNORDERED_ACCESS flag"); + else + UNEXPECTED("Unexpected buffer view type"); + CreateViewInternal( ViewDesc, ppView, false ); } template -void BufferBase :: CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc ) +void BufferBase :: CorrectBufferViewDesc(struct BufferViewDesc& ViewDesc) { if( ViewDesc.ByteWidth == 0 ) - ViewDesc.ByteWidth = this->m_Desc.uiSizeInBytes; + { + DEV_CHECK_ERR(this->m_Desc.uiSizeInBytes > ViewDesc.ByteOffset, "Byte offset (", ViewDesc.ByteOffset, ") exceeds buffer size (", this->m_Desc.uiSizeInBytes, ")"); + ViewDesc.ByteWidth = this->m_Desc.uiSizeInBytes - ViewDesc.ByteOffset; + } if( ViewDesc.ByteOffset + ViewDesc.ByteWidth > this->m_Desc.uiSizeInBytes ) LOG_ERROR_AND_THROW( "Buffer view range [", ViewDesc.ByteOffset, ", ", ViewDesc.ByteOffset + ViewDesc.ByteWidth, ") is out of the buffer boundaries [0, ", this->m_Desc.uiSizeInBytes, ")." ); if( (this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS) || (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE) ) { - VERIFY( this->m_Desc.ElementByteStride != 0, "Element byte stride is zero" ); - if( (ViewDesc.ByteOffset % this->m_Desc.ElementByteStride) != 0 ) - LOG_ERROR_AND_THROW( "Buffer view byte offset (", ViewDesc.ByteOffset, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ")." ); - if( (ViewDesc.ByteWidth % this->m_Desc.ElementByteStride) != 0 ) - LOG_ERROR_AND_THROW( "Buffer view byte width (", ViewDesc.ByteWidth, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ")." ); + if (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_FORMATTED) + { + VERIFY( this->m_Desc.ElementByteStride != 0, "Element byte stride is zero" ); + if( (ViewDesc.ByteOffset % this->m_Desc.ElementByteStride) != 0 ) + LOG_ERROR_AND_THROW( "Buffer view byte offset (", ViewDesc.ByteOffset, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ")." ); + if( (ViewDesc.ByteWidth % this->m_Desc.ElementByteStride) != 0 ) + LOG_ERROR_AND_THROW( "Buffer view byte width (", ViewDesc.ByteWidth, ") is not multiple of element byte stride (", this->m_Desc.ElementByteStride, ")." ); + } + + if (this->m_Desc.Mode == BUFFER_MODE_FORMATTED && ViewDesc.Format.ValueType == VT_UNDEFINED) + LOG_ERROR_AND_THROW("Format must be specified when creating a view of a formatted buffer"); + + if (this->m_Desc.Mode == BUFFER_MODE_FORMATTED || this->m_Desc.Mode == BUFFER_MODE_RAW && ViewDesc.Format.ValueType != VT_UNDEFINED) + { + if (ViewDesc.Format.NumComponents <= 0 || ViewDesc.Format.NumComponents > 4) + LOG_ERROR_AND_THROW("Incorrect number of components (", Uint32{ViewDesc.Format.NumComponents}, "). 1, 2, 3, or 4 are allowed values"); + if (ViewDesc.Format.ValueType == VT_FLOAT32 || ViewDesc.Format.ValueType == VT_FLOAT16) + ViewDesc.Format.IsNormalized = false; + auto ViewElementStride = GetValueSize( ViewDesc.Format.ValueType ) * Uint32{ViewDesc.Format.NumComponents}; + if (this->m_Desc.Mode == BUFFER_MODE_RAW && this->m_Desc.ElementByteStride == 0) + LOG_ERROR_AND_THROW("To enable formatted views of a raw buffer, element byte must be specified during buffer initialization"); + if (ViewElementStride != this->m_Desc.ElementByteStride) + LOG_ERROR_AND_THROW("Buffer element byte stride (", this->m_Desc.ElementByteStride, ") is not consistent with the size (", ViewElementStride, ") defined by the fromat of the view (", GetBufferFormatString(ViewDesc.Format), ')' ); + } + + if (this->m_Desc.Mode == BUFFER_MODE_RAW && ViewDesc.Format.ValueType == VT_UNDEFINED) + { + if ((ViewDesc.ByteOffset % 16) != 0) + LOG_ERROR_AND_THROW("When creating a RAW view, the offset of the first element from the start of the buffer (", ViewDesc.ByteOffset, ") must be a multiple of 16 bytes"); + } } } @@ -261,7 +293,10 @@ IBufferView* BufferBase void BufferBase :: CreateDefaultViews() { - if( this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS ) + // Create default views for structured and raw buffers. For formatted buffers we do not know the view format, so + // cannot create views. + + if (this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS && (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_RAW)) { BufferViewDesc ViewDesc; ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; @@ -271,7 +306,7 @@ void BufferBaseGetDesc().ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Unexpected view type" ); } - if( this->m_Desc.BindFlags & BIND_SHADER_RESOURCE ) + if (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE && (this->m_Desc.Mode == BUFFER_MODE_STRUCTURED || this->m_Desc.Mode == BUFFER_MODE_RAW)) { BufferViewDesc ViewDesc; ViewDesc.ViewType = BUFFER_VIEW_SHADER_RESOURCE; diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h index a4b19b21..b20e3761 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.h +++ b/Graphics/GraphicsEngine/include/TextureBase.h @@ -115,6 +115,18 @@ public: /// creates texture view for the specific engine implementation. virtual void CreateView( const struct TextureViewDesc& ViewDesc, ITextureView** ppView )override { + DEV_CHECK_ERR(ViewDesc.ViewType != TEXTURE_VIEW_UNDEFINED, "Texture view type is not specified"); + if (ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE) + DEV_CHECK_ERR(this->m_Desc.BindFlags & BIND_SHADER_RESOURCE, "Attempting to create SRV for texture '", this->m_Desc.Name, "' that was not created with BIND_SHADER_RESOURCE flag"); + else if (ViewDesc.ViewType == TEXTURE_VIEW_UNORDERED_ACCESS) + DEV_CHECK_ERR(this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS, "Attempting to create UAV for texture '", this->m_Desc.Name, "' that was not created with BIND_UNORDERED_ACCESS flag"); + else if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET) + DEV_CHECK_ERR(this->m_Desc.BindFlags & BIND_RENDER_TARGET, "Attempting to create RTV for texture '", this->m_Desc.Name, "' that was not created with BIND_RENDER_TARGET flag"); + else if (ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL) + DEV_CHECK_ERR(this->m_Desc.BindFlags & BIND_DEPTH_STENCIL, "Attempting to create DSV for texture '", this->m_Desc.Name, "' that was not created with BIND_DEPTH_STENCIL flag"); + else + UNEXPECTED("Unexpected texture view type"); + CreateViewInternal( ViewDesc, ppView, false ); } diff --git a/Graphics/GraphicsEngine/interface/Buffer.h b/Graphics/GraphicsEngine/interface/Buffer.h index 077e2925..1f2f8d2d 100644 --- a/Graphics/GraphicsEngine/interface/Buffer.h +++ b/Graphics/GraphicsEngine/interface/Buffer.h @@ -38,19 +38,27 @@ static constexpr INTERFACE_ID IID_Buffer = /// Describes the buffer access mode. /// This enumeration is used by BufferDesc structure. -enum BUFFER_MODE : Int32 +enum BUFFER_MODE : Uint8 { /// Undefined mode. BUFFER_MODE_UNDEFINED = 0, /// Formated buffer. Access to the buffer will use format conversion operations. - /// In this mode, the BufferFormat member of BufferDesc defines the buffer format. + /// In this mode, ElementByteStride member of BufferDesc defines the buffer element size. + /// Buffer views can use different formats, but the format size must match ElementByteStride. BUFFER_MODE_FORMATTED, /// Structured buffer. /// In this mode, ElementByteStride member of BufferDesc defines the structure stride. BUFFER_MODE_STRUCTURED, + /// Raw buffer. + /// In this mode, the buffer is accessed as raw bytes. Formatted views of a raw + /// buffer can be also created similar to formatted buffer. If formatted views + /// are to be created, the ElementByteStride member of BufferDesc must specify the + /// size of the format. + BUFFER_MODE_RAW, + /// Helper value storing the total number of modes in the enumeration. BUFFER_MODE_NUM_MODES }; @@ -59,7 +67,7 @@ enum BUFFER_MODE : Int32 struct BufferDesc : DeviceObjectAttribs { /// Size of the buffer, in bytes. For a uniform buffer, this must be multiple of 16. - Uint32 uiSizeInBytes; + Uint32 uiSizeInBytes = 0; /// Buffer bind flags, see Diligent::BIND_FLAGS for details @@ -67,92 +75,26 @@ struct BufferDesc : DeviceObjectAttribs /// Diligent::BIND_VERTEX_BUFFER, Diligent::BIND_INDEX_BUFFER, Diligent::BIND_UNIFORM_BUFFER, /// Diligent::BIND_SHADER_RESOURCE, Diligent::BIND_STREAM_OUTPUT, Diligent::BIND_UNORDERED_ACCESS, /// Diligent::BIND_INDIRECT_DRAW_ARGS - Uint32 BindFlags; + Uint32 BindFlags = 0; /// Buffer usage, see Diligent::USAGE for details - USAGE Usage; + USAGE Usage = USAGE_DEFAULT; /// CPU access flags or 0 if no CPU access is allowed, /// see Diligent::CPU_ACCESS_FLAG for details. - Uint32 CPUAccessFlags; + Uint8 CPUAccessFlags = 0; - /// Buffer mode - BUFFER_MODE Mode; + /// Buffer mode, see Diligent::BUFFER_MODE + BUFFER_MODE Mode = BUFFER_MODE_UNDEFINED; - /// Buffer format description - struct BufferFormat - { - /// Type of components. For a formatted buffer, this value cannot be VT_UNDEFINED - VALUE_TYPE ValueType; - - /// Number of components. Allowed values: 1, 2, 3, 4. - /// For a formatted buffer, this value cannot be 0 - Uint32 NumComponents; - - /// For signed and unsigned integer value types - /// (VT_INT8, VT_INT16, VT_INT32, VT_UINT8, VT_UINT16, VT_UINT32) - /// indicates if the value should be normalized to [-1,+1] or - /// [0, 1] range respectively. For floating point types - /// (VT_FLOAT16 and VT_FLOAT32), this member is ignored. - Bool IsNormalized; - - /// Initializes the structure members with default values - - /// Default values: - /// Member | Default value - /// --------------------|-------------- - /// ValueType | VT_UNDEFINED - /// NumComponents | 0 - /// IsNormalized | True - BufferFormat() : - ValueType( VT_UNDEFINED ), - NumComponents( 0 ), - IsNormalized(True) - {} - - /// Tests if two structures are equivalent - bool operator == (const BufferFormat& RHS)const - { - return ValueType == RHS.ValueType && - NumComponents == RHS.NumComponents && - IsNormalized == RHS.IsNormalized; - } - }; - - /// Buffer format - - /// For a formatted buffer (BufferDesc::Mode equals Diligent::BUFFER_MODE_FORMATTED), this member describes the - /// buffer format, see BufferFormat. Ignored otherwise. - BufferFormat Format; - - /// Buffer element stride, in bytes. For a structured buffer (BufferDesc::Mode - /// equals Diligent::BUFFER_MODE_STRUCTURED), this member cannot be zero. For a formatted buffer - /// (BufferDesc::Mode equals Diligent::BUFFER_MODE_FORMATTED), this member can either specify the stride, or - /// be 0. In the latter case, the stride is computed automatically based - /// on the format size and assuming that elements are densely packed. - Uint32 ElementByteStride; - - /// Initializes the structure members with default values - - /// Default values: - /// Member | Default value - /// --------------------|-------------- - /// uiSizeInBytes | 0 - /// BindFlags | 0 - /// Usage | Diligent::USAGE_DEFAULT - /// CPUAccessFlags | 0 - /// Mode | Diligent::BUFFER_MODE_UNDEFINED - /// ElementByteStride | 0 - /// Members of BufferDesc::Format are initialized with default values by BufferFormat::BufferFormat() - BufferDesc() : - uiSizeInBytes(0), - BindFlags(0), - Usage(USAGE_DEFAULT), - CPUAccessFlags(0), - Mode( BUFFER_MODE_UNDEFINED ), - ElementByteStride(0) - {} + /// Buffer element stride, in bytes. + /// For a structured buffer (BufferDesc::Mode equals Diligent::BUFFER_MODE_STRUCTURED) this member + /// defines the size of each buffer element. For a formatted buffer + /// (BufferDesc::Mode equals Diligent::BUFFER_MODE_FORMATTED) and optionally for a raw buffer + /// (Diligent::BUFFER_MODE_RAW), this member defines the size of the format that will be used for views + /// created for this buffer. + Uint32 ElementByteStride = 0; /// Tests if two structures are equivalent @@ -169,7 +111,6 @@ struct BufferDesc : DeviceObjectAttribs Usage == RHS.Usage && CPUAccessFlags == RHS.CPUAccessFlags && Mode == RHS.Mode && - Format == RHS.Format && ElementByteStride == RHS.ElementByteStride; } }; @@ -260,6 +201,9 @@ public: /// \param [in] ViewType - Type of the requested view. See Diligent::BUFFER_VIEW_TYPE. /// \return Pointer to the interface /// + /// \remarks Default views are only created for structured and raw buffers. As for formatted buffers + /// the view format is unknown at buffer initialization time, no default views are created. + /// /// \note The function does not increase the reference counter for the returned interface, so /// Release() must *NOT* be called. virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType ) = 0; diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h index 767c8e4a..7dc4490d 100644 --- a/Graphics/GraphicsEngine/interface/BufferView.h +++ b/Graphics/GraphicsEngine/interface/BufferView.h @@ -35,33 +35,49 @@ namespace Diligent static constexpr INTERFACE_ID IID_BufferView = { 0xe2e83490, 0xe9d2, 0x495b, { 0x9a, 0x83, 0xab, 0xb4, 0x13, 0xa3, 0x8b, 0x7 } }; +/// Buffer format description +struct BufferFormat +{ + /// Type of components. For a formatted buffer views, this value cannot be VT_UNDEFINED + VALUE_TYPE ValueType = VT_UNDEFINED; + + /// Number of components. Allowed values: 1, 2, 3, 4. + /// For a formatted buffer, this value cannot be 0 + Uint8 NumComponents = 0; + + /// For signed and unsigned integer value types + /// (VT_INT8, VT_INT16, VT_INT32, VT_UINT8, VT_UINT16, VT_UINT32) + /// indicates if the value should be normalized to [-1,+1] or + /// [0, 1] range respectively. For floating point types + /// (VT_FLOAT16 and VT_FLOAT32), this member is ignored. + Bool IsNormalized = False; + + /// Tests if two structures are equivalent + bool operator == (const BufferFormat& RHS)const + { + return ValueType == RHS.ValueType && + NumComponents == RHS.NumComponents && + IsNormalized == RHS.IsNormalized; + } +}; + /// Buffer view description struct BufferViewDesc : DeviceObjectAttribs { /// View type. See Diligent::BUFFER_VIEW_TYPE for details. - BUFFER_VIEW_TYPE ViewType; + BUFFER_VIEW_TYPE ViewType = BUFFER_VIEW_UNDEFINED; + + /// Format of the view. This member is only used for formatted and raw buffers. + /// To create raw view of a raw buffer, set Format.ValueType member to VT_UNDEFINED + /// (default value). + BufferFormat Format; /// Offset in bytes from the beginnig of the buffer to the start of the /// buffer region referenced by the view - Uint32 ByteOffset; + Uint32 ByteOffset = 0; /// Size in bytes of the referenced buffer region - Uint32 ByteWidth; - - /// Initializes the structure members with default values - - /// Default values: - /// Member | Default value - /// --------------------|-------------- - /// ViewType | Diligent::BUFFER_VIEW_UNDEFINED - /// ByteOffset | 0 - /// ByteWidth | 0 - BufferViewDesc() : - ViewType( BUFFER_VIEW_UNDEFINED ), - ByteOffset(0), - ByteWidth(0) - { - } + Uint32 ByteWidth = 0; /// Comparison operator tests if two structures are equivalent @@ -76,9 +92,10 @@ struct BufferViewDesc : DeviceObjectAttribs // Name is primarily used for debug purposes and does not affect the view. // It is ignored in comparison operation. return //strcmp(Name, RHS.Name) == 0 && - ViewType == RHS.ViewType && - ByteOffset== RHS.ByteOffset && - ByteWidth == RHS.ByteWidth; + ViewType == RHS.ViewType && + ByteOffset== RHS.ByteOffset && + ByteWidth == RHS.ByteWidth && + Format == RHS.Format; } }; diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 12b0fc1d..8201ebd6 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -37,7 +37,7 @@ namespace Diligent /// This enumeration describes value type. It is used by /// - BufferDesc structure to describe value type of a formatted buffer /// - DrawAttribs structure to describe index type for an indexed draw call - enum VALUE_TYPE : Int32 + enum VALUE_TYPE : Uint8 { VT_UNDEFINED = 0, ///< Undefined type VT_INT8, ///< Signed 8-bit integer @@ -59,7 +59,7 @@ namespace Diligent /// It generally mirrors [D3D11_BIND_FLAG][] enumeration. It is used by /// - BufferDesc to describe bind flags for a buffer /// - TextureDesc to describe bind flags for a texture - enum BIND_FLAGS : Int32 + enum BIND_FLAGS : Uint32 { BIND_NONE = 0x0L, ///< Undefined binding BIND_VERTEX_BUFFER = 0x1L, ///< A buffer can be bound as a vertex buffer @@ -82,7 +82,7 @@ namespace Diligent /// The enumeration is used by /// - BufferDesc to describe usage for a buffer /// - TextureDesc to describe usage for a texture - enum USAGE : Int32 + enum USAGE : Uint8 { /// A resource that can only be read by the GPU. It cannot be written by the GPU, /// and cannot be accessed at all by the CPU. This type of resource must be initialized @@ -110,7 +110,7 @@ namespace Diligent /// - BufferDesc to describe CPU access mode for a buffer /// - TextureDesc to describe CPU access mode for a texture /// \note Only USAGE_DYNAMIC resources can be mapped - enum CPU_ACCESS_FLAG : Int32 + enum CPU_ACCESS_FLAG : Uint8 { CPU_ACCESS_READ = 0x01, ///< A resource can be mapped for reading CPU_ACCESS_WRITE = 0x02 ///< A resource can be mapped for writing @@ -123,7 +123,7 @@ namespace Diligent /// mirrors [D3D11_MAP][] enumeration. It is used by /// - IBuffer::Map to describe buffer mapping type /// - ITexture::Map to describe texture mapping type - enum MAP_TYPE : Int32 + enum MAP_TYPE : Uint8 { /// Resource is mapped for reading. \n /// D3D11 counterpart: D3D11_MAP_READ. OpenGL counterpart: GL_MAP_READ_BIT @@ -144,7 +144,7 @@ namespace Diligent /// This enumeration is used by /// - IBuffer::Map to describe buffer mapping flags /// - ITexture::Map to describe texture mapping flags - enum MAP_FLAGS : Int32 + enum MAP_FLAGS : Uint8 { /// Specifies that map operation should not wait until previous command that /// using the same resource completes. Map returns null pointer if the resource @@ -170,7 +170,7 @@ namespace Diligent /// This enumeration is used by /// - TextureDesc to describe texture type /// - TextureViewDesc to describe texture view type - enum RESOURCE_DIMENSION : Int32 + enum RESOURCE_DIMENSION : Uint8 { RESOURCE_DIM_UNDEFINED = 0, ///< Texture type undefined RESOURCE_DIM_BUFFER, ///< Buffer @@ -188,7 +188,7 @@ namespace Diligent /// This enumeration describes allowed view types for a texture view. It is used by TextureViewDesc /// structure. - enum TEXTURE_VIEW_TYPE : Int32 + enum TEXTURE_VIEW_TYPE : Uint8 { /// Undefined view type TEXTURE_VIEW_UNDEFINED = 0, @@ -217,7 +217,7 @@ namespace Diligent /// This enumeration describes allowed view types for a buffer view. It is used by BufferViewDesc /// structure. - enum BUFFER_VIEW_TYPE : Int32 + enum BUFFER_VIEW_TYPE : Uint8 { /// Undefined view type BUFFER_VIEW_UNDEFINED = 0, @@ -242,7 +242,7 @@ namespace Diligent /// \sa DXGI_FORMAT enumeration on MSDN, /// OpenGL Texture Formats /// - enum TEXTURE_FORMAT : Int16 + enum TEXTURE_FORMAT : Uint16 { /// Unknown format TEX_FORMAT_UNKNOWN = 0, @@ -778,7 +778,7 @@ namespace Diligent /// This enumeration defines filter type. It is used by SamplerDesc structure to define min, mag and mip filters. /// \note On D3D11, comparison filters only work with textures that have the following formats: /// R32_FLOAT_X8X24_TYPELESS, R32_FLOAT, R24_UNORM_X8_TYPELESS, R16_UNORM. - enum FILTER_TYPE : Int32 + enum FILTER_TYPE : Uint8 { FILTER_TYPE_UNKNOWN = 0, ///< Unknown filter type FILTER_TYPE_POINT, ///< Point filtering @@ -803,7 +803,7 @@ namespace Diligent /// Defines a technique for resolving texture coordinates that are outside of /// the boundaries of a texture. The enumeration generally mirrors [D3D11_TEXTURE_ADDRESS_MODE][]/[D3D12_TEXTURE_ADDRESS_MODE][] enumeration. /// It is used by SamplerDesc structure to define the address mode for U,V and W texture coordinates. - enum TEXTURE_ADDRESS_MODE : Int32 + enum TEXTURE_ADDRESS_MODE : Uint8 { /// Unknown mode TEXTURE_ADDRESS_UNKNOWN = 0, @@ -845,7 +845,7 @@ namespace Diligent /// - SamplerDesc to define a comparison function if one of the comparison mode filters is used /// - StencilOpDesc to define a stencil function /// - DepthStencilStateDesc to define a depth function - enum COMPARISON_FUNCTION : Int8 + enum COMPARISON_FUNCTION : Uint8 { /// Unknown comparison function COMPARISON_FUNC_UNKNOWN = 0, @@ -889,7 +889,7 @@ namespace Diligent /// Miscellaneous texture flags /// The enumeration is used by TextureDesc to describe misc texture flags - enum MISC_TEXTURE_FLAG : Int8 + enum MISC_TEXTURE_FLAG : Uint8 { /// Allow automatic mipmap generation with ITextureView::GenerateMips() @@ -900,7 +900,7 @@ namespace Diligent /// Input primitive topology. /// This enumeration is used by DrawAttribs structure to define input primitive topology. - enum PRIMITIVE_TOPOLOGY : Int8 + enum PRIMITIVE_TOPOLOGY : Uint8 { /// Undefined topology PRIMITIVE_TOPOLOGY_UNDEFINED = 0, @@ -1413,7 +1413,7 @@ namespace Diligent /// Describes texture format component type - enum COMPONENT_TYPE : Int8 + enum COMPONENT_TYPE : Uint8 { /// Undefined component type COMPONENT_TYPE_UNDEFINED, @@ -1530,39 +1530,27 @@ namespace Diligent struct TextureFormatInfoExt : TextureFormatInfo { /// Indicates if the format can be filtered - bool Filterable; + bool Filterable = false; /// Indicates if the format can be used as a render target format - bool ColorRenderable; + bool ColorRenderable = false; /// Indicates if the format can be used as a depth format - bool DepthRenderable; + bool DepthRenderable = false; /// Indicates if the format can be used to create a 1D texture - bool Tex1DFmt; + bool Tex1DFmt = false; /// Indicates if the format can be used to create a 2D texture - bool Tex2DFmt; + bool Tex2DFmt = false; /// Indicates if the format can be used to create a 3D texture - bool Tex3DFmt; + bool Tex3DFmt = false; /// Indicates if the format can be used to create a cube texture - bool TexCubeFmt; + bool TexCubeFmt = false; /// Indicates if the format can be used to create a multisampled 2D texture - bool SupportsMS; - - /// Initializes the structure with default values - explicit TextureFormatInfoExt() : - Filterable(false), - ColorRenderable(false), - DepthRenderable(false), - Tex1DFmt(false), - Tex2DFmt(false), - Tex3DFmt(false), - TexCubeFmt(false), - SupportsMS(false) - {} + bool SupportsMS = false; }; } -- cgit v1.2.3