Parcourir la source

Always try to legalize sample offsets (#1610)

Vishal Sharma il y a 7 ans
Parent
commit
d6412a4077

+ 3 - 2
lib/Transforms/IPO/PassManagerBuilder.cpp

@@ -599,8 +599,9 @@ void PassManagerBuilder::populateModulePassManager(
     MPM.add(createDxilLowerCreateHandleForLibPass());
     MPM.add(createDxilTranslateRawBuffer());
     MPM.add(createDeadCodeEliminationPass());
-    if (DisableUnrollLoops)
-      MPM.add(createDxilLegalizeSampleOffsetPass());
+    // Always try to legalize sample offsets as loop unrolling
+    // is not guaranteed for higher opt levels.
+    MPM.add(createDxilLegalizeSampleOffsetPass());
     MPM.add(createDxilFinalizeModulePass());
     MPM.add(createComputeViewIdStatePass());
     MPM.add(createDxilDeadFunctionEliminationPass());

+ 24 - 0
tools/clang/test/CodeGenHLSL/quick-test/legalize-offset-higher-opts.hlsl

@@ -0,0 +1,24 @@
+// RUN: %dxc /Tps_6_0 /Emain > %s | FileCheck %s
+
+// Make sure that the sample offsets get legalized even when loop is not unrolled
+// for higher optimizations.
+// CHECK: define void @main()
+// CHECK: entry
+
+sampler g_pointSampler : register(s0);
+Texture2D s0 : register(t0);
+
+float4 main( float2 input : A ) : SV_TARGET
+{   
+	float4 result = float4(1.0, 1.0, 1.0, 1.0);
+	for( int y = -1; y <= 1; y++ ) 
+	{
+		for( int x = -1; x <= 1; x++ )
+		{
+			result += s0.Sample( g_pointSampler, input, int2(x,y) );
+			
+		}
+	}
+
+	return result;
+}