Force uninitialized variables to be zero for shader compiler on D3D12
The shader with uninitialized variables will fail to compile on D3D12 backend. SPIRV-Cross has added an option for supporting forcefully zero-initialized variables in latest version. Bug: dawn:347 Change-Id: Id02fa486317c583ee11cfe3bc382816dc34121fb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18680 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
parent
27dcffcc02
commit
be73a51136
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue