1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © Microsoft Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci#ifndef D3D12_BATCH_H
25bf215546Sopenharmony_ci#define D3D12_BATCH_H
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#include "util/u_dynarray.h"
28bf215546Sopenharmony_ci#include "util/hash_table.h"
29bf215546Sopenharmony_ci#include <stdint.h>
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "d3d12_common.h"
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_cistruct d3d12_bo;
34bf215546Sopenharmony_cistruct d3d12_descriptor_heap;
35bf215546Sopenharmony_cistruct d3d12_fence;
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistruct d3d12_batch {
38bf215546Sopenharmony_ci   struct d3d12_fence *fence;
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci   struct hash_table *bos;
41bf215546Sopenharmony_ci   struct set *sampler_views;
42bf215546Sopenharmony_ci   struct set *surfaces;
43bf215546Sopenharmony_ci   struct set *objects;
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci   struct util_dynarray zombie_samplers;
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci   ID3D12CommandAllocator *cmdalloc;
48bf215546Sopenharmony_ci   struct d3d12_descriptor_heap *sampler_heap;
49bf215546Sopenharmony_ci   struct d3d12_descriptor_heap *view_heap;
50bf215546Sopenharmony_ci   bool has_errors;
51bf215546Sopenharmony_ci   bool pending_memory_barrier;
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci   uint64_t submit_id;
54bf215546Sopenharmony_ci};
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_cibool
57bf215546Sopenharmony_cid3d12_init_batch(struct d3d12_context *ctx, struct d3d12_batch *batch);
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_civoid
60bf215546Sopenharmony_cid3d12_destroy_batch(struct d3d12_context *ctx, struct d3d12_batch *batch);
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_civoid
63bf215546Sopenharmony_cid3d12_start_batch(struct d3d12_context *ctx, struct d3d12_batch *batch);
64bf215546Sopenharmony_ci
65bf215546Sopenharmony_civoid
66bf215546Sopenharmony_cid3d12_end_batch(struct d3d12_context *ctx, struct d3d12_batch *batch);
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_cibool
69bf215546Sopenharmony_cid3d12_reset_batch(struct d3d12_context *ctx, struct d3d12_batch *batch, uint64_t timeout_ns);
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_cibool
72bf215546Sopenharmony_cid3d12_batch_has_references(struct d3d12_batch *batch,
73bf215546Sopenharmony_ci                           struct d3d12_bo *bo,
74bf215546Sopenharmony_ci                           bool want_to_write);
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_civoid
77bf215546Sopenharmony_cid3d12_batch_reference_resource(struct d3d12_batch *batch,
78bf215546Sopenharmony_ci                               struct d3d12_resource *res,
79bf215546Sopenharmony_ci                               bool write);
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_civoid
82bf215546Sopenharmony_cid3d12_batch_reference_sampler_view(struct d3d12_batch *batch,
83bf215546Sopenharmony_ci                                   struct d3d12_sampler_view *sv);
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_civoid
86bf215546Sopenharmony_cid3d12_batch_reference_surface_texture(struct d3d12_batch *batch,
87bf215546Sopenharmony_ci                              struct d3d12_surface *surf);
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_civoid
90bf215546Sopenharmony_cid3d12_batch_reference_object(struct d3d12_batch *batch,
91bf215546Sopenharmony_ci                             ID3D12Object *object);
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_ci#endif
94