tint: Fix dxc on Linux
Fixes "dxc failed : unable to parse shader model.". On windows the called program is responsible for splitting arguments from one joined string. Command line arguments on 'nix systems need to be passed as separate strings. This CL makes it so that we pass in the arg separately, and support ignoring empty string args to make writing this code easier. Change-Id: Ia9618c2a743f8fdb49913572e2bbfc4bd1519d3a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98110 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
50940aeef1
commit
50bddbffca
|
@ -251,7 +251,9 @@ Command::Output Command::Exec(std::initializer_list<std::string> arguments) cons
|
||||||
std::vector<const char*> args;
|
std::vector<const char*> args;
|
||||||
args.emplace_back(path_.c_str());
|
args.emplace_back(path_.c_str());
|
||||||
for (auto& arg : arguments) {
|
for (auto& arg : arguments) {
|
||||||
args.emplace_back(arg.c_str());
|
if (!arg.empty()) {
|
||||||
|
args.emplace_back(arg.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
args.emplace_back(nullptr);
|
args.emplace_back(nullptr);
|
||||||
auto res = execv(path_.c_str(), const_cast<char* const*>(args.data()));
|
auto res = execv(path_.c_str(), const_cast<char* const*>(args.data()));
|
||||||
|
|
|
@ -200,7 +200,9 @@ Command::Output Command::Exec(std::initializer_list<std::string> arguments) cons
|
||||||
std::stringstream args;
|
std::stringstream args;
|
||||||
args << path_;
|
args << path_;
|
||||||
for (auto& arg : arguments) {
|
for (auto& arg : arguments) {
|
||||||
args << " " << arg;
|
if (!arg.empty()) {
|
||||||
|
args << " " << arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS_INFORMATION pi{};
|
PROCESS_INFORMATION pi{};
|
||||||
|
|
|
@ -69,21 +69,16 @@ Result HlslUsingDXC(const std::string& dxc_path,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string profile =
|
|
||||||
"-T " + std::string(stage_prefix) + "_" + std::string(shader_model_version);
|
|
||||||
if (require_16bit_types) {
|
|
||||||
// Add "-enable-16bit-types" flag if required
|
|
||||||
profile = profile + " -enable-16bit-types";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Match Dawn's compile flags
|
// Match Dawn's compile flags
|
||||||
// See dawn\src\dawn_native\d3d12\RenderPipelineD3D12.cpp
|
// See dawn\src\dawn_native\d3d12\RenderPipelineD3D12.cpp
|
||||||
// and dawn_native\d3d12\ShaderModuleD3D12.cpp (GetDXCArguments)
|
// and dawn_native\d3d12\ShaderModuleD3D12.cpp (GetDXCArguments)
|
||||||
auto res = dxc(profile.c_str(),
|
auto res = dxc(
|
||||||
"-E " + ep.first, // Entry point
|
"-T " + std::string(stage_prefix) + "_" + std::string(shader_model_version), // Profile
|
||||||
"/Zpr", // D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
|
"-E " + ep.first, // Entry point
|
||||||
"/Gis", // D3DCOMPILE_IEEE_STRICTNESS
|
"/Zpr", // D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
|
||||||
file.Path());
|
"/Gis", // D3DCOMPILE_IEEE_STRICTNESS
|
||||||
|
require_16bit_types ? "-enable-16bit-types" : "", // Enable 16-bit if required
|
||||||
|
file.Path());
|
||||||
if (!res.out.empty()) {
|
if (!res.out.empty()) {
|
||||||
if (!result.output.empty()) {
|
if (!result.output.empty()) {
|
||||||
result.output += "\n";
|
result.output += "\n";
|
||||||
|
|
Loading…
Reference in New Issue