I removed this text from the cpp help chat and posted it here so it doesn't disapear. The issue is that the retHandle variable doesn't get updated inside the GetNewSlot() method. I can see inside the GetDescriptorHandles() function that the debugger jumps to the return-statement upon entry, but then it jumps back up to the start of the method and runs it. I can also see inside the SetHeapIndex() method that the member variable "heapIndex" is updated to the input value "slotIndex". But once the method exits the objects member variables get reset to garbage values. What have I missed here?
{
std::vector<DescriptorHandle> handles;
for (int i = 0; i < _numHandles; i++)
handles.emplace_back(GetNewSlot());
return handles;
}
DescriptorHandle HiddenDescriptorHeap::GetNewSlot()
{
DescriptorHandle retHandle;
int slotIndex = descriptorSlots.LendKey();
D3D12_CPU_DESCRIPTOR_HANDLE handleCPUAddress = handle.GetCPUHandle();
handleCPUAddress.ptr += (SIZE_T)(slotIndex * descriptorSize);
retHandle.SetHeapIndex(slotIndex);
retHandle.SetHandle(handleCPUAddress);
return retHandle;
}
void DescriptorHandle::SetHeapIndex(int _index) { heapIndex = _index; }