summaryrefslogtreecommitdiff
path: root/src/microsoft/vulkan/dzn_nir.h
blob: f3aced31a71a3c17e948717dc4d50f6be748df50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 * Copyright © Microsoft Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef DZN_NIR_H
#define DZN_NIR_H

#define D3D12_IGNORE_SDK_LAYERS
#include <directx/d3d12.h>

#include "nir.h"

#ifdef __cplusplus
extern "C" {
#endif

struct dzn_indirect_draw_params {
   uint32_t vertex_count;
   uint32_t instance_count;
   uint32_t first_vertex;
   uint32_t first_instance;
};

struct dzn_indirect_indexed_draw_params {
   uint32_t index_count;
   uint32_t instance_count;
   uint32_t first_index;
   int32_t vertex_offset;
   uint32_t first_instance;
};

struct dzn_indirect_draw_rewrite_params {
   uint32_t draw_buf_stride;
};

struct dzn_indirect_draw_triangle_fan_rewrite_params {
   uint32_t draw_buf_stride;
   uint32_t triangle_fan_index_buf_stride;
   uint64_t triangle_fan_index_buf_start;
};

struct dzn_indirect_draw_exec_params {
   struct {
      uint32_t first_vertex;
      uint32_t base_instance;
   } sysvals;
   union {
      struct dzn_indirect_draw_params draw;
      struct dzn_indirect_indexed_draw_params indexed_draw;
   };
};

struct dzn_indirect_triangle_fan_draw_exec_params {
   D3D12_INDEX_BUFFER_VIEW ibview;
   struct {
      uint32_t first_vertex;
      uint32_t base_instance;
   } sysvals;
   union {
      struct dzn_indirect_draw_params draw;
      struct dzn_indirect_indexed_draw_params indexed_draw;
   };
};

struct dzn_triangle_fan_rewrite_index_params {
   union {
      uint32_t first_index;
      uint32_t first_vertex;
   };
};

struct dzn_indirect_triangle_fan_rewrite_index_exec_params {
   uint64_t new_index_buf;
   struct dzn_triangle_fan_rewrite_index_params params;
   struct {
      uint32_t x, y, z;
   } group_count;
};

enum dzn_indirect_draw_type {
   DZN_INDIRECT_DRAW,
   DZN_INDIRECT_INDEXED_DRAW,
   DZN_INDIRECT_DRAW_TRIANGLE_FAN,
   DZN_INDIRECT_INDEXED_DRAW_TRIANGLE_FAN,
   DZN_NUM_INDIRECT_DRAW_TYPES,
};

nir_shader *
dzn_nir_indirect_draw_shader(enum dzn_indirect_draw_type type);

nir_shader *
dzn_nir_triangle_fan_rewrite_index_shader(uint8_t old_index_size);

struct dzn_nir_blit_info {
   union {
      struct {
         uint32_t src_samples : 6;
         uint32_t loc : 4;
         uint32_t out_type : 4;
         uint32_t sampler_dim : 4;
         uint32_t src_is_array : 1;
         uint32_t resolve : 1;
         uint32_t padding : 12;
      };
      const uint32_t hash_key;
   };
};

nir_shader *
dzn_nir_blit_vs(void);

nir_shader *
dzn_nir_blit_fs(const struct dzn_nir_blit_info *info);

#ifdef __cplusplus
}
#endif

#endif