diff --git a/.clang-format b/.clang-format index 34a7ab9..6a5432a 100644 --- a/.clang-format +++ b/.clang-format @@ -5,7 +5,7 @@ AllowShortLoopsOnASingleLine: false AlwaysBreakTemplateDeclarations: true BreakBeforeBraces: Allman ColumnLimit: 140 -Cpp11BracedListStyle: false +Cpp11BracedListStyle: true IndentWidth: 4 Language: Cpp MaxEmptyLinesToKeep: 2 diff --git a/Include/ShaderConductor/ShaderConductor.hpp b/Include/ShaderConductor/ShaderConductor.hpp index c91b962..e6cf1f6 100644 --- a/Include/ShaderConductor/ShaderConductor.hpp +++ b/Include/ShaderConductor/ShaderConductor.hpp @@ -152,7 +152,7 @@ namespace ShaderConductor bool disableOptimizations = false; // Force to turn off optimizations. Ignore optimizationLevel below. int optimizationLevel = 3; // 0 to 3, no optimization to most optimization - ShaderModel shaderModel = { 6, 0 }; + ShaderModel shaderModel = {6, 0}; int shiftAllTexturesBindings; int shiftAllSamplersBindings; diff --git a/Source/Core/ShaderConductor.cpp b/Source/Core/ShaderConductor.cpp index 130787e..247547a 100644 --- a/Source/Core/ShaderConductor.cpp +++ b/Source/Core/ShaderConductor.cpp @@ -444,7 +444,7 @@ namespace valueUtf16 = nullptr; } - dxcDefines.push_back({ nameUtf16, valueUtf16 }); + dxcDefines.push_back({nameUtf16, valueUtf16}); } CComPtr sourceBlob; @@ -473,7 +473,7 @@ namespace if (options.enable16bitTypes) { - if (options.shaderModel >= Compiler::ShaderModel{ 6, 2 }) + if (options.shaderModel >= Compiler::ShaderModel{6, 2}) { dxcArgStrings.push_back(L"-enable-16bit-types"); } diff --git a/Source/Tests/ShaderConductorTest.cpp b/Source/Tests/ShaderConductorTest.cpp index 7da42d5..1f5b5ae 100644 --- a/Source/Tests/ShaderConductorTest.cpp +++ b/Source/Tests/ShaderConductorTest.cpp @@ -80,7 +80,7 @@ namespace void HlslToAnyTest(const std::string& name, const Compiler::SourceDesc& source, const Compiler::Options& options, const std::vector& targets, const std::vector& expectSuccessFlags) { - static const std::string extMap[] = { "dxil", "spv", "hlsl", "glsl", "essl", "msl", "msl" }; + static const std::string extMap[] = {"dxil", "spv", "hlsl", "glsl", "essl", "msl", "msl"}; static_assert(sizeof(extMap) / sizeof(extMap[0]) == static_cast(ShadingLanguage::NumShadingLanguages), "extMap doesn't match with the number of shading languages."); @@ -121,14 +121,14 @@ namespace std::vector input = LoadFile(inputFileName, true); const std::string source = std::string(reinterpret_cast(input.data()), input.size()); - const auto result = Compiler::Compile({ source.c_str(), inputFileName.c_str(), "", ShaderStage::PixelShader }, {}, target); + const auto result = Compiler::Compile({source.c_str(), inputFileName.c_str(), "", ShaderStage::PixelShader}, {}, target); EXPECT_FALSE(result.hasError); EXPECT_FALSE(result.isText); DestroyBlob(result.errorWarningMsg); - return { moduleName, result.target }; + return {moduleName, result.target}; } class TestBase : public testing::Test @@ -290,7 +290,7 @@ namespace } private: - std::vector defines_ = { { "FIXED_VERTEX_RADIUS", "5.0" } }; + std::vector defines_ = {{"FIXED_VERTEX_RADIUS", "5.0"}}; }; class HullShaderTest : public TestBase @@ -389,8 +389,8 @@ namespace Compiler::Options options; options.packMatricesInRowMajor = false; - HlslToAnyTest("Transform_VS_ColumnMajor", { source.c_str(), fileName.c_str(), nullptr, ShaderStage::VertexShader }, options, - { { ShadingLanguage::Glsl, "300" } }, { true }); + HlslToAnyTest("Transform_VS_ColumnMajor", {source.c_str(), fileName.c_str(), nullptr, ShaderStage::VertexShader}, options, + {{ShadingLanguage::Glsl, "300"}}, {true}); } TEST_F(VertexShaderTest, ToEssl) @@ -516,7 +516,7 @@ namespace const std::string source = std::string(reinterpret_cast(input.data()), input.size()); const auto result = - Compiler::Compile({ source.c_str(), fileName.c_str(), "main", ShaderStage::PixelShader }, {}, { ShadingLanguage::Glsl, "30" }); + Compiler::Compile({source.c_str(), fileName.c_str(), "main", ShaderStage::PixelShader}, {}, {ShadingLanguage::Glsl, "30"}); EXPECT_FALSE(result.hasError); EXPECT_EQ(result.errorWarningMsg, nullptr); @@ -537,7 +537,7 @@ namespace const std::string source = std::string(reinterpret_cast(input.data()), input.size()); const auto result = - Compiler::Compile({ source.c_str(), fileName.c_str(), "main", ShaderStage::PixelShader }, {}, { ShadingLanguage::Glsl, "30" }); + Compiler::Compile({source.c_str(), fileName.c_str(), "main", ShaderStage::PixelShader}, {}, {ShadingLanguage::Glsl, "30"}); EXPECT_TRUE(result.hasError); const char* errorStr = reinterpret_cast(result.errorWarningMsg->Data()); @@ -555,7 +555,7 @@ namespace const std::string source = std::string(reinterpret_cast(input.data()), input.size()); const auto result = - Compiler::Compile({ source.c_str(), fileName.c_str(), "main", ShaderStage::PixelShader }, {}, { ShadingLanguage::Glsl, "30" }); + Compiler::Compile({source.c_str(), fileName.c_str(), "main", ShaderStage::PixelShader}, {}, {ShadingLanguage::Glsl, "30"}); EXPECT_FALSE(result.hasError); EXPECT_EQ(result.errorWarningMsg, nullptr); @@ -576,11 +576,11 @@ namespace const std::string source = std::string(reinterpret_cast(input.data()), input.size()); Compiler::Options option; - option.shaderModel = { 6, 2 }; + option.shaderModel = {6, 2}; option.enable16bitTypes = true; - const auto result = Compiler::Compile({ source.c_str(), fileName.c_str(), "DotHalfPS", ShaderStage::PixelShader }, option, - { ShadingLanguage::Glsl, "30" }); + const auto result = Compiler::Compile({source.c_str(), fileName.c_str(), "DotHalfPS", ShaderStage::PixelShader}, option, + {ShadingLanguage::Glsl, "30"}); EXPECT_FALSE(result.hasError); EXPECT_TRUE(result.isText); @@ -600,11 +600,11 @@ namespace const std::string source = std::string(reinterpret_cast(input.data()), input.size()); Compiler::Options option; - option.shaderModel = { 6, 2 }; + option.shaderModel = {6, 2}; option.enable16bitTypes = true; - const auto result = Compiler::Compile({ source.c_str(), fileName.c_str(), "HalfOutParamPS", ShaderStage::PixelShader }, option, - { ShadingLanguage::Glsl, "30" }); + const auto result = Compiler::Compile({source.c_str(), fileName.c_str(), "HalfOutParamPS", ShaderStage::PixelShader}, option, + {ShadingLanguage::Glsl, "30"}); EXPECT_FALSE(result.hasError); EXPECT_TRUE(result.isText); @@ -623,7 +623,7 @@ namespace GTEST_SKIP_("Link is not supported on this platform"); } - const Compiler::TargetDesc target = { ShadingLanguage::Dxil, "", true }; + const Compiler::TargetDesc target = {ShadingLanguage::Dxil, "", true}; const Compiler::ModuleDesc dxilModules[] = { CompileToModule("CalcLight", TEST_DATA_DIR "Input/CalcLight.hlsl", target), CompileToModule("CalcLightDiffuse", TEST_DATA_DIR "Input/CalcLightDiffuse.hlsl", target), @@ -631,21 +631,21 @@ namespace }; const Compiler::ModuleDesc* testModules[][2] = { - { &dxilModules[0], &dxilModules[1] }, - { &dxilModules[0], &dxilModules[2] }, + {&dxilModules[0], &dxilModules[1]}, + {&dxilModules[0], &dxilModules[2]}, }; #ifdef NDEBUG - const std::string expectedNames[] = { "CalcLight+Diffuse.Release.dxilasm", "CalcLight+DiffuseSpecular.Release.dxilasm" }; + const std::string expectedNames[] = {"CalcLight+Diffuse.Release.dxilasm", "CalcLight+DiffuseSpecular.Release.dxilasm"}; #else - const std::string expectedNames[] = { "CalcLight+Diffuse.Debug.dxilasm", "CalcLight+DiffuseSpecular.Debug.dxilasm" }; + const std::string expectedNames[] = {"CalcLight+Diffuse.Debug.dxilasm", "CalcLight+DiffuseSpecular.Debug.dxilasm"}; #endif for (size_t i = 0; i < 2; ++i) { const auto linkedResult = - Compiler::Link({ "main", ShaderStage::PixelShader, testModules[i], sizeof(testModules[i]) / sizeof(testModules[i][0]) }, {}, - { ShadingLanguage::Dxil, "" }); + Compiler::Link({"main", ShaderStage::PixelShader, testModules[i], sizeof(testModules[i]) / sizeof(testModules[i][0])}, {}, + {ShadingLanguage::Dxil, ""}); EXPECT_FALSE(linkedResult.hasError); EXPECT_FALSE(linkedResult.isText); diff --git a/Source/Tools/ShaderConductorCmd.cpp b/Source/Tools/ShaderConductorCmd.cpp index c0c3cd1..37f5df9 100644 --- a/Source/Tools/ShaderConductorCmd.cpp +++ b/Source/Tools/ShaderConductorCmd.cpp @@ -145,7 +145,7 @@ int main(int argc, char** argv) std::string outputName; if (opts.count("output") == 0) { - static const std::string extMap[] = { "dxil", "spv", "hlsl", "glsl", "essl", "msl", "msl" }; + static const std::string extMap[] = {"dxil", "spv", "hlsl", "glsl", "essl", "msl", "msl"}; static_assert(sizeof(extMap) / sizeof(extMap[0]) == static_cast(ShadingLanguage::NumShadingLanguages), "extMap doesn't match with the number of shading languages."); outputName = fileName + "." + extMap[static_cast(targetDesc.language)]; diff --git a/Source/Wrapper/Native.cpp b/Source/Wrapper/Native.cpp index 5eb5484..6f9390b 100644 --- a/Source/Wrapper/Native.cpp +++ b/Source/Wrapper/Native.cpp @@ -45,7 +45,7 @@ void Compile(SourceDescription* source, OptionsDescription* optionsDesc, TargetD options.enableDebugInfo = optionsDesc->enableDebugInfo; options.disableOptimizations = optionsDesc->disableOptimizations; options.optimizationLevel = optionsDesc->optimizationLevel; - options.shaderModel = { static_cast(optionsDesc->shaderModel.major), static_cast(optionsDesc->shaderModel.minor) }; + options.shaderModel = {static_cast(optionsDesc->shaderModel.major), static_cast(optionsDesc->shaderModel.minor)}; options.shiftAllTexturesBindings = optionsDesc->shiftAllTexturesBindings; options.shiftAllSamplersBindings = optionsDesc->shiftAllSamplersBindings; options.shiftAllCBuffersBindings = optionsDesc->shiftAllCBuffersBindings; diff --git a/Source/Wrapper/Native.h b/Source/Wrapper/Native.h index 5851bf3..db0734c 100644 --- a/Source/Wrapper/Native.h +++ b/Source/Wrapper/Native.h @@ -52,7 +52,7 @@ struct OptionsDescription bool disableOptimizations = false; // Force to turn off optimizations. Ignore optimizationLevel below. int optimizationLevel = 3; // 0 to 3, no optimization to most optimization - ShaderModel shaderModel = { 6, 0 }; + ShaderModel shaderModel = {6, 0}; int shiftAllTexturesBindings; int shiftAllSamplersBindings;