Fix code style

This commit is contained in:
Wojtek Figat
2020-12-30 11:20:37 +01:00
parent 4ec3e6aed9
commit 4c205be617
56 changed files with 608 additions and 1139 deletions

View File

@@ -144,23 +144,17 @@ void GPUContextDX12::SetResourceState(ResourceOwnerDX12* resource, D3D12_RESOURC
auto& state = resource->State;
if (subresourceIndex == D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES && !state.AreAllSubresourcesSame())
{
// Slow path. Want to transition the entire resource (with multiple subresources). But they aren't in the same state.
// Slow path because we have to transition the entire resource with multiple subresources that aren't in the same state
const uint32 subresourceCount = resource->GetSubresourcesCount();
for (uint32 i = 0; i < subresourceCount; i++)
{
const D3D12_RESOURCE_STATES before = state.GetSubresourceState(i);
// We're not using IsTransitionNeeded() because we do want to transition even if 'after' is a subset of 'before'
// This is so that we can ensure all subresources are in the same state, simplifying future barriers
if (before != after)
{
AddTransitionBarrier(resource, before, after, i);
state.SetSubresourceState(i, after);
}
}
// The entire resource should now be in the after state on this command list
ASSERT(state.CheckResourceState(after));
state.SetResourceState(after);
}

View File

@@ -172,12 +172,8 @@ public:
{
if (sampleCount <= 8)
{
// 0 has better quality (a more even distribution)
// Higher quality levels might be useful for non box filtered AA or when using weighted samples.
return 0;
}
// Not supported.
return 0xffffffff;
}
@@ -187,7 +183,7 @@ public:
#endif
private:
#if PLATFORM_XBOX_SCARLETT
void updateFrameEvents();
#endif

View File

@@ -33,14 +33,11 @@ public:
/// Returns true if resource state transition is needed in order to use resource in given state.
/// </summary>
/// <param name="currentState">The current resource state.</param>
/// <param name="targeState">the destination resource state.</param>
/// <param name="targetState">the destination resource state.</param>
/// <returns>True if need to perform a transition, otherwise false.</returns>
static bool IsTransitionNeeded(D3D12_RESOURCE_STATES currentState, D3D12_RESOURCE_STATES targeState)
static bool IsTransitionNeeded(D3D12_RESOURCE_STATES currentState, D3D12_RESOURCE_STATES targetState)
{
// If 'targeState' is a subset of 'before', then there's no need for a transition
// Note: COMMON is an oddball state that doesn't follow the RESOURE_STATE pattern of
// having exactly one bit set so we need to special case these
return currentState != targeState && ((currentState | targeState) != currentState || targeState == D3D12_RESOURCE_STATE_COMMON);
return currentState != targetState && ((currentState | targetState) != currentState || targetState == D3D12_RESOURCE_STATE_COMMON);
}
};

View File

@@ -267,43 +267,33 @@ protected:
// [GPUDevice]
bool Init() override
{
// Cache adapter description
const DXGI_ADAPTER_DESC& adapterDesc = _adapter->Description;
const uint64 dedicatedVideoMemory = static_cast<uint64>(adapterDesc.DedicatedVideoMemory);
const uint64 dedicatedSystemMemory = static_cast<uint64>(adapterDesc.DedicatedSystemMemory);
const uint64 sharedSystemMemory = static_cast<uint64>(adapterDesc.SharedSystemMemory);
// Total amount of system memory clamped to 8 GB
const uint64 totalPhysicalMemory = Math::Min(Platform::GetMemoryStats().TotalPhysicalMemory, 8Ull * 1024Ull * 1024Ull * 1024Ull);
// Consider 50% of the shared memory but max 25% of total system memory
const uint64 consideredSharedSystemMemory = Math::Min(sharedSystemMemory / 2Ull, totalPhysicalMemory / 4Ull);
// Calculate total GPU memory
const uint64 totalPhysicalMemory = Math::Min(Platform::GetMemoryStats().TotalPhysicalMemory, 16Ull * 1024Ull * 1024Ull * 1024Ull);
const uint64 totalSystemMemory = Math::Min(sharedSystemMemory / 2Ull, totalPhysicalMemory / 4Ull);
TotalGraphicsMemory = 0;
if (_adapter->IsIntel())
{
// Use total memory for integrated cards
TotalGraphicsMemory = dedicatedVideoMemory + dedicatedSystemMemory + consideredSharedSystemMemory;
TotalGraphicsMemory = dedicatedVideoMemory + dedicatedSystemMemory + totalSystemMemory;
}
else if (dedicatedVideoMemory >= 200 * 1024 * 1024)
{
// Use dedicated video memory, if it's more than 200 MB
TotalGraphicsMemory = dedicatedVideoMemory;
}
else if (dedicatedSystemMemory >= 200 * 1024 * 1024)
{
// Use dedicated system memory, if it's more than 200 MB
TotalGraphicsMemory = dedicatedSystemMemory;
}
else if (sharedSystemMemory >= 400 * 1024 * 1024)
{
// Use some shared system memory, if it's more than 400 MB
TotalGraphicsMemory = consideredSharedSystemMemory;
TotalGraphicsMemory = totalSystemMemory;
}
else
{
// Otherwise consider 25% of total system memory for graphics
TotalGraphicsMemory = totalPhysicalMemory / 4Ull;
}