Procházet zdrojové kódy

Merge pull request #1 from aws-lumberyard/AddDriverBugFix

Add support to disable depth hint for OpTypeImage because some mobile drivers crash.
moudgils před 4 roky
rodič
revize
082cbfa7f4

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

@@ -336,6 +336,8 @@ def Wno_vk_emulated_features : Joined<["-"], "Wno-vk-emulated-features">, Group<
   HelpText<"Do not emit warnings for emulated features resulting from no direct mapping">;
 def Oconfig : CommaJoined<["-"], "Oconfig=">, Group<spirv_Group>, Flags<[CoreOption]>,
   HelpText<"Specify a comma-separated list of SPIRV-Tools passes to customize optimization configuration (see http://khr.io/hlsl2spirv#optimization)">;
+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
 
 //////////////////////////////////////////////////////////////////////////////

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

@@ -55,6 +55,7 @@ struct SpirvCodeGenOptions {
   bool useGlLayout;
   bool useScalarLayout;
   bool flattenResourceArrays;
+  bool disableImageTypeDepthHint; // Disable depth hint for OpTypeImage because some mobile drivers crash.
   bool autoShiftBindings;
   bool supportNonzeroBaseInstance;
   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.flattenResourceArrays =
       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);
 
   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
     spv::Dim dim = {};
     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") ||
         (dim = spv::Dim::Dim2D, isArray = false, name == "Texture2D") ||
         (dim = spv::Dim::Dim3D, isArray = false, name == "Texture3D") ||
@@ -548,7 +552,7 @@ const SpirvType *LowerTypeVisitor::lowerResourceType(QualType type,
       return spvContext.getImageType(
           lowerType(getElementType(astContext, sampledType), rule,
                     /*isRowMajor*/ llvm::None, srcLoc),
-          dim, ImageType::WithDepth::Unknown, isArray,
+          dim, depth, isArray,
           /*isMultiSampled=*/false, /*sampled=*/ImageType::WithSampler::No,
           format);
     }