in utils/hct/hctdb.py [0:0]
def populate_dxil_operations(self):
# $o in a parameter type means the overload type
# $r in a parameter type means the resource type
# $cb in a parameter type means cbuffer legacy load return type
# overload types are a string of (v)oid, (h)alf, (f)loat, (d)ouble, (1)-bit, (8)-bit, (w)ord, (i)nt, (l)ong
self.opcode_param = db_dxil_param(1, "i32", "opcode", "DXIL opcode")
retvoid_param = db_dxil_param(0, "v", "", "no return value")
next_op_idx = 0
self.add_dxil_op("TempRegLoad", next_op_idx, "TempRegLoad", "helper load operation", "hfwi", "ro", [
db_dxil_param(0, "$o", "", "register value"),
db_dxil_param(2, "u32", "index", "linearized register index")])
next_op_idx += 1
self.add_dxil_op("TempRegStore", next_op_idx, "TempRegStore", "helper store operation", "hfwi", "", [
retvoid_param,
db_dxil_param(2, "u32", "index", "linearized register index"),
db_dxil_param(3, "$o", "value", "value to store")])
next_op_idx += 1
self.add_dxil_op("MinPrecXRegLoad", next_op_idx, "MinPrecXRegLoad", "helper load operation for minprecision", "hw", "ro", [
db_dxil_param(0, "$o", "", "register value"),
db_dxil_param(2, "pf32", "regIndex", "pointer to indexable register"),
db_dxil_param(3, "i32", "index", "index"),
db_dxil_param(4, "u8", "component", "component")])
next_op_idx += 1
self.add_dxil_op("MinPrecXRegStore", next_op_idx, "MinPrecXRegStore", "helper store operation for minprecision", "hw", "", [
retvoid_param,
db_dxil_param(2, "pf32", "regIndex", "pointer to indexable register"),
db_dxil_param(3, "i32", "index", "index"),
db_dxil_param(4, "u8", "component", "component"),
db_dxil_param(5, "$o", "value", "value to store")])
next_op_idx += 1
self.add_dxil_op("LoadInput", next_op_idx, "LoadInput", "loads the value from shader input", "hfwi", "rn", [
db_dxil_param(0, "$o", "", "input value"),
db_dxil_param(2, "u32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "u32", "rowIndex", "row index relative to element"),
db_dxil_param(4, "u8", "colIndex", "column index relative to element"),
db_dxil_param(5, "i32", "gsVertexAxis", "gsVertexAxis")],
counters=('sig_ld',))
next_op_idx += 1
self.add_dxil_op("StoreOutput", next_op_idx, "StoreOutput", "stores the value to shader output", "hfwi", "", [ # note, cannot store bit even though load supports it
retvoid_param,
db_dxil_param(2, "u32", "outputSigId", "output signature element ID"),
db_dxil_param(3, "u32", "rowIndex", "row index relative to element"),
db_dxil_param(4, "u8", "colIndex", "column index relative to element"),
db_dxil_param(5, "$o", "value", "value to store")],
counters=('sig_st',))
next_op_idx += 1
def UFI(name, **mappings):
name = name.upper()
for k,v in mappings.items():
if name.startswith(k):
return v
if name.upper().startswith('F'):
return 'floats'
elif name.upper().startswith('U'):
return 'uints'
else:
return 'ints'
# Unary float operations are regular.
for i in "FAbs,Saturate".split(","):
self.add_dxil_op(i, next_op_idx, "Unary", "returns the " + i, "hfd", "rn", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")],
counters=('floats',))
next_op_idx += 1
for i in "IsNaN,IsInf,IsFinite,IsNormal".split(","):
self.add_dxil_op(i, next_op_idx, "IsSpecialFloat", "returns the " + i, "hf", "rn", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")],
counters=('floats',))
next_op_idx += 1
for i in "Cos,Sin,Tan,Acos,Asin,Atan,Hcos,Hsin,Htan,Exp,Frc,Log,Sqrt,Rsqrt,Round_ne,Round_ni,Round_pi,Round_z".split(","):
self.add_dxil_op(i, next_op_idx, "Unary", "returns the " + i, "hf", "rn", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")],
counters=('floats',))
next_op_idx += 1
# Unary int operations are regular.
for i in "Bfrev".split(","):
self.add_dxil_op(i, next_op_idx, "Unary", "returns the reverse bit pattern of the input value", "wil", "rn", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")],
counters=('uints',))
next_op_idx += 1
for i in "Countbits,FirstbitLo".split(","):
self.add_dxil_op(i, next_op_idx, "UnaryBits", "returns the " + i, "wil", "rn", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")],
counters=('uints',))
next_op_idx += 1
for i in "FirstbitHi,FirstbitSHi".split(","):
self.add_dxil_op(i, next_op_idx, "UnaryBits", "returns src != 0? (BitWidth-1 - " + i + ") : -1", "wil", "rn", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")],
counters=('uints',))
next_op_idx += 1
# Binary float operations
for i in "FMax,FMin".split(","):
self.add_dxil_op(i, next_op_idx, "Binary", "returns the " + i + " of the input values", "hfd", "rn", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "a", "input value"),
db_dxil_param(3, "$o", "b", "input value")],
counters=('floats',))
next_op_idx += 1
# Binary int operations
for i in "IMax,IMin,UMax,UMin".split(","):
self.add_dxil_op(i, next_op_idx, "Binary", "returns the " + i + " of the input values", "wil", "rn", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "a", "input value"),
db_dxil_param(3, "$o", "b", "input value")],
counters=(UFI(i),))
next_op_idx += 1
# Binary int operations with two outputs
for i in "IMul,UMul,UDiv".split(","):
self.add_dxil_op(i, next_op_idx, "BinaryWithTwoOuts", "returns the " + i + " of the input values", "i", "rn", [
db_dxil_param(0, "twoi32", "", "operation result"),
db_dxil_param(2, "$o", "a", "input value"),
db_dxil_param(3, "$o", "b", "input value")],
counters=(UFI(i),))
next_op_idx += 1
# Binary int operations with carry
for i in "UAddc,USubb".split(","):
self.add_dxil_op(i, next_op_idx, "BinaryWithCarryOrBorrow", "returns the " + i + " of the input values", "i", "rn", [
db_dxil_param(0, "i32c", "", "operation result with carry/borrow value"),
db_dxil_param(2, "$o", "a", "input value"),
db_dxil_param(3, "$o", "b", "input value")],
counters=('uints',))
next_op_idx += 1
# Tertiary float.
self.add_dxil_op("FMad", next_op_idx, "Tertiary", "performs a fused multiply add (FMA) of the form a * b + c", "hfd", "rn", [
db_dxil_param(0, "$o", "", "the fused multiply-addition of parameters a * b + c"),
db_dxil_param(2, "$o", "a", "first value for FMA, the first factor"),
db_dxil_param(3, "$o", "b", "second value for FMA, the second factor"),
db_dxil_param(4, "$o", "c", "third value for FMA, the addend")])
next_op_idx += 1
self.add_dxil_op("Fma", next_op_idx, "Tertiary", "performs a fused multiply add (FMA) of the form a * b + c", "d", "rn", [
db_dxil_param(0, "$o", "", "the double-precision fused multiply-addition of parameters a * b + c, accurate to 0.5 units of least precision (ULP)"),
db_dxil_param(2, "$o", "a", "first value for FMA, the first factor"),
db_dxil_param(3, "$o", "b", "second value for FMA, the second factor"),
db_dxil_param(4, "$o", "c", "third value for FMA, the addend")],
counters=('floats',))
next_op_idx += 1
# Tertiary int.
for i in "IMad,UMad".split(","):
self.add_dxil_op(i, next_op_idx, "Tertiary", "performs an integral " + i, "wil", "rn", [
db_dxil_param(0, "$o", "", "the operation result"),
db_dxil_param(2, "$o", "a", "first value for FMA, the first factor"),
db_dxil_param(3, "$o", "b", "second value for FMA, the second factor"),
db_dxil_param(4, "$o", "c", "third value for FMA, the addend")],
counters=(UFI(i),))
next_op_idx += 1
for i in "Msad,Ibfe,Ubfe".split(","):
self.add_dxil_op(i, next_op_idx, "Tertiary", "performs an integral " + i, "il", "rn", [
db_dxil_param(0, "$o", "", "the operation result"),
db_dxil_param(2, "$o", "a", "first value for FMA, the first factor"),
db_dxil_param(3, "$o", "b", "second value for FMA, the second factor"),
db_dxil_param(4, "$o", "c", "third value for FMA, the addend")],
counters=(UFI(i, M='uints'),))
next_op_idx += 1
# Quaternary
self.add_dxil_op("Bfi", next_op_idx, "Quaternary", "given a bit range from the LSB of a number, places that number of bits in another number at any offset", "i", "rn", [
db_dxil_param(0, "$o", "", "the operation result"),
db_dxil_param(2, "$o", "width", "the bitfield width to take from the value"),
db_dxil_param(3, "$o", "offset", "the bitfield offset to replace in the value"),
db_dxil_param(4, "$o", "value", "the number the bits are taken from"),
db_dxil_param(5, "$o", "replacedValue", "the number with bits to be replaced")],
counters=('uints',))
next_op_idx += 1
# Dot
self.add_dxil_op("Dot2", next_op_idx, "Dot2", "two-dimensional vector dot-product", "hf", "rn", [
db_dxil_param(0, "$o", "", "the operation result"),
db_dxil_param(2, "$o", "ax", "the first component of the first vector"),
db_dxil_param(3, "$o", "ay", "the second component of the first vector"),
db_dxil_param(4, "$o", "bx", "the first component of the second vector"),
db_dxil_param(5, "$o", "by", "the second component of the second vector")],
counters=('floats',))
next_op_idx += 1
self.add_dxil_op("Dot3", next_op_idx, "Dot3", "three-dimensional vector dot-product", "hf", "rn", [
db_dxil_param(0, "$o", "", "the operation result"),
db_dxil_param(2, "$o", "ax", "the first component of the first vector"),
db_dxil_param(3, "$o", "ay", "the second component of the first vector"),
db_dxil_param(4, "$o", "az", "the third component of the first vector"),
db_dxil_param(5, "$o", "bx", "the first component of the second vector"),
db_dxil_param(6, "$o", "by", "the second component of the second vector"),
db_dxil_param(7, "$o", "bz", "the third component of the second vector")],
counters=('floats',))
next_op_idx += 1
self.add_dxil_op("Dot4", next_op_idx, "Dot4", "four-dimensional vector dot-product", "hf", "rn", [
db_dxil_param(0, "$o", "", "the operation result"),
db_dxil_param(2, "$o", "ax", "the first component of the first vector"),
db_dxil_param(3, "$o", "ay", "the second component of the first vector"),
db_dxil_param(4, "$o", "az", "the third component of the first vector"),
db_dxil_param(5, "$o", "aw", "the fourth component of the first vector"),
db_dxil_param(6, "$o", "bx", "the first component of the second vector"),
db_dxil_param(7, "$o", "by", "the second component of the second vector"),
db_dxil_param(8, "$o", "bz", "the third component of the second vector"),
db_dxil_param(9, "$o", "bw", "the fourth component of the second vector")],
counters=('floats',))
next_op_idx += 1
# Resources.
self.add_dxil_op("CreateHandle", next_op_idx, "CreateHandle", "creates the handle to a resource", "v", "ro", [
db_dxil_param(0, "res", "", "the handle to the resource"),
db_dxil_param(2, "i8", "resourceClass", "the class of resource to create (SRV, UAV, CBuffer, Sampler)", is_const=True), # maps to DxilResourceBase::Class
db_dxil_param(3, "i32", "rangeId", "range identifier for resource", is_const=True),
db_dxil_param(4, "i32", "index", "zero-based index into range"),
db_dxil_param(5, "i1", "nonUniformIndex", "non-uniform resource index", is_const=True)])
next_op_idx += 1
self.add_dxil_op("CBufferLoad", next_op_idx, "CBufferLoad", "loads a value from a constant buffer resource", "hfd8wil", "ro", [
db_dxil_param(0, "$o", "", "the value for the constant buffer variable"),
db_dxil_param(2, "res", "handle", "cbuffer handle"),
db_dxil_param(3, "u32", "byteOffset", "linear byte offset of value"),
db_dxil_param(4, "u32", "alignment", "load access alignment", is_const=True)])
next_op_idx += 1
self.add_dxil_op("CBufferLoadLegacy", next_op_idx, "CBufferLoadLegacy", "loads a value from a constant buffer resource", "hfdwil", "ro", [
db_dxil_param(0, "$cb", "", "the value for the constant buffer variable"),
db_dxil_param(2, "res", "handle", "cbuffer handle"),
db_dxil_param(3, "u32", "regIndex", "0-based index into cbuffer instance")])
next_op_idx += 1
self.add_dxil_op("Sample", next_op_idx, "Sample", "samples a texture", "hf", "ro", [
db_dxil_param(0, "$r", "", "the sampled value"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "offset2", "optional offset, applicable to Texture3D"),
db_dxil_param(11, "f", "clamp", "clamp value")],
counters=('tex_norm',))
next_op_idx += 1
self.add_dxil_op("SampleBias", next_op_idx, "SampleBias", "samples a texture after applying the input bias to the mipmap level", "hf", "ro", [
db_dxil_param(0, "$r", "", "the sampled value"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "offset2", "optional offset, applicable to Texture3D"),
db_dxil_param(11, "f", "bias", "bias value"),
db_dxil_param(12, "f", "clamp", "clamp value")],
counters=('tex_bias',))
next_op_idx += 1
self.add_dxil_op("SampleLevel", next_op_idx, "SampleLevel", "samples a texture using a mipmap-level offset", "hf", "ro", [
db_dxil_param(0, "$r", "", "the sampled value"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "offset2", "optional offset, applicable to Texture3D"),
db_dxil_param(11, "f", "LOD", "level of detail, biggest map if less than or equal to zero; fraction used to interpolate across levels")],
counters=('tex_norm',))
next_op_idx += 1
self.add_dxil_op("SampleGrad", next_op_idx, "SampleGrad", "samples a texture using a gradient to influence the way the sample location is calculated", "hf", "ro", [
db_dxil_param(0, "$r", "", "the sampled value"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "offset2", "optional offset, applicable to Texture3D"),
db_dxil_param(11, "f", "ddx0", "rate of change of the texture coordinate in the x direction"),
db_dxil_param(12, "f", "ddx1", "rate of change of the texture coordinate in the x direction"),
db_dxil_param(13, "f", "ddx2", "rate of change of the texture coordinate in the x direction"),
db_dxil_param(14, "f", "ddy0", "rate of change of the texture coordinate in the y direction"),
db_dxil_param(15, "f", "ddy1", "rate of change of the texture coordinate in the y direction"),
db_dxil_param(16, "f", "ddy2", "rate of change of the texture coordinate in the y direction"),
db_dxil_param(17, "f", "clamp", "clamp value")],
counters=('tex_grad',))
next_op_idx += 1
self.add_dxil_op("SampleCmp", next_op_idx, "SampleCmp", "samples a texture and compares a single component against the specified comparison value", "hf", "ro", [
db_dxil_param(0, "$r", "", "the value for the constant buffer variable"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "offset2", "optional offset, applicable to Texture3D"),
db_dxil_param(11, "f", "compareValue", "the value to compare with"),
db_dxil_param(12, "f", "clamp", "clamp value")],
counters=('tex_cmp',))
next_op_idx += 1
self.add_dxil_op("SampleCmpLevelZero", next_op_idx, "SampleCmpLevelZero", "samples a texture and compares a single component against the specified comparison value", "hf", "ro", [
db_dxil_param(0, "$r", "", "the value for the constant buffer variable"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "offset2", "optional offset, applicable to Texture3D"),
db_dxil_param(11, "f", "compareValue", "the value to compare with")],
counters=('tex_cmp',))
next_op_idx += 1
self.add_dxil_op("TextureLoad", next_op_idx, "TextureLoad", "reads texel data without any filtering or sampling", "hfwi", "ro", [
db_dxil_param(0, "$r", "", "the loaded value"),
db_dxil_param(2, "res", "srv", "handle of SRV or UAV to sample"),
db_dxil_param(3, "i32", "mipLevelOrSampleCount", "sample count for Texture2DMS, mip level otherwise"),
db_dxil_param(4, "i32", "coord0", "coordinate"),
db_dxil_param(5, "i32", "coord1", "coordinate"),
db_dxil_param(6, "i32", "coord2", "coordinate"),
db_dxil_param(7, "i32", "offset0", "optional offset"),
db_dxil_param(8, "i32", "offset1", "optional offset"),
db_dxil_param(9, "i32", "offset2", "optional offset")],
counters=('tex_load',))
next_op_idx += 1
self.add_dxil_op("TextureStore", next_op_idx, "TextureStore", "reads texel data without any filtering or sampling", "hfwi", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "srv", "handle of UAV to store to"),
db_dxil_param(3, "i32", "coord0", "coordinate"),
db_dxil_param(4, "i32", "coord1", "coordinate"),
db_dxil_param(5, "i32", "coord2", "coordinate"),
db_dxil_param(6, "$o", "value0", "value"),
db_dxil_param(7, "$o", "value1", "value"),
db_dxil_param(8, "$o", "value2", "value"),
db_dxil_param(9, "$o", "value3", "value"),
db_dxil_param(10,"i8", "mask", "written value mask")],
counters=('tex_store',))
next_op_idx += 1
self.add_dxil_op("BufferLoad", next_op_idx, "BufferLoad", "reads from a TypedBuffer", "hfwi", "ro", [
db_dxil_param(0, "$r", "", "the loaded value"),
db_dxil_param(2, "res", "srv", "handle of TypedBuffer SRV to sample"),
db_dxil_param(3, "i32", "index", "element index"),
db_dxil_param(4, "i32", "wot", "coordinate")],
counters=('tex_load',))
next_op_idx += 1
self.add_dxil_op("BufferStore", next_op_idx, "BufferStore", "writes to a RWTypedBuffer", "hfwi", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "uav", "handle of UAV to store to"),
db_dxil_param(3, "i32", "coord0", "coordinate in elements"),
db_dxil_param(4, "i32", "coord1", "coordinate (unused?)"),
db_dxil_param(5, "$o", "value0", "value"),
db_dxil_param(6, "$o", "value1", "value"),
db_dxil_param(7, "$o", "value2", "value"),
db_dxil_param(8, "$o", "value3", "value"),
db_dxil_param(9, "i8", "mask", "written value mask")],
counters=('tex_store',))
next_op_idx += 1
self.add_dxil_op("BufferUpdateCounter", next_op_idx, "BufferUpdateCounter", "atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV", "v", "", [
db_dxil_param(0, "i32", "", "the new value in the buffer"),
db_dxil_param(2, "res", "uav", "handle to a structured buffer UAV with the count or append flag"),
db_dxil_param(3, "i8", "inc", "1 to increase, 0 to decrease")],
counters=('atomic',))
next_op_idx += 1
self.add_dxil_op("CheckAccessFullyMapped", next_op_idx, "CheckAccessFullyMapped", "determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource", "i", "ro", [
db_dxil_param(0, "i1", "", "nonzero if all values accessed mapped tiles in a tiled resource"),
db_dxil_param(2, "u32", "status", "status result from the Sample, Gather or Load operation")])
next_op_idx += 1
self.add_dxil_op("GetDimensions", next_op_idx, "GetDimensions", "gets texture size information", "v", "ro", [
db_dxil_param(0, "dims", "", "dimension information for texture"),
db_dxil_param(2, "res", "handle", "resource handle to query"),
db_dxil_param(3, "i32", "mipLevel", "mip level to query")])
next_op_idx += 1
self.add_dxil_op("TextureGather", next_op_idx, "TextureGather", "gathers the four texels that would be used in a bi-linear filtering operation", "hfwi", "ro", [
db_dxil_param(0, "$r", "", "dimension information for texture"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "channel", "channel to sample")],
counters=('tex_norm',))
next_op_idx += 1
self.add_dxil_op("TextureGatherCmp", next_op_idx, "TextureGatherCmp", "same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp", "hfwi", "ro", [
db_dxil_param(0, "$r", "", "gathered texels"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "res", "sampler", "handle of sampler to use"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate, undef for Texture1D"),
db_dxil_param(6, "f", "coord2", "coordinate, undef for Texture1D, Texture1DArray or Texture2D"),
db_dxil_param(7, "f", "coord3", "coordinate, defined only for TextureCubeArray"),
db_dxil_param(8, "i32", "offset0", "optional offset, applicable to Texture1D, Texture1DArray, and as part of offset1"),
db_dxil_param(9, "i32", "offset1", "optional offset, applicable to Texture2D, Texture2DArray, and as part of offset2"),
db_dxil_param(10, "i32", "channel", "channel to sample"),
db_dxil_param(11, "f", "compareValue", "value to compare with")],
counters=('tex_cmp',))
next_op_idx += 1
self.add_dxil_op("Texture2DMSGetSamplePosition", next_op_idx, "Texture2DMSGetSamplePosition", "gets the position of the specified sample", "v", "ro", [
db_dxil_param(0, "SamplePos", "", "sample position"),
db_dxil_param(2, "res", "srv", "handle of SRV to sample"),
db_dxil_param(3, "i32", "index", "zero-based sample index")])
next_op_idx += 1
self.add_dxil_op("RenderTargetGetSamplePosition", next_op_idx, "RenderTargetGetSamplePosition", "gets the position of the specified sample", "v", "ro", [
db_dxil_param(0, "SamplePos", "", "sample position"),
db_dxil_param(2, "i32", "index", "zero-based sample index")])
next_op_idx += 1
self.add_dxil_op("RenderTargetGetSampleCount", next_op_idx, "RenderTargetGetSampleCount", "gets the number of samples for a render target", "v", "ro", [
db_dxil_param(0, "u32", "", "number of sampling locations for a render target")])
next_op_idx += 1
# Atomics. Note that on TGSM, atomics are performed with LLVM instructions.
self.add_dxil_op("AtomicBinOp", next_op_idx, "AtomicBinOp", "performs an atomic operation on two operands", "li", "", [
db_dxil_param(0, "$o", "", "the original value in the location updated"),
db_dxil_param(2, "res", "handle", "typed int or uint UAV handle"),
db_dxil_param(3, "i32", "atomicOp", "atomic operation as per DXIL::AtomicBinOpCode"),
db_dxil_param(4, "i32", "offset0", "offset in elements"),
db_dxil_param(5, "i32", "offset1", "offset"),
db_dxil_param(6, "i32", "offset2", "offset"),
db_dxil_param(7, "$o", "newValue", "new value")],
counters=('atomic',))
next_op_idx += 1
self.add_dxil_op("AtomicCompareExchange", next_op_idx, "AtomicCompareExchange", "atomic compare and exchange to memory", "li", "", [
db_dxil_param(0, "$o", "", "the original value in the location updated"),
db_dxil_param(2, "res", "handle", "typed int or uint UAV handle"),
db_dxil_param(3, "i32", "offset0", "offset in elements"),
db_dxil_param(4, "i32", "offset1", "offset"),
db_dxil_param(5, "i32", "offset2", "offset"),
db_dxil_param(6, "$o", "compareValue", "value to compare for exchange"),
db_dxil_param(7, "$o", "newValue", "new value")],
counters=('atomic',))
next_op_idx += 1
# Synchronization.
self.add_dxil_op("Barrier", next_op_idx, "Barrier", "inserts a memory barrier in the shader", "v", "nd", [
retvoid_param,
db_dxil_param(2, "i32", "barrierMode", "a mask of DXIL::BarrierMode values", is_const=True)],
counters=('barrier',))
next_op_idx += 1
# Pixel shader
self.add_dxil_op("CalculateLOD", next_op_idx, "CalculateLOD", "calculates the level of detail", "f", "ro", [
db_dxil_param(0, "f", "", "level of detail"),
db_dxil_param(2, "res", "handle", "resource handle"),
db_dxil_param(3, "res", "sampler", "sampler handle"),
db_dxil_param(4, "f", "coord0", "coordinate"),
db_dxil_param(5, "f", "coord1", "coordinate"),
db_dxil_param(6, "f", "coord2", "coordinate"),
db_dxil_param(7, "i1", "clamped", "1 if clampled LOD should be calculated, 0 for unclamped")])
next_op_idx += 1
self.add_dxil_op("Discard", next_op_idx, "Discard", "discard the current pixel", "v", "", [
retvoid_param,
db_dxil_param(2, "i1", "condition", "condition for conditional discard")])
next_op_idx += 1
self.add_dxil_op("DerivCoarseX", next_op_idx, "Unary", "computes the rate of change of components per stamp", "hf", "rn", [
db_dxil_param(0, "$o", "", "rate of change in value with regards to RenderTarget x direction"),
db_dxil_param(2, "$o", "value", "input to rate of change")])
next_op_idx += 1
self.add_dxil_op("DerivCoarseY", next_op_idx, "Unary", "computes the rate of change of components per stamp", "hf", "rn", [
db_dxil_param(0, "$o", "", "rate of change in value with regards to RenderTarget y direction"),
db_dxil_param(2, "$o", "value", "input to rate of change")])
next_op_idx += 1
self.add_dxil_op("DerivFineX", next_op_idx, "Unary", "computes the rate of change of components per pixel", "hf", "rn", [
db_dxil_param(0, "$o", "", "rate of change in value with regards to RenderTarget x direction"),
db_dxil_param(2, "$o", "value", "input to rate of change")])
next_op_idx += 1
self.add_dxil_op("DerivFineY", next_op_idx, "Unary", "computes the rate of change of components per pixel", "hf", "rn", [
db_dxil_param(0, "$o", "", "rate of change in value with regards to RenderTarget y direction"),
db_dxil_param(2, "$o", "value", "input to rate of change")])
next_op_idx += 1
self.add_dxil_op("EvalSnapped", next_op_idx, "EvalSnapped", "evaluates an input attribute at pixel center with an offset", "hf", "rn", [
db_dxil_param(0, "$o", "", "result"),
db_dxil_param(2, "i32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "i32", "inputRowIndex", "row index of an input attribute"),
db_dxil_param(4, "i8", "inputColIndex", "column index of an input attribute"),
db_dxil_param(5, "i32", "offsetX", "2D offset from the pixel center using a 16x16 grid"),
db_dxil_param(6, "i32", "offsetY", "2D offset from the pixel center using a 16x16 grid")])
next_op_idx += 1
self.add_dxil_op("EvalSampleIndex", next_op_idx, "EvalSampleIndex", "evaluates an input attribute at a sample location", "hf", "rn", [
db_dxil_param(0, "$o", "", "result"),
db_dxil_param(2, "i32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "i32", "inputRowIndex", "row index of an input attribute"),
db_dxil_param(4, "i8", "inputColIndex", "column index of an input attribute"),
db_dxil_param(5, "i32", "sampleIndex", "sample location")])
next_op_idx += 1
self.add_dxil_op("EvalCentroid", next_op_idx, "EvalCentroid", "evaluates an input attribute at pixel center", "hf", "rn", [
db_dxil_param(0, "$o", "", "result"),
db_dxil_param(2, "i32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "i32", "inputRowIndex", "row index of an input attribute"),
db_dxil_param(4, "i8", "inputColIndex", "column index of an input attribute")])
next_op_idx += 1
self.add_dxil_op("SampleIndex", next_op_idx, "SampleIndex", "returns the sample index in a sample-frequency pixel shader", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("Coverage", next_op_idx, "Coverage", "returns the coverage mask input in a pixel shader", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("InnerCoverage", next_op_idx, "InnerCoverage", "returns underestimated coverage input from conservative rasterization in a pixel shader", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
# Compute shader.
self.add_dxil_op("ThreadId", next_op_idx, "ThreadId", "reads the thread ID", "i", "rn", [
db_dxil_param(0, "i32", "", "thread ID component"),
db_dxil_param(2, "i32", "component", "component to read (x,y,z)")])
next_op_idx += 1
self.add_dxil_op("GroupId", next_op_idx, "GroupId", "reads the group ID (SV_GroupID)", "i", "rn", [
db_dxil_param(0, "i32", "", "group ID component"),
db_dxil_param(2, "i32", "component", "component to read")])
next_op_idx += 1
self.add_dxil_op("ThreadIdInGroup", next_op_idx, "ThreadIdInGroup", "reads the thread ID within the group (SV_GroupThreadID)", "i", "rn", [
db_dxil_param(0, "i32", "", "thread ID in group component"),
db_dxil_param(2, "i32", "component", "component to read (x,y,z)")])
next_op_idx += 1
self.add_dxil_op("FlattenedThreadIdInGroup", next_op_idx, "FlattenedThreadIdInGroup", "provides a flattened index for a given thread within a given group (SV_GroupIndex)", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
# Geometry shader
self.add_dxil_op("EmitStream", next_op_idx, "EmitStream", "emits a vertex to a given stream", "v", "", [
retvoid_param,
db_dxil_param(2, "i8", "streamId", "target stream ID for operation")],
counters=('gs_emit',))
next_op_idx += 1
self.add_dxil_op("CutStream", next_op_idx, "CutStream", "completes the current primitive topology at the specified stream", "v", "", [
retvoid_param,
db_dxil_param(2, "i8", "streamId", "target stream ID for operation")],
counters=('gs_cut',))
next_op_idx += 1
self.add_dxil_op("EmitThenCutStream", next_op_idx, "EmitThenCutStream", "equivalent to an EmitStream followed by a CutStream", "v", "", [
retvoid_param,
db_dxil_param(2, "i8", "streamId", "target stream ID for operation")],
counters=('gs_emit','gs_cut'))
next_op_idx += 1
self.add_dxil_op("GSInstanceID", next_op_idx, "GSInstanceID", "GSInstanceID", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
# Double precision
self.add_dxil_op("MakeDouble", next_op_idx, "MakeDouble", "creates a double value", "d", "rn", [
db_dxil_param(0, "d", "", "result"),
db_dxil_param(2, "i32", "lo", "low part of double"),
db_dxil_param(3, "i32", "hi", "high part of double")])
next_op_idx += 1
self.add_dxil_op("SplitDouble", next_op_idx, "SplitDouble", "splits a double into low and high parts", "d", "rn", [
db_dxil_param(0, "splitdouble", "", "result"),
db_dxil_param(2, "d", "value", "value to split")])
next_op_idx += 1
# Domain & Hull shader.
self.add_dxil_op("LoadOutputControlPoint", next_op_idx, "LoadOutputControlPoint", "LoadOutputControlPoint", "hfwi", "rn", [
db_dxil_param(0, "$o", "", "result"),
db_dxil_param(2, "i32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "i32", "row", "row, relative to the element"),
db_dxil_param(4, "i8", "col", "column, relative to the element"),
db_dxil_param(5, "i32", "index", "vertex/point index")],
counters=('sig_ld',))
next_op_idx += 1
self.add_dxil_op("LoadPatchConstant", next_op_idx, "LoadPatchConstant", "LoadPatchConstant", "hfwi", "rn", [
db_dxil_param(0, "$o", "", "result"),
db_dxil_param(2, "i32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "i32", "row", "row, relative to the element"),
db_dxil_param(4, "i8", "col", "column, relative to the element")],
counters=('sig_ld',))
next_op_idx += 1
# Domain shader.
self.add_dxil_op("DomainLocation", next_op_idx, "DomainLocation", "DomainLocation", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i8", "component", "input", is_const=True)])
next_op_idx += 1
# Hull shader.
self.add_dxil_op("StorePatchConstant", next_op_idx, "StorePatchConstant", "StorePatchConstant", "hfwi", "", [
retvoid_param,
db_dxil_param(2, "i32", "outputSigID", "output signature element ID"),
db_dxil_param(3, "i32", "row", "row, relative to the element"),
db_dxil_param(4, "i8", "col", "column, relative to the element"),
db_dxil_param(5, "$o", "value", "value to store")],
counters=('sig_st',))
next_op_idx += 1
self.add_dxil_op("OutputControlPointID", next_op_idx, "OutputControlPointID", "OutputControlPointID", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("PrimitiveID", next_op_idx, "PrimitiveID", "PrimitiveID", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("CycleCounterLegacy", next_op_idx, "CycleCounterLegacy", "CycleCounterLegacy", "v", "", [
db_dxil_param(0, "twoi32", "", "result")])
next_op_idx += 1
# Add wave intrinsics.
self.add_dxil_op("WaveIsFirstLane", next_op_idx, "WaveIsFirstLane", "returns 1 for the first lane in the wave", "v", "", [
db_dxil_param(0, "i1", "", "operation result")])
next_op_idx += 1
self.add_dxil_op("WaveGetLaneIndex", next_op_idx, "WaveGetLaneIndex", "returns the index of the current lane in the wave", "v", "rn", [
db_dxil_param(0, "i32", "", "operation result")])
next_op_idx += 1
self.add_dxil_op("WaveGetLaneCount", next_op_idx, "WaveGetLaneCount", "returns the number of lanes in the wave", "v", "rn", [
db_dxil_param(0, "i32", "", "operation result")])
next_op_idx += 1
self.add_dxil_op("WaveAnyTrue", next_op_idx, "WaveAnyTrue", "returns 1 if any of the lane evaluates the value to true", "v", "", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "i1", "cond", "condition to test")])
next_op_idx += 1
self.add_dxil_op("WaveAllTrue", next_op_idx, "WaveAllTrue", "returns 1 if all the lanes evaluate the value to true", "v", "", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "i1", "cond", "condition to test")])
next_op_idx += 1
self.add_dxil_op("WaveActiveAllEqual", next_op_idx, "WaveActiveAllEqual", "returns 1 if all the lanes have the same value", "hfd18wil", "", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "$o", "value", "value to compare")])
next_op_idx += 1
self.add_dxil_op("WaveActiveBallot", next_op_idx, "WaveActiveBallot", "returns a struct with a bit set for each lane where the condition is true", "v", "", [
db_dxil_param(0, "fouri32", "", "operation result"),
db_dxil_param(2, "i1", "cond", "condition to ballot on")])
next_op_idx += 1
self.add_dxil_op("WaveReadLaneAt", next_op_idx, "WaveReadLaneAt", "returns the value from the specified lane", "hfd18wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "value to read"),
db_dxil_param(3, "i32", "lane", "lane index")])
next_op_idx += 1
self.add_dxil_op("WaveReadLaneFirst", next_op_idx, "WaveReadLaneFirst", "returns the value from the first lane", "hfd18wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "value to read")])
next_op_idx += 1
self.add_dxil_op("WaveActiveOp", next_op_idx, "WaveActiveOp", "returns the result the operation across waves", "hfd18wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value"),
db_dxil_param(3, "i8", "op", "kind of operation to perform", enum_name="WaveOpKind", is_const=True),
db_dxil_param(4, "i8", "sop", "sign of operands", enum_name="SignedOpKind", is_const=True)])
next_op_idx += 1
self.add_enum_type("SignedOpKind", "Sign vs. unsigned operands for operation", [
(0, "Signed", "signed integer or floating-point operands"),
(1, "Unsigned", "unsigned integer operands")])
self.add_enum_type("WaveOpKind", "Kind of cross-lane operation", [
(0, "Sum", "sum of values"),
(1, "Product", "product of values"),
(2, "Min", "minimum value"),
(3, "Max", "maximum value")])
self.add_dxil_op("WaveActiveBit", next_op_idx, "WaveActiveBit", "returns the result of the operation across all lanes", "8wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value"),
db_dxil_param(3, "i8", "op", "kind of operation to perform", enum_name="WaveBitOpKind", is_const=True)])
next_op_idx += 1
self.add_enum_type("WaveBitOpKind", "Kind of bitwise cross-lane operation", [
(0, "And", "bitwise and of values"),
(1, "Or", "bitwise or of values"),
(2, "Xor", "bitwise xor of values")])
self.add_dxil_op("WavePrefixOp", next_op_idx, "WavePrefixOp", "returns the result of the operation on prior lanes", "hfd8wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value"),
db_dxil_param(3, "i8", "op", "0=sum,1=product", enum_name="WaveOpKind", is_const=True),
db_dxil_param(4, "i8", "sop", "sign of operands", enum_name="SignedOpKind", is_const=True)])
next_op_idx += 1
self.add_dxil_op("QuadReadLaneAt", next_op_idx, "QuadReadLaneAt", "reads from a lane in the quad", "hfd18wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "value to read"),
db_dxil_param(3, "u32", "quadLane", "lane to read from (0-4)", max_value = 3)])
next_op_idx += 1
self.add_enum_type("QuadOpKind", "Kind of quad-level operation", [
(0, "ReadAcrossX", "returns the value from the other lane in the quad in the horizontal direction"),
(1, "ReadAcrossY", "returns the value from the other lane in the quad in the vertical direction"),
(2, "ReadAcrossDiagonal", "returns the value from the lane across the quad in horizontal and vertical direction")])
self.add_dxil_op("QuadOp", next_op_idx, "QuadOp", "returns the result of a quad-level operation", "hfd8wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "value for operation"),
db_dxil_param(3, "i8", "op", "operation", enum_name = "QuadOpKind", is_const=True)])
next_op_idx += 1
# Add bitcasts
self.add_dxil_op("BitcastI16toF16", next_op_idx, "BitcastI16toF16", "bitcast between different sizes", "v", "rn", [
db_dxil_param(0, "h", "", "operation result"),
db_dxil_param(2, "i16", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("BitcastF16toI16", next_op_idx, "BitcastF16toI16", "bitcast between different sizes", "v", "rn", [
db_dxil_param(0, "i16", "", "operation result"),
db_dxil_param(2, "h", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("BitcastI32toF32", next_op_idx, "BitcastI32toF32", "bitcast between different sizes", "v", "rn", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("BitcastF32toI32", next_op_idx, "BitcastF32toI32", "bitcast between different sizes", "v", "rn", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "f", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("BitcastI64toF64", next_op_idx, "BitcastI64toF64", "bitcast between different sizes", "v", "rn", [
db_dxil_param(0, "d", "", "operation result"),
db_dxil_param(2, "i64", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("BitcastF64toI64", next_op_idx, "BitcastF64toI64", "bitcast between different sizes", "v", "rn", [
db_dxil_param(0, "i64", "", "operation result"),
db_dxil_param(2, "d", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("LegacyF32ToF16", next_op_idx, "LegacyF32ToF16", "legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)", "v", "rn", [
db_dxil_param(0, "i32", "", "low 16 bits - half value, high 16 bits - zeroes"),
db_dxil_param(2, "f", "value", "float value to convert")])
next_op_idx += 1
self.add_dxil_op("LegacyF16ToF32", next_op_idx, "LegacyF16ToF32", "legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)", "v", "rn", [
db_dxil_param(0, "f", "", "converted float value"),
db_dxil_param(2, "i32", "value", "half value to convert")])
next_op_idx += 1
self.add_dxil_op("LegacyDoubleToFloat", next_op_idx, "LegacyDoubleToFloat", "legacy fuction to convert double to float", "v", "rn", [
db_dxil_param(0, "f", "", "float value"),
db_dxil_param(2, "d", "value", "double value to convert")])
next_op_idx += 1
self.add_dxil_op("LegacyDoubleToSInt32", next_op_idx, "LegacyDoubleToSInt32", "legacy fuction to convert double to int32", "v", "rn", [
db_dxil_param(0, "i32", "", "i32 value"),
db_dxil_param(2, "d", "value", "double value to convert")])
next_op_idx += 1
self.add_dxil_op("LegacyDoubleToUInt32", next_op_idx, "LegacyDoubleToUInt32", "legacy fuction to convert double to uint32", "v", "rn", [
db_dxil_param(0, "i32", "", "i32 value"),
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", "", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i1", "value", "input value")])
next_op_idx += 1
# WavePrefixBitCount has different signature compare to WavePrefixOp, set its opclass to WavePrefixOp is not correct.
# It works now because WavePrefixOp and WavePrefixBitCount don't interfere on overload types.
# Keep it unchanged for back-compat.
self.add_dxil_op("WavePrefixBitCount", next_op_idx, "WavePrefixOp", "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
# End of DXIL 1.0 opcodes.
self.set_op_count_for_version(1, 0, next_op_idx)
self.add_dxil_op("AttributeAtVertex", next_op_idx, "AttributeAtVertex", "returns the values of the attributes at the vertex.", "hfiw", "rn", [
db_dxil_param(0, "$o", "", "result"),
db_dxil_param(2, "i32", "inputSigId", "input signature element ID"),
db_dxil_param(3, "i32", "inputRowIndex", "row index of an input attribute"),
db_dxil_param(4, "i8", "inputColIndex", "column index of an input attribute"),
db_dxil_param(5, "i8", "VertexID", "Vertex Index")
])
next_op_idx += 1
self.add_dxil_op("ViewID", next_op_idx, "ViewID", "returns the view index", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
# End of DXIL 1.1 opcodes.
self.set_op_count_for_version(1, 1, next_op_idx)
self.add_dxil_op("RawBufferLoad", next_op_idx, "RawBufferLoad", "reads from a raw buffer and structured buffer", "hfwidl", "ro", [
db_dxil_param(0, "$r", "", "the loaded value"),
db_dxil_param(2, "res", "srv", "handle of TypedBuffer SRV to sample"),
db_dxil_param(3, "i32", "index", "element index for StructuredBuffer, or byte offset for ByteAddressBuffer"),
db_dxil_param(4, "i32", "elementOffset", "offset into element for StructuredBuffer, or undef for ByteAddressBuffer"),
db_dxil_param(5, "i8", "mask", "loading value mask", is_const=True),
db_dxil_param(6, "i32", "alignment", "relative load access alignment", is_const=True)],
counters=('tex_load',))
next_op_idx += 1
self.add_dxil_op("RawBufferStore", next_op_idx, "RawBufferStore", "writes to a RWByteAddressBuffer or RWStructuredBuffer", "hfwidl", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "uav", "handle of UAV to store to"),
db_dxil_param(3, "i32", "index", "element index for StructuredBuffer, or byte offset for ByteAddressBuffer"),
db_dxil_param(4, "i32", "elementOffset", "offset into element for StructuredBuffer, or undef for ByteAddressBuffer"),
db_dxil_param(5, "$o", "value0", "value"),
db_dxil_param(6, "$o", "value1", "value"),
db_dxil_param(7, "$o", "value2", "value"),
db_dxil_param(8, "$o", "value3", "value"),
db_dxil_param(9, "i8", "mask", "mask of contiguous components stored starting at first component (valid: 1, 3, 7, 15)", is_const=True),
db_dxil_param(10, "i32", "alignment", "relative store access alignment", is_const=True)],
counters=('tex_store',))
next_op_idx += 1
# End of DXIL 1.2 opcodes.
self.set_op_count_for_version(1, 2, next_op_idx)
assert next_op_idx == 141, "next operation index is %d rather than 141 and thus opcodes are broken" % next_op_idx
self.add_dxil_op("InstanceID", next_op_idx, "InstanceID", "The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("InstanceIndex", next_op_idx, "InstanceIndex", "The autogenerated index of the current instance in the top-level structure", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("HitKind", next_op_idx, "HitKind", "Returns the value passed as HitKind in ReportIntersection(). If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE.", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("RayFlags", next_op_idx, "RayFlags", "uint containing the current ray flags.", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("DispatchRaysIndex", next_op_idx, "DispatchRaysIndex", "The current x and y location within the Width and Height", "i", "rn", [
db_dxil_param(0, "i32", "", "result"),
db_dxil_param(2, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("DispatchRaysDimensions", next_op_idx, "DispatchRaysDimensions", "The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call.", "i", "rn", [
db_dxil_param(0, "i32", "", "result"),
db_dxil_param(2, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("WorldRayOrigin", next_op_idx, "WorldRayOrigin", "The world-space origin for the current ray.", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("WorldRayDirection", next_op_idx, "WorldRayDirection", "The world-space direction for the current ray.", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("ObjectRayOrigin", next_op_idx, "ObjectRayOrigin", "Object-space origin for the current ray.", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("ObjectRayDirection", next_op_idx, "ObjectRayDirection", "Object-space direction for the current ray.", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("ObjectToWorld", next_op_idx, "ObjectToWorld", "Matrix for transforming from object-space to world-space.", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i32", "row", "row, relative to the element"),
db_dxil_param(3, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("WorldToObject", next_op_idx, "WorldToObject", "Matrix for transforming from world-space to object-space.", "f", "rn", [
db_dxil_param(0, "f", "", "result"),
db_dxil_param(2, "i32", "row", "row, relative to the element"),
db_dxil_param(3, "i8", "col", "column, relative to the element")])
next_op_idx += 1
self.add_dxil_op("RayTMin", next_op_idx, "RayTMin", "float representing the parametric starting point for the ray.", "f", "rn", [
db_dxil_param(0, "f", "", "result")])
next_op_idx += 1
self.add_dxil_op("RayTCurrent", next_op_idx, "RayTCurrent", "float representing the current parametric ending point for the ray", "f", "ro", [
db_dxil_param(0, "f", "", "result")])
next_op_idx += 1
self.add_dxil_op("IgnoreHit", next_op_idx, "IgnoreHit", "Used in an any hit shader to reject an intersection and terminate the shader", "v", "nr", [
db_dxil_param(0, "v", "", "")])
next_op_idx += 1
self.add_dxil_op("AcceptHitAndEndSearch", next_op_idx, "AcceptHitAndEndSearch", "Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far", "v", "nr", [
db_dxil_param(0, "v", "", "")])
next_op_idx += 1
self.add_dxil_op("TraceRay", next_op_idx, "TraceRay", "initiates raytrace", "u", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "AccelerationStructure", "Top-level acceleration structure to use"),
db_dxil_param(3, "i32", "RayFlags", "Valid combination of Ray_flags"),
db_dxil_param(4, "i32", "InstanceInclusionMask", "Bottom 8 bits of InstanceInclusionMask are used to include/rejectgeometry instances based on the InstanceMask in each instance: if(!((InstanceInclusionMask & InstanceMask) & 0xff)) { ignore intersection }"),
db_dxil_param(5, "i32", "RayContributionToHitGroupIndex", "Offset to add into Addressing calculations within shader tables for hit group indexing. Only the bottom 4 bits of this value are used"),
db_dxil_param(6, "i32", "MultiplierForGeometryContributionToShaderIndex", "Stride to multiply by per-geometry GeometryContributionToHitGroupIndex in Addressing calculations within shader tables for hit group indexing. Only the bottom 4 bits of this value are used"),
db_dxil_param(7, "i32", "MissShaderIndex", "Miss shader index in Addressing calculations within shader tables. Only the bottom 16 bits of this value are used"),
db_dxil_param(8, "f", "Origin_X", "Origin x of the ray"),
db_dxil_param(9, "f", "Origin_Y", "Origin y of the ray"),
db_dxil_param(10, "f", "Origin_Z", "Origin z of the ray"),
db_dxil_param(11, "f", "TMin", "Tmin of the ray"),
db_dxil_param(12, "f", "Direction_X", "Direction x of the ray"),
db_dxil_param(13, "f", "Direction_Y", "Direction y of the ray"),
db_dxil_param(14, "f", "Direction_Z", "Direction z of the ray"),
db_dxil_param(15, "f", "TMax", "Tmax of the ray"),
db_dxil_param(16, "udt", "payload", "User-defined intersection attribute structure")])
next_op_idx += 1
self.add_dxil_op("ReportHit", next_op_idx, "ReportHit", "returns true if hit was accepted", "u", "", [
db_dxil_param(0, "i1", "", "result"),
db_dxil_param(2, "f", "THit", "parametric distance of the intersection"),
db_dxil_param(3, "i32", "HitKind", "User-specified value in range of 0-127 to identify the type of hit. Read by any_hit or closes_hit shaders with HitKind()"),
db_dxil_param(4, "udt", "Attributes", "User-defined intersection attribute structure")])
next_op_idx += 1
self.add_dxil_op("CallShader", next_op_idx, "CallShader", "Call a shader in the callable shader table supplied through the DispatchRays() API", "u", "", [
db_dxil_param(0, "v", "", "result"),
db_dxil_param(2, "i32", "ShaderIndex", "Provides index into the callable shader table supplied through the DispatchRays() API"),
db_dxil_param(3, "udt", "Parameter", "User-defined parameters to pass to the callable shader,This parameter structure must match the parameter structure used in the callable shader pointed to in the shader table")])
next_op_idx += 1
self.add_dxil_op("CreateHandleForLib", next_op_idx, "CreateHandleForLib", "create resource handle from resource struct for library", "o", "ro", [
db_dxil_param(0, "res", "", "result"),
db_dxil_param(2, "obj", "Resource", "resource to create the handle")])
next_op_idx += 1
# Maps to PrimitiveIndex() intrinsics for raytracing (same meaning as PrimitiveID)
self.add_dxil_op("PrimitiveIndex", next_op_idx, "PrimitiveIndex", "PrimitiveIndex for raytracing shaders", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
# End of DXIL 1.3 opcodes.
self.set_op_count_for_version(1, 3, next_op_idx)
assert next_op_idx == 162, "next operation index is %d rather than 162 and thus opcodes are broken" % next_op_idx
self.add_dxil_op("Dot2AddHalf", next_op_idx, "Dot2AddHalf", "2D half dot product with accumulate to float", "f", "rn", [
db_dxil_param(0, "$o", "", "accumulated result"),
db_dxil_param(2, "$o", "acc", "input accumulator"),
db_dxil_param(3, "h", "ax", "the first component of the first vector"),
db_dxil_param(4, "h", "ay", "the second component of the first vector"),
db_dxil_param(5, "h", "bx", "the first component of the second vector"),
db_dxil_param(6, "h", "by", "the second component of the second vector")],
counters=('floats',))
next_op_idx += 1
self.add_dxil_op("Dot4AddI8Packed", next_op_idx, "Dot4AddPacked", "signed dot product of 4 x i8 vectors packed into i32, with accumulate to i32", "i", "rn", [
db_dxil_param(0, "i32", "", "accumulated result"),
db_dxil_param(2, "i32", "acc", "input accumulator"),
db_dxil_param(3, "i32", "a", "first packed 4 x i8 for dot product"),
db_dxil_param(4, "i32", "b", "second packed 4 x i8 for dot product")],
counters=('ints',))
next_op_idx += 1
self.add_dxil_op("Dot4AddU8Packed", next_op_idx, "Dot4AddPacked", "unsigned dot product of 4 x u8 vectors packed into i32, with accumulate to i32", "i", "rn", [
db_dxil_param(0, "i32", "", "accumulated result"),
db_dxil_param(2, "i32", "acc", "input accumulator"),
db_dxil_param(3, "i32", "a", "first packed 4 x u8 for dot product"),
db_dxil_param(4, "i32", "b", "second packed 4 x u8 for dot product")],
counters=('uints',))
next_op_idx += 1
# End of DXIL 1.4 opcodes.
self.set_op_count_for_version(1, 4, next_op_idx)
assert next_op_idx == 165, "next operation index is %d rather than 165 and thus opcodes are broken" % next_op_idx
self.add_dxil_op("WaveMatch", next_op_idx, "WaveMatch", "returns the bitmask of active lanes that have the same value", "hfd8wil", "", [
db_dxil_param(0, "fouri32", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value")])
next_op_idx += 1
self.add_dxil_op("WaveMultiPrefixOp", next_op_idx, "WaveMultiPrefixOp", "returns the result of the operation on groups of lanes identified by a bitmask", "hfd8wil", "", [
db_dxil_param(0, "$o", "", "operation result"),
db_dxil_param(2, "$o", "value", "input value"),
db_dxil_param(3, "i32", "mask0", "mask 0"),
db_dxil_param(4, "i32", "mask1", "mask 1"),
db_dxil_param(5, "i32", "mask2", "mask 2"),
db_dxil_param(6, "i32", "mask3", "mask 3"),
db_dxil_param(7, "i8", "op", "operation", enum_name="WaveMultiPrefixOpKind", is_const=True),
db_dxil_param(8, "i8", "sop", "sign of operands", enum_name="SignedOpKind", is_const=True)])
next_op_idx += 1
self.add_enum_type("WaveMultiPrefixOpKind", "Kind of cross-lane for multi-prefix operation", [
(0, "Sum", "sum of values"),
(1, "And", "bitwise and of values"),
(2, "Or", "bitwise or of values"),
(3, "Xor", "bitwise xor of values"),
(4, "Product", "product of values")])
self.add_dxil_op("WaveMultiPrefixBitCount", next_op_idx, "WaveMultiPrefixBitCount", "returns the count of bits set to 1 on groups of lanes identified by a bitmask", "v", "", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i1", "value", "input value"),
db_dxil_param(3, "i32", "mask0", "mask 0"),
db_dxil_param(4, "i32", "mask1", "mask 1"),
db_dxil_param(5, "i32", "mask2", "mask 2"),
db_dxil_param(6, "i32", "mask3", "mask 3")])
next_op_idx += 1
# Mesh Shader
self.add_dxil_op("SetMeshOutputCounts", next_op_idx, "SetMeshOutputCounts", "Mesh shader intrinsic SetMeshOutputCounts", "v", "", [
retvoid_param,
db_dxil_param(2, "i32", "numVertices", "number of output vertices"),
db_dxil_param(3, "i32", "numPrimitives", "number of output primitives")])
next_op_idx += 1
self.add_dxil_op("EmitIndices", next_op_idx, "EmitIndices", "emit a primitive's vertex indices in a mesh shader", "v", "", [
retvoid_param,
db_dxil_param(2, "u32", "PrimitiveIndex", "a primitive's index"),
db_dxil_param(3, "u32", "VertexIndex0", "a primitive's first vertex index"),
db_dxil_param(4, "u32", "VertexIndex1", "a primitive's second vertex index"),
db_dxil_param(5, "u32", "VertexIndex2", "a primitive's third vertex index")])
next_op_idx += 1
self.add_dxil_op("GetMeshPayload", next_op_idx, "GetMeshPayload", "get the mesh payload which is from amplification shader", "u", "ro", [
db_dxil_param(0, "$o", "", "mesh payload result")])
next_op_idx += 1
self.add_dxil_op("StoreVertexOutput", next_op_idx, "StoreVertexOutput", "stores the value to mesh shader vertex output", "hfwi", "", [
retvoid_param,
db_dxil_param(2, "u32", "outputSigId", "vertex output signature element ID"),
db_dxil_param(3, "u32", "rowIndex", "row index relative to element"),
db_dxil_param(4, "u8", "colIndex", "column index relative to element"),
db_dxil_param(5, "$o", "value", "value to store"),
db_dxil_param(6, "u32", "vertexIndex", "vertex index")],
counters=('sig_st',))
next_op_idx += 1
self.add_dxil_op("StorePrimitiveOutput", next_op_idx, "StorePrimitiveOutput", "stores the value to mesh shader primitive output", "hfwi", "", [
retvoid_param,
db_dxil_param(2, "u32", "outputSigId", "primitive output signature element ID"),
db_dxil_param(3, "u32", "rowIndex", "row index relative to element"),
db_dxil_param(4, "u8", "colIndex", "column index relative to element"),
db_dxil_param(5, "$o", "value", "value to store"),
db_dxil_param(6, "u32", "primitiveIndex", "primitive index")],
counters=('sig_st',))
next_op_idx += 1
# Amplification Shader
self.add_dxil_op("DispatchMesh", next_op_idx, "DispatchMesh", "Amplification shader intrinsic DispatchMesh", "u", "", [
retvoid_param,
db_dxil_param(2, "i32", "threadGroupCountX", "thread group count x"),
db_dxil_param(3, "i32", "threadGroupCountY", "thread group count y"),
db_dxil_param(4, "i32", "threadGroupCountZ", "thread group count z"),
db_dxil_param(5, "$o", "payload", "payload")])
next_op_idx += 1
# Sampler feedback
self.add_dxil_op("WriteSamplerFeedback", next_op_idx, "WriteSamplerFeedback", "updates a feedback texture for a sampling operation", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "feedbackTex", "handle of feedback texture UAV"),
db_dxil_param(3, "res", "sampledTex", "handled of sampled texture SRV"),
db_dxil_param(4, "res", "sampler", "handle of sampler"),
db_dxil_param(5, "f", "c0", "coordinate c0"),
db_dxil_param(6, "f", "c1", "coordinate c1"),
db_dxil_param(7, "f", "c2", "coordinate c2"),
db_dxil_param(8, "f", "c3", "coordinate c3"),
db_dxil_param(9, "f", "clamp", "clamp")],
counters=('tex_store',))
next_op_idx += 1
self.add_dxil_op("WriteSamplerFeedbackBias", next_op_idx, "WriteSamplerFeedbackBias", "updates a feedback texture for a sampling operation with a bias on the mipmap level", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "feedbackTex", "handle of feedback texture UAV"),
db_dxil_param(3, "res", "sampledTex", "handled of sampled texture SRV"),
db_dxil_param(4, "res", "sampler", "handle of sampler"),
db_dxil_param(5, "f", "c0", "coordinate c0"),
db_dxil_param(6, "f", "c1", "coordinate c1"),
db_dxil_param(7, "f", "c2", "coordinate c2"),
db_dxil_param(8, "f", "c3", "coordinate c3"),
db_dxil_param(9, "f", "bias", "bias in [-16.f,15.99f]"),
db_dxil_param(10, "f", "clamp", "clamp")],
counters=('tex_store',))
next_op_idx += 1
self.add_dxil_op("WriteSamplerFeedbackLevel", next_op_idx, "WriteSamplerFeedbackLevel", "updates a feedback texture for a sampling operation with a mipmap-level offset", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "feedbackTex", "handle of feedback texture UAV"),
db_dxil_param(3, "res", "sampledTex", "handled of sampled texture SRV"),
db_dxil_param(4, "res", "sampler", "handle of sampler"),
db_dxil_param(5, "f", "c0", "coordinate c0"),
db_dxil_param(6, "f", "c1", "coordinate c1"),
db_dxil_param(7, "f", "c2", "coordinate c2"),
db_dxil_param(8, "f", "c3", "coordinate c3"),
db_dxil_param(9, "f", "lod", "LOD")],
counters=('tex_store',))
next_op_idx += 1
self.add_dxil_op("WriteSamplerFeedbackGrad", next_op_idx, "WriteSamplerFeedbackGrad", "updates a feedback texture for a sampling operation with explicit gradients", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "res", "feedbackTex", "handle of feedback texture UAV"),
db_dxil_param(3, "res", "sampledTex", "handled of sampled texture SRV"),
db_dxil_param(4, "res", "sampler", "handle of sampler"),
db_dxil_param(5, "f", "c0", "coordinate c0"),
db_dxil_param(6, "f", "c1", "coordinate c1"),
db_dxil_param(7, "f", "c2", "coordinate c2"),
db_dxil_param(8, "f", "c3", "coordinate c3"),
db_dxil_param(9, "f", "ddx0", "rate of change of coordinate c0 in the x direction"),
db_dxil_param(10, "f", "ddx1", "rate of change of coordinate c1 in the x direction"),
db_dxil_param(11, "f", "ddx2", "rate of change of coordinate c2 in the x direction"),
db_dxil_param(12, "f", "ddy0", "rate of change of coordinate c0 in the y direction"),
db_dxil_param(13, "f", "ddy1", "rate of change of coordinate c1 in the y direction"),
db_dxil_param(14, "f", "ddy2", "rate of change of coordinate c2 in the y direction"),
db_dxil_param(15, "f", "clamp", "clamp")],
counters=('tex_store',))
next_op_idx += 1
# RayQuery
self.add_dxil_op("AllocateRayQuery", next_op_idx, "AllocateRayQuery", "allocates space for RayQuery and return handle", "v", "", [
db_dxil_param(0, "i32", "", "handle to RayQuery state"),
db_dxil_param(2, "u32", "constRayFlags", "Valid combination of RAY_FLAGS", is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_TraceRayInline", next_op_idx, "RayQuery_TraceRayInline", "initializes RayQuery for raytrace", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "res", "accelerationStructure", "Top-level acceleration structure to use"),
db_dxil_param(4, "i32", "rayFlags", "Valid combination of RAY_FLAGS, combined with constRayFlags provided to AllocateRayQuery"),
db_dxil_param(5, "i32", "instanceInclusionMask", "Bottom 8 bits of InstanceInclusionMask are used to include/rejectgeometry instances based on the InstanceMask in each instance: if(!((InstanceInclusionMask & InstanceMask) & 0xff)) { ignore intersection }"),
db_dxil_param(6, "f", "origin_X", "Origin x of the ray"),
db_dxil_param(7, "f", "origin_Y", "Origin y of the ray"),
db_dxil_param(8, "f", "origin_Z", "Origin z of the ray"),
db_dxil_param(9, "f", "tMin", "Tmin of the ray"),
db_dxil_param(10, "f", "direction_X", "Direction x of the ray"),
db_dxil_param(11, "f", "direction_Y", "Direction y of the ray"),
db_dxil_param(12, "f", "direction_Z", "Direction z of the ray"),
db_dxil_param(13, "f", "tMax", "Tmax of the ray")])
next_op_idx += 1
self.add_dxil_op("RayQuery_Proceed", next_op_idx, "RayQuery_Proceed", "advances a ray query", "1", "", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_Abort", next_op_idx, "RayQuery_Abort", "aborts a ray query", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommitNonOpaqueTriangleHit", next_op_idx, "RayQuery_CommitNonOpaqueTriangleHit", "commits a non opaque triangle hit", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommitProceduralPrimitiveHit", next_op_idx, "RayQuery_CommitProceduralPrimitiveHit", "commits a procedural primitive hit", "v", "", [
db_dxil_param(0, "v", "", ""),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "f", "t", "Procedural primitive hit distance (t) to commit.")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedStatus", next_op_idx, "RayQuery_StateScalar", "returns uint status (COMMITTED_STATUS) of the committed hit in a ray query", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateType", next_op_idx, "RayQuery_StateScalar", "returns uint candidate type (CANDIDATE_TYPE) of the current hit candidate in a ray query, after Proceed() has returned true", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateObjectToWorld3x4", next_op_idx, "RayQuery_StateMatrix", "returns matrix for transforming from object-space to world-space for a candidate hit.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i32", "row", "row [0..2], relative to the element"),
db_dxil_param(4, "i8", "col", "column [0..3], relative to the element")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateWorldToObject3x4", next_op_idx, "RayQuery_StateMatrix", "returns matrix for transforming from world-space to object-space for a candidate hit.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i32", "row", "row [0..2], relative to the element"),
db_dxil_param(4, "i8", "col", "column [0..3], relative to the element")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedObjectToWorld3x4", next_op_idx, "RayQuery_StateMatrix", "returns matrix for transforming from object-space to world-space for a Committed hit.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i32", "row", "row [0..2], relative to the element"),
db_dxil_param(4, "i8", "col", "column [0..3], relative to the element")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedWorldToObject3x4", next_op_idx, "RayQuery_StateMatrix", "returns matrix for transforming from world-space to object-space for a Committed hit.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i32", "row", "row [0..2], relative to the element"),
db_dxil_param(4, "i8", "col", "column [0..3], relative to the element")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateProceduralPrimitiveNonOpaque", next_op_idx, "RayQuery_StateScalar", "returns if current candidate procedural primitive is non opaque", "1", "ro", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateTriangleFrontFace", next_op_idx, "RayQuery_StateScalar", "returns if current candidate triangle is front facing", "1", "ro", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedTriangleFrontFace", next_op_idx, "RayQuery_StateScalar", "returns if current committed triangle is front facing", "1", "ro", [
db_dxil_param(0, "i1", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateTriangleBarycentrics", next_op_idx, "RayQuery_StateVector", "returns candidate triangle hit barycentrics", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedTriangleBarycentrics", next_op_idx, "RayQuery_StateVector", "returns committed triangle hit barycentrics", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_RayFlags", next_op_idx, "RayQuery_StateScalar", "returns ray flags", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_WorldRayOrigin", next_op_idx, "RayQuery_StateVector", "returns world ray origin", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_WorldRayDirection", next_op_idx, "RayQuery_StateVector", "returns world ray direction", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_RayTMin", next_op_idx, "RayQuery_StateScalar", "returns float representing the parametric starting point for the ray.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateTriangleRayT", next_op_idx, "RayQuery_StateScalar", "returns float representing the parametric point on the ray for the current candidate triangle hit.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedRayT", next_op_idx, "RayQuery_StateScalar", "returns float representing the parametric point on the ray for the current committed hit.", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateInstanceIndex", next_op_idx, "RayQuery_StateScalar", "returns candidate hit instance index", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateInstanceID", next_op_idx, "RayQuery_StateScalar", "returns candidate hit instance ID", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateGeometryIndex", next_op_idx, "RayQuery_StateScalar", "returns candidate hit geometry index", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidatePrimitiveIndex", next_op_idx, "RayQuery_StateScalar", "returns candidate hit geometry index", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateObjectRayOrigin", next_op_idx, "RayQuery_StateVector", "returns candidate hit object ray origin", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateObjectRayDirection", next_op_idx, "RayQuery_StateVector", "returns candidate object ray direction", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedInstanceIndex", next_op_idx, "RayQuery_StateScalar", "returns committed hit instance index", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedInstanceID", next_op_idx, "RayQuery_StateScalar", "returns committed hit instance ID", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedGeometryIndex", next_op_idx, "RayQuery_StateScalar", "returns committed hit geometry index", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedPrimitiveIndex", next_op_idx, "RayQuery_StateScalar", "returns committed hit geometry index", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedObjectRayOrigin", next_op_idx, "RayQuery_StateVector", "returns committed hit object ray origin", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedObjectRayDirection", next_op_idx, "RayQuery_StateVector", "returns committed object ray direction", "f", "ro", [
db_dxil_param(0, "f", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
next_op_idx += 1
self.add_dxil_op("GeometryIndex", next_op_idx, "GeometryIndex", "The autogenerated index of the current geometry in the bottom-level structure", "i", "rn", [
db_dxil_param(0, "i32", "", "result")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CandidateInstanceContributionToHitGroupIndex", next_op_idx, "RayQuery_StateScalar", "returns candidate hit InstanceContributionToHitGroupIndex", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
self.add_dxil_op("RayQuery_CommittedInstanceContributionToHitGroupIndex", next_op_idx, "RayQuery_StateScalar", "returns committed hit InstanceContributionToHitGroupIndex", "i", "ro", [
db_dxil_param(0, "i32", "", "operation result"),
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle")])
next_op_idx += 1
# End of DXIL 1.5 opcodes.
self.set_op_count_for_version(1, 5, next_op_idx)
assert next_op_idx == 216, "216 is expected next operation index but encountered %d and thus opcodes are broken" % next_op_idx
self.add_dxil_op("AnnotateHandle", next_op_idx, "AnnotateHandle", "annotate handle with resource properties", "v", "rn", [
db_dxil_param(0, "res", "", "annotated handle"),
db_dxil_param(2, "res", "res", "input handle"),
db_dxil_param(3, "resproperty", "props", "details like component type, strutrure stride...", is_const=True)])
next_op_idx += 1
self.add_dxil_op("CreateHandleFromBinding", next_op_idx, "CreateHandleFromBinding", "create resource handle from binding", "v", "rn", [
db_dxil_param(0, "res", "", "result"),
db_dxil_param(2, "resbind", "bind", "resource binding", is_const=True), #{ rangeLowerBound, rangeUpperBound, spaceID, resourceClass }
db_dxil_param(3, "i32", "index", "index"),
db_dxil_param(4, "i1", "nonUniformIndex", "non-uniform resource index", is_const=True)])
next_op_idx += 1
self.add_dxil_op("CreateHandleFromHeap", next_op_idx, "CreateHandleFromHeap", "create resource handle from heap", "v", "rn", [
db_dxil_param(0, "res", "", "result"),
db_dxil_param(2, "i32", "index", "heap index"),
db_dxil_param(3, "i1", "samplerHeap", "If samplerHeap is 1, the heap indexed is the sampler descriptor heap, otherwise it is the CBV_SRV_UAV (resource) descriptor heap", is_const=True),
db_dxil_param(4, "i1", "nonUniformIndex", "non-uniform resource index", is_const=True)])
next_op_idx += 1
self.add_dxil_op("Unpack4x8", next_op_idx, "Unpack4x8", "unpacks 4 8-bit signed or unsigned values into int32 or int16 vector", "iw", "rn", [
db_dxil_param(0, "$vec4", "", "result"),
db_dxil_param(2, "i8", "unpackMode", "signed/unsigned"),
db_dxil_param(3, "i32", "pk", "packed 4 x i8")])
next_op_idx += 1
self.add_dxil_op("Pack4x8", next_op_idx, "Pack4x8", "packs vector of 4 signed or unsigned values into a packed datatype, drops or clamps unused bits", "iw", "rn", [
db_dxil_param(0, "i32", "", "result packed 4 x i8"),
db_dxil_param(2, "i8", "packMode", "trunc/unsigned clamp/signed clamp"),
db_dxil_param(3, "$o", "x", "the first component of the vector"),
db_dxil_param(4, "$o", "y", "the second component of the vector"),
db_dxil_param(5, "$o", "z", "the third component of the vector"),
db_dxil_param(6, "$o", "w", "the fourth component of the vector")])
next_op_idx += 1
self.add_dxil_op("IsHelperLane", next_op_idx, "IsHelperLane", "returns true on helper lanes in pixel shaders", "1", "ro", [
db_dxil_param(0, "i1", "", "result")])
next_op_idx += 1
# End of DXIL 1.6 opcodes.
self.set_op_count_for_version(1, 6, next_op_idx)
assert next_op_idx == 222, "222 is expected next operation index but encountered %d and thus opcodes are broken" % next_op_idx
# Set interesting properties.
self.build_indices()
for i in "CalculateLOD,DerivCoarseX,DerivCoarseY,DerivFineX,DerivFineY,Sample,SampleBias,SampleCmp".split(","):
self.name_idx[i].is_gradient = True
for i in "DerivCoarseX,DerivCoarseY,DerivFineX,DerivFineY".split(","):
assert self.name_idx[i].is_gradient == True, "all derivatives are marked as requiring gradients"
self.name_idx[i].is_deriv = True
# TODO - some arguments are required to be immediate constants in DXIL, eg resource kinds; add this information
# consider - report instructions that are overloaded on a single type, then turn them into non-overloaded version of that type
self.verify_dense(self.get_dxil_insts(), lambda x : x.dxil_opid, lambda x : x.name)
for i in self.instr:
self.verify_dense(i.ops, lambda x : x.pos, lambda x : i.name)
for i in self.instr:
if i.is_dxil_op:
assert i.oload_types != "", "overload for DXIL operation %s should not be empty - use void if n/a" % (i.name)
assert i.oload_types == "v" or i.oload_types.find("v") < 0, "void overload should be exclusive to other types (%s)" % i.name
assert type(i.oload_types) is str, "overload for %s should be a string - use empty if n/a" % (i.name)
# Verify that all operations in each class have the same signature.
import itertools
class_sort_func = lambda x, y: x < y
class_key_func = lambda x : x.dxil_class
instr_ordered_by_class = sorted([i for i in self.instr if i.is_dxil_op], key=class_key_func)
instr_grouped_by_class = itertools.groupby(instr_ordered_by_class, key=class_key_func)
def calc_oload_sig(inst):
result = ""
for o in inst.ops:
result += o.llvm_type
return result
for k, g in instr_grouped_by_class:
group = list(g)
if len(group) > 1:
first = group[0]
first_group = calc_oload_sig(first)
for other in group[1:]:
other_group = calc_oload_sig(other)