Browse Source

Allow select resource for library profile.

Xiang Li 8 năm trước cách đây
mục cha
commit
5d23e2c3d3

+ 3 - 1
lib/HLSL/DxilGenerationPass.cpp

@@ -846,6 +846,8 @@ void DxilGenerationPass::AddCreateHandleForPhiNodeAndSelect(OP *hlslOP) {
     UpdateHandleOperands(Res, handleMap, nonUniformOps);
   }
 
+  bool bIsLib = m_pHLModule->GetShaderModel()->IsLib();
+
   // ResClass and ResID must be uniform.
   // Try to merge res class, res id into imm.
   while (1) {
@@ -866,7 +868,7 @@ void DxilGenerationPass::AddCreateHandleForPhiNodeAndSelect(OP *hlslOP) {
     }
 
     if (!bUpdated) {
-      if (!nonUniformOps.empty()) {
+      if (!nonUniformOps.empty() && !bIsLib) {
         for (Instruction *I : nonUniformOps) {
           // Non uniform res class or res id.
           FT->getContext().emitError(I, kResourceMapErrorMsg);

+ 13 - 0
tools/clang/test/CodeGenHLSL/shader-compat-suite/lib_res_sel.hlsl

@@ -0,0 +1,13 @@
+// RUN: %dxc -T lib_6_1 %s | FileCheck %s
+
+// Make sure select resource works for lib profile.
+// CHECK: call %dx.types.Handle @dx.op.createHandle(
+
+RWStructuredBuffer<float2> buf0;
+RWStructuredBuffer<float2> buf1;
+
+
+void Store(bool bBufX, float2 v, uint idx) {
+  RWStructuredBuffer<float2> buf = bBufX ? buf0: buf1;
+  buf[idx] = v;
+}