我有一个奇怪的问题只发生在我的 Intel HD Graphics 530 上
渲染图像时,某些像素的颜色会随机变化。见下图: 错误
对于有问题的像素,图形调试器显示图形管道输出的颜色是正确的。但是像素显示的颜色是错误的。请参阅:调试器
根据我的调查,我发现这些像素似乎使用了其他像素的信息。我的材料信息由描述符堆处理。所以在我的渲染循环中图形根描述符表之间的切换似乎是我的问题(当我只绘制一个对象时一切都很好)
这是我使用的代码片段:
void ForwardLighningEffect::pushCommands(ForwardLigthningPushArgs data, ID3D12GraphicsCommandList* commandList, int frameIndex) {
// set PSO
commandList->SetPipelineState(m_mainPipelineStateObject);
// set root signature
commandList->SetGraphicsRootSignature(m_rootSignature);
// set constant buffer view
commandList->SetGraphicsRootConstantBufferView(0, m_constantBufferUploadHeaps[frameIndex]->GetGPUVirtualAddress());
const auto& meshes = data.model->getMeshes();
for (auto mesh : meshes)
{
if (auto materialHandle = mesh->material.lock()) // get material handle from weak ptr.
{
ID3D12DescriptorHeap * matDescriptorHeap = materialHandle->material.descriptorHeap;
// set the material descriptor heap
ID3D12DescriptorHeap* descriptorHeaps[] = { matDescriptorHeap };
commandList->SetDescriptorHeaps(_countof(descriptorHeaps), descriptorHeaps);
// HERE ! set the descriptor table to the descriptor heap (parameter 1, as constant buffer root descriptor is parameter index 0)
commandList->SetGraphicsRootDescriptorTable(1, matDescriptorHeap->GetGPUDescriptorHandleForHeapStart());
}
commandList->IASetVertexBuffers(0, 1, &mesh->vertexBuffer.bufferView);
commandList->IASetIndexBuffer(&mesh->indexBuffer.bufferView);
for (auto camera : data.cameras)
{
updateConstantBuffer(camera, frameIndex);
// Draw mesh.
commandList->DrawIndexedInstanced(mesh->nbIndices, 1, 0, 0, 0);
}
}
}
怎么了 ?