• 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 DZN_NIR_H
25 #define DZN_NIR_H
26 
27 #define D3D12_IGNORE_SDK_LAYERS
28 #define COBJMACROS
29 #include <unknwn.h>
30 #include <directx/d3d12.h>
31 
32 #include "nir.h"
33 
34 struct dzn_indirect_draw_params {
35    uint32_t vertex_count;
36    uint32_t instance_count;
37    uint32_t first_vertex;
38    uint32_t first_instance;
39 };
40 
41 struct dzn_indirect_indexed_draw_params {
42    uint32_t index_count;
43    uint32_t instance_count;
44    uint32_t first_index;
45    int32_t vertex_offset;
46    uint32_t first_instance;
47 };
48 
49 struct dzn_indirect_draw_rewrite_params {
50    uint32_t draw_buf_stride;
51 };
52 
53 struct dzn_indirect_draw_triangle_fan_rewrite_params {
54    uint32_t draw_buf_stride;
55    uint32_t triangle_fan_index_buf_stride;
56    uint64_t triangle_fan_index_buf_start;
57 };
58 
59 struct dzn_indirect_draw_triangle_fan_prim_restart_rewrite_params {
60    uint32_t draw_buf_stride;
61    uint32_t triangle_fan_index_buf_stride;
62    uint64_t triangle_fan_index_buf_start;
63    uint64_t exec_buf_start;
64 };
65 
66 struct dzn_indirect_draw_exec_params {
67    struct {
68       uint32_t first_vertex;
69       uint32_t base_instance;
70       uint32_t draw_id;
71    } sysvals;
72    union {
73       struct dzn_indirect_draw_params draw;
74       struct dzn_indirect_indexed_draw_params indexed_draw;
75    };
76 };
77 
78 struct dzn_indirect_triangle_fan_draw_exec_params {
79    D3D12_INDEX_BUFFER_VIEW ibview;
80    struct {
81       uint32_t first_vertex;
82       uint32_t base_instance;
83       uint32_t draw_id;
84    } sysvals;
85    union {
86       struct dzn_indirect_draw_params draw;
87       struct dzn_indirect_indexed_draw_params indexed_draw;
88    };
89 };
90 
91 struct dzn_triangle_fan_rewrite_index_params {
92    uint32_t first_index;
93 };
94 
95 struct dzn_triangle_fan_prim_restart_rewrite_index_params {
96    uint32_t first_index;
97    uint32_t index_count;
98 };
99 
100 struct dzn_indirect_triangle_fan_rewrite_index_exec_params {
101    uint64_t new_index_buf;
102    struct dzn_triangle_fan_rewrite_index_params params;
103    struct {
104       uint32_t x, y, z;
105    } group_count;
106 };
107 
108 struct dzn_indirect_triangle_fan_prim_restart_rewrite_index_exec_params {
109    uint64_t new_index_buf;
110    struct dzn_triangle_fan_prim_restart_rewrite_index_params params;
111    uint64_t index_count_ptr;
112    struct {
113       uint32_t x, y, z;
114    } group_count;
115 };
116 
117 enum dzn_indirect_draw_type {
118    DZN_INDIRECT_DRAW,
119    DZN_INDIRECT_DRAW_COUNT,
120    DZN_INDIRECT_INDEXED_DRAW,
121    DZN_INDIRECT_INDEXED_DRAW_COUNT,
122    DZN_INDIRECT_DRAW_TRIANGLE_FAN,
123    DZN_INDIRECT_DRAW_COUNT_TRIANGLE_FAN,
124    DZN_INDIRECT_INDEXED_DRAW_TRIANGLE_FAN,
125    DZN_INDIRECT_INDEXED_DRAW_COUNT_TRIANGLE_FAN,
126    DZN_INDIRECT_INDEXED_DRAW_TRIANGLE_FAN_PRIM_RESTART,
127    DZN_INDIRECT_INDEXED_DRAW_COUNT_TRIANGLE_FAN_PRIM_RESTART,
128    DZN_NUM_INDIRECT_DRAW_TYPES,
129 };
130 
131 nir_shader *
132 dzn_nir_indirect_draw_shader(enum dzn_indirect_draw_type type);
133 
134 nir_shader *
135 dzn_nir_triangle_fan_rewrite_index_shader(uint8_t old_index_size);
136 
137 nir_shader *
138 dzn_nir_triangle_fan_prim_restart_rewrite_index_shader(uint8_t old_index_size);
139 
140 struct dzn_nir_blit_info {
141    union {
142       struct {
143          uint32_t src_samples : 6;
144          uint32_t loc : 4;
145          uint32_t out_type : 4;
146          uint32_t sampler_dim : 4;
147          uint32_t src_is_array : 1;
148          uint32_t resolve : 1;
149          uint32_t padding : 12;
150       };
151       const uint32_t hash_key;
152    };
153 };
154 
155 nir_shader *
156 dzn_nir_blit_vs(void);
157 
158 nir_shader *
159 dzn_nir_blit_fs(const struct dzn_nir_blit_info *info);
160 
161 #endif
162