Browse Source

Adding a driver bug fix

Fixed conflicts from original changes from @moudgils

Signed-off-by: galibzon <[email protected]>
moudgils 4 years ago
parent
commit
c2552dc3d6

+ 2 - 0
include/dxc/Support/HLSLOptions.td

@@ -398,6 +398,8 @@ def fspv_preserve_interface : Flag<["-"], "fspv-preserve-interface">, Group<spir
   HelpText<"Preserves all interface variables in the entry point, even when those variables are unused">;
   HelpText<"Preserves all interface variables in the entry point, even when those variables are unused">;
 def fvk_allow_rwstructuredbuffer_arrays: Flag<["-"], "fvk-allow-rwstructuredbuffer-arrays">, Group<spirv_Group>, Flags<[CoreOption, DriverOption, HelpHidden]>,
 def fvk_allow_rwstructuredbuffer_arrays: Flag<["-"], "fvk-allow-rwstructuredbuffer-arrays">, Group<spirv_Group>, Flags<[CoreOption, DriverOption, HelpHidden]>,
   HelpText<"Allow arrays of RWStructuredBuffers, AppendStructuredBuffers, and ConsumeStructuredBuffers. This is in development, and the option will be removed when the feature is complete.">;
   HelpText<"Allow arrays of RWStructuredBuffers, AppendStructuredBuffers, and ConsumeStructuredBuffers. This is in development, and the option will be removed when the feature is complete.">;
+def fvk_disable_depth_hint: Flag<["-"], "fvk-disable-depth-hint">, Group<spirv_Group>, Flags<[CoreOption, DriverOption]>,
+  HelpText<"Disable the depth hint when generating OpTypeImage (driver issues)">;
 // SPIRV Change Ends
 // SPIRV Change Ends
 
 
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////

+ 1 - 0
include/dxc/Support/SPIRVOptions.h

@@ -63,6 +63,7 @@ struct SpirvCodeGenOptions {
   bool useScalarLayout;
   bool useScalarLayout;
   bool flattenResourceArrays;
   bool flattenResourceArrays;
   bool reduceLoadSize;
   bool reduceLoadSize;
+  bool disableImageTypeDepthHint; // Disable depth hint for OpTypeImage because some mobile drivers crash.
   bool autoShiftBindings;
   bool autoShiftBindings;
   bool supportNonzeroBaseInstance;
   bool supportNonzeroBaseInstance;
   bool fixFuncCallArguments;
   bool fixFuncCallArguments;

+ 1 - 0
lib/DxcSupport/HLSLOptions.cpp

@@ -981,6 +981,7 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
       Args.hasFlag(OPT_fspv_reduce_load_size, OPT_INVALID, false);
       Args.hasFlag(OPT_fspv_reduce_load_size, OPT_INVALID, false);
   opts.SpirvOptions.fixFuncCallArguments =
   opts.SpirvOptions.fixFuncCallArguments =
       Args.hasFlag(OPT_fspv_fix_func_call_arguments, OPT_INVALID, false);
       Args.hasFlag(OPT_fspv_fix_func_call_arguments, OPT_INVALID, false);
+  opts.SpirvOptions.disableImageTypeDepthHint = Args.hasFlag(OPT_fvk_disable_depth_hint, OPT_INVALID, false);
   opts.SpirvOptions.autoShiftBindings = Args.hasFlag(OPT_fvk_auto_shift_bindings, OPT_INVALID, false);
   opts.SpirvOptions.autoShiftBindings = Args.hasFlag(OPT_fvk_auto_shift_bindings, OPT_INVALID, false);
   opts.SpirvOptions.finiteMathOnly =
   opts.SpirvOptions.finiteMathOnly =
       Args.hasFlag(OPT_ffinite_math_only, OPT_fno_finite_math_only, false);
       Args.hasFlag(OPT_ffinite_math_only, OPT_fno_finite_math_only, false);

+ 5 - 1
tools/clang/lib/SPIRV/LowerTypeVisitor.cpp

@@ -647,6 +647,10 @@ const SpirvType *LowerTypeVisitor::lowerResourceType(QualType type,
   { // Texture types
   { // Texture types
     spv::Dim dim = {};
     spv::Dim dim = {};
     bool isArray = {};
     bool isArray = {};
+    // Disable depth hint because of driver issues
+    ImageType::WithDepth depth = spvOptions.disableImageTypeDepthHint
+                                     ? ImageType::WithDepth::No
+                                     : ImageType::WithDepth::Unknown;
     if ((dim = spv::Dim::Dim1D, isArray = false, name == "Texture1D") ||
     if ((dim = spv::Dim::Dim1D, isArray = false, name == "Texture1D") ||
         (dim = spv::Dim::Dim2D, isArray = false, name == "Texture2D") ||
         (dim = spv::Dim::Dim2D, isArray = false, name == "Texture2D") ||
         (dim = spv::Dim::Dim3D, isArray = false, name == "Texture3D") ||
         (dim = spv::Dim::Dim3D, isArray = false, name == "Texture3D") ||
@@ -683,7 +687,7 @@ const SpirvType *LowerTypeVisitor::lowerResourceType(QualType type,
       return spvContext.getImageType(
       return spvContext.getImageType(
           lowerType(getElementType(astContext, sampledType), rule,
           lowerType(getElementType(astContext, sampledType), rule,
                     /*isRowMajor*/ llvm::None, srcLoc),
                     /*isRowMajor*/ llvm::None, srcLoc),
-          dim, ImageType::WithDepth::Unknown, isArray,
+          dim, depth, isArray,
           /*isMultiSampled=*/false, /*sampled=*/ImageType::WithSampler::No,
           /*isMultiSampled=*/false, /*sampled=*/ImageType::WithSampler::No,
           format);
           format);
     }
     }