~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/d3d12/d3d12_compiler.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
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_COMPILER_H
25
 
#define D3D12_COMPILER_H
26
 
 
27
 
#include "dxil_nir_lower_int_samplers.h"
28
 
 
29
 
#include "pipe/p_defines.h"
30
 
#include "pipe/p_state.h"
31
 
 
32
 
#include "compiler/shader_info.h"
33
 
#include "program/prog_statevars.h"
34
 
 
35
 
#include "nir.h"
36
 
 
37
 
struct pipe_screen;
38
 
 
39
 
#ifdef __cplusplus
40
 
extern "C" {
41
 
#endif
42
 
 
43
 
enum d3d12_state_var {
44
 
   D3D12_STATE_VAR_Y_FLIP = 0,
45
 
   D3D12_STATE_VAR_PT_SPRITE,
46
 
   D3D12_STATE_VAR_DRAW_PARAMS,
47
 
   D3D12_STATE_VAR_DEPTH_TRANSFORM,
48
 
   D3D12_STATE_VAR_DEFAULT_INNER_TESS_LEVEL,
49
 
   D3D12_STATE_VAR_DEFAULT_OUTER_TESS_LEVEL,
50
 
   D3D12_STATE_VAR_PATCH_VERTICES_IN,
51
 
   D3D12_MAX_GRAPHICS_STATE_VARS,
52
 
 
53
 
   D3D12_STATE_VAR_NUM_WORKGROUPS = 0,
54
 
   D3D12_STATE_VAR_TRANSFORM_GENERIC0,
55
 
   D3D12_MAX_COMPUTE_STATE_VARS,
56
 
 
57
 
   D3D12_MAX_STATE_VARS = MAX2(D3D12_MAX_GRAPHICS_STATE_VARS, D3D12_MAX_COMPUTE_STATE_VARS)
58
 
};
59
 
 
60
 
#define D3D12_MAX_POINT_SIZE 255.0f
61
 
 
62
 
const void *
63
 
d3d12_get_compiler_options(struct pipe_screen *screen,
64
 
                           enum pipe_shader_ir ir,
65
 
                           enum pipe_shader_type shader);
66
 
 
67
 
struct d3d12_varying_info {
68
 
   struct {
69
 
      const struct glsl_type *types[4];
70
 
      uint8_t location_frac_mask:2;
71
 
      uint8_t patch:1;
72
 
      struct {
73
 
         unsigned interpolation:3;   // INTERP_MODE_COUNT = 5
74
 
         unsigned driver_location:6; // VARYING_SLOT_MAX = 64
75
 
         unsigned compact:1;
76
 
      } vars[4];
77
 
   } slots[VARYING_SLOT_MAX];
78
 
   uint64_t mask;
79
 
};
80
 
 
81
 
struct d3d12_image_format_conversion_info {
82
 
   enum pipe_format view_format, emulated_format;
83
 
};
84
 
 
85
 
struct d3d12_shader_key {
86
 
   enum pipe_shader_type stage;
87
 
 
88
 
   struct d3d12_varying_info required_varying_inputs;
89
 
   struct d3d12_varying_info required_varying_outputs;
90
 
   uint64_t next_varying_inputs;
91
 
   uint64_t prev_varying_outputs;
92
 
   unsigned last_vertex_processing_stage : 1;
93
 
   unsigned invert_depth : 16;
94
 
   unsigned samples_int_textures : 1;
95
 
   unsigned input_clip_size : 4;
96
 
   unsigned tex_saturate_s : PIPE_MAX_SAMPLERS;
97
 
   unsigned tex_saturate_r : PIPE_MAX_SAMPLERS;
98
 
   unsigned tex_saturate_t : PIPE_MAX_SAMPLERS;
99
 
 
100
 
   struct {
101
 
      unsigned needs_format_emulation:1;
102
 
      enum pipe_format format_conversion[PIPE_MAX_ATTRIBS];
103
 
   } vs;
104
 
 
105
 
   struct {
106
 
      unsigned sprite_coord_enable:24;
107
 
      unsigned sprite_origin_upper_left:1;
108
 
      unsigned point_pos_stream_out:1;
109
 
      unsigned writes_psize:1;
110
 
      unsigned point_size_per_vertex:1;
111
 
      unsigned aa_point:1;
112
 
      unsigned stream_output_factor:3;
113
 
      unsigned primitive_id:1;
114
 
      unsigned triangle_strip:1;
115
 
   } gs;
116
 
 
117
 
   struct {
118
 
      unsigned primitive_mode:2;
119
 
      unsigned ccw:1;
120
 
      unsigned point_mode:1;
121
 
      unsigned spacing:2;
122
 
      unsigned patch_vertices_in:5;
123
 
      struct d3d12_varying_info required_patch_outputs;
124
 
      uint32_t next_patch_inputs;
125
 
   } hs;
126
 
 
127
 
   struct {
128
 
      unsigned tcs_vertices_out;
129
 
      struct d3d12_varying_info required_patch_inputs;
130
 
      uint32_t prev_patch_outputs;
131
 
   } ds;
132
 
 
133
 
   struct {
134
 
      unsigned missing_dual_src_outputs : 2;
135
 
      unsigned frag_result_color_lowering : 4;
136
 
      unsigned cast_to_uint : 1;
137
 
      unsigned cast_to_int : 1;
138
 
      unsigned provoking_vertex : 2;
139
 
      unsigned manual_depth_range : 1;
140
 
      unsigned polygon_stipple : 1;
141
 
      unsigned remap_front_facing : 1;
142
 
      unsigned multisample_disabled : 1;
143
 
   } fs;
144
 
 
145
 
   struct {
146
 
      unsigned workgroup_size[3];
147
 
   } cs;
148
 
 
149
 
   int n_texture_states;
150
 
   dxil_wrap_sampler_state tex_wrap_states[PIPE_MAX_SHADER_SAMPLER_VIEWS];
151
 
   dxil_texture_swizzle_state swizzle_state[PIPE_MAX_SHADER_SAMPLER_VIEWS];
152
 
   enum compare_func sampler_compare_funcs[PIPE_MAX_SHADER_SAMPLER_VIEWS];
153
 
 
154
 
   int n_images;
155
 
   struct d3d12_image_format_conversion_info image_format_conversion[PIPE_MAX_SHADER_IMAGES];
156
 
};
157
 
 
158
 
struct d3d12_shader {
159
 
   void *bytecode;
160
 
   size_t bytecode_length;
161
 
 
162
 
   nir_shader *nir;
163
 
 
164
 
   struct {
165
 
      unsigned binding;
166
 
   } cb_bindings[PIPE_MAX_CONSTANT_BUFFERS];
167
 
   size_t num_cb_bindings;
168
 
 
169
 
   struct {
170
 
      enum d3d12_state_var var;
171
 
      unsigned offset;
172
 
   } state_vars[D3D12_MAX_STATE_VARS];
173
 
   unsigned num_state_vars;
174
 
   size_t state_vars_size;
175
 
   bool state_vars_used;
176
 
 
177
 
   struct {
178
 
      uint32_t dimension;
179
 
   } srv_bindings[PIPE_MAX_SHADER_SAMPLER_VIEWS];
180
 
   size_t begin_srv_binding;
181
 
   size_t end_srv_binding;
182
 
 
183
 
   struct {
184
 
      enum pipe_format format;
185
 
      uint32_t dimension;
186
 
   } uav_bindings[PIPE_MAX_SHADER_IMAGES];
187
 
 
188
 
   bool has_default_ubo0;
189
 
   unsigned pstipple_binding;
190
 
 
191
 
   struct d3d12_shader_key key;
192
 
   struct d3d12_shader *next_variant;
193
 
};
194
 
 
195
 
struct d3d12_gs_variant_key
196
 
{
197
 
   unsigned passthrough:1;
198
 
   unsigned provoking_vertex:3;
199
 
   unsigned alternate_tri:1;
200
 
   unsigned fill_mode:2;
201
 
   unsigned cull_mode:2;
202
 
   unsigned has_front_face:1;
203
 
   unsigned front_ccw:1;
204
 
   unsigned edge_flag_fix:1;
205
 
   unsigned flatshade_first:1;
206
 
   uint64_t flat_varyings;
207
 
   struct d3d12_varying_info varyings;
208
 
};
209
 
 
210
 
struct d3d12_tcs_variant_key
211
 
{
212
 
   unsigned vertices_out;
213
 
   struct d3d12_varying_info varyings;
214
 
};
215
 
 
216
 
struct d3d12_shader_selector {
217
 
   enum pipe_shader_type stage;
218
 
   nir_shader *initial;
219
 
   struct d3d12_shader *first;
220
 
   struct d3d12_shader *current;
221
 
 
222
 
   struct pipe_stream_output_info so_info;
223
 
 
224
 
   unsigned samples_int_textures:1;
225
 
   unsigned compare_with_lod_bias_grad:1;
226
 
   unsigned workgroup_size_variable:1;
227
 
 
228
 
   bool is_variant;
229
 
   union {
230
 
      struct d3d12_gs_variant_key gs_key;
231
 
      struct d3d12_tcs_variant_key tcs_key;
232
 
   };
233
 
};
234
 
 
235
 
struct d3d12_context;
236
 
 
237
 
struct d3d12_shader_selector *
238
 
d3d12_create_shader(struct d3d12_context *ctx,
239
 
                    enum pipe_shader_type stage,
240
 
                    const struct pipe_shader_state *shader);
241
 
 
242
 
struct d3d12_shader_selector *
243
 
d3d12_create_compute_shader(struct d3d12_context *ctx,
244
 
                            const struct pipe_compute_state *shader);
245
 
 
246
 
void
247
 
d3d12_shader_free(struct d3d12_shader_selector *shader);
248
 
 
249
 
void
250
 
d3d12_select_shader_variants(struct d3d12_context *ctx,
251
 
                             const struct pipe_draw_info *dinfo);
252
 
 
253
 
void
254
 
d3d12_select_compute_shader_variants(struct d3d12_context *ctx,
255
 
                                     const struct pipe_grid_info *info);
256
 
 
257
 
void
258
 
d3d12_gs_variant_cache_init(struct d3d12_context *ctx);
259
 
 
260
 
void
261
 
d3d12_gs_variant_cache_destroy(struct d3d12_context *ctx);
262
 
 
263
 
struct d3d12_shader_selector *
264
 
d3d12_get_gs_variant(struct d3d12_context *ctx, struct d3d12_gs_variant_key *key);
265
 
 
266
 
void
267
 
d3d12_tcs_variant_cache_init(struct d3d12_context *ctx);
268
 
 
269
 
void
270
 
d3d12_tcs_variant_cache_destroy(struct d3d12_context *ctx);
271
 
 
272
 
struct d3d12_shader_selector *
273
 
d3d12_get_tcs_variant(struct d3d12_context *ctx, struct d3d12_tcs_variant_key *key);
274
 
 
275
 
#ifdef __cplusplus
276
 
}
277
 
#endif
278
 
 
279
 
#endif