Skip to content

Commit

Permalink
[XB] Use different size of output pool for different targets (#2730)
Browse files Browse the repository at this point in the history
[XB] Use different size of output pool for different targets
b/331391545

Change-Id: I4f22e49079a8de8eb4bdbde8d9988df18ce8a35b
(cherry picked from commit a0f924a)
  • Loading branch information
victorpasoshnikov authored and anonymous1-me committed Apr 9, 2024
1 parent 1a079f5 commit d9519cf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
23 changes: 19 additions & 4 deletions starboard/shared/uwp/extended_resources_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ const SbTime kReleaseTimeout = kSbTimeSecond;
// To make playback more smooth it is better to increase the output queue size
// up to 30-50 frames, but it should not exceed memory budgetd.
// Compromise value was found out experimentally.
// 400 Mb leaves enough memory for stable working of the rest system.
// Just in case to be more sure we reduce this value down to 380 Mb.
const uint64_t kFrameBuffersPoolMemorySize = 380 * 1024 * 1024;
// In XBOX ONE S/Base 400 Mb leaves enough memory for stable working of the rest
// system. Just in case to be more sure we reduce this value down to 380 Mb. In
// Sereies devices (if to use gpu based decoders) the max available frame size
// size is 4K instead of 2K. On the other hand the memory budget is greater than
// for Base/S. So we can use more memory for output queue.
const uint64_t kFrameBuffersPoolMemorySizeForXB1 = 380 * 1024 * 1024;
// +8 extra frames 4K HDR DXGI_FORMAT_R10G10B10A2_UNORM
const uint64_t kFrameBuffersPoolMemorySizeForXBSeries =
kFrameBuffersPoolMemorySizeForXB1 + 8 * 16588800;

bool IsExtendedResourceModeRequired() {
if (!::starboard::xb1::shared::CanAcquire()) {
Expand Down Expand Up @@ -174,6 +180,10 @@ void ExtendedResourcesManager::Quit() {
pending_extended_resources_release_.store(true);
}

void ExtendedResourcesManager::ReleaseBuffersHeap() {
d3d12FrameBuffersHeap_.Reset();
}

bool ExtendedResourcesManager::GetD3D12Objects(
Microsoft::WRL::ComPtr<ID3D12Device>* device,
Microsoft::WRL::ComPtr<ID3D12Heap>* buffer_heap,
Expand Down Expand Up @@ -263,8 +273,13 @@ bool ExtendedResourcesManager::GetD3D12ObjectsInternal() {
SB_DCHECK(d3d12queue_);
}
if (!d3d12FrameBuffersHeap_) {
const bool isSeries = ::starboard::shared::uwp::GetXboxType() ==
::starboard::shared::uwp::kXboxSeriesS ||
::starboard::shared::uwp::GetXboxType() ==
::starboard::shared::uwp::kXboxSeriesX;
D3D12_HEAP_DESC heap_desc;
heap_desc.SizeInBytes = kFrameBuffersPoolMemorySize;
heap_desc.SizeInBytes = isSeries ? kFrameBuffersPoolMemorySizeForXBSeries
: kFrameBuffersPoolMemorySizeForXB1;
heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
heap_desc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heap_desc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
Expand Down
1 change: 1 addition & 0 deletions starboard/shared/uwp/extended_resources_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ExtendedResourcesManager {
void AcquireExtendedResources();
void ReleaseExtendedResources();
void Quit();
void ReleaseBuffersHeap();

// Returns true when the d3d12 device, buffer heap
// and command queue can be used.
Expand Down
4 changes: 4 additions & 0 deletions starboard/shared/uwp/player_components_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
}

using MftVideoDecoder = ::starboard::xb1::shared::VideoDecoderUwp;
using ExtendedResourcesManager = shared::uwp::ExtendedResourcesManager;

const auto output_mode = creation_parameters.output_mode();
const auto is_hdr_video =
Expand All @@ -208,6 +209,9 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
MftVideoDecoder::IsHardwareAv1DecoderSupported())) {
video_render_algorithm->reset(
new VideoRenderAlgorithmImpl(std::bind(GetRefreshRate)));
// The memory heap for gpu decoders isn't used by hw decoders.
// Release it.
ExtendedResourcesManager::GetInstance()->ReleaseBuffersHeap();
video_decoder->reset(new MftVideoDecoder(
video_codec, output_mode,
creation_parameters.decode_target_graphics_context_provider(),
Expand Down

0 comments on commit d9519cf

Please sign in to comment.