Retry surface creation to work around transient VDP_STATUS_RESOURCES errors
This commit is contained in:
parent
48a770edec
commit
3117e360f4
1 changed files with 25 additions and 11 deletions
|
|
@ -28,24 +28,24 @@ VDPAURenderer::VDPAURenderer()
|
||||||
|
|
||||||
VDPAURenderer::~VDPAURenderer()
|
VDPAURenderer::~VDPAURenderer()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < OUTPUT_SURFACE_COUNT; i++) {
|
if (m_PresentationQueue != 0) {
|
||||||
if (m_OutputSurface[i] != 0) {
|
m_VdpPresentationQueueDestroy(m_PresentationQueue);
|
||||||
m_VdpOutputSurfaceDestroy(m_OutputSurface[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_VideoMixer != 0) {
|
if (m_VideoMixer != 0) {
|
||||||
m_VdpVideoMixerDestroy(m_VideoMixer);
|
m_VdpVideoMixerDestroy(m_VideoMixer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_PresentationQueue != 0) {
|
|
||||||
m_VdpPresentationQueueDestroy(m_PresentationQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_PresentationQueueTarget != 0) {
|
if (m_PresentationQueueTarget != 0) {
|
||||||
m_VdpPresentationQueueTargetDestroy(m_PresentationQueueTarget);
|
m_VdpPresentationQueueTargetDestroy(m_PresentationQueueTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < OUTPUT_SURFACE_COUNT; i++) {
|
||||||
|
if (m_OutputSurface[i] != 0) {
|
||||||
|
m_VdpOutputSurfaceDestroy(m_OutputSurface[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This must be done last as it frees VDPAU context required to call
|
// This must be done last as it frees VDPAU context required to call
|
||||||
// the functions above.
|
// the functions above.
|
||||||
if (m_HwContext != nullptr) {
|
if (m_HwContext != nullptr) {
|
||||||
|
|
@ -164,9 +164,23 @@ bool VDPAURenderer::initialize(SDL_Window* window, int, int width, int height)
|
||||||
|
|
||||||
// Create the output surfaces
|
// Create the output surfaces
|
||||||
for (int i = 0; i < OUTPUT_SURFACE_COUNT; i++) {
|
for (int i = 0; i < OUTPUT_SURFACE_COUNT; i++) {
|
||||||
status = m_VdpOutputSurfaceCreate(vdpauCtx->device, m_OutputSurfaceFormat,
|
// It seems there's some lazy freeing going on or something in VDPAU
|
||||||
m_DisplayWidth, m_DisplayHeight,
|
// because we can get VDP_STATUS_RESOURCES, then wait a bit and it'll
|
||||||
&m_OutputSurface[i]);
|
// complete without a problem.
|
||||||
|
int tries = 1;
|
||||||
|
do {
|
||||||
|
status = m_VdpOutputSurfaceCreate(vdpauCtx->device, m_OutputSurfaceFormat,
|
||||||
|
m_DisplayWidth, m_DisplayHeight,
|
||||||
|
&m_OutputSurface[i]);
|
||||||
|
if (status != VDP_STATUS_OK) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"VdpOutputSurfaceCreate() try #%d: %s",
|
||||||
|
tries,
|
||||||
|
m_VdpGetErrorString(status));
|
||||||
|
SDL_Delay(250);
|
||||||
|
}
|
||||||
|
} while (status == VDP_STATUS_RESOURCES && ++tries <= 10);
|
||||||
|
|
||||||
if (status != VDP_STATUS_OK) {
|
if (status != VDP_STATUS_OK) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"VdpOutputSurfaceCreate() failed: %s",
|
"VdpOutputSurfaceCreate() failed: %s",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue