Fix some code formatting problems

This commit is contained in:
Minmin Gong 2018-11-17 15:03:08 -08:00
Родитель 514764fc70
Коммит c73face89b
4 изменённых файлов: 25 добавлений и 7 удалений

Просмотреть файл

@ -8,6 +8,7 @@ ColumnLimit: 140
Cpp11BracedListStyle: false
IndentWidth: 4
Language: Cpp
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PointerAlignment: Left
SpaceBeforeParens: ControlStatements

Просмотреть файл

@ -186,7 +186,7 @@ namespace
return E_FAIL;
}
std::string source = m_loadCallback(utf8FileName);
const std::string source = m_loadCallback(utf8FileName);
if (source.empty())
{
return E_FAIL;
@ -342,11 +342,13 @@ namespace
std::wstring entryPointUtf16;
Unicode::UTF8ToUTF16String(source.entryPoint.c_str(), &entryPointUtf16);
// clang-format off
std::vector<std::wstring> dxcArgStrings =
{
L"-T", shaderProfile,
L"-E", entryPointUtf16,
};
// clang-format on
switch (targetLanguage)
{
@ -374,10 +376,9 @@ namespace
CComPtr<IDxcIncludeHandler> includeHandler = new ScIncludeHandler(std::move(source.loadIncludeCallback));
CComPtr<IDxcOperationResult> compileResult;
IFT(Dxcompiler::Instance().Compiler()->Compile(sourceBlob, shaderNameUtf16.c_str(), entryPointUtf16.c_str(),
shaderProfile.c_str(), dxcArgs.data(), static_cast<UINT32>(dxcArgs.size()),
dxcDefines.data(), static_cast<UINT32>(dxcDefines.size()), includeHandler,
&compileResult));
IFT(Dxcompiler::Instance().Compiler()->Compile(sourceBlob, shaderNameUtf16.c_str(), entryPointUtf16.c_str(), shaderProfile.c_str(),
dxcArgs.data(), static_cast<UINT32>(dxcArgs.size()), dxcDefines.data(),
static_cast<UINT32>(dxcDefines.size()), includeHandler, &compileResult));
HRESULT status;
IFT(compileResult->GetStatus(&status));
@ -413,7 +414,7 @@ namespace
}
Compiler::ResultDesc ConvertBinary(const Compiler::ResultDesc& binaryResult, const Compiler::SourceDesc& source,
const Compiler::TargetDesc& target)
const Compiler::TargetDesc& target)
{
assert((target.language != ShadingLanguage::Dxil) && (target.language != ShadingLanguage::SpirV));
assert((binaryResult.target.size() & (sizeof(uint32_t) - 1)) == 0);

Просмотреть файл

@ -70,7 +70,7 @@ namespace
{
static const std::string extMap[] = { "dxil", "spv", "hlsl", "glsl", "essl", "msl" };
static_assert(sizeof(extMap) / sizeof(extMap[0]) == static_cast<uint32_t>(ShadingLanguage::NumShadingLanguages),
"extMap doesn't match with the number of shading languages.");
"extMap doesn't match with the number of shading languages.");
const auto result = Compiler::Compile(source, target);
@ -152,6 +152,7 @@ namespace
protected:
std::vector<std::tuple<std::string, Compiler::SourceDesc, std::vector<std::tuple<bool, Compiler::TargetDesc>>>> m_combinations;
// clang-format off
const std::vector<std::tuple<bool, Compiler::TargetDesc>> m_allTestTargets =
{
{ true, { ShadingLanguage::Hlsl, "30" } },
@ -166,6 +167,7 @@ namespace
{ true, { ShadingLanguage::Msl } },
};
// clang-format on
};
class VertexShaderTest : public TestBase
@ -173,6 +175,7 @@ namespace
public:
void SetUp() override
{
// clang-format off
m_combinations =
{
{
@ -191,6 +194,7 @@ namespace
m_allTestTargets,
},
};
// clang-format on
TestBase::SetUp();
}
@ -201,6 +205,7 @@ namespace
public:
void SetUp() override
{
// clang-format off
m_combinations =
{
{
@ -219,6 +224,7 @@ namespace
m_allTestTargets,
},
};
// clang-format on
TestBase::SetUp();
}
@ -229,6 +235,7 @@ namespace
public:
void SetUp() override
{
// clang-format off
m_combinations =
{
{
@ -249,6 +256,7 @@ namespace
},
},
};
// clang-format on
TestBase::SetUp();
}
@ -259,6 +267,7 @@ namespace
public:
void SetUp() override
{
// clang-format off
m_combinations =
{
{
@ -279,6 +288,7 @@ namespace
},
},
};
// clang-format on
TestBase::SetUp();
}
@ -289,6 +299,7 @@ namespace
public:
void SetUp() override
{
// clang-format off
m_combinations =
{
{
@ -309,6 +320,7 @@ namespace
},
},
};
// clang-format on
TestBase::SetUp();
}
@ -319,6 +331,7 @@ namespace
public:
void SetUp() override
{
// clang-format off
m_combinations =
{
{
@ -339,6 +352,7 @@ namespace
},
},
};
// clang-format on
TestBase::SetUp();
}

Просмотреть файл

@ -42,12 +42,14 @@
int main(int argc, char** argv)
{
cxxopts::Options options("ShaderConductorCmd", "A tool for compiling HLSL to many shader languages.");
// clang-format off
options.add_options()
("E,entry", "Entry point of the shader", cxxopts::value<std::string>()->default_value("main"))
("I,input", "Input file name", cxxopts::value<std::string>())("O,output", "Output file name", cxxopts::value<std::string>())
("S,stage", "Shader stage: vs, ps, gs, hs, ds, cs", cxxopts::value<std::string>())
("T,target", "Target shading language: dxil, spirv, hlsl, glsl, essl, msl", cxxopts::value<std::string>()->default_value("dxil"))
("V,version", "The version of target shading language", cxxopts::value<std::string>()->default_value(""));
// clang-format on
auto opts = options.parse(argc, argv);