• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © Microsoft Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef D3D12_COMPUTE_TRANSFORMS_H
25 #define D3D12_COMPUTE_TRANSFORMS_H
26 
27 #include "d3d12_context.h"
28 #include "d3d12_compiler.h"
29 
30 enum class d3d12_compute_transform_type
31 {
32    /* Extract vertex shader draw params (base vertex, instance, draw ID) from
33     * a stream of indirect draw (indexed) params
34     */
35    base_vertex,
36    /* Given an SO buffer's declaration in the key, copy filled items from a fake (multiplied)
37     * buffer into the original SO buffer, after the original filled size (loaded from the indirect
38     * arg buffer double-bound as a UBO), making sure to skip gaps
39     */
40    fake_so_buffer_copy_back,
41    /* Append a fake SO buffer filed size with (vertex count, 1, 1, original filled size)
42     * for an indirect dispatch of the fake_so_buffer_copy_back transform, and also update
43     * the original filled size with the fake filled size
44     */
45    fake_so_buffer_vertex_count,
46    /* Append a buffer filled size with (vertex count, 1, 0, 0) */
47    draw_auto,
48    max,
49 };
50 
51 struct d3d12_compute_transform_key
52 {
53    d3d12_compute_transform_type type;
54 
55    union
56    {
57       struct {
58          unsigned indexed : 1;
59          unsigned dynamic_count : 1;
60       } base_vertex;
61 
62       struct {
63          uint16_t stride;
64          uint16_t num_ranges;
65          struct {
66             uint16_t offset;
67             uint16_t size;
68          } ranges[PIPE_MAX_SO_OUTPUTS];
69       } fake_so_buffer_copy_back;
70    };
71 };
72 
73 d3d12_shader_selector *
74 d3d12_get_compute_transform(struct d3d12_context *ctx, const d3d12_compute_transform_key *key);
75 
76 void
77 d3d12_compute_transform_cache_init(struct d3d12_context *ctx);
78 
79 void
80 d3d12_compute_transform_cache_destroy(struct d3d12_context *ctx);
81 
82 struct d3d12_compute_transform_save_restore
83 {
84    struct d3d12_shader_selector *cs;
85    struct pipe_constant_buffer cbuf0;
86    struct pipe_shader_buffer ssbos[2];
87 };
88 
89 void
90 d3d12_save_compute_transform_state(struct d3d12_context *ctx, d3d12_compute_transform_save_restore *save);
91 
92 void
93 d3d12_restore_compute_transform_state(struct d3d12_context *ctx, d3d12_compute_transform_save_restore *save);
94 
95 #endif
96