From f6cc08651827e628df57cd83fe7707a13c1c2d3e Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 8 Dec 2021 20:15:44 -0800 Subject: [PATCH] Render state notation: updated enum testing + some changes --- .../PipelineState/GraphicsPipelineDesc.json | 2 +- .../DiligentToolsTest/include/DRSNLoader.hpp | 20 ++-- .../BlendStateParserTest.cpp | 18 +-- .../DepthStencilStateParserTest.cpp | 2 +- .../GraphicsTypesParserTest.cpp | 108 +++++++++--------- .../InputLayoutParserTest.cpp | 17 ++- .../PipelineResourceSignatureParserTest.cpp | 21 ++-- .../PipelineStateParserTest.cpp | 53 ++++----- .../RasterizerStateParserTest.cpp | 9 +- .../RenderPassParserTest.cpp | 70 ++++++------ .../SamplerParserTest.cpp | 6 +- .../ShaderParserTest.cpp | 21 ++-- 12 files changed, 162 insertions(+), 185 deletions(-) diff --git a/Tests/DiligentToolsTest/assets/RenderStates/PipelineState/GraphicsPipelineDesc.json b/Tests/DiligentToolsTest/assets/RenderStates/PipelineState/GraphicsPipelineDesc.json index b60f345d..91775305 100644 --- a/Tests/DiligentToolsTest/assets/RenderStates/PipelineState/GraphicsPipelineDesc.json +++ b/Tests/DiligentToolsTest/assets/RenderStates/PipelineState/GraphicsPipelineDesc.json @@ -16,7 +16,7 @@ { "InputIndex": 1, "NumComponents": 4 } ] }, - "SampleMask": 0, + "SampleMask": 1245678, "PrimitiveTopology": "POINT_LIST", "NumRenderTargets": 2, "NumViewports": 2, diff --git a/Tests/DiligentToolsTest/include/DRSNLoader.hpp b/Tests/DiligentToolsTest/include/DRSNLoader.hpp index 1d39f435..3023e982 100644 --- a/Tests/DiligentToolsTest/include/DRSNLoader.hpp +++ b/Tests/DiligentToolsTest/include/DRSNLoader.hpp @@ -24,6 +24,8 @@ * of the possibility of such damages. */ +#include + #include "json.hpp" #include "BasicMath.hpp" #include "DynamicLinearAllocator.hpp" @@ -67,13 +69,14 @@ inline nlohmann::json LoadDRSNFromFile(const Char* FilePath) } } -template -bool TestEnum(DynamicLinearAllocator& Allocator, Type ValueBegin, Type ValueEnd) +template +bool TestEnum(DynamicLinearAllocator& Allocator, Type FirstValue, Type LastValue) { - for (Counter i = static_cast(ValueBegin); i < static_cast(ValueEnd) + 1; i++) + using UnderlyingType = typename std::underlying_type::type; + for (auto i = static_cast(FirstValue); i <= static_cast(LastValue); ++i) { nlohmann::json Json; - Type EnumReference = static_cast(i); + const auto EnumReference = static_cast(i); Serialize(Json, EnumReference, Allocator); Type Enum = {}; @@ -84,13 +87,14 @@ bool TestEnum(DynamicLinearAllocator& Allocator, Type ValueBegin, Type ValueEnd) return true; } -template -bool TestBitwiseEnum(DynamicLinearAllocator& Allocator, Type Value) +template +bool TestBitwiseEnum(DynamicLinearAllocator& Allocator, Type MaxBit) { - for (Counter Bits = static_cast(Value | (Value - 1u)); Bits != 0;) + VERIFY_EXPR(IsPowerOfTwo(MaxBit)); + for (auto Bits = static_cast(MaxBit | (MaxBit - 1)); Bits != 0;) { nlohmann::json Json; - Type EnumReference = static_cast(ExtractLSB(Bits)); + const auto EnumReference = ExtractLSB(Bits); SerializeBitwiseEnum(Json, EnumReference, Allocator); Type Enum = {}; diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/BlendStateParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/BlendStateParserTest.cpp index ccf3c6ef..3fa43411 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/BlendStateParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/BlendStateParserTest.cpp @@ -36,13 +36,13 @@ TEST(Tools_RenderStateNotationParser, ParseBlendStateEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, BLEND_FACTOR_UNDEFINED, BLEND_FACTOR_NUM_FACTORS))); + ASSERT_TRUE(TestEnum(Allocator, BLEND_FACTOR_UNDEFINED, BLEND_FACTOR_NUM_FACTORS)); - ASSERT_TRUE((TestEnum(Allocator, BLEND_OPERATION_UNDEFINED, BLEND_OPERATION_NUM_OPERATIONS))); + ASSERT_TRUE(TestEnum(Allocator, BLEND_OPERATION_UNDEFINED, BLEND_OPERATION_NUM_OPERATIONS)); - ASSERT_TRUE((TestEnum(Allocator, LOGIC_OP_CLEAR, LOGIC_OP_NUM_OPERATIONS))); + ASSERT_TRUE(TestEnum(Allocator, LOGIC_OP_CLEAR, LOGIC_OP_NUM_OPERATIONS)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, COLOR_MASK_ALL))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, COLOR_MASK_ALPHA)); } TEST(Tools_RenderStateNotationParser, ParseRenderTargetBlendDesc) @@ -51,11 +51,11 @@ TEST(Tools_RenderStateNotationParser, ParseRenderTargetBlendDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/BlendState/RenderTargetBlendDesc.json"); - RenderTargetBlendDesc DescReference = {}; - DescReference.DestBlend = BLEND_FACTOR_INV_DEST_ALPHA; - DescReference.LogicOp = LOGIC_OP_AND_REVERSE; + RenderTargetBlendDesc DescReference{}; + DescReference.DestBlend = BLEND_FACTOR_INV_DEST_ALPHA; + DescReference.LogicOp = LOGIC_OP_AND_REVERSE; - RenderTargetBlendDesc Desc = {}; + RenderTargetBlendDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -66,7 +66,7 @@ TEST(Tools_RenderStateNotationParser, ParseBlendStateDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/BlendState/BlendStateDesc.json"); - BlendStateDesc DescReference = {}; + BlendStateDesc DescReference{}; DescReference.AlphaToCoverageEnable = true; DescReference.IndependentBlendEnable = true; DescReference.RenderTargets[0].DestBlend = BLEND_FACTOR_INV_DEST_ALPHA; diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/DepthStencilStateParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/DepthStencilStateParserTest.cpp index c11df0f1..8d16b3ea 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/DepthStencilStateParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/DepthStencilStateParserTest.cpp @@ -36,7 +36,7 @@ TEST(Tools_RenderStateNotationParser, ParseDepthStencilStateEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, STENCIL_OP_UNDEFINED, STENCIL_OP_NUM_OPS))); + ASSERT_TRUE(TestEnum(Allocator, STENCIL_OP_UNDEFINED, STENCIL_OP_NUM_OPS)); } TEST(Tools_RenderStateNotationParser, ParserStencilOpDesc) diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/GraphicsTypesParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/GraphicsTypesParserTest.cpp index 954b16ae..a29faedc 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/GraphicsTypesParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/GraphicsTypesParserTest.cpp @@ -36,27 +36,27 @@ TEST(Tools_RenderStateNotationParser, ParseGraphicsTypesEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, VT_UNDEFINED, VT_NUM_TYPES))); + ASSERT_TRUE(TestEnum(Allocator, VT_UNDEFINED, VT_NUM_TYPES)); - ASSERT_TRUE((TestEnum(Allocator, TEX_FORMAT_UNKNOWN, TEX_FORMAT_NUM_FORMATS))); + ASSERT_TRUE(TestEnum(Allocator, TEX_FORMAT_UNKNOWN, TEX_FORMAT_NUM_FORMATS)); - ASSERT_TRUE((TestEnum(Allocator, FILTER_TYPE_UNKNOWN, FILTER_TYPE_NUM_FILTERS))); + ASSERT_TRUE(TestEnum(Allocator, FILTER_TYPE_UNKNOWN, FILTER_TYPE_NUM_FILTERS)); - ASSERT_TRUE((TestEnum(Allocator, TEXTURE_ADDRESS_UNKNOWN, TEXTURE_ADDRESS_NUM_MODES))); + ASSERT_TRUE(TestEnum(Allocator, TEXTURE_ADDRESS_UNKNOWN, TEXTURE_ADDRESS_NUM_MODES)); - ASSERT_TRUE((TestEnum(Allocator, COMPARISON_FUNC_UNKNOWN, COMPARISON_FUNC_NUM_FUNCTIONS))); + ASSERT_TRUE(TestEnum(Allocator, COMPARISON_FUNC_UNKNOWN, COMPARISON_FUNC_NUM_FUNCTIONS)); - ASSERT_TRUE((TestEnum(Allocator, PRIMITIVE_TOPOLOGY_UNDEFINED, PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES))); + ASSERT_TRUE(TestEnum(Allocator, PRIMITIVE_TOPOLOGY_UNDEFINED, PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES)); - ASSERT_TRUE((TestEnum(Allocator, RENDER_DEVICE_TYPE_UNDEFINED, RENDER_DEVICE_TYPE_COUNT))); + ASSERT_TRUE(TestEnum(Allocator, RENDER_DEVICE_TYPE_UNDEFINED, RENDER_DEVICE_TYPE_COUNT)); - ASSERT_TRUE((TestEnum(Allocator, ADAPTER_TYPE_UNKNOWN, ADAPTER_TYPE_DISCRETE))); + ASSERT_TRUE(TestEnum(Allocator, ADAPTER_TYPE_UNKNOWN, ADAPTER_TYPE_DISCRETE)); - ASSERT_TRUE((TestEnum(Allocator, DEVICE_FEATURE_STATE_DISABLED, DEVICE_FEATURE_STATE_OPTIONAL))); + ASSERT_TRUE(TestEnum(Allocator, DEVICE_FEATURE_STATE_DISABLED, DEVICE_FEATURE_STATE_OPTIONAL)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, SAMPLE_COUNT_ALL))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, SAMPLE_COUNT_MAX)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, RESOURCE_STATE_MAX_BIT))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, RESOURCE_STATE_MAX_BIT)); } TEST(Tools_RenderStateNotationParser, ParseVersion) @@ -65,11 +65,11 @@ TEST(Tools_RenderStateNotationParser, ParseVersion) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/Version.json"); - Version DescReference = {}; - DescReference.Major = 1; - DescReference.Minor = 2; + Version DescReference{}; + DescReference.Major = 1; + DescReference.Minor = 2; - Version Desc = {}; + Version Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -80,10 +80,10 @@ TEST(Tools_RenderStateNotationParser, ParseDeviceObjectAttribs) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/DeviceObjectAttribs.json"); - DeviceObjectAttribs DescReference = {}; - DescReference.Name = "TestName"; + DeviceObjectAttribs DescReference{}; + DescReference.Name = "TestName"; - DeviceObjectAttribs Desc = {}; + DeviceObjectAttribs Desc; Deserialize(JsonReference, Desc, Allocator); ASSERT_TRUE(SafeStrEqual(Desc.Name, DescReference.Name)); } @@ -94,8 +94,7 @@ TEST(Tools_RenderStateNotationParser, ParseDeviceFeatures) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/DeviceFeatures.json"); - DeviceFeatures DescReference = {}; - + DeviceFeatures DescReference{}; DescReference.SeparablePrograms = DEVICE_FEATURE_STATE_ENABLED; DescReference.ShaderResourceQueries = DEVICE_FEATURE_STATE_ENABLED; DescReference.WireframeFill = DEVICE_FEATURE_STATE_ENABLED; @@ -134,7 +133,7 @@ TEST(Tools_RenderStateNotationParser, ParseDeviceFeatures) DescReference.VariableRateShading = DEVICE_FEATURE_STATE_ENABLED; DescReference.SparseResources = DEVICE_FEATURE_STATE_ENABLED; - DeviceFeatures Desc = {}; + DeviceFeatures Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -145,8 +144,7 @@ TEST(Tools_RenderStateNotationParser, ParseTextureProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/TextureProperties.json"); - TextureProperties DescReference = {}; - + TextureProperties DescReference{}; DescReference.MaxTexture1DDimension = 2048; DescReference.MaxTexture1DArraySlices = 512; DescReference.MaxTexture2DDimension = 512; @@ -159,7 +157,7 @@ TEST(Tools_RenderStateNotationParser, ParseTextureProperties) DescReference.CubemapArraysSupported = true; DescReference.TextureView2DOn3DSupported = true; - TextureProperties Desc = {}; + TextureProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -170,12 +168,12 @@ TEST(Tools_RenderStateNotationParser, ParseSamplerProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/SamplerProperties.json"); - SamplerProperties DescReference = {}; + SamplerProperties DescReference{}; DescReference.AnisotropicFilteringSupported = true; DescReference.BorderSamplingModeSupported = true; DescReference.LODBiasSupported = true; - SamplerProperties Desc = {}; + SamplerProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -186,14 +184,13 @@ TEST(Tools_RenderStateNotationParser, ParseWaveOpProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/WaveOpProperties.json"); - WaveOpProperties DescReference = {}; - + WaveOpProperties DescReference{}; DescReference.MinSize = 1; DescReference.MaxSize = 64; DescReference.Features = WAVE_FEATURE_BALLOUT | WAVE_FEATURE_QUAD; DescReference.SupportedStages = SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL; - WaveOpProperties Desc = {}; + WaveOpProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -204,12 +201,11 @@ TEST(Tools_RenderStateNotationParser, ParseBufferPropertiess) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/BufferProperties.json"); - BufferProperties DescReference = {}; - + BufferProperties DescReference{}; DescReference.ConstantBufferOffsetAlignment = 64; DescReference.StructuredBufferOffsetAlignment = 128; - BufferProperties Desc = {}; + BufferProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -220,7 +216,7 @@ TEST(Tools_RenderStateNotationParser, ParseRayTracingProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/RayTracingProperties.json"); - RayTracingProperties DescReference = {}; + RayTracingProperties DescReference{}; DescReference.IndexBufferAlignment = 4; DescReference.InstanceBufferAlignment = 8; @@ -241,7 +237,7 @@ TEST(Tools_RenderStateNotationParser, ParseRayTracingProperties) DescReference.CapFlags = RAY_TRACING_CAP_FLAG_INLINE_RAY_TRACING | RAY_TRACING_CAP_FLAG_INDIRECT_RAY_TRACING; - RayTracingProperties Desc = {}; + RayTracingProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -252,10 +248,10 @@ TEST(Tools_RenderStateNotationParser, ParseMeshShaderProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/MeshShaderProperties.json"); - MeshShaderProperties DescReference = {}; - DescReference.MaxTaskCount = 4; + MeshShaderProperties DescReference{}; + DescReference.MaxTaskCount = 4; - MeshShaderProperties Desc = {}; + MeshShaderProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -266,7 +262,7 @@ TEST(Tools_RenderStateNotationParser, ParseComputeShaderProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/ComputeShaderProperties.json"); - ComputeShaderProperties DescReference = {}; + ComputeShaderProperties DescReference{}; DescReference.SharedMemorySize = 1024; DescReference.MaxThreadGroupSizeX = 4; @@ -277,7 +273,7 @@ TEST(Tools_RenderStateNotationParser, ParseComputeShaderProperties) DescReference.MaxThreadGroupCountY = 512; DescReference.MaxThreadGroupCountZ = 64; - ComputeShaderProperties Desc = {}; + ComputeShaderProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -288,13 +284,13 @@ TEST(Tools_RenderStateNotationParser, ParseNDCAttribs) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/NDCAttribs.json"); - NDCAttribs DescReference = {}; + NDCAttribs DescReference{}; DescReference.MinZ = 0.5f; DescReference.YtoVScale = 1.0f; DescReference.ZtoDepthScale = 0.25f; - NDCAttribs Desc = {}; + NDCAttribs Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -305,14 +301,13 @@ TEST(Tools_RenderStateNotationParser, ParseRenderDeviceInfo) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/RenderDeviceInfo.json"); - RenderDeviceInfo DescReference = {}; - + RenderDeviceInfo DescReference{}; DescReference.APIVersion = Version{1, 2}; DescReference.NDC.MinZ = -1.0f; DescReference.Type = RENDER_DEVICE_TYPE_VULKAN; DescReference.Features.BinaryOcclusionQueries = DEVICE_FEATURE_STATE_ENABLED; - RenderDeviceInfo Desc = {}; + RenderDeviceInfo Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -323,7 +318,7 @@ TEST(Tools_RenderStateNotationParser, ParseAdapterMemoryInfo) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/AdapterMemoryInfo.json"); - AdapterMemoryInfo DescReference = {}; + AdapterMemoryInfo DescReference{}; DescReference.LocalMemory = 8192; DescReference.HostVisibleMemory = 256; @@ -333,7 +328,7 @@ TEST(Tools_RenderStateNotationParser, ParseAdapterMemoryInfo) DescReference.UnifiedMemoryCPUAccess = CPU_ACCESS_READ | CPU_ACCESS_WRITE; DescReference.MemorylessTextureBindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET; - AdapterMemoryInfo Desc = {}; + AdapterMemoryInfo Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -344,12 +339,12 @@ TEST(Tools_RenderStateNotationParser, ParseShadingRateMode) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/ShadingRateMode.json"); - ShadingRateMode DescReference = {}; + ShadingRateMode DescReference{}; DescReference.Rate = SHADING_RATE_2X4; DescReference.SampleBits = SAMPLE_COUNT_4 | SAMPLE_COUNT_16; - ShadingRateMode Desc = {}; + ShadingRateMode Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -360,7 +355,7 @@ TEST(Tools_RenderStateNotationParser, ParseShadingRateProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/ShadingRateProperties.json"); - ShadingRateProperties DescReference = {}; + ShadingRateProperties DescReference{}; DescReference.BindFlags = BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE; DescReference.CapFlags = SHADING_RATE_CAP_FLAG_PER_DRAW | SHADING_RATE_CAP_FLAG_PER_PRIMITIVE; @@ -376,7 +371,7 @@ TEST(Tools_RenderStateNotationParser, ParseShadingRateProperties) DescReference.MaxTileSize[0] = 8; DescReference.MaxTileSize[1] = 16; - ShadingRateProperties Desc = {}; + ShadingRateProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -387,13 +382,13 @@ TEST(Tools_RenderStateNotationParser, ParseDrawCommandProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/DrawCommandProperties.json"); - DrawCommandProperties DescReference = {}; + DrawCommandProperties DescReference{}; DescReference.CapFlags = DRAW_COMMAND_CAP_FLAG_DRAW_INDIRECT | DRAW_COMMAND_CAP_FLAG_NATIVE_MULTI_DRAW_INDIRECT; DescReference.MaxDrawIndirectCount = 2048; DescReference.MaxIndexValue = 1024; - DrawCommandProperties Desc = {}; + DrawCommandProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -404,7 +399,7 @@ TEST(Tools_RenderStateNotationParser, ParseSparseResourceProperties) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/SparseResourceProperties.json"); - SparseResourceProperties DescReference = {}; + SparseResourceProperties DescReference{}; DescReference.AddressSpaceSize = 2048; DescReference.BufferBindFlags = BIND_UNORDERED_ACCESS | BIND_SHADER_RESOURCE; @@ -412,7 +407,7 @@ TEST(Tools_RenderStateNotationParser, ParseSparseResourceProperties) DescReference.ResourceSpaceSize = 1024; DescReference.StandardBlockSize = 64; - SparseResourceProperties Desc = {}; + SparseResourceProperties Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -423,7 +418,7 @@ TEST(Tools_RenderStateNotationParser, ParseCommandQueueInfo) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/CommandQueueInfo.json"); - CommandQueueInfo DescReference = {}; + CommandQueueInfo DescReference{}; DescReference.QueueType = COMMAND_QUEUE_TYPE_GRAPHICS; DescReference.MaxDeviceContexts = 16; @@ -443,8 +438,7 @@ TEST(Tools_RenderStateNotationParser, ParseGraphicsAdapterInfo) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/GraphicsTypes/GraphicsAdapterInfo.json"); - GraphicsAdapterInfo DescReference = {}; - + GraphicsAdapterInfo DescReference{}; DescReference.Type = ADAPTER_TYPE_DISCRETE; DescReference.Vendor = ADAPTER_VENDOR_NVIDIA; DescReference.VendorId = 8; diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/InputLayoutParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/InputLayoutParserTest.cpp index bc7eac80..dc705fbb 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/InputLayoutParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/InputLayoutParserTest.cpp @@ -36,7 +36,7 @@ TEST(Tools_RenderStateNotationParser, ParseInputLayoutEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, INPUT_ELEMENT_FREQUENCY_UNDEFINED, INPUT_ELEMENT_FREQUENCY_NUM_FREQUENCIES))); + ASSERT_TRUE(TestEnum(Allocator, INPUT_ELEMENT_FREQUENCY_UNDEFINED, INPUT_ELEMENT_FREQUENCY_NUM_FREQUENCIES)); } TEST(Tools_RenderStateNotationParser, ParseLayoutElement) @@ -45,8 +45,7 @@ TEST(Tools_RenderStateNotationParser, ParseLayoutElement) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/InputLayout/LayoutElement.json"); - LayoutElement DescReference = {}; - + LayoutElement DescReference{}; DescReference.InputIndex = 1; DescReference.BufferSlot = 1; DescReference.NumComponents = 3; @@ -58,7 +57,7 @@ TEST(Tools_RenderStateNotationParser, ParseLayoutElement) DescReference.Frequency = INPUT_ELEMENT_FREQUENCY_PER_INSTANCE; DescReference.HLSLSemantic = "TestSemantic0"; - LayoutElement Desc = {}; + LayoutElement Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -69,17 +68,17 @@ TEST(Tools_RenderStateNotationParser, ParseInputLayoutDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/InputLayout/InputLayoutDesc.json"); - LayoutElement LayoutElements[] = { + constexpr LayoutElement LayoutElements[] = { LayoutElement{0, 0, 3, VT_FLOAT32, False}, LayoutElement{1, 1, 4, VT_FLOAT32, False}, LayoutElement{2, 2, 3, VT_FLOAT16}, }; - InputLayoutDesc DescReference = {}; - DescReference.LayoutElements = LayoutElements; - DescReference.NumElements = _countof(LayoutElements); + InputLayoutDesc DescReference{}; + DescReference.LayoutElements = LayoutElements; + DescReference.NumElements = _countof(LayoutElements); - InputLayoutDesc Desc = {}; + InputLayoutDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineResourceSignatureParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineResourceSignatureParserTest.cpp index 1b157483..c03f3190 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineResourceSignatureParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineResourceSignatureParserTest.cpp @@ -36,7 +36,7 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceSignatureEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestBitwiseEnum(Allocator, PIPELINE_RESOURCE_FLAG_LAST))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, PIPELINE_RESOURCE_FLAG_LAST)); } TEST(Tools_RenderStateNotationParser, ParsePipelineResourceDesc) @@ -45,8 +45,7 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineResourceSignature/PipelineResourceDesc.json"); - PipelineResourceDesc DescReference = {}; - + PipelineResourceDesc DescReference{}; DescReference.Name = "TestName"; DescReference.ShaderStages = SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL; DescReference.VarType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC; @@ -54,7 +53,7 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceDesc) DescReference.ArraySize = 16; DescReference.Flags = PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY; - PipelineResourceDesc Desc = {}; + PipelineResourceDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -65,13 +64,12 @@ TEST(Tools_RenderStateNotationParser, ParseImmutableSamplerDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineResourceSignature/ImmutableSamplerDesc.json"); - ImmutableSamplerDesc DescReference = {}; - + ImmutableSamplerDesc DescReference{}; DescReference.ShaderStages = SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL; DescReference.SamplerOrTextureName = "TestName"; DescReference.Desc.Flags = SAMPLER_FLAG_SUBSAMPLED; - ImmutableSamplerDesc Desc = {}; + ImmutableSamplerDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -82,17 +80,16 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceSignatureDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineResourceSignature/PipelineResourceSignatureDesc.json"); - PipelineResourceDesc Resources[] = { + constexpr PipelineResourceDesc Resources[] = { PipelineResourceDesc{SHADER_TYPE_VERTEX, "TestName0", 1, SHADER_RESOURCE_TYPE_BUFFER_UAV}, PipelineResourceDesc{SHADER_TYPE_ALL_MESH, "TestName1", 2, SHADER_RESOURCE_TYPE_TEXTURE_SRV}, PipelineResourceDesc{SHADER_TYPE_ALL_GRAPHICS, "TestName2", 3, SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT}}; - ImmutableSamplerDesc Samplers[] = { + constexpr ImmutableSamplerDesc Samplers[] = { ImmutableSamplerDesc{SHADER_TYPE_ALL_RAY_TRACING, "TestName0", {}}, ImmutableSamplerDesc{SHADER_TYPE_PIXEL, "TestName1", {}}}; - PipelineResourceSignatureDesc DescReference = {}; - + PipelineResourceSignatureDesc DescReference{}; DescReference.Resources = Resources; DescReference.NumResources = _countof(Resources); DescReference.ImmutableSamplers = Samplers; @@ -102,7 +99,7 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceSignatureDesc) DescReference.CombinedSamplerSuffix = "_sampler_test"; DescReference.SRBAllocationGranularity = 16; - PipelineResourceSignatureDesc Desc = {}; + PipelineResourceSignatureDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineStateParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineStateParserTest.cpp index b0e732a1..5cd337d6 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineStateParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/PipelineStateParserTest.cpp @@ -36,15 +36,15 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineStateEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, PIPELINE_TYPE_GRAPHICS, PIPELINE_TYPE_LAST))); + ASSERT_TRUE(TestEnum(Allocator, PIPELINE_TYPE_GRAPHICS, PIPELINE_TYPE_LAST)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, SHADER_VARIABLE_FLAG_LAST))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, SHADER_VARIABLE_FLAG_LAST)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, PIPELINE_SHADING_RATE_FLAG_LAST))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, PIPELINE_SHADING_RATE_FLAG_LAST)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, SHADER_VARIABLE_FLAG_LAST))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, SHADER_VARIABLE_FLAG_LAST)); - ASSERT_TRUE((TestBitwiseEnum(Allocator, PSO_CREATE_FLAG_DONT_REMAP_SHADER_RESOURCES))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, PSO_CREATE_FLAG_LAST)); } TEST(Tools_RenderStateNotationParser, ParseSampleDesc) @@ -53,12 +53,11 @@ TEST(Tools_RenderStateNotationParser, ParseSampleDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/SampleDesc.json"); - SampleDesc DescReference = {}; - + SampleDesc DescReference{}; DescReference.Count = 4; DescReference.Quality = 1; - SampleDesc Desc = {}; + SampleDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -69,14 +68,13 @@ TEST(Tools_RenderStateNotationParser, ParseShaderResourceVariableDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/ShaderResourceVariableDesc.json"); - ShaderResourceVariableDesc DescReference = {}; - + ShaderResourceVariableDesc DescReference{}; DescReference.Name = "TestName"; DescReference.Type = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC; DescReference.ShaderStages = SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL; DescReference.Flags = SHADER_VARIABLE_FLAG_NO_DYNAMIC_BUFFERS | SHADER_VARIABLE_FLAG_GENERAL_INPUT_ATTACHMENT; - ShaderResourceVariableDesc Desc = {}; + ShaderResourceVariableDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -87,16 +85,15 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceLayoutDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/PipelineResourceLayoutDesc.json"); - ShaderResourceVariableDesc Variables[] = { + constexpr ShaderResourceVariableDesc Variables[] = { {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "TestName0", SHADER_RESOURCE_VARIABLE_TYPE_STATIC}, {SHADER_TYPE_VERTEX | SHADER_TYPE_PIXEL, "TestName1", SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}}; - ImmutableSamplerDesc Samplers[] = { + constexpr ImmutableSamplerDesc Samplers[] = { ImmutableSamplerDesc{SHADER_TYPE_ALL_RAY_TRACING, "TestName0", {FILTER_TYPE_POINT, FILTER_TYPE_MAXIMUM_POINT, FILTER_TYPE_ANISOTROPIC}}, ImmutableSamplerDesc{SHADER_TYPE_PIXEL, "TestName1", {FILTER_TYPE_COMPARISON_POINT, FILTER_TYPE_COMPARISON_LINEAR, FILTER_TYPE_COMPARISON_ANISOTROPIC}}}; - PipelineResourceLayoutDesc DescReference = {}; - + PipelineResourceLayoutDesc DescReference{}; DescReference.DefaultVariableMergeStages = SHADER_TYPE_ALL_GRAPHICS; DescReference.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE; DescReference.Variables = Variables; @@ -104,7 +101,7 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineResourceLayoutDesc) DescReference.ImmutableSamplers = Samplers; DescReference.NumImmutableSamplers = _countof(Samplers); - PipelineResourceLayoutDesc Desc = {}; + PipelineResourceLayoutDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -115,13 +112,12 @@ TEST(Tools_RenderStateNotationParser, ParseGraphicsPipelineDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/GraphicsPipelineDesc.json"); - LayoutElement InputLayoutElemets[] = { + constexpr LayoutElement InputLayoutElemets[] = { LayoutElement{0, 0, 3, VT_FLOAT32}, LayoutElement{1, 0, 4, VT_FLOAT32}}; - GraphicsPipelineDesc DescReference = {}; - - DescReference.SampleMask = 0; + GraphicsPipelineDesc DescReference{}; + DescReference.SampleMask = 1245678; DescReference.PrimitiveTopology = PRIMITIVE_TOPOLOGY_POINT_LIST; DescReference.NumViewports = 2; DescReference.SubpassIndex = 1; @@ -141,7 +137,7 @@ TEST(Tools_RenderStateNotationParser, ParseGraphicsPipelineDesc) DescReference.SmplDesc.Count = 4; DescReference.SmplDesc.Quality = 1; - GraphicsPipelineDesc Desc = {}; + GraphicsPipelineDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -152,12 +148,11 @@ TEST(Tools_RenderStateNotationParser, ParseRayTracingPipelineDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/RayTracingPipelineDesc.json"); - RayTracingPipelineDesc DescReference = {}; - + RayTracingPipelineDesc DescReference{}; DescReference.MaxRecursionDepth = 7; DescReference.ShaderRecordSize = 4096; - RayTracingPipelineDesc Desc = {}; + RayTracingPipelineDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -168,15 +163,14 @@ TEST(Tools_RenderStateNotationParser, ParsePipelineStateDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/PipelineStateDesc.json"); - PipelineStateDesc DescReference = {}; - + PipelineStateDesc DescReference{}; DescReference.PipelineType = PIPELINE_TYPE_COMPUTE; DescReference.Name = "TestName"; DescReference.SRBAllocationGranularity = 16; DescReference.ImmediateContextMask = 1; DescReference.ResourceLayout.DefaultVariableType = SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC; - PipelineStateDesc Desc = {}; + PipelineStateDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -187,14 +181,13 @@ TEST(Tools_RenderStateNotationParser, ParseTilePipelineDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/PipelineState/TilePipelineDesc.json"); - TilePipelineDesc DescReference = {}; - + TilePipelineDesc DescReference{}; DescReference.NumRenderTargets = 2; DescReference.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM; DescReference.RTVFormats[1] = TEX_FORMAT_RG16_FLOAT; DescReference.SampleCount = 4; - TilePipelineDesc Desc = {}; + TilePipelineDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/RasterizerStateParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/RasterizerStateParserTest.cpp index fb53307c..83ffadb0 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/RasterizerStateParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/RasterizerStateParserTest.cpp @@ -36,9 +36,9 @@ TEST(Tools_RenderStateNotationParser, ParseRasterizerStateEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, FILL_MODE_UNDEFINED, FILL_MODE_NUM_MODES))); + ASSERT_TRUE(TestEnum(Allocator, FILL_MODE_UNDEFINED, FILL_MODE_NUM_MODES)); - ASSERT_TRUE((TestEnum(Allocator, CULL_MODE_UNDEFINED, CULL_MODE_NUM_MODES))); + ASSERT_TRUE(TestEnum(Allocator, CULL_MODE_UNDEFINED, CULL_MODE_NUM_MODES)); } TEST(Tools_RenderStateNotationParser, ParseRasterizerStateDesc) @@ -47,8 +47,7 @@ TEST(Tools_RenderStateNotationParser, ParseRasterizerStateDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RasterizerState/RasterizerStateDesc.json"); - RasterizerStateDesc DescReference = {}; - + RasterizerStateDesc DescReference{}; DescReference.FillMode = FILL_MODE_WIREFRAME; DescReference.CullMode = CULL_MODE_FRONT; DescReference.FrontCounterClockwise = true; @@ -59,7 +58,7 @@ TEST(Tools_RenderStateNotationParser, ParseRasterizerStateDesc) DescReference.DepthBiasClamp = 0.25f; DescReference.SlopeScaledDepthBias = 0.75f; - RasterizerStateDesc Desc = {}; + RasterizerStateDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/RenderPassParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/RenderPassParserTest.cpp index 871191c5..e29dfd33 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/RenderPassParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/RenderPassParserTest.cpp @@ -36,9 +36,9 @@ TEST(Tools_RenderStateNotationParser, ParseRenderPassEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, ATTACHMENT_LOAD_OP_LOAD, ATTACHMENT_LOAD_OP_DISCARD))); + ASSERT_TRUE(TestEnum(Allocator, ATTACHMENT_LOAD_OP_LOAD, ATTACHMENT_LOAD_OP_DISCARD)); - ASSERT_TRUE((TestEnum(Allocator, ATTACHMENT_STORE_OP_STORE, ATTACHMENT_STORE_OP_DISCARD))); + ASSERT_TRUE(TestEnum(Allocator, ATTACHMENT_STORE_OP_STORE, ATTACHMENT_STORE_OP_DISCARD)); } TEST(Tools_RenderStateNotationParser, ParseRenderPassAttachmentDesc) @@ -47,8 +47,7 @@ TEST(Tools_RenderStateNotationParser, ParseRenderPassAttachmentDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RenderPass/RenderPassAttachmentDesc.json"); - RenderPassAttachmentDesc DescReference = {}; - + RenderPassAttachmentDesc DescReference{}; DescReference.Format = TEX_FORMAT_RGBA8_UNORM; DescReference.SampleCount = 4; DescReference.LoadOp = ATTACHMENT_LOAD_OP_CLEAR; @@ -58,7 +57,7 @@ TEST(Tools_RenderStateNotationParser, ParseRenderPassAttachmentDesc) DescReference.InitialState = RESOURCE_STATE_SHADER_RESOURCE; DescReference.FinalState = RESOURCE_STATE_RENDER_TARGET; - RenderPassAttachmentDesc Desc = {}; + RenderPassAttachmentDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -69,11 +68,11 @@ TEST(Tools_RenderStateNotationParser, ParseAttachmentReference) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RenderPass/AttachmentReference.json"); - AttachmentReference DescReference = {}; - DescReference.AttachmentIndex = 1; - DescReference.State = RESOURCE_STATE_RENDER_TARGET; + AttachmentReference DescReference{}; + DescReference.AttachmentIndex = 1; + DescReference.State = RESOURCE_STATE_RENDER_TARGET; - AttachmentReference Desc = {}; + AttachmentReference Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -84,14 +83,13 @@ TEST(Tools_RenderStateNotationParser, ParseShadingRateAttachment) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RenderPass/ShadingRateAttachment.json"); - ShadingRateAttachment DescReference = {}; - + ShadingRateAttachment DescReference{}; DescReference.Attachment.AttachmentIndex = 0; DescReference.Attachment.State = RESOURCE_STATE_SHADING_RATE; DescReference.TileSize[0] = 8; DescReference.TileSize[1] = 16; - ShadingRateAttachment Desc = {}; + ShadingRateAttachment Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -102,26 +100,25 @@ TEST(Tools_RenderStateNotationParser, ParseSubpassDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RenderPass/SubpassDesc.json"); - AttachmentReference InputAttachments[] = { + constexpr AttachmentReference InputAttachments[] = { {0, RESOURCE_STATE_INPUT_ATTACHMENT}, {1, RESOURCE_STATE_INPUT_ATTACHMENT}}; - AttachmentReference RenderTargetAttachments[] = { + constexpr AttachmentReference RenderTargetAttachments[] = { {2, RESOURCE_STATE_RENDER_TARGET}}; - AttachmentReference DepthTargetAttachment[] = { + constexpr AttachmentReference DepthTargetAttachment[] = { {2, RESOURCE_STATE_DEPTH_WRITE}}; - AttachmentReference ResolveAttachments[] = { + constexpr AttachmentReference ResolveAttachments[] = { {2, RESOURCE_STATE_RESOLVE_SOURCE}}; - ShadingRateAttachment ShadingRateAttachment[] = { + constexpr ShadingRateAttachment ShadingRateAttachment[] = { {{3, RESOURCE_STATE_SHADING_RATE}, 4, 8}}; - Uint32 PreserveAttachments[] = {2, 4}; - - SubpassDesc DescReference = {}; + constexpr Uint32 PreserveAttachments[] = {2, 4}; + SubpassDesc DescReference{}; DescReference.InputAttachmentCount = _countof(InputAttachments); DescReference.pInputAttachments = InputAttachments; DescReference.RenderTargetAttachmentCount = _countof(RenderTargetAttachments); @@ -132,7 +129,7 @@ TEST(Tools_RenderStateNotationParser, ParseSubpassDesc) DescReference.pPreserveAttachments = PreserveAttachments; DescReference.pShadingRateAttachment = ShadingRateAttachment; - SubpassDesc Desc = {}; + SubpassDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -143,8 +140,7 @@ TEST(Tools_RenderStateNotationParser, ParseSubpassDependencyDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RenderPass/SubpassDependencyDesc.json"); - SubpassDependencyDesc DescReference = {}; - + SubpassDependencyDesc DescReference{}; DescReference.SrcSubpass = 0; DescReference.DstSubpass = 1; DescReference.SrcAccessMask = ACCESS_FLAG_MEMORY_READ | ACCESS_FLAG_MEMORY_WRITE; @@ -152,7 +148,7 @@ TEST(Tools_RenderStateNotationParser, ParseSubpassDependencyDesc) DescReference.DstAccessMask = ACCESS_FLAG_MEMORY_READ; DescReference.DstStageMask = PIPELINE_STAGE_FLAG_EARLY_FRAGMENT_TESTS | PIPELINE_STAGE_FLAG_PIXEL_SHADER; - SubpassDependencyDesc Desc = {}; + SubpassDependencyDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -163,31 +159,30 @@ TEST(Tools_RenderStateNotationParser, ParseRenderPassDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/RenderPass/RenderPassDesc.json"); - RenderPassAttachmentDesc Attachments[4] = {}; - + RenderPassAttachmentDesc Attachments[4]{}; Attachments[0].Format = TEX_FORMAT_RGBA8_UNORM; Attachments[1].Format = TEX_FORMAT_R32_FLOAT; Attachments[2].Format = TEX_FORMAT_D32_FLOAT; Attachments[3].Format = TEX_FORMAT_RGBA8_UNORM; - AttachmentReference RTAttachmentRefs0[] = { + constexpr AttachmentReference RTAttachmentRefs0[] = { {0, RESOURCE_STATE_RENDER_TARGET}, {1, RESOURCE_STATE_RENDER_TARGET}}; - AttachmentReference DepthAttachmentRef0[] = { + constexpr AttachmentReference DepthAttachmentRef0[] = { {2, RESOURCE_STATE_DEPTH_WRITE}}; - AttachmentReference RTAttachmentRefs1[] = { + constexpr AttachmentReference RTAttachmentRefs1[] = { {3, RESOURCE_STATE_RENDER_TARGET}}; - AttachmentReference DepthAttachmentRef1[] = { + constexpr AttachmentReference DepthAttachmentRef1[] = { {2, RESOURCE_STATE_DEPTH_WRITE}}; - AttachmentReference InputAttachmentRefs1[] = { + constexpr AttachmentReference InputAttachmentRefs1[] = { {0, RESOURCE_STATE_INPUT_ATTACHMENT}, {1, RESOURCE_STATE_INPUT_ATTACHMENT}}; - SubpassDesc Subpasses[2] = {}; + SubpassDesc Subpasses[2]{}; Subpasses[0].RenderTargetAttachmentCount = _countof(RTAttachmentRefs0); Subpasses[0].pRenderTargetAttachments = RTAttachmentRefs0; @@ -199,12 +194,11 @@ TEST(Tools_RenderStateNotationParser, ParseRenderPassDesc) Subpasses[1].InputAttachmentCount = _countof(InputAttachmentRefs1); Subpasses[1].pInputAttachments = InputAttachmentRefs1; - SubpassDependencyDesc Dependencies[1] = {}; - Dependencies[0].SrcSubpass = 0; - Dependencies[0].DstSubpass = 1; - - RenderPassDesc DescReference = {}; + SubpassDependencyDesc Dependencies[1]{}; + Dependencies[0].SrcSubpass = 0; + Dependencies[0].DstSubpass = 1; + RenderPassDesc DescReference{}; DescReference.Name = "TestName"; DescReference.AttachmentCount = _countof(Attachments); DescReference.pAttachments = Attachments; @@ -213,7 +207,7 @@ TEST(Tools_RenderStateNotationParser, ParseRenderPassDesc) DescReference.DependencyCount = _countof(Dependencies); DescReference.pDependencies = Dependencies; - RenderPassDesc Desc = {}; + RenderPassDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/SamplerParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/SamplerParserTest.cpp index 3a060d08..68075250 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/SamplerParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/SamplerParserTest.cpp @@ -36,7 +36,7 @@ TEST(Tools_RenderStateNotationParser, ParseSamplerEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestBitwiseEnum(Allocator, SAMPLER_FLAG_SUBSAMPLED_COARSE_RECONSTRUCTION))); + ASSERT_TRUE(TestBitwiseEnum(Allocator, SAMPLER_FLAG_LAST)); } TEST(Tools_RenderStateNotationParser, ParseSamplerDesc) @@ -45,7 +45,7 @@ TEST(Tools_RenderStateNotationParser, ParseSamplerDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/Sampler/SamplerDesc.json"); - SamplerDesc DescReference = {}; + SamplerDesc DescReference{}; DescReference.Name = "TestName"; DescReference.MinFilter = FILTER_TYPE_ANISOTROPIC; @@ -69,7 +69,7 @@ TEST(Tools_RenderStateNotationParser, ParseSamplerDesc) DescReference.MaxLOD = 4.0f; DescReference.MaxAnisotropy = 16; - SamplerDesc Desc = {}; + SamplerDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } diff --git a/Tests/DiligentToolsTest/src/RenderStateNotationParser/ShaderParserTest.cpp b/Tests/DiligentToolsTest/src/RenderStateNotationParser/ShaderParserTest.cpp index 23f19efe..8e7f2945 100644 --- a/Tests/DiligentToolsTest/src/RenderStateNotationParser/ShaderParserTest.cpp +++ b/Tests/DiligentToolsTest/src/RenderStateNotationParser/ShaderParserTest.cpp @@ -36,11 +36,11 @@ TEST(Tools_RenderStateNotationParser, ParseShaderEnums) { DynamicLinearAllocator Allocator{DefaultRawMemoryAllocator::GetAllocator()}; - ASSERT_TRUE((TestEnum(Allocator, SHADER_SOURCE_LANGUAGE_DEFAULT, SHADER_SOURCE_LANGUAGE_GLSL_VERBATIM))); + ASSERT_TRUE(TestEnum(Allocator, SHADER_SOURCE_LANGUAGE_DEFAULT, SHADER_SOURCE_LANGUAGE_GLSL_VERBATIM)); - ASSERT_TRUE((TestEnum(Allocator, SHADER_COMPILER_DEFAULT, SHADER_COMPILER_LAST))); + ASSERT_TRUE(TestEnum(Allocator, SHADER_COMPILER_DEFAULT, SHADER_COMPILER_LAST)); - ASSERT_TRUE((TestEnum(Allocator, SHADER_RESOURCE_TYPE_UNKNOWN, SHADER_RESOURCE_TYPE_LAST))); + ASSERT_TRUE(TestEnum(Allocator, SHADER_RESOURCE_TYPE_UNKNOWN, SHADER_RESOURCE_TYPE_LAST)); } TEST(Tools_RenderStateNotationParser, ParseShaderDesc) @@ -49,12 +49,11 @@ TEST(Tools_RenderStateNotationParser, ParseShaderDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/Shader/ShaderDesc.json"); - ShaderDesc DescReference = {}; - + ShaderDesc DescReference{}; DescReference.Name = "TestName"; DescReference.ShaderType = SHADER_TYPE_VERTEX; - ShaderDesc Desc = {}; + ShaderDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_EQ(Desc, DescReference); } @@ -65,12 +64,11 @@ TEST(Tools_RenderStateNotationParser, ParseShaderMacro) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/Shader/ShaderMacro.json"); - ShaderMacro DescReference = {}; - + ShaderMacro DescReference{}; DescReference.Name = "TestName"; DescReference.Definition = "TestDefinition"; - ShaderMacro Desc = {}; + ShaderMacro Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_TRUE(SafeStrEqual(Desc.Name, DescReference.Name)); ASSERT_TRUE(SafeStrEqual(Desc.Definition, DescReference.Definition)); @@ -82,13 +80,12 @@ TEST(Tools_RenderStateNotationParser, ParseShaderResourceDesc) nlohmann::json JsonReference = LoadDRSNFromFile("RenderStates/Shader/ShaderResourceDesc.json"); - ShaderResourceDesc DescReference = {}; - + ShaderResourceDesc DescReference{}; DescReference.Name = "TestName"; DescReference.Type = SHADER_RESOURCE_TYPE_BUFFER_UAV; DescReference.ArraySize = 2; - ShaderResourceDesc Desc = {}; + ShaderResourceDesc Desc{}; Deserialize(JsonReference, Desc, Allocator); ASSERT_TRUE(SafeStrEqual(Desc.Name, DescReference.Name)); ASSERT_EQ(Desc.Type, DescReference.Type);