libobs-d3d11: Set acquired bool when texture acquired
This is used when the device needs to be rebuilt. Ensures that the texture doesn't get locked again if the texture is rebuilt.master
parent
a2201d5898
commit
492f50ee87
|
@ -2222,22 +2222,26 @@ extern "C" EXPORT uint32_t device_texture_get_shared_handle(gs_texture_t *tex)
|
|||
return tex2d->isShared ? tex2d->sharedHandle : GS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
extern "C" EXPORT int device_texture_acquire_sync(gs_texture_t *tex,
|
||||
uint64_t key, uint32_t ms)
|
||||
int device_texture_acquire_sync(gs_texture_t *tex, uint64_t key, uint32_t ms)
|
||||
{
|
||||
gs_texture_2d *tex2d = reinterpret_cast<gs_texture_2d *>(tex);
|
||||
if (tex->type != GS_TEXTURE_2D)
|
||||
return -1;
|
||||
|
||||
if (tex2d->acquired)
|
||||
return 0;
|
||||
|
||||
ComQIPtr<IDXGIKeyedMutex> keyedMutex(tex2d->texture);
|
||||
if (!keyedMutex)
|
||||
return -1;
|
||||
|
||||
HRESULT hr = keyedMutex->AcquireSync(key, ms);
|
||||
if (hr == S_OK)
|
||||
if (hr == S_OK) {
|
||||
tex2d->acquired = true;
|
||||
return 0;
|
||||
else if (hr == WAIT_TIMEOUT)
|
||||
} else if (hr == WAIT_TIMEOUT) {
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -2249,12 +2253,20 @@ extern "C" EXPORT int device_texture_release_sync(gs_texture_t *tex,
|
|||
if (tex->type != GS_TEXTURE_2D)
|
||||
return -1;
|
||||
|
||||
if (!tex2d->acquired)
|
||||
return 0;
|
||||
|
||||
ComQIPtr<IDXGIKeyedMutex> keyedMutex(tex2d->texture);
|
||||
if (!keyedMutex)
|
||||
return -1;
|
||||
|
||||
HRESULT hr = keyedMutex->ReleaseSync(key);
|
||||
return hr == S_OK ? 0 : -1;
|
||||
if (hr == S_OK) {
|
||||
tex2d->acquired = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" EXPORT bool device_texture_create_nv12(gs_device_t *device,
|
||||
|
|
|
@ -358,6 +358,7 @@ struct gs_texture_2d : gs_texture {
|
|||
gs_texture_2d *pairedNV12texture = nullptr;
|
||||
bool nv12 = false;
|
||||
bool chroma = false;
|
||||
bool acquired = false;
|
||||
|
||||
vector<vector<uint8_t>> data;
|
||||
vector<D3D11_SUBRESOURCE_DATA> srd;
|
||||
|
@ -862,3 +863,6 @@ struct gs_device {
|
|||
gs_device(uint32_t adapterIdx);
|
||||
~gs_device();
|
||||
};
|
||||
|
||||
extern "C" EXPORT int device_texture_acquire_sync(gs_texture_t *tex,
|
||||
uint64_t key, uint32_t ms);
|
||||
|
|
|
@ -150,6 +150,7 @@ void gs_texture_2d::InitTexture(const uint8_t **data)
|
|||
}
|
||||
|
||||
km->AcquireSync(0, INFINITE);
|
||||
acquired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue