diff --git a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp index 14c4f5debc..6e8e38cbb2 100644 --- a/src/dawn_native/d3d12/ShaderModuleD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderModuleD3D12.cpp @@ -43,6 +43,7 @@ namespace dawn_native { namespace d3d12 { if (GetDevice()->IsToggleEnabled(Toggle::UseSpvc)) { shaderc_spvc::CompileOptions options = GetCompileOptions(); + options.SetForceZeroInitializedVariables(true); 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 @@ -74,6 +75,9 @@ namespace dawn_native { namespace d3d12 { // If these options are changed, the values in DawnSPIRVCrossHLSLFastFuzzer.cpp need to // be updated. spirv_cross::CompilerGLSL::Options options_glsl; + // Force all uninitialized variables to be 0, otherwise they will fail to compile + // by FXC. + options_glsl.force_zero_initialized_variables = true; spirv_cross::CompilerHLSL::Options options_hlsl; options_hlsl.shader_model = 51; diff --git a/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp b/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp index e404be2d7c..ac75be1f57 100644 --- a/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp +++ b/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp @@ -33,6 +33,7 @@ namespace { options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1); // Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp + options.SetForceZeroInitializedVariables(true); options.SetHLSLShaderModel(51); // TODO (hao.x.li@intel.com): The HLSLPointCoordCompat and HLSLPointSizeCompat are // required temporarily for https://bugs.chromium.org/p/dawn/issues/detail?id=146,