diff --git a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp index 52abc7800..0305cd303 100644 --- a/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp +++ b/Graphics/GraphicsAccessories/interface/GraphicsAccessories.hpp @@ -140,8 +140,8 @@ template <> struct VALUE_TYPE2CType typedef Float64 CType; }; -static const Uint32 ValueTypeToSizeMap[] = - // clang-format off +// clang-format off +static constexpr Uint32 ValueTypeToSizeMap[] = { 0, sizeof(VALUE_TYPE2CType :: CType), diff --git a/Graphics/GraphicsEngine/interface/BottomLevelAS.h b/Graphics/GraphicsEngine/interface/BottomLevelAS.h index c63ee39d1..864cf100c 100644 --- a/Graphics/GraphicsEngine/interface/BottomLevelAS.h +++ b/Graphics/GraphicsEngine/interface/BottomLevelAS.h @@ -46,7 +46,7 @@ static DILIGENT_CONSTEXPR INTERFACE_ID IID_BottomLevelAS = #define DILIGENT_INVALID_INDEX 0xFFFFFFFFU -static const Uint32 INVALID_INDEX = DILIGENT_INVALID_INDEX; +static DILIGENT_CONSTEXPR Uint32 INVALID_INDEX = DILIGENT_INVALID_INDEX; /// Defines bottom level acceleration structure triangles description. diff --git a/Graphics/GraphicsEngine/interface/BufferView.h b/Graphics/GraphicsEngine/interface/BufferView.h index cc199f885..7d1639e73 100644 --- a/Graphics/GraphicsEngine/interface/BufferView.h +++ b/Graphics/GraphicsEngine/interface/BufferView.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,7 +37,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {E2E83490-E9D2-495B-9A83-ABB413A38B07} -static const struct INTERFACE_ID IID_BufferView = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_BufferView = {0xe2e83490, 0xe9d2, 0x495b, {0x9a, 0x83, 0xab, 0xb4, 0x13, 0xa3, 0x8b, 0x7}}; /// Buffer format description diff --git a/Graphics/GraphicsEngine/interface/CommandList.h b/Graphics/GraphicsEngine/interface/CommandList.h index 0a33de50e..a875869ed 100644 --- a/Graphics/GraphicsEngine/interface/CommandList.h +++ b/Graphics/GraphicsEngine/interface/CommandList.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {C38C68F2-8A8C-4ED5-B7EE-69126E75DCD8} -static const struct INTERFACE_ID IID_CommandList = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_CommandList = {0xc38c68f2, 0x8a8c, 0x4ed5, {0xb7, 0xee, 0x69, 0x12, 0x6e, 0x75, 0xdc, 0xd8}}; diff --git a/Graphics/GraphicsEngine/interface/Constants.h b/Graphics/GraphicsEngine/interface/Constants.h index 46419ac56..ce3bc5564 100644 --- a/Graphics/GraphicsEngine/interface/Constants.h +++ b/Graphics/GraphicsEngine/interface/Constants.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,14 +62,14 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) /// Bit shift for the the shading X-axis rate. #define DILIGENT_SHADING_RATE_X_SHIFT 2 -static const Uint32 MAX_BUFFER_SLOTS = DILIGENT_MAX_BUFFER_SLOTS; -static const Uint32 MAX_RENDER_TARGETS = DILIGENT_MAX_RENDER_TARGETS; -static const Uint32 MAX_VIEWPORTS = DILIGENT_MAX_VIEWPORTS; -static const Uint32 MAX_RESOURCE_SIGNATURES = DILIGENT_MAX_RESOURCE_SIGNATURES; -static const Uint32 MAX_ADAPTER_QUEUES = DILIGENT_MAX_ADAPTER_QUEUES; -static const Uint32 DEFAULT_ADAPTER_ID = DILIGENT_DEFAULT_ADAPTER_ID; -static const Uint8 DEFAULT_QUEUE_ID = DILIGENT_DEFAULT_QUEUE_ID; -static const Uint32 MAX_SHADING_RATES = DILIGENT_MAX_SHADING_RATES; -static const Uint32 SHADING_RATE_X_SHIFT = DILIGENT_SHADING_RATE_X_SHIFT; +static DILIGENT_CONSTEXPR Uint32 MAX_BUFFER_SLOTS = DILIGENT_MAX_BUFFER_SLOTS; +static DILIGENT_CONSTEXPR Uint32 MAX_RENDER_TARGETS = DILIGENT_MAX_RENDER_TARGETS; +static DILIGENT_CONSTEXPR Uint32 MAX_VIEWPORTS = DILIGENT_MAX_VIEWPORTS; +static DILIGENT_CONSTEXPR Uint32 MAX_RESOURCE_SIGNATURES = DILIGENT_MAX_RESOURCE_SIGNATURES; +static DILIGENT_CONSTEXPR Uint32 MAX_ADAPTER_QUEUES = DILIGENT_MAX_ADAPTER_QUEUES; +static DILIGENT_CONSTEXPR Uint32 DEFAULT_ADAPTER_ID = DILIGENT_DEFAULT_ADAPTER_ID; +static DILIGENT_CONSTEXPR Uint8 DEFAULT_QUEUE_ID = DILIGENT_DEFAULT_QUEUE_ID; +static DILIGENT_CONSTEXPR Uint32 MAX_SHADING_RATES = DILIGENT_MAX_SHADING_RATES; +static DILIGENT_CONSTEXPR Uint32 SHADING_RATE_X_SHIFT = DILIGENT_SHADING_RATE_X_SHIFT; DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index dc8767546..f1eeb880b 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -1290,7 +1290,7 @@ typedef struct BuildBLASAttribs BuildBLASAttribs; #define DILIGENT_TLAS_INSTANCE_OFFSET_AUTO 0xFFFFFFFFU -static const Uint32 TLAS_INSTANCE_OFFSET_AUTO = DILIGENT_TLAS_INSTANCE_OFFSET_AUTO; +static DILIGENT_CONSTEXPR Uint32 TLAS_INSTANCE_OFFSET_AUTO = DILIGENT_TLAS_INSTANCE_OFFSET_AUTO; /// Row-major matrix @@ -1383,7 +1383,7 @@ typedef struct TLASBuildInstanceData TLASBuildInstanceData; #define DILIGENT_TLAS_INSTANCE_DATA_SIZE 64 -static const Uint32 TLAS_INSTANCE_DATA_SIZE = DILIGENT_TLAS_INSTANCE_DATA_SIZE; +static DILIGENT_CONSTEXPR Uint32 TLAS_INSTANCE_DATA_SIZE = DILIGENT_TLAS_INSTANCE_DATA_SIZE; /// This structure is used by IDeviceContext::BuildTLAS(). @@ -1896,8 +1896,8 @@ typedef struct BindSparseResourceMemoryAttribs BindSparseResourceMemoryAttribs; /// Special constant for all remaining array slices. #define DILIGENT_REMAINING_ARRAY_SLICES 0xFFFFFFFFU -static const Uint32 REMAINING_MIP_LEVELS = DILIGENT_REMAINING_MIP_LEVELS; -static const Uint32 REMAINING_ARRAY_SLICES = DILIGENT_REMAINING_ARRAY_SLICES; +static DILIGENT_CONSTEXPR Uint32 REMAINING_MIP_LEVELS = DILIGENT_REMAINING_MIP_LEVELS; +static DILIGENT_CONSTEXPR Uint32 REMAINING_ARRAY_SLICES = DILIGENT_REMAINING_ARRAY_SLICES; /// Resource state transition flags. DILIGENT_TYPED_ENUM(STATE_TRANSITION_FLAGS, Uint8) diff --git a/Graphics/GraphicsEngine/interface/Framebuffer.h b/Graphics/GraphicsEngine/interface/Framebuffer.h index 60bf677a6..d8356d8c0 100644 --- a/Graphics/GraphicsEngine/interface/Framebuffer.h +++ b/Graphics/GraphicsEngine/interface/Framebuffer.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {05DA9E47-3CA6-4F96-A967-1DDDC53181A6} -static const struct INTERFACE_ID IID_Framebuffer = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_Framebuffer = { 0x5da9e47, 0x3ca6, 0x4f96, { 0xa9, 0x67, 0x1d, 0xdd, 0xc5, 0x31, 0x81, 0xa6 } }; /// Framebuffer description. diff --git a/Graphics/GraphicsEngine/interface/InputLayout.h b/Graphics/GraphicsEngine/interface/InputLayout.h index 88e136ea0..aa15a0922 100644 --- a/Graphics/GraphicsEngine/interface/InputLayout.h +++ b/Graphics/GraphicsEngine/interface/InputLayout.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,9 +45,9 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) /// Compute layout element stride automatically, see Diligen::LayoutElement::Stride for details. #define DILIGENT_LAYOUT_ELEMENT_AUTO_STRIDE 0xFFFFFFFFU -static const Uint32 MAX_LAYOUT_ELEMENTS = DILIGENT_MAX_LAYOUT_ELEMENTS; -static const Uint32 LAYOUT_ELEMENT_AUTO_OFFSET = DILIGENT_LAYOUT_ELEMENT_AUTO_OFFSET; -static const Uint32 LAYOUT_ELEMENT_AUTO_STRIDE = DILIGENT_LAYOUT_ELEMENT_AUTO_STRIDE; +static DILIGENT_CONSTEXPR Uint32 MAX_LAYOUT_ELEMENTS = DILIGENT_MAX_LAYOUT_ELEMENTS; +static DILIGENT_CONSTEXPR Uint32 LAYOUT_ELEMENT_AUTO_OFFSET = DILIGENT_LAYOUT_ELEMENT_AUTO_OFFSET; +static DILIGENT_CONSTEXPR Uint32 LAYOUT_ELEMENT_AUTO_STRIDE = DILIGENT_LAYOUT_ELEMENT_AUTO_STRIDE; /// Input frequency DILIGENT_TYPED_ENUM(INPUT_ELEMENT_FREQUENCY, Uint8) diff --git a/Graphics/GraphicsEngine/interface/PipelineState.h b/Graphics/GraphicsEngine/interface/PipelineState.h index cf5ede6a5..bf4ac07eb 100644 --- a/Graphics/GraphicsEngine/interface/PipelineState.h +++ b/Graphics/GraphicsEngine/interface/PipelineState.h @@ -955,7 +955,7 @@ typedef struct TilePipelineStateCreateInfo TilePipelineStateCreateInfo; // {06084AE5-6A71-4FE8-84B9-395DD489A28C} -static const struct INTERFACE_ID IID_PipelineState = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_PipelineState = {0x6084ae5, 0x6a71, 0x4fe8, {0x84, 0xb9, 0x39, 0x5d, 0xd4, 0x89, 0xa2, 0x8c}}; #define DILIGENT_INTERFACE_NAME IPipelineState diff --git a/Graphics/GraphicsEngine/interface/RenderPass.h b/Graphics/GraphicsEngine/interface/RenderPass.h index ca70cc536..7dfe51cc8 100644 --- a/Graphics/GraphicsEngine/interface/RenderPass.h +++ b/Graphics/GraphicsEngine/interface/RenderPass.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,7 +37,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {B818DEC7-174D-447A-A8E4-94D21C57B40A} -static const struct INTERFACE_ID IID_RenderPass = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_RenderPass = { 0xb818dec7, 0x174d, 0x447a, { 0xa8, 0xe4, 0x94, 0xd2, 0x1c, 0x57, 0xb4, 0xa } }; @@ -152,7 +152,7 @@ typedef struct RenderPassAttachmentDesc RenderPassAttachmentDesc; /// Special constant indicating that the render pass attachment is not used. #define DILIGENT_ATTACHMENT_UNUSED 0xFFFFFFFFU -static const Uint32 ATTACHMENT_UNUSED = DILIGENT_ATTACHMENT_UNUSED; +static DILIGENT_CONSTEXPR Uint32 ATTACHMENT_UNUSED = DILIGENT_ATTACHMENT_UNUSED; /// Attachment reference description. struct AttachmentReference @@ -358,7 +358,7 @@ typedef struct SubpassDesc SubpassDesc; /// Special subpass index value expanding synchronization scope outside a subpass. #define DILIGENT_SUBPASS_EXTERNAL 0xFFFFFFFFU -static const Uint32 SUBPASS_EXTERNAL = DILIGENT_SUBPASS_EXTERNAL; +static DILIGENT_CONSTEXPR Uint32 SUBPASS_EXTERNAL = DILIGENT_SUBPASS_EXTERNAL; /// Subpass dependency description struct SubpassDependencyDesc diff --git a/Graphics/GraphicsEngineD3D11/interface/BufferD3D11.h b/Graphics/GraphicsEngineD3D11/interface/BufferD3D11.h index 088a8306a..0003231a5 100644 --- a/Graphics/GraphicsEngineD3D11/interface/BufferD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/BufferD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {4A696D2E-44BB-4C4B-9DE2-3AF7C94DCFC0} -static const struct INTERFACE_ID IID_BufferD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_BufferD3D11 = {0x4a696d2e, 0x44bb, 0x4c4b, {0x9d, 0xe2, 0x3a, 0xf7, 0xc9, 0x4d, 0xcf, 0xc0}}; #define DILIGENT_INTERFACE_NAME IBufferD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/BufferViewD3D11.h b/Graphics/GraphicsEngineD3D11/interface/BufferViewD3D11.h index 3f13e197f..e865131ae 100644 --- a/Graphics/GraphicsEngineD3D11/interface/BufferViewD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/BufferViewD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {6ABA95FC-CD7D-4C03-8CAE-AFC45F9696B7} -static const struct INTERFACE_ID IID_BufferViewD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_BufferViewD3D11 = {0x6aba95fc, 0xcd7d, 0x4c03, {0x8c, 0xae, 0xaf, 0xc4, 0x5f, 0x96, 0x96, 0xb7}}; #define DILIGENT_INTERFACE_NAME IBufferViewD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/DeviceContextD3D11.h b/Graphics/GraphicsEngineD3D11/interface/DeviceContextD3D11.h index 4f7ff9e93..fa4c56d70 100644 --- a/Graphics/GraphicsEngineD3D11/interface/DeviceContextD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/DeviceContextD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {F0EE0335-C8AB-4EC1-BB15-B8EE5F003B99} -static const struct INTERFACE_ID IID_DeviceContextD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_DeviceContextD3D11 = {0xf0ee0335, 0xc8ab, 0x4ec1, {0xbb, 0x15, 0xb8, 0xee, 0x5f, 0x0, 0x3b, 0x99}}; #define DILIGENT_INTERFACE_NAME IDeviceContextD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h b/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h index 378e14bf3..4138e75bc 100644 --- a/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/EngineFactoryD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +42,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {62663A30-AAF0-4A9A-9729-9EAC6BF789F2} -static const struct INTERFACE_ID IID_EngineFactoryD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_EngineFactoryD3D11 = {0x62663a30, 0xaaf0, 0x4a9a, {0x97, 0x29, 0x9e, 0xac, 0x6b, 0xf7, 0x89, 0xf2}}; #define DILIGENT_INTERFACE_NAME IEngineFactoryD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h b/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h index 45513072f..cfbed4ecc 100644 --- a/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/FenceD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {45F2BE28-652B-4180-B6E4-E75F83F63CC7} -static const struct INTERFACE_ID IID_FenceD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_FenceD3D11 = {0x45f2be28, 0x652b, 0x4180, {0xb6, 0xe4, 0xe7, 0x5f, 0x83, 0xf6, 0x3c, 0xc7}}; #define DILIGENT_INTERFACE_NAME IFenceD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/PipelineStateD3D11.h b/Graphics/GraphicsEngineD3D11/interface/PipelineStateD3D11.h index f7af24bbb..e941b88ee 100644 --- a/Graphics/GraphicsEngineD3D11/interface/PipelineStateD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/PipelineStateD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {3EA6E3F4-9966-47FC-8CE8-0EB3E2273061} -static const struct INTERFACE_ID IID_PipelineStateD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_PipelineStateD3D11 = {0x3ea6e3f4, 0x9966, 0x47fc, {0x8c, 0xe8, 0xe, 0xb3, 0xe2, 0x27, 0x30, 0x61}}; #define DILIGENT_INTERFACE_NAME IPipelineStateD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/QueryD3D11.h b/Graphics/GraphicsEngineD3D11/interface/QueryD3D11.h index 43235a520..bdfdfab2c 100644 --- a/Graphics/GraphicsEngineD3D11/interface/QueryD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/QueryD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {77D95EAA-D16E-43F4-B0EB-BEBCD2EC8C57} -static const struct INTERFACE_ID IID_QueryD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_QueryD3D11 = {0x77d95eaa, 0xd16e, 0x43f4, {0xb0, 0xeb, 0xbe, 0xbc, 0xd2, 0xec, 0x8c, 0x57}}; #define DILIGENT_INTERFACE_NAME IQueryD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/RenderDeviceD3D11.h b/Graphics/GraphicsEngineD3D11/interface/RenderDeviceD3D11.h index 189aa6d4a..b89a6f9ce 100644 --- a/Graphics/GraphicsEngineD3D11/interface/RenderDeviceD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/RenderDeviceD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {05B1CBB8-FCAD-49EE-BADA-7801223EC3FE} -static const struct INTERFACE_ID IID_RenderDeviceD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_RenderDeviceD3D11 = {0x5b1cbb8, 0xfcad, 0x49ee, {0xba, 0xda, 0x78, 0x1, 0x22, 0x3e, 0xc3, 0xfe}}; #define DILIGENT_INTERFACE_NAME IRenderDeviceD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/SamplerD3D11.h b/Graphics/GraphicsEngineD3D11/interface/SamplerD3D11.h index 0fa9210d8..53060ac89 100644 --- a/Graphics/GraphicsEngineD3D11/interface/SamplerD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/SamplerD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {31A3BFAF-738E-4D8C-AD18-B021C5D948DD} -static const struct INTERFACE_ID IID_SamplerD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_SamplerD3D11 = {0x31a3bfaf, 0x738e, 0x4d8c, {0xad, 0x18, 0xb0, 0x21, 0xc5, 0xd9, 0x48, 0xdd}}; #define DILIGENT_INTERFACE_NAME ISamplerD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/ShaderD3D11.h b/Graphics/GraphicsEngineD3D11/interface/ShaderD3D11.h index cbd25a673..523163289 100644 --- a/Graphics/GraphicsEngineD3D11/interface/ShaderD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/ShaderD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {C513E83E-B037-405B-8B49-BF8F5C220DEE} -static const struct INTERFACE_ID IID_ShaderD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_ShaderD3D11 = {0xc513e83e, 0xb037, 0x405b, {0x8b, 0x49, 0xbf, 0x8f, 0x5c, 0x22, 0xd, 0xee}}; #define DILIGENT_INTERFACE_NAME IShaderD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/ShaderResourceBindingD3D11.h b/Graphics/GraphicsEngineD3D11/interface/ShaderResourceBindingD3D11.h index d4b845b5c..3da400515 100644 --- a/Graphics/GraphicsEngineD3D11/interface/ShaderResourceBindingD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/ShaderResourceBindingD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {97A6D4AC-D4AF-4AA9-B46C-67417B89026A} -static const struct INTERFACE_ID IID_ShaderResourceBindingD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_ShaderResourceBindingD3D11 = {0x97a6d4ac, 0xd4af, 0x4aa9, {0xb4, 0x6c, 0x67, 0x41, 0x7b, 0x89, 0x2, 0x6a}}; #define DILIGENT_INTERFACE_NAME IShaderResourceBindingD3D11 diff --git a/Graphics/GraphicsEngineD3D11/interface/SwapChainD3D11.h b/Graphics/GraphicsEngineD3D11/interface/SwapChainD3D11.h index c19970cc6..f8f2ffdff 100644 --- a/Graphics/GraphicsEngineD3D11/interface/SwapChainD3D11.h +++ b/Graphics/GraphicsEngineD3D11/interface/SwapChainD3D11.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {4DAF2E76-9204-4DC4-A53A-B00097412D3A} -static const struct INTERFACE_ID IID_SwapChainD3D11 = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_SwapChainD3D11 = {0x4daf2e76, 0x9204, 0x4dc4, {0xa5, 0x3a, 0xb0, 0x0, 0x97, 0x41, 0x2d, 0x3a}}; #define DILIGENT_INTERFACE_NAME ISwapChainD3D11 diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index fda728112..cb26abf84 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -860,7 +860,7 @@ void DeviceContextD3D11Impl::ClearRenderTarget(ITextureView* pView, const float* auto* pViewD3D11 = ClassPtrCast(pView); auto* pd3d11RTV = static_cast(pViewD3D11->GetD3D11View()); - static const float Zero[4] = {0.f, 0.f, 0.f, 0.f}; + static constexpr float Zero[4] = {0.f, 0.f, 0.f, 0.f}; if (RGBA == nullptr) RGBA = Zero; diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp index 0620fd5b9..a638ed279 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12Utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,26 +30,25 @@ #include "D3D12Utils.h" #include +#include namespace Diligent { const Char* GetD3D12DescriptorHeapTypeLiteralName(D3D12_DESCRIPTOR_HEAP_TYPE Type) { - static bool bIsInitialized = false; - static const Char* HeapTypeNames[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES]; - if (!bIsInitialized) - { - // clang-format off - HeapTypeNames[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] = "D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV"; - HeapTypeNames[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER] = "D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER"; - HeapTypeNames[D3D12_DESCRIPTOR_HEAP_TYPE_RTV] = "D3D12_DESCRIPTOR_HEAP_TYPE_RTV"; - HeapTypeNames[D3D12_DESCRIPTOR_HEAP_TYPE_DSV] = "D3D12_DESCRIPTOR_HEAP_TYPE_DSV"; - // clang-format on - - bIsInitialized = true; - } - VERIFY_EXPR(Type >= 0 && Type < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES); + // clang-format off + static_assert(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV == 0, "D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV is expected to be 0"); + static_assert(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER == 1, "D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER is expected to be 1"); + static_assert(D3D12_DESCRIPTOR_HEAP_TYPE_RTV == 2, "D3D12_DESCRIPTOR_HEAP_TYPE_RTV is expected to be 2"); + static_assert(D3D12_DESCRIPTOR_HEAP_TYPE_DSV == 3, "D3D12_DESCRIPTOR_HEAP_TYPE_DSV is expected to be 3"); + // clang-format on + static constexpr std::array HeapTypeNames{ + "D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV", + "D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER", + "D3D12_DESCRIPTOR_HEAP_TYPE_RTV", + "D3D12_DESCRIPTOR_HEAP_TYPE_DSV", + }; return HeapTypeNames[Type]; } diff --git a/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h b/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h index 2c11de82e..14f6bac86 100644 --- a/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h +++ b/Graphics/GraphicsEngineD3DBase/interface/ShaderD3D.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {1EA0898C-1612-457F-B74E-808843D2CBE3} -static const struct INTERFACE_ID IID_ShaderD3D = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_ShaderD3D = {0x1ea0898c, 0x1612, 0x457f, {0xb7, 0x4e, 0x80, 0x88, 0x43, 0xd2, 0xcb, 0xe3}}; diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index 57e77d41d..5617b66dc 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -1213,7 +1213,7 @@ void DeviceContextGLImpl::ClearRenderTarget(ITextureView* pView, const float* RG return; } - static const float Zero[4] = {0, 0, 0, 0}; + static constexpr float Zero[4] = {0, 0, 0, 0}; if (RGBA == nullptr) RGBA = Zero; diff --git a/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp b/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp index 353dadafe..a12c4c80c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -171,7 +171,7 @@ GLObjectWrappers::GLFrameBufferObj FBOCache::CreateFBO(GLContextState& Contex // color attachments. This largely redundant step is performed // by glDrawBuffers() // clang-format off - static const GLenum DrawBuffers[] = + static constexpr GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 7d4846df5..51e28dd35 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -1402,7 +1402,7 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat) glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColorTex, 0); CHECK_GL_ERROR("Failed to bind dummy render target to framebuffer"); - static const GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0}; + static constexpr GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0}; glDrawBuffers(_countof(DrawBuffers), DrawBuffers); CHECK_GL_ERROR("Failed to set draw buffers via glDrawBuffers()"); @@ -1416,7 +1416,7 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat) glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TestGLTex2D, 0); if (glGetError() == GL_NO_ERROR) { - static const GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0}; + static constexpr GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0}; glDrawBuffers(_countof(DrawBuffers), DrawBuffers); CHECK_GL_ERROR("Failed to set draw buffers via glDrawBuffers()"); diff --git a/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp b/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp index 13b684b8b..44eacf1c4 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TexRegionRender.cpp @@ -74,8 +74,7 @@ TexRegionRender::TexRegionRender(class RenderDeviceGLImpl* pDeviceGL) pDeviceGL->CreateShader(ShaderAttrs, &m_pVertexShader, nullptr, IsInternalDeviceObject); - static const char* SamplerType[RESOURCE_DIM_NUM_DIMENSIONS] = {}; - + const char* SamplerType[RESOURCE_DIM_NUM_DIMENSIONS]{}; SamplerType[RESOURCE_DIM_TEX_1D] = "sampler1D"; SamplerType[RESOURCE_DIM_TEX_1D_ARRAY] = "sampler1DArray"; SamplerType[RESOURCE_DIM_TEX_2D] = "sampler2D"; @@ -86,8 +85,7 @@ TexRegionRender::TexRegionRender(class RenderDeviceGLImpl* pDeviceGL) //SamplerType[RESOURCE_DIM_TEX_CUBE_ARRAY] = "samplerCubeArray"; - static const char* SrcLocations[RESOURCE_DIM_NUM_DIMENSIONS] = {}; - + const char* SrcLocations[RESOURCE_DIM_NUM_DIMENSIONS]{}; SrcLocations[RESOURCE_DIM_TEX_1D] = "int(gl_FragCoord.x) + Constants.x"; SrcLocations[RESOURCE_DIM_TEX_1D_ARRAY] = "ivec2(int(gl_FragCoord.x) + Constants.x, Constants.z)"; SrcLocations[RESOURCE_DIM_TEX_2D] = "ivec2(gl_FragCoord.xy) + Constants.xy"; diff --git a/Primitives/interface/BasicTypes.h b/Primitives/interface/BasicTypes.h index 178b1b1bb..60e5a486b 100644 --- a/Primitives/interface/BasicTypes.h +++ b/Primitives/interface/BasicTypes.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,8 +57,8 @@ typedef const void* CPVoid; typedef bool Bool; ///< Boolean -static const Bool False = false; -static const Bool True = true; +static DILIGENT_CONSTEXPR Bool False = false; +static DILIGENT_CONSTEXPR Bool True = true; typedef char Char; #if !DILIGENT_C_INTERFACE && !defined(DILIGENT_SHARP_GEN) diff --git a/Primitives/interface/DataBlob.h b/Primitives/interface/DataBlob.h index b46c5d730..faf7b2fa7 100644 --- a/Primitives/interface/DataBlob.h +++ b/Primitives/interface/DataBlob.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) // {F578FF0D-ABD2-4514-9D32-7CB454D4A73B} -static const struct INTERFACE_ID IID_DataBlob = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_DataBlob = {0xf578ff0d, 0xabd2, 0x4514, {0x9d, 0x32, 0x7c, 0xb4, 0x54, 0xd4, 0xa7, 0x3b}}; // clang-format off diff --git a/Primitives/interface/FileStream.h b/Primitives/interface/FileStream.h index 3a66cd8ec..912399d39 100644 --- a/Primitives/interface/FileStream.h +++ b/Primitives/interface/FileStream.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 Diligent Graphics LLC + * Copyright 2019-2023 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,7 +37,7 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) /// IFileStream interface unique identifier // {E67F386C-6A5A-4A24-A0CE-C66435465D41} -static const struct INTERFACE_ID IID_FileStream = +static DILIGENT_CONSTEXPR struct INTERFACE_ID IID_FileStream = {0xe67f386c, 0x6a5a, 0x4a24, {0xa0, 0xce, 0xc6, 0x64, 0x35, 0x46, 0x5d, 0x41}}; // clang-format off