/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class AutoCheckLockD3D11Texture final { public: explicit AutoCheckLockD3D11Texture(ID3D11Texture2D* aTexture)
: mIsLocked(false) {
aTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex)); if (!mMutex) { // If D3D11Texture does not have keyed mutex, we think that the // D3D11Texture could be locked.
mIsLocked = true; return;
}
// Test to see if the keyed mutex has been released
HRESULT hr = mMutex->AcquireSync(0, 0); if (hr == S_OK || hr == WAIT_ABANDONED) {
mIsLocked = true; // According to Microsoft documentation: // WAIT_ABANDONED - The shared surface and keyed mutex are no longer in a // consistent state. If AcquireSync returns this value, you should release // and recreate both the keyed mutex and the shared surface // So even if we do get WAIT_ABANDONED, the keyed mutex will have to be // released.
mSyncAcquired = true;
}
}
~AutoCheckLockD3D11Texture() { if (!mSyncAcquired) { return;
}
HRESULT hr = mMutex->ReleaseSync(0); if (FAILED(hr)) {
NS_WARNING("Failed to unlock the texture");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.