2
0
Эх сурвалжийг харах

Check-in rest of the bug fix

moudgils 4 жил өмнө
parent
commit
091f45482f

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

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

+ 1 - 0
lib/DxcSupport/HLSLOptions.cpp

@@ -819,6 +819,7 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
   opts.SpirvOptions.noWarnEmulatedFeatures = Args.hasFlag(OPT_Wno_vk_emulated_features, OPT_INVALID, false);
   opts.SpirvOptions.noWarnEmulatedFeatures = Args.hasFlag(OPT_Wno_vk_emulated_features, OPT_INVALID, false);
   opts.SpirvOptions.flattenResourceArrays =
   opts.SpirvOptions.flattenResourceArrays =
       Args.hasFlag(OPT_fspv_flatten_resource_arrays, OPT_INVALID, false);
       Args.hasFlag(OPT_fspv_flatten_resource_arrays, 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);
 
 
   if (!handleVkShiftArgs(Args, OPT_fvk_b_shift, "b", &opts.SpirvOptions.bShift, errors) ||
   if (!handleVkShiftArgs(Args, OPT_fvk_b_shift, "b", &opts.SpirvOptions.bShift, errors) ||

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

@@ -517,6 +517,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") ||
@@ -548,7 +552,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);
     }
     }