mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Add ExternalTexture::Refresh() and ExternalTexture::Expire()
ExternalTexture has active, expired and destroyed states. Only active state external texture is valid to submit. Expired state external texture can be refresh to active but destroyed external texture cannot be refresh. Bug: chromium:1412338 Change-Id: Ic7f12d274d27b644f19ec3ef8b46c110610afa2b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120982 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
This commit is contained in:
@@ -133,7 +133,7 @@ ExternalTextureBase::ExternalTextureBase(DeviceBase* device,
|
||||
: ApiObjectBase(device, descriptor->label),
|
||||
mVisibleOrigin(descriptor->visibleOrigin),
|
||||
mVisibleSize(descriptor->visibleSize),
|
||||
mState(ExternalTextureState::Alive) {
|
||||
mState(ExternalTextureState::Active) {
|
||||
GetObjectTrackingList()->Track(this);
|
||||
}
|
||||
|
||||
@@ -324,8 +324,8 @@ const std::array<Ref<TextureViewBase>, kMaxPlanesPerFormat>& ExternalTextureBase
|
||||
|
||||
MaybeError ExternalTextureBase::ValidateCanUseInSubmitNow() const {
|
||||
ASSERT(!IsError());
|
||||
DAWN_INVALID_IF(mState == ExternalTextureState::Destroyed,
|
||||
"Destroyed external texture %s is used in a submit.", this);
|
||||
DAWN_INVALID_IF(mState != ExternalTextureState::Active,
|
||||
"External texture %s used in a submit is not active.", this);
|
||||
|
||||
for (uint32_t i = 0; i < kMaxPlanesPerFormat; ++i) {
|
||||
if (mTextureViews[i] != nullptr) {
|
||||
@@ -336,10 +336,33 @@ MaybeError ExternalTextureBase::ValidateCanUseInSubmitNow() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
void ExternalTextureBase::APIDestroy() {
|
||||
if (GetDevice()->ConsumedError(GetDevice()->ValidateObject(this))) {
|
||||
MaybeError ExternalTextureBase::ValidateRefresh() {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
DAWN_INVALID_IF(mState == ExternalTextureState::Destroyed, "%s is destroyed.", this);
|
||||
return {};
|
||||
}
|
||||
|
||||
MaybeError ExternalTextureBase::ValidateExpire() {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
DAWN_INVALID_IF(mState != ExternalTextureState::Active, "%s is not active.", this);
|
||||
return {};
|
||||
}
|
||||
|
||||
void ExternalTextureBase::APIRefresh() {
|
||||
if (GetDevice()->ConsumedError(ValidateRefresh(), "calling %s.Refresh()", this)) {
|
||||
return;
|
||||
}
|
||||
mState = ExternalTextureState::Active;
|
||||
}
|
||||
|
||||
void ExternalTextureBase::APIExpire() {
|
||||
if (GetDevice()->ConsumedError(ValidateExpire(), "calling %s.Expire()", this)) {
|
||||
return;
|
||||
}
|
||||
mState = ExternalTextureState::Expired;
|
||||
}
|
||||
|
||||
void ExternalTextureBase::APIDestroy() {
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ class ExternalTextureBase : public ApiObjectBase {
|
||||
MaybeError ValidateCanUseInSubmitNow() const;
|
||||
static ExternalTextureBase* MakeError(DeviceBase* device);
|
||||
|
||||
void APIExpire();
|
||||
void APIDestroy();
|
||||
void APIRefresh();
|
||||
|
||||
protected:
|
||||
ExternalTextureBase(DeviceBase* device, const ExternalTextureDescriptor* descriptor);
|
||||
@@ -68,9 +70,12 @@ class ExternalTextureBase : public ApiObjectBase {
|
||||
~ExternalTextureBase() override;
|
||||
|
||||
private:
|
||||
enum class ExternalTextureState { Alive, Destroyed };
|
||||
enum class ExternalTextureState { Active, Expired, Destroyed };
|
||||
ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
MaybeError ValidateRefresh();
|
||||
MaybeError ValidateExpire();
|
||||
|
||||
Ref<TextureBase> mPlaceholderTexture;
|
||||
Ref<BufferBase> mParamsBuffer;
|
||||
std::array<Ref<TextureViewBase>, kMaxPlanesPerFormat> mTextureViews;
|
||||
|
||||
Reference in New Issue
Block a user