Merge two calls to InitializeHLSL into one

BUG=dawn:290

Change-Id: I6dca2120278be998ef342a24ac027c1aa60d3a78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14221
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
Ryan Harrison 2019-12-04 21:54:00 +00:00 committed by Commit Bot service account
parent 42b3b9c413
commit 7ecb9268df
1 changed files with 10 additions and 12 deletions

View File

@ -42,6 +42,16 @@ namespace dawn_native { namespace d3d12 {
mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
shaderc_spvc::CompileOptions options;
options.SetHLSLShaderModel(51);
// PointCoord and PointSize are not supported in HLSL
// TODO (hao.x.li@intel.com): The point_coord_compat and point_size_compat are
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
// but should be removed once WebGPU requires there is no gl_PointSize builtin.
// See https://github.com/gpuweb/gpuweb/issues/332
options.SetHLSLPointCoordCompat(true);
options.SetHLSLPointSizeCompat(true);
shaderc_spvc_status status =
mSpvcContext.InitializeForHlsl(descriptor->code, descriptor->codeSize, options);
if (status != shaderc_spvc_status_success) {
@ -62,18 +72,6 @@ namespace dawn_native { namespace d3d12 {
std::unique_ptr<spirv_cross::CompilerHLSL> compiler_impl;
spirv_cross::CompilerHLSL* compiler;
if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
shaderc_spvc::CompileOptions options;
options.SetHLSLShaderModel(51);
// PointCoord and PointSize are not supported in HLSL
// TODO (hao.x.li@intel.com): The point_coord_compat and point_size_compat are
// required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,
// but should be removed once WebGPU requires there is no gl_PointSize builtin.
// See https://github.com/gpuweb/gpuweb/issues/332
options.SetHLSLPointCoordCompat(true);
options.SetHLSLPointSizeCompat(true);
mSpvcContext.InitializeForHlsl(mSpirv.data(), mSpirv.size(), options);
compiler = reinterpret_cast<spirv_cross::CompilerHLSL*>(mSpvcContext.GetCompiler());
// TODO(rharrison): Check status & have some sort of meaningful error path
} else {