Skip to content

Commit

Permalink
Cherry pick PR #467: [XB1] Remove usage of internal files from extern…
Browse files Browse the repository at this point in the history
…al builds (#485)

b/269658038

Change-Id: I8fa658d12fce86aa5f69e3ebbe58a2211ee9672d
(cherry picked from commit 5409534)

Co-authored-by: Tyler Holcombe <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and TyHolc authored May 26, 2023
1 parent 69eb7b2 commit ba2ad61
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions starboard/build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ config("starboard") {
defines += [ "SB_ABORT_ON_ALLOCATION_FAILURE" ]
}

if (is_internal_build) {
defines += [ "INTERNAL_BUILD" ]
}

if (sb_allows_memory_tracking) {
defines += [ "STARBOARD_ALLOWS_MEMORY_TRACKING" ]
}
Expand Down
19 changes: 15 additions & 4 deletions starboard/shared/uwp/extended_resources_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

#include <ppltasks.h>

#include "internal/starboard/xb1/shared/av1_video_decoder.h"
#include "internal/starboard/xb1/shared/internal_shims.h"
#include "internal/starboard/xb1/shared/vpx_video_decoder.h"
#include "starboard/common/condition_variable.h"
#include "starboard/common/semaphore.h"
#include "starboard/common/string.h"
Expand All @@ -27,7 +25,11 @@
#include "starboard/shared/win32/video_decoder.h"
#include "starboard/thread.h"
#include "starboard/time.h"
#if defined(INTERNAL_BUILD)
#include "internal/starboard/xb1/internal/av1_video_decoder.h"
#include "internal/starboard/xb1/internal/vpx_video_decoder.h"
#include "third_party/internal/libvpx_xb1/libvpx/d3dx12.h"
#endif // defined(INTERNAL_BUILD)

namespace starboard {
namespace shared {
Expand All @@ -37,9 +39,11 @@ namespace {

using Microsoft::WRL::ComPtr;
using ::starboard::shared::starboard::media::MimeSupportabilityCache;
using Windows::Foundation::Metadata::ApiInformation;
#if defined(INTERNAL_BUILD)
using ::starboard::xb1::shared::Av1VideoDecoder;
using ::starboard::xb1::shared::VpxVideoDecoder;
using Windows::Foundation::Metadata::ApiInformation;
#endif // defined(INTERNAL_BUILD)

const SbTime kReleaseTimeout = kSbTimeSecond;

Expand Down Expand Up @@ -173,6 +177,7 @@ bool ExtendedResourcesManager::GetD3D12Objects(
return false;
}

#if defined(INTERNAL_BUILD)
// Verify that we can allocate one MB without getting an error. This should
// detect a DXGI_ERROR_DEVICE_REMOVED failure mode.
ComPtr<ID3D12Resource> res;
Expand All @@ -187,6 +192,7 @@ bool ExtendedResourcesManager::GetD3D12Objects(
OnNonrecoverableFailure();
return false;
}
#endif // defined(INTERNAL_BUILD)

*device = d3d12device_;
*command_queue = d3d12queue_.Get();
Expand Down Expand Up @@ -320,6 +326,7 @@ void ExtendedResourcesManager::CompileShadersAsynchronously() {
// and they will be placed in cache as binaries for further reusing.
Concurrency::create_task([this] {
ScopedLock scoped_lock(mutex_);
#if defined(INTERNAL_BUILD)
SB_LOG(INFO) << "Start to compile AV1 decoder shaders.";
SB_DCHECK(!is_av1_shader_compiled_)
<< "Unexpected attempt to recompile AV1 decoder shaders.";
Expand Down Expand Up @@ -355,6 +362,7 @@ void ExtendedResourcesManager::CompileShadersAsynchronously() {
SB_LOG(WARNING) << "Failed to compile VP9 decoder shaders, next attempt "
"will happen right on the VP9 decoder instantiation.";
}
#endif // defined(INTERNAL_BUILD)

if (is_av1_shader_compiled_ && is_vp9_shader_compiled_) {
MimeSupportabilityCache::GetInstance()->ClearCachedMimeSupportabilities();
Expand All @@ -364,8 +372,9 @@ void ExtendedResourcesManager::CompileShadersAsynchronously() {

void ExtendedResourcesManager::ReleaseExtendedResourcesInternal() {
SB_DCHECK(thread_checker_.CalledOnValidThread());

#if defined(INTERNAL_BUILD)
Av1VideoDecoder::ClearFrameBufferPool();
#endif // defined(INTERNAL_BUILD)

ScopedLock scoped_lock(mutex_);
if (!is_extended_resources_acquired_.load()) {
Expand Down Expand Up @@ -400,8 +409,10 @@ void ExtendedResourcesManager::ReleaseExtendedResourcesInternal() {
} else {
SB_LOG(INFO) << "CreateEvent() failed with " << GetLastError();
}
#if defined(INTERNAL_BUILD)
Av1VideoDecoder::ReleaseShaders();
VpxVideoDecoder::ReleaseShaders();
#endif // #if defined(INTERNAL_BUILD)
is_av1_shader_compiled_ = false;
is_vp9_shader_compiled_ = false;
} else {
Expand Down
9 changes: 7 additions & 2 deletions starboard/shared/uwp/player_components_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

#include <functional>

#include "internal/starboard/xb1/shared/av1_video_decoder.h"
#include "internal/starboard/xb1/shared/video_decoder_uwp.h"
#include "internal/starboard/xb1/shared/vpx_video_decoder.h"
#include "starboard/common/device_type.h"
#include "starboard/common/log.h"
#include "starboard/common/ref_counted.h"
Expand All @@ -44,6 +42,11 @@
#include "starboard/shared/uwp/extended_resources_manager.h"
#include "starboard/shared/win32/audio_decoder.h"

#if defined(INTERNAL_BUILD)
#include "internal/starboard/xb1/internal/av1_video_decoder.h"
#include "internal/starboard/xb1/internal/vpx_video_decoder.h"
#endif // defined(INTERNAL_BUILD)

namespace starboard {
namespace shared {
namespace starboard {
Expand Down Expand Up @@ -247,6 +250,7 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
SB_DCHECK(d3d12device);
SB_DCHECK(d3d12queue);

#if defined(INTERNAL_BUILD)
using GpuVp9VideoDecoder = ::starboard::xb1::shared::VpxVideoDecoder;
using GpuAv1VideoDecoder = ::starboard::xb1::shared::Av1VideoDecoder;

Expand All @@ -263,6 +267,7 @@ class PlayerComponentsFactory : public PlayerComponents::Factory {
creation_parameters.video_stream_info(), is_hdr_video, d3d12device,
d3d12queue));
}
#endif // defined(INTERNAL_BUILD)

if (video_decoder) {
video_render_algorithm->reset(
Expand Down

0 comments on commit ba2ad61

Please sign in to comment.