return ret;
}
+static void
+D3DWindowBuffer_release(struct NineSwapChain9 *This,
+ D3DWindowBuffer *present_handle)
+{
+ int i;
+ /* Add it to the 'pending release' list */
+ for (i = 0; i < D3DPRESENT_BACK_BUFFERS_MAX_EX + 1; i++) {
+ if (!This->present_handles_pending_release[i]) {
+ This->present_handles_pending_release[i] = present_handle;
+ break;
+ }
+ }
+ if (i == (D3DPRESENT_BACK_BUFFERS_MAX_EX + 1)) {
+ ERR("Server not releasing buffers...\n");
+ assert(false);
+ }
+
+ /* Destroy elements of the list released by the server */
+ for (i = 0; i < D3DPRESENT_BACK_BUFFERS_MAX_EX + 1; i++) {
+ if (This->present_handles_pending_release[i] &&
+ ID3DPresent_IsBufferReleased(This->present, This->present_handles_pending_release[i])) {
+ /* WaitBufferReleased also waits the presentation feedback
+ * (which should arrive at about the same time),
+ * while IsBufferReleased doesn't. DestroyD3DWindowBuffer unfortunately
+ * checks it to release immediately all data, else the release
+ * is postponed for This->present release. To avoid leaks (we may handle
+ * a lot of resize), call WaitBufferReleased. */
+ ID3DPresent_WaitBufferReleased(This->present, This->present_handles_pending_release[i]);
+ ID3DPresent_DestroyD3DWindowBuffer(This->present, This->present_handles_pending_release[i]);
+ This->present_handles_pending_release[i] = NULL;
+ }
+ }
+}
+
static int
NineSwapChain9_GetBackBufferCountForParams( struct NineSwapChain9 *This,
D3DPRESENT_PARAMETERS *pParams );
This->enable_threadpool = FALSE;
for (i = 0; i < oldBufferCount; i++) {
- ID3DPresent_DestroyD3DWindowBuffer(This->present, This->present_handles[i]);
+ D3DWindowBuffer_release(This, This->present_handles[i]);
This->present_handles[i] = NULL;
if (This->present_buffers[i])
pipe_resource_reference(&(This->present_buffers[i]), NULL);
FREE(This->pending_presentation[i]);
}
+ for (i = 0; i < D3DPRESENT_BACK_BUFFERS_MAX_EX + 1; i++) {
+ if (This->present_handles_pending_release[i])
+ ID3DPresent_DestroyD3DWindowBuffer(This->present, This->present_handles_pending_release[i]);
+ }
+
for (i = 0; i < This->num_back_buffers; i++) {
if (This->buffers[i])
NineUnknown_Detach(NineUnknown(This->buffers[i]));
create_present_buffer(This, target_width, target_height, &new_resource, &new_handle);
/* Switch to the new buffer */
if (new_handle) {
- /* WaitBufferReleased also waits the presentation feedback,
- * while IsBufferReleased doesn't. DestroyD3DWindowBuffer unfortunately
- * checks it to release immediately all data, else the release
- * is postponed for This->present release. To avoid leaks (we may handle
- * a lot of resize), call WaitBufferReleased. */
- ID3DPresent_WaitBufferReleased(This->present, This->present_handles[0]);
- ID3DPresent_DestroyD3DWindowBuffer(This->present, This->present_handles[0]);
+ D3DWindowBuffer_release(This, This->present_handles[0]);
This->present_handles[0] = new_handle;
pipe_resource_reference(&This->present_buffers[0], new_resource);
pipe_resource_reference(&new_resource, NULL);