The external swapchain API is weird and not really needed here.
Unified · Split
| @@ -511,33 +511,24 @@ static void egl_swap_buffers(struct ra_ctx *ctx) · 510 unmodified lines | |||
| 511 | static void angle_swap_buffers(struct ra_ctx *ctx) | 511 | static void angle_swap_buffers(struct ra_ctx *ctx) |
| 512 | { | 512 | { |
| 513 | struct priv *p = ctx->priv; | 513 | struct priv *p = ctx->priv; |
| 514 | if (p->dxgi_swapchain) | 514 | if (p->dxgi_swapchain) { |
| 515 | // DXGI Present doesn't flush the immediate context, which can make | ||
| 516 | // timers inaccurate, since the end queries might not be sent until the | ||
| 517 | // next frame. Fix this by flushing the context now. | ||
| 518 | ID3D11DeviceContext_Flush(p->d3d11_context); | ||
| 515 | d3d11_swap_buffers(ctx); | 519 | d3d11_swap_buffers(ctx); |
| 516 | else | 520 | } else { |
| 517 | egl_swap_buffers(ctx); | 521 | egl_swap_buffers(ctx); |
| 522 | } | ||
| 518 | } | 523 | } |
| 519 | 524 | ||
| 520 | 525 | ||
| 521 | static int angle_color_depth(struct ra_swapchain *sw) | 526 | static int angle_color_depth(struct ra_ctx *ctx) |
| 522 | { | 527 | { |
| 523 | // Only 8-bit output is supported at the moment | 528 | // Only 8-bit output is supported at the moment |
| 524 | return 8; | 529 | return 8; |
| 525 | } | 530 | } |
| 526 | 531 | ||
| 527 | static bool angle_submit_frame(struct ra_swapchain *sw, | ||
| 528 | const struct vo_frame *frame) | ||
| 529 | { | ||
| 530 | struct priv *p = sw->ctx->priv; | ||
| 531 | bool ret = ra_gl_ctx_submit_frame(sw, frame); | ||
| 532 | if (p->d3d11_context) { | ||
| 533 | // DXGI Present doesn't flush the immediate context, which can make | ||
| 534 | // timers inaccurate, since the end queries might not be sent until the | ||
| 535 | // next frame. Fix this by flushing the context now. | ||
| 536 | ID3D11DeviceContext_Flush(p->d3d11_context); | ||
| 537 | } | ||
| 538 | return ret; | ||
| 539 | } | ||
| 540 | |||
| 541 | static bool angle_init(struct ra_ctx *ctx) | 532 | static bool angle_init(struct ra_ctx *ctx) |
| 542 | { | 533 | { |
| 543 | struct priv *p = ctx->priv = talloc_zero(ctx, struct priv); | 534 | struct priv *p = ctx->priv = talloc_zero(ctx, struct priv); |
| @@ -596,14 +587,9 @@ static bool angle_init(struct ra_ctx *ctx) · 52 unmodified lines | |||
| 596 | current_ctx = ctx; | 587 | current_ctx = ctx; |
| 597 | gl->SwapInterval = angle_swap_interval; | 588 | gl->SwapInterval = angle_swap_interval; |
| 598 | 589 | ||
| 599 | // Custom swapchain impl for the D3D11 swapchain-based surface | ||
| 600 | static const struct ra_swapchain_fns dxgi_swapchain_fns = { | ||
| 601 | .color_depth = angle_color_depth, | ||
| 602 | .submit_frame = angle_submit_frame, | ||
| 603 | }; | ||
| 604 | struct ra_ctx_params params = { | 590 | struct ra_ctx_params params = { |
| 591 | .color_depth = p->dxgi_swapchain ? angle_color_depth : NULL, | ||
| 605 | .swap_buffers = angle_swap_buffers, | 592 | .swap_buffers = angle_swap_buffers, |
| 606 | .external_swapchain = p->dxgi_swapchain ? &dxgi_swapchain_fns : NULL, | ||
| 607 | }; | 593 | }; |
| 608 | 594 | ||
| 609 | gl->flipped = p->flipped; | 595 | gl->flipped = p->flipped; |