mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-23 21:20:21 +01:00
d3d12: Assert that there's no front buffer writes
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39077>
This commit is contained in:
parent
86587517b2
commit
d9997c97be
3 changed files with 23 additions and 3 deletions
|
|
@ -60,6 +60,10 @@ struct d3d12_bo {
|
|||
*/
|
||||
uint64_t unique_id;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool is_front_buffer;
|
||||
#endif
|
||||
|
||||
struct list_head residency_list_entry;
|
||||
uint64_t estimated_size;
|
||||
int64_t last_used_timestamp;
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ transition_required(D3D12_RESOURCE_STATES current_state, D3D12_RESOURCE_STATES *
|
|||
}
|
||||
|
||||
static void
|
||||
resolve_global_state(struct d3d12_context *ctx, ID3D12Resource *res, d3d12_resource_state *batch_state, d3d12_resource_state *res_state)
|
||||
resolve_global_state(struct d3d12_context *ctx, struct d3d12_bo *bo, d3d12_resource_state *batch_state, d3d12_resource_state *res_state)
|
||||
{
|
||||
assert(batch_state->num_subresources == res_state->num_subresources);
|
||||
unsigned num_subresources = batch_state->homogenous && res_state->homogenous ? 1 : batch_state->num_subresources;
|
||||
|
|
@ -340,10 +340,11 @@ resolve_global_state(struct d3d12_context *ctx, ID3D12Resource *res, d3d12_resou
|
|||
continue;
|
||||
|
||||
D3D12_RESOURCE_BARRIER barrier = { D3D12_RESOURCE_BARRIER_TYPE_TRANSITION };
|
||||
barrier.Transition.pResource = res;
|
||||
barrier.Transition.pResource = bo->res;
|
||||
barrier.Transition.StateBefore = current_state->state;
|
||||
barrier.Transition.StateAfter = after;
|
||||
barrier.Transition.Subresource = num_subresources == 1 ? D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES : i;
|
||||
assert(!bo->is_front_buffer); // No explicit barriers against front buffers
|
||||
util_dynarray_append(&ctx->barrier_scratch, barrier);
|
||||
}
|
||||
}
|
||||
|
|
@ -355,7 +356,7 @@ context_state_resolve_submission(struct d3d12_context *ctx, d3d12_bo *bo)
|
|||
if (!bo_state->batch_end.supports_simultaneous_access) {
|
||||
assert(bo->res && bo->global_state.subresource_states);
|
||||
|
||||
resolve_global_state(ctx, bo->res, &bo_state->batch_begin, &bo->global_state);
|
||||
resolve_global_state(ctx, bo, &bo_state->batch_begin, &bo->global_state);
|
||||
|
||||
copy_resource_state(&bo_state->batch_begin, &bo_state->batch_end);
|
||||
copy_resource_state(&bo->global_state, &bo_state->batch_end);
|
||||
|
|
@ -470,6 +471,8 @@ append_barrier(struct d3d12_context *ctx,
|
|||
is_promotion = true;
|
||||
}
|
||||
|
||||
assert(!bo->is_front_buffer || (is_promotion && may_decay));
|
||||
|
||||
d3d12_subresource_state new_subresource_state { after, ctx->submit_id, is_promotion, may_decay };
|
||||
if (subresource == D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES)
|
||||
set_resource_state(current_state, &new_subresource_state);
|
||||
|
|
|
|||
|
|
@ -291,6 +291,11 @@ d3d12_wgl_framebuffer_resize(stw_winsys_framebuffer *fb,
|
|||
pipe_resource_reference(&framebuffer->buffers[i],
|
||||
screen->base.base.resource_from_handle(&screen->base.base, &templ, &handle,
|
||||
PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE));
|
||||
|
||||
#ifndef NDEBUG
|
||||
struct d3d12_bo *bo = d3d12_resource(framebuffer->buffers[i])->bo;
|
||||
bo->is_front_buffer = i != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (framebuffer->single_buffered) {
|
||||
|
|
@ -334,6 +339,14 @@ d3d12_wgl_framebuffer_present(stw_winsys_framebuffer *fb, int interval)
|
|||
hr = framebuffer->swapchain->Present(interval, 0);
|
||||
assert(SUCCEEDED(hr));
|
||||
|
||||
#ifndef NDEBUG
|
||||
uint32_t back_buffer_idx = framebuffer->swapchain->GetCurrentBackBufferIndex();
|
||||
for (uint32_t i = 0; i < num_buffers; ++i) {
|
||||
struct d3d12_bo *bo = d3d12_resource(framebuffer->buffers[i])->bo;
|
||||
bo->is_front_buffer = i != back_buffer_idx;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
(void)WaitForSingleObject(framebuffer->waitable_object, 2000);
|
||||
return SUCCEEDED(hr);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue