コード例 #1
0
void FD3D12BuddyAllocator::Initialize()
{
	FD3D12Device* Device = GetParentDevice();
	FD3D12Adapter* Adapter = Device->GetParentAdapter();

	if (AllocationStrategy == eBuddyAllocationStrategy::kPlacedResourceStrategy)
	{
		D3D12_HEAP_PROPERTIES HeapProps = CD3DX12_HEAP_PROPERTIES(HeapType);
		HeapProps.CreationNodeMask = GetNodeMask();
		HeapProps.VisibleNodeMask = GetVisibilityMask();

		D3D12_HEAP_DESC Desc = {};
		Desc.SizeInBytes = MaxBlockSize;
		Desc.Properties = HeapProps;
		Desc.Alignment = 0;
		Desc.Flags = HeapFlags;

		ID3D12Heap* Heap = nullptr;
		VERIFYD3D12RESULT(Adapter->GetD3DDevice()->CreateHeap(&Desc, IID_PPV_ARGS(&Heap)));
		SetName(Heap, L"Placed Resource Allocator Backing Heap");

		BackingHeap = new FD3D12Heap(GetParentDevice(), GetVisibilityMask());
		BackingHeap->SetHeap(Heap);

		if (IsCPUWritable(HeapType) == false)
		{
			BackingHeap->BeginTrackingResidency(Desc.SizeInBytes);
		}
	}
	else
	{
		VERIFYD3D12RESULT(Adapter->CreateBuffer(HeapType, GetNodeMask(), GetVisibilityMask(), MaxBlockSize, BackingResource.GetInitReference(), ResourceFlags));
		SetName(BackingResource, L"Resource Allocator Underlying Buffer");

		if (IsCPUWritable(HeapType))
		{
			BackingResource->Map();
		}
	}
}
コード例 #2
0
HRESULT CD3DX12AffinityFence::SetEventOnCompletion(UINT64 Value, HANDLE hEvent, UINT AffinityMask)
{
    UINT EffectiveAffinityMask = (AffinityMask == 0) ? GetNodeMask() : AffinityMask & GetNodeMask();
    for (UINT i = 0; i < D3DX12_MAX_ACTIVE_NODES;i++)
    {
        if (((1 << i) & EffectiveAffinityMask) != 0)
        {
            return mFences[i]->SetEventOnCompletion(Value, hEvent);
        }
    }
    //should never get here, mask is incorrect
    return E_FAIL;
}
コード例 #3
0
UINT64 CD3DX12AffinityFence::GetCompletedValue(UINT AffinityMask)
{
    UINT64 Minimum = 0 - 1ull;
    UINT EffectiveAffinityMask = (AffinityMask == 0) ? GetNodeMask() : AffinityMask & GetNodeMask();

    for (UINT i = 0; i < D3DX12_MAX_ACTIVE_NODES;i++)
    {
        if (((1 << i) & EffectiveAffinityMask) != 0)
        {
            UINT64 CompletedValue = mFences[i]->GetCompletedValue();
            Minimum = min(CompletedValue, Minimum);
        }
    }
    return Minimum;
}
コード例 #4
0
void STDMETHODCALLTYPE CD3DX12AffinityObject::SetAffinity(
    UINT AffinityMask)
{
    mAffinityMask = AffinityMask & GetNodeMask();
}