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

Change WaveAllBitCount and WavePrefixBitCount into same OpClass WaveBitCount.
This will not affect users.
Only OpClass problem is WavePrefixBitCount and WavePrefixOp share same OpClass,
but these 2 opcode don't have same overload.

Xiang Li 8 жил өмнө
parent
commit
65a3367a03

+ 1 - 1
include/dxc/HLSL/DxilConstants.h

@@ -598,9 +598,9 @@ namespace DXIL {
     WaveActiveBallot,
     WaveActiveBit,
     WaveActiveOp,
-    WaveAllOp,
     WaveAllTrue,
     WaveAnyTrue,
+    WaveBitCount,
     WaveGetLaneCount,
     WaveGetLaneIndex,
     WaveIsFirstLane,

+ 2 - 2
lib/HLSL/DxilOperations.cpp

@@ -236,8 +236,8 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
   {  OC::LegacyDoubleToUInt32,    "LegacyDoubleToUInt32",     OCC::LegacyDoubleToUInt32,     "legacyDoubleToUInt32",        true, false, false, false, false, false, false, false, false, Attribute::ReadNone, },
 
   // Wave                                                                                                                   void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64  function attribute
-  {  OC::WaveAllBitCount,         "WaveAllBitCount",          OCC::WaveAllOp,                "waveAllOp",                   true, false, false, false, false, false, false, false, false, Attribute::None,     },
-  {  OC::WavePrefixBitCount,      "WavePrefixBitCount",       OCC::WavePrefixOp,             "wavePrefixOp",                true, false, false, false, false, false, false, false, false, Attribute::None,     },
+  {  OC::WaveAllBitCount,         "WaveAllBitCount",          OCC::WaveBitCount,             "waveBitCount",                true, false, false, false, false, false, false, false, false, Attribute::None,     },
+  {  OC::WavePrefixBitCount,      "WavePrefixBitCount",       OCC::WaveBitCount,             "waveBitCount",                true, false, false, false, false, false, false, false, false, Attribute::None,     },
 
   // Pixel shader                                                                                                           void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64  function attribute
   {  OC::AttributeAtVertex,       "AttributeAtVertex",        OCC::AttributeAtVertex,        "attributeAtVertex",          false,  true,  true, false, false, false, false, false, false, Attribute::ReadNone, },

+ 16 - 0
tools/clang/test/CodeGenHLSL/OpClass.hlsl

@@ -0,0 +1,16 @@
+// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
+
+// Make sure WavePrefixSum and WavePrefixCountBits use different function.
+// CHECK: dx.op.wavePrefixOp.i64(i32 121
+// CHECK: dx.op.waveBitCount(i32 135
+// CHECK: dx.op.waveBitCount(i32 136
+
+float4 main() : SV_TARGET {
+  uint3 u3 = { 1, 2, 3 };
+  u3 += WavePrefixSum(3);
+
+  uint u = 0;
+  u += WaveActiveCountBits(1);
+  u += WavePrefixCountBits(1);
+  return u + u3.xyzx;
+}

+ 5 - 0
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -557,6 +557,7 @@ public:
   TEST_METHOD(CodeGenNegabs1)
   TEST_METHOD(CodeGenNoise)
   TEST_METHOD(CodeGenNonUniform)
+  TEST_METHOD(CodeGenOpClass)
   TEST_METHOD(CodeGenOptForNoOpt)
   TEST_METHOD(CodeGenOptForNoOpt2)
   TEST_METHOD(CodeGenOptionGis)
@@ -2981,6 +2982,10 @@ TEST_F(CompilerTest, CodeGenNonUniform) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\NonUniform.hlsl");
 }
 
+TEST_F(CompilerTest, CodeGenOpClass) {
+  CodeGenTestCheck(L"..\\CodeGenHLSL\\OpClass.hlsl");
+}
+
 TEST_F(CompilerTest, CodeGenOptForNoOpt) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\optForNoOpt.hlsl");
 }

+ 2 - 2
utils/hct/hctdb.py

@@ -1041,11 +1041,11 @@ class db_dxil(object):
             db_dxil_param(2, "d", "value", "double value to convert")])
         next_op_idx += 1
 
-        self.add_dxil_op("WaveAllBitCount", next_op_idx, "WaveAllOp", "returns the count of bits set to 1 across the wave", "v", "", [
+        self.add_dxil_op("WaveAllBitCount", next_op_idx, "WaveBitCount", "returns the count of bits set to 1 across the wave", "v", "", [
             db_dxil_param(0, "i32", "", "operation result"),
             db_dxil_param(2, "i1", "value", "input value")])
         next_op_idx += 1
-        self.add_dxil_op("WavePrefixBitCount", next_op_idx, "WavePrefixOp", "returns the count of bits set to 1 on prior lanes", "v", "", [
+        self.add_dxil_op("WavePrefixBitCount", next_op_idx, "WaveBitCount", "returns the count of bits set to 1 on prior lanes", "v", "", [
             db_dxil_param(0, "i32", "", "operation result"),
             db_dxil_param(2, "i1", "value", "input value")])
         next_op_idx += 1