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

Integerating driver fix from dxc-az

moudgils 4 жил өмнө
parent
commit
843305c051

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

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

+ 1 - 0
lib/DxcSupport/HLSLOptions.cpp

@@ -820,6 +820,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

@@ -540,6 +540,10 @@ const SpirvType *LowerTypeVisitor::lowerResourceType(QualType type,
   { // Texture types
     spv::Dim dim = {};
     bool isArray = {};
+    // Amazon: 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") ||
@@ -555,7 +559,7 @@ const SpirvType *LowerTypeVisitor::lowerResourceType(QualType type,
       return spvContext.getImageType(
           lowerType(getElementType(astContext, sampledType), rule,
                     /*isRowMajor*/ llvm::None, srcLoc),
-          dim, ImageType::WithDepth::Unknown, isArray, isMS,
+          dim, depth, isArray, isMS,
           ImageType::WithSampler::Yes, spv::ImageFormat::Unknown);
     }