From 12fc6a98352b65f0cfcfdef3d7882cd404adc9d3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 27 May 2024 13:51:49 +0100 Subject: [PATCH] Use dxc-faithful intrinsic signatures for dxc disassembly --- .../driver/shaders/dxil/dxil_disassemble.cpp | 265 +++++++++++++++++- 1 file changed, 263 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp index 5743a1815..db22d6629 100644 --- a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp @@ -367,6 +367,267 @@ static const char *dxOpFunctionNames[] = { "dx.op.startInstanceLocation", }; +static const char *dxcOpNames[] = { +"TempRegLoad(index)", +"TempRegStore(index,value)", +"MinPrecXRegLoad(regIndex,index,component)", +"MinPrecXRegStore(regIndex,index,component,value)", +"LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis)", +"StoreOutput(outputSigId,rowIndex,colIndex,value)", +"FAbs(value)", +"Saturate(value)", +"IsNaN(value)", +"IsInf(value)", +"IsFinite(value)", +"IsNormal(value)", +"Cos(value)", +"Sin(value)", +"Tan(value)", +"Acos(value)", +"Asin(value)", +"Atan(value)", +"Hcos(value)", +"Hsin(value)", +"Htan(value)", +"Exp(value)", +"Frc(value)", +"Log(value)", +"Sqrt(value)", +"Rsqrt(value)", +"Round_ne(value)", +"Round_ni(value)", +"Round_pi(value)", +"Round_z(value)", +"Bfrev(value)", +"Countbits(value)", +"FirstbitLo(value)", +"FirstbitHi(value)", +"FirstbitSHi(value)", +"FMax(a,b)", +"FMin(a,b)", +"IMax(a,b)", +"IMin(a,b)", +"UMax(a,b)", +"UMin(a,b)", +"IMul(a,b)", +"UMul(a,b)", +"UDiv(a,b)", +"UAddc(a,b)", +"USubb(a,b)", +"FMad(a,b,c)", +"Fma(a,b,c)", +"IMad(a,b,c)", +"UMad(a,b,c)", +"Msad(a,b,c)", +"Ibfe(a,b,c)", +"Ubfe(a,b,c)", +"Bfi(width,offset,value,replacedValue)", +"Dot2(ax,ay,bx,by)", +"Dot3(ax,ay,az,bx,by,bz)", +"Dot4(ax,ay,az,aw,bx,by,bz,bw)", +"CreateHandle(resourceClass,rangeId,index,nonUniformIndex)", +"CBufferLoad(handle,byteOffset,alignment)", +"CBufferLoadLegacy(handle,regIndex)", +"Sample(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,clamp)", +"SampleBias(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,bias,clamp)", +"SampleLevel(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,LOD)", +"SampleGrad(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,ddx0,ddx1,ddx2,ddy0,ddy1,ddy2,clamp)", +"SampleCmp(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,compareValue,clamp)", +"SampleCmpLevelZero(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,compareValue)", +"TextureLoad(srv,mipLevelOrSampleCount,coord0,coord1,coord2,offset0,offset1,offset2)", +"TextureStore(srv,coord0,coord1,coord2,value0,value1,value2,value3,mask)", +"BufferLoad(srv,index,wot)", +"BufferStore(uav,coord0,coord1,value0,value1,value2,value3,mask)", +"BufferUpdateCounter(uav,inc)", +"CheckAccessFullyMapped(status)", +"GetDimensions(handle,mipLevel)", +"TextureGather(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,channel)", +"TextureGatherCmp(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,channel,compareValue)", +"Texture2DMSGetSamplePosition(srv,index)", +"RenderTargetGetSamplePosition(index)", +"RenderTargetGetSampleCount()", +"AtomicBinOp(handle,atomicOp,offset0,offset1,offset2,newValue)", +"AtomicCompareExchange(handle,offset0,offset1,offset2,compareValue,newValue)", +"Barrier(barrierMode)", +"CalculateLOD(handle,sampler,coord0,coord1,coord2,clamped)", +"Discard(condition)", +"DerivCoarseX(value)", +"DerivCoarseY(value)", +"DerivFineX(value)", +"DerivFineY(value)", +"EvalSnapped(inputSigId,inputRowIndex,inputColIndex,offsetX,offsetY)", +"EvalSampleIndex(inputSigId,inputRowIndex,inputColIndex,sampleIndex)", +"EvalCentroid(inputSigId,inputRowIndex,inputColIndex)", +"SampleIndex()", +"Coverage()", +"InnerCoverage()", +"ThreadId(component)", +"GroupId(component)", +"ThreadIdInGroup(component)", +"FlattenedThreadIdInGroup()", +"EmitStream(streamId)", +"CutStream(streamId)", +"EmitThenCutStream(streamId)", +"GSInstanceID()", +"MakeDouble(lo,hi)", +"SplitDouble(value)", +"LoadOutputControlPoint(inputSigId,row,col,index)", +"LoadPatchConstant(inputSigId,row,col)", +"DomainLocation(component)", +"StorePatchConstant(outputSigID,row,col,value)", +"OutputControlPointID()", +"PrimitiveID()", +"CycleCounterLegacy()", +"WaveIsFirstLane()", +"WaveGetLaneIndex()", +"WaveGetLaneCount()", +"WaveAnyTrue(cond)", +"WaveAllTrue(cond)", +"WaveActiveAllEqual(value)", +"WaveActiveBallot(cond)", +"WaveReadLaneAt(value,lane)", +"WaveReadLaneFirst(value)", +"WaveActiveOp(value,op,sop)", +"WaveActiveBit(value,op)", +"WavePrefixOp(value,op,sop)", +"QuadReadLaneAt(value,quadLane)", +"QuadOp(value,op)", +"BitcastI16toF16(value)", +"BitcastF16toI16(value)", +"BitcastI32toF32(value)", +"BitcastF32toI32(value)", +"BitcastI64toF64(value)", +"BitcastF64toI64(value)", +"LegacyF32ToF16(value)", +"LegacyF16ToF32(value)", +"LegacyDoubleToFloat(value)", +"LegacyDoubleToSInt32(value)", +"LegacyDoubleToUInt32(value)", +"WaveAllBitCount(value)", +"WavePrefixBitCount(value)", +"AttributeAtVertex(inputSigId,inputRowIndex,inputColIndex,VertexID)", +"ViewID()", +"RawBufferLoad(srv,index,elementOffset,mask,alignment)", +"RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)", +"InstanceID()", +"InstanceIndex()", +"HitKind()", +"RayFlags()", +"DispatchRaysIndex(col)", +"DispatchRaysDimensions(col)", +"WorldRayOrigin(col)", +"WorldRayDirection(col)", +"ObjectRayOrigin(col)", +"ObjectRayDirection(col)", +"ObjectToWorld(row,col)", +"WorldToObject(row,col)", +"RayTMin()", +"RayTCurrent()", +"IgnoreHit()", +"AcceptHitAndEndSearch()", +"TraceRay(AccelerationStructure,RayFlags,InstanceInclusionMask,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToShaderIndex,MissShaderIndex,Origin_X,Origin_Y,Origin_Z,TMin,Direction_X,Direction_Y,Direction_Z,TMax,payload)", +"ReportHit(THit,HitKind,Attributes)", +"CallShader(ShaderIndex,Parameter)", +"CreateHandleForLib(Resource)", +"PrimitiveIndex()", +"Dot2AddHalf(acc,ax,ay,bx,by)", +"Dot4AddI8Packed(acc,a,b)", +"Dot4AddU8Packed(acc,a,b)", +"WaveMatch(value)", +"WaveMultiPrefixOp(value,mask0,mask1,mask2,mask3,op,sop)", +"WaveMultiPrefixBitCount(value,mask0,mask1,mask2,mask3)", +"SetMeshOutputCounts(numVertices,numPrimitives)", +"EmitIndices(PrimitiveIndex,VertexIndex0,VertexIndex1,VertexIndex2)", +"GetMeshPayload()", +"StoreVertexOutput(outputSigId,rowIndex,colIndex,value,vertexIndex)", +"StorePrimitiveOutput(outputSigId,rowIndex,colIndex,value,primitiveIndex)", +"DispatchMesh(threadGroupCountX,threadGroupCountY,threadGroupCountZ,payload)", +"WriteSamplerFeedback(feedbackTex,sampledTex,sampler,c0,c1,c2,c3,clamp)", +"WriteSamplerFeedbackBias(feedbackTex,sampledTex,sampler,c0,c1,c2,c3,bias,clamp)", +"WriteSamplerFeedbackLevel(feedbackTex,sampledTex,sampler,c0,c1,c2,c3,lod)", +"WriteSamplerFeedbackGrad(feedbackTex,sampledTex,sampler,c0,c1,c2,c3,ddx0,ddx1,ddx2,ddy0,ddy1,ddy2,clamp)", +"AllocateRayQuery(constRayFlags)", +"RayQuery_TraceRayInline(rayQueryHandle,accelerationStructure,rayFlags,instanceInclusionMask,origin_X,origin_Y,origin_Z,tMin,direction_X,direction_Y,direction_Z,tMax)", +"RayQuery_Proceed(rayQueryHandle)", +"RayQuery_Abort(rayQueryHandle)", +"RayQuery_CommitNonOpaqueTriangleHit(rayQueryHandle)", +"RayQuery_CommitProceduralPrimitiveHit(rayQueryHandle,t)", +"RayQuery_CommittedStatus(rayQueryHandle)", +"RayQuery_CandidateType(rayQueryHandle)", +"RayQuery_CandidateObjectToWorld3x4(rayQueryHandle,row,col)", +"RayQuery_CandidateWorldToObject3x4(rayQueryHandle,row,col)", +"RayQuery_CommittedObjectToWorld3x4(rayQueryHandle,row,col)", +"RayQuery_CommittedWorldToObject3x4(rayQueryHandle,row,col)", +"RayQuery_CandidateProceduralPrimitiveNonOpaque(rayQueryHandle)", +"RayQuery_CandidateTriangleFrontFace(rayQueryHandle)", +"RayQuery_CommittedTriangleFrontFace(rayQueryHandle)", +"RayQuery_CandidateTriangleBarycentrics(rayQueryHandle,component)", +"RayQuery_CommittedTriangleBarycentrics(rayQueryHandle,component)", +"RayQuery_RayFlags(rayQueryHandle)", +"RayQuery_WorldRayOrigin(rayQueryHandle,component)", +"RayQuery_WorldRayDirection(rayQueryHandle,component)", +"RayQuery_RayTMin(rayQueryHandle)", +"RayQuery_CandidateTriangleRayT(rayQueryHandle)", +"RayQuery_CommittedRayT(rayQueryHandle)", +"RayQuery_CandidateInstanceIndex(rayQueryHandle)", +"RayQuery_CandidateInstanceID(rayQueryHandle)", +"RayQuery_CandidateGeometryIndex(rayQueryHandle)", +"RayQuery_CandidatePrimitiveIndex(rayQueryHandle)", +"RayQuery_CandidateObjectRayOrigin(rayQueryHandle,component)", +"RayQuery_CandidateObjectRayDirection(rayQueryHandle,component)", +"RayQuery_CommittedInstanceIndex(rayQueryHandle)", +"RayQuery_CommittedInstanceID(rayQueryHandle)", +"RayQuery_CommittedGeometryIndex(rayQueryHandle)", +"RayQuery_CommittedPrimitiveIndex(rayQueryHandle)", +"RayQuery_CommittedObjectRayOrigin(rayQueryHandle,component)", +"RayQuery_CommittedObjectRayDirection(rayQueryHandle,component)", +"GeometryIndex()", +"RayQuery_CandidateInstanceContributionToHitGroupIndex(rayQueryHandle)", +"RayQuery_CommittedInstanceContributionToHitGroupIndex(rayQueryHandle)", +"AnnotateHandle(res,props)", +"CreateHandleFromBinding(bind,index,nonUniformIndex)", +"CreateHandleFromHeap(index,samplerHeap,nonUniformIndex)", +"Unpack4x8(unpackMode,pk)", +"Pack4x8(packMode,x,y,z,w)", +"IsHelperLane()", +"QuadVote(cond,op)", +"TextureGatherRaw(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1)", +"SampleCmpLevel(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,compareValue,lod)", +"TextureStoreSample(srv,coord0,coord1,coord2,value0,value1,value2,value3,mask,sampleIdx)", +"WaveMatrix_Annotate(waveMatrixPtr,waveMatProps)", +"WaveMatrix_Depth(waveMatProps)", +"WaveMatrix_Fill(waveMatrixPtr,value)", +"WaveMatrix_LoadRawBuf(waveMatrixPtr,rawBuf,offsetInBytes,strideInBytes,alignmentInBytes,colMajor)", +"WaveMatrix_LoadGroupShared(waveMatrixPtr,groupsharedPtr,startArrayIndex,strideInElements,colMajor)", +"WaveMatrix_StoreRawBuf(waveMatrixPtr,rawBuf,offsetInBytes,strideInBytes,alignmentInBytes,colMajor)", +"WaveMatrix_StoreGroupShared(waveMatrixPtr,groupsharedPtr,startArrayIndex,strideInElements,colMajor)", +"WaveMatrix_Multiply(waveMatrixAccumulator,waveMatrixLeft,waveMatrixRight)", +"WaveMatrix_MultiplyAccumulate(waveMatrixAccumulator,waveMatrixLeft,waveMatrixRight)", +"WaveMatrix_ScalarOp(waveMatrixPtr,op,value)", +"WaveMatrix_SumAccumulate(waveMatrixFragment,waveMatrixInput)", +"WaveMatrix_Add(waveMatrixAccumulator,waveMatrixAccumulatorOrFragment)", +"AllocateNodeOutputRecords(output,numRecords,perThread)", +"GetNodeRecordPtr(recordhandle,arrayIndex)", +"IncrementOutputCount(output,count,perThread)", +"OutputComplete(output)", +"GetInputRecordCount(input)", +"FinishedCrossGroupSharing(input)", +"BarrierByMemoryType(MemoryTypeFlags,SemanticFlags)", +"BarrierByMemoryHandle(object,SemanticFlags)", +"BarrierByNodeRecordHandle(object,SemanticFlags)", +"CreateNodeOutputHandle(MetadataIdx)", +"IndexNodeHandle(NodeOutputHandle,ArrayIndex)", +"AnnotateNodeHandle(node,props)", +"CreateNodeInputRecordHandle(MetadataIdx)", +"AnnotateNodeRecordHandle(noderecord,props)", +"NodeOutputIsValid(output)", +"GetRemainingRecursionLevels()", +"SampleCmpGrad(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,compareValue,ddx0,ddx1,ddx2,ddy0,ddy1,ddy2,clamp)", +"SampleCmpBias(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,offset2,compareValue,bias,clamp)", +"StartVertexLocation()", +"StartInstanceLocation()", +}; + static const char *funcNameSigs[] = { "TempRegLoad(index)", "TempRegStore(index,value)", @@ -2011,10 +2272,10 @@ void Program::MakeDXCDisassemblyString() if(Constant *op = cast(inst.args[0])) { uint32_t opcode = op->getU32(); - if(opcode < ARRAY_COUNT(funcNameSigs)) + if(opcode < ARRAY_COUNT(dxcOpNames)) { m_Disassembly += " ; "; - m_Disassembly += funcNameSigs[opcode]; + m_Disassembly += dxcOpNames[opcode]; } } }