message: Use correct Initialize call to spvc for Metal backend
diff: @@ -38,6 +38,25 @@ namespace dawn_native { namespace metal {
  UNREACHABLE();
  }
  }
  +
  + shaderc_spvc::CompileOptions GetMSLCompileOptions() {
  + // If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
  + // be updated.
  + shaderc_spvc::CompileOptions options;
  +
  + // Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
  + // Because Metal will reject PointSize builtin if the shader is compiled into a render
  + // pipeline that uses a non-point topology.
  + // TODO (hao.x.li@intel.com): Remove this once WebGPU requires there is no
  + // gl_PointSize builtin (https://github.com/gpuweb/gpuweb/issues/332).
  + options.SetMSLEnablePointSizeBuiltIn(false);
  +
  + // Always use vertex buffer 30 (the last one in the vertex buffer table) to contain
  + // the shader storage buffer lengths.
  + options.SetMSLBufferSizeBufferIndex(kBufferLengthBufferSlot);
  +
  + return options;
  + }
  } // namespace
  // static
  @@ -57,9 +76,8 @@ namespace dawn_native { namespace metal {
  MaybeError ShaderModule::Initialize(const ShaderModuleDescriptor* descriptor) {
  mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
  if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
  - shaderc_spvc::CompileOptions options;
  - shaderc_spvc_status status =
  - mSpvcContext.InitializeForGlsl(descriptor->code, descriptor->codeSize, options);
  + shaderc_spvc_status status = mSpvcContext.InitializeForMsl(
  + descriptor->code, descriptor->codeSize, GetMSLCompileOptions());
  if (status != shaderc_spvc_status_success) {
  return DAWN_VALIDATION_ERROR("Unable to initialize instance of spvc");
  }
  @@ -80,21 +98,9 @@ namespace dawn_native { namespace metal {
  std::unique_ptr<spirv_cross::CompilerMSL> compiler_impl;
  spirv_cross::CompilerMSL* compiler;
  if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) {
  - // If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to
  - // be updated.
  - shaderc_spvc::CompileOptions options;
  -
  - // Disable PointSize builtin for https://bugs.chromium.org/p/dawn/issues/detail?id=146
  - // Because Metal will reject PointSize builtin if the shader is compiled into a render
  - // pipeline that uses a non-point topology.
  - // TODO (hao.x.li@intel.com): Remove this once WebGPU requires there is no
  - // gl_PointSize builtin (https://github.com/gpuweb/gpuweb/issues/332).
  - options.SetMSLEnablePointSizeBuiltIn(false);
  -
  - // Always use vertex buffer 30 (the last one in the vertex buffer table) to contain
  - // the shader storage buffer lengths.
  - options.SetMSLBufferSizeBufferIndex(kBufferLengthBufferSlot);
  - mSpvcContext.InitializeForMsl(mSpirv.data(), mSpirv.size(), options);
  + // Initializing the compiler is needed every call, because this method uses reflection
  + // to mutate the compiler's IR.
  + mSpvcContext.InitializeForMsl(mSpirv.data(), mSpirv.size(), GetMSLCompileOptions());
  // TODO(rharrison): Handle initialize failing
  compiler = reinterpret_cast<spirv_cross::CompilerMSL*>(mSpvcContext.GetCompiler());
  