PIX pixel-cost visualizer: Fix byte offset, simplify ReEmitDxilResources (#749)

* byte offset, not element offset => multiply by sizeof(dword)
set uav to r/w
Re-emit meta-data becomes delete then emit

* update test

* re-compute view id state
This commit is contained in:
Jeff Noyle 2017-10-31 13:37:07 -07:00 коммит произвёл GitHub
Родитель 3563ae9c5a
Коммит 0acdbd9a8c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 6 добавлений и 19 удалений

Просмотреть файл

@ -143,6 +143,7 @@ bool DxilAddPixelHitInstrumentation::runOnModule(Module &M)
pUAV->SetLowerBound(0);
pUAV->SetRangeSize(1);
pUAV->SetKind(DXIL::ResourceKind::RawBuffer);
pUAV->SetRW(true);
auto pAnnotation = DM.GetTypeSystem().GetStructAnnotation(UAVStructTy);
if (pAnnotation == nullptr)
@ -247,7 +248,7 @@ bool DxilAddPixelHitInstrumentation::runOnModule(Module &M)
{
Function* LoadWeight = HlslOP->GetOpFunc(OP::OpCode::BufferLoad, Type::getInt32Ty(Ctx));
Constant* LoadWeightOpcode = HlslOP->GetU32Const((unsigned)DXIL::OpCode::BufferLoad);
Constant* OffsetIntoUAV = HlslOP->GetU32Const(NumPixels * 2);
Constant* OffsetIntoUAV = HlslOP->GetU32Const(NumPixels * 2 * 4);
auto WeightStruct = Builder.CreateCall(LoadWeight, {
LoadWeightOpcode, // i32 opcode
HandleForUAV, // %dx.types.Handle, ; resource handle

Просмотреть файл

@ -1393,23 +1393,9 @@ MDTuple *DxilModule::EmitDxilResources() {
}
void DxilModule::ReEmitDxilResources() {
MDTuple *pNewResource = EmitDxilResources();
m_pMDHelper->UpdateDxilResources(pNewResource);
m_pMDHelper->EmitDxilTypeSystem(GetTypeSystem(), m_LLVMUsed);
const llvm::NamedMDNode *pEntries = m_pMDHelper->GetDxilEntryPoints();
IFTBOOL(pEntries->getNumOperands() == 1, DXC_E_INCORRECT_DXIL_METADATA);
Function *pEntryFunc;
string EntryName;
const llvm::MDOperand *pSignatures, *pResources, *pProperties;
m_pMDHelper->GetDxilEntryPoint(pEntries->getOperand(0), pEntryFunc, EntryName, pSignatures, pResources, pProperties);
MDTuple *pMDSignatures = m_pMDHelper->EmitDxilSignatures(*m_EntrySignature);
MDTuple *pMDProperties = EmitDxilShaderProperties();
MDTuple *pEntry = m_pMDHelper->EmitDxilEntryPointTuple(pEntryFunc, EntryName, pMDSignatures, pNewResource, pMDProperties);
vector<MDNode *> Entries;
Entries.emplace_back(pEntry);
m_pMDHelper->UpdateDxilEntryPoints(Entries);
ClearDxilMetadata(*m_pModule);
m_pViewIdState->Compute();
EmitDxilMetadata();
}
void DxilModule::LoadDxilResources(const llvm::MDOperand &MDO) {

Просмотреть файл

@ -4,7 +4,7 @@
// CHECK: %UAVIncResult = call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 0, i32 %ByteIndex, i32 undef, i32 undef, i32 1)
// Check for pixel cost instructions:
// CHECK: %WeightStruct = call %dx.types.ResRet.i32 @dx.op.bufferLoad.i32(i32 68, %dx.types.Handle %PIX_CountUAV_Handle, i32 128, i32 undef)
// CHECK: %WeightStruct = call %dx.types.ResRet.i32 @dx.op.bufferLoad.i32(i32 68, %dx.types.Handle %PIX_CountUAV_Handle, i32 512, i32 undef)
// CHECK: %Weight = extractvalue %dx.types.ResRet.i32 %WeightStruct, 0
// CHECK: %OffsetByteIndex = add i32 %ByteIndex, 256
// CHECK: %UAVIncResult2 = call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 0, i32 %OffsetByteIndex, i32 undef, i32 undef, i32 %Weight)