From b97fe162853aac2a117e08678da8c2779a6187a5 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 3 Apr 2018 21:29:25 -0700 Subject: Rearranged some basic graphics types to reduce sizeof(PipelineStateDesc) from 352 to 240 bytes on x64 build --- Graphics/GraphicsEngine/interface/BlendState.h | 4 ++-- .../GraphicsEngine/interface/DepthStencilState.h | 2 +- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 6 ++--- Graphics/GraphicsEngine/interface/PipelineState.h | 27 +++++++++------------- .../GraphicsEngine/interface/RasterizerState.h | 26 ++++++++++----------- 5 files changed, 29 insertions(+), 36 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/interface/BlendState.h b/Graphics/GraphicsEngine/interface/BlendState.h index b2c79a0c..8bfb811c 100644 --- a/Graphics/GraphicsEngine/interface/BlendState.h +++ b/Graphics/GraphicsEngine/interface/BlendState.h @@ -160,7 +160,7 @@ enum BLEND_OPERATION : Int8 /// These flags are used by RenderTargetBlendDesc structure to define /// writable components of the render target -enum COLOR_MASK : Int32 +enum COLOR_MASK : Int8 { /// Allow data to be stored in the red component. COLOR_MASK_RED = 1, @@ -294,7 +294,7 @@ struct RenderTargetBlendDesc LOGIC_OPERATION LogicOp; /// Render target write mask - Uint32 RenderTargetWriteMask; + Uint8 RenderTargetWriteMask; /// Constructor initializes structure members with default values diff --git a/Graphics/GraphicsEngine/interface/DepthStencilState.h b/Graphics/GraphicsEngine/interface/DepthStencilState.h index ec4b75ba..9a785c4f 100644 --- a/Graphics/GraphicsEngine/interface/DepthStencilState.h +++ b/Graphics/GraphicsEngine/interface/DepthStencilState.h @@ -39,7 +39,7 @@ namespace Diligent /// [D3D11_STENCIL_OP][]/[D3D12_STENCIL_OP][] enumeration. /// It is used by Diligent::StencilOpDesc structure to describe the stencil fail, depth fail /// and stencil pass operations -enum STENCIL_OP : Int32 +enum STENCIL_OP : Int8 { /// Undefined operation. STENCIL_OP_UNDEFINED = 0, diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 57d591ee..53fc1039 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -242,7 +242,7 @@ namespace Diligent /// \sa DXGI_FORMAT enumeration on MSDN, /// OpenGL Texture Formats /// - enum TEXTURE_FORMAT : Int32 + enum TEXTURE_FORMAT : Int16 { /// Unknown format TEX_FORMAT_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 : Int32 + enum COMPARISON_FUNCTION : Int8 { /// 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 + enum MISC_TEXTURE_FLAG : Int8 { /// Allow automatic mipmap generation with ITextureView::GenerateMips() diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index 58f05f7f..a8f386f2 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -44,7 +44,7 @@ namespace Diligent /// This enumeration describes primitive topology type. It generally mirrors [D3D12_PRIMITIVE_TOPOLOGY_TYPE] enumeration. /// The enumeration is used by GraphicsPipelineDesc to describe how the pipeline interprets /// geometry or hull shader input primitives -enum PRIMITIVE_TOPOLOGY_TYPE : Int32 +enum PRIMITIVE_TOPOLOGY_TYPE : Int8 { /// Topology is not defined PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED = 0, @@ -71,10 +71,10 @@ enum PRIMITIVE_TOPOLOGY_TYPE : Int32 struct SampleDesc { /// Sample count - Uint32 Count; + Uint8 Count; /// Quality - Uint32 Quality; + Uint8 Quality; SampleDesc() : Count(1), @@ -128,7 +128,7 @@ struct GraphicsPipelineDesc PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType = PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; /// Number of render targets in the RTVFormats member - Uint32 NumRenderTargets = 0; + Uint8 NumRenderTargets = 0; /// Render target formats TEXTURE_FORMAT RTVFormats[8]; @@ -170,24 +170,19 @@ struct ComputePipelineDesc struct PipelineStateDesc : DeviceObjectAttribs { /// Flag indicating if pipeline state is a compute pipeline state - bool IsComputePipeline; + bool IsComputePipeline = false; + + /// Shader resource binding allocation granularity + + /// This member defines allocation granularity for internal resources required by the shader resource + /// binding object instances. + Uint32 SRBAllocationGranularity = 1; /// Graphics pipeline state description. This memeber is ignored if IsComputePipeline == True GraphicsPipelineDesc GraphicsPipeline; /// Compute pipeline state description. This memeber is ignored if IsComputePipeline == False ComputePipelineDesc ComputePipeline; - - /// Shader resource binding allocation granularity - - /// This member defines allocation granularity for internal resources required by the shader resource - /// binding object instances. - Uint32 SRBAllocationGranularity; - - PipelineStateDesc() : - IsComputePipeline(false), - SRBAllocationGranularity(1) - {} }; // {06084AE5-6A71-4FE8-84B9-395DD489A28C} diff --git a/Graphics/GraphicsEngine/interface/RasterizerState.h b/Graphics/GraphicsEngine/interface/RasterizerState.h index 0e8d5299..eb548bba 100644 --- a/Graphics/GraphicsEngine/interface/RasterizerState.h +++ b/Graphics/GraphicsEngine/interface/RasterizerState.h @@ -37,7 +37,7 @@ namespace Diligent /// [D3D12_FILL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770366(v=vs.85).aspx /// This enumeration determines the fill mode to use when rendering triangles and mirrors the /// [D3D11_FILL_MODE][]/[D3D12_FILL_MODE][] enum. It is used by RasterizerStateDesc structure to define the fill mode. -enum FILL_MODE : Int32 +enum FILL_MODE : Int8 { /// Undefined fill mode. FILL_MODE_UNDEFINED = 0, @@ -60,7 +60,7 @@ enum FILL_MODE : Int32 /// [D3D12_CULL_MODE]: https://msdn.microsoft.com/en-us/library/windows/desktop/dn770354(v=vs.85).aspx /// This enumeration defines which triangles are not drawn during the rasterization and mirrors /// [D3D11_CULL_MODE][]/[D3D12_CULL_MODE][] enum. It is used by RasterizerStateDesc structure to define the polygon cull mode. -enum CULL_MODE : Int32 +enum CULL_MODE : Int8 { /// Undefined cull mode. CULL_MODE_UNDEFINED = 0, @@ -101,16 +101,6 @@ struct RasterizerStateDesc /// If this parameter is False, the opposite is true. Bool FrontCounterClockwise; - /// Constant value added to the depth of a given pixel. - Int32 DepthBias; - - /// Maximum depth bias of a pixel. - /// \warning Depth bias clamp is not available in OpenGL - Float32 DepthBiasClamp; - - /// Scalar that scales the given pixel's slope before adding to the pixel's depth. - Float32 SlopeScaledDepthBias; - /// Enable clipping based on distance. /// \warning On DirectX this only disables clipping against far clipping plane, /// while on OpenGL this disables clipping against both far and near clip planes. @@ -122,7 +112,15 @@ struct RasterizerStateDesc /// Specifies whether to enable line antialiasing. Bool AntialiasedLineEnable; - /// Initializes the structure members + /// Constant value added to the depth of a given pixel. + Int32 DepthBias; + + /// Maximum depth bias of a pixel. + /// \warning Depth bias clamp is not available in OpenGL + Float32 DepthBiasClamp; + + /// Scalar that scales the given pixel's slope before adding to the pixel's depth. + Float32 SlopeScaledDepthBias; /// Member | Default value /// ----------------------|-------------- @@ -177,4 +175,4 @@ struct RasterizerStateDesc } }; -} \ No newline at end of file +} -- cgit v1.2.3