| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#pragma once |
| 8 |
|
| 9 |
#include "util/string_buffer.h" |
| 10 |
#include "nir.h" |
| 11 |
|
| 12 |
struct io_slot_info { |
| 13 |
nir_alu_type type; |
| 14 |
uint32_t interpolation; |
| 15 |
unsigned num_components; |
| 16 |
bool centroid; |
| 17 |
bool sample; |
| 18 |
bool uses_interpolant; |
| 19 |
}; |
| 20 |
|
| 21 |
struct nir_to_msl_ctx { |
| 22 |
FILE *output; |
| 23 |
struct hash_table *types; |
| 24 |
nir_shader *shader; |
| 25 |
struct _mesa_string_buffer *text; |
| 26 |
uint64_t disabled_workarounds; |
| 27 |
unsigned short indentlevel; |
| 28 |
struct io_slot_info inputs_info[NUM_TOTAL_VARYING_SLOTS]; |
| 29 |
struct io_slot_info outputs_info[NUM_TOTAL_VARYING_SLOTS]; |
| 30 |
}; |
| 31 |
|
| 32 |
#define P_IND(ctx, ...) \ |
| 33 |
do { \ |
| 34 |
for (unsigned i = 0; i < (ctx)->indentlevel; i++) \ |
| 35 |
_mesa_string_buffer_append((ctx)->text, " "); \ |
| 36 |
_mesa_string_buffer_printf((ctx)->text, __VA_ARGS__); \ |
| 37 |
} while (0); |
| 38 |
|
| 39 |
#define P(ctx, ...) _mesa_string_buffer_printf((ctx)->text, __VA_ARGS__); |
| 40 |
|
| 41 |
#define P_INDENT(ctx) \ |
| 42 |
do { \ |
| 43 |
for (unsigned i = 0; i < (ctx)->indentlevel; i++) \ |
| 44 |
_mesa_string_buffer_append((ctx)->text, " "); \ |
| 45 |
} while (0) |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
struct hash_table *msl_infer_types(nir_shader *shader); |
| 51 |
|
| 52 |
const char *msl_type_for_def(struct hash_table *types, nir_def *def); |
| 53 |
|
| 54 |
const char *msl_uint_type(uint8_t bit_size, uint8_t num_components); |
| 55 |
|
| 56 |
const char *msl_type_for_src(struct hash_table *types, nir_src *src); |
| 57 |
|
| 58 |
const char *msl_bitcast_for_src(struct hash_table *types, nir_src *src); |
| 59 |
|
| 60 |
void msl_src_as_const(struct nir_to_msl_ctx *ctx, nir_src *src); |
| 61 |
|
| 62 |
void msl_emit_io_blocks(struct nir_to_msl_ctx *ctx, nir_shader *shader); |
| 63 |
|
| 64 |
void msl_emit_output_var(struct nir_to_msl_ctx *ctx, nir_shader *shader); |
| 65 |
|
| 66 |
void msl_gather_io_info(struct nir_to_msl_ctx *ctx, |
| 67 |
struct io_slot_info *info_array_input, |
| 68 |
struct io_slot_info *info_array_output); |
| 69 |
|
| 70 |
void msl_input_name(struct nir_to_msl_ctx *ctx, unsigned location, |
| 71 |
unsigned component); |
| 72 |
|
| 73 |
void msl_output_name(struct nir_to_msl_ctx *ctx, unsigned location, |
| 74 |
unsigned component); |
| 75 |
|
| 76 |
uint32_t msl_input_num_components(struct nir_to_msl_ctx *ctx, |
| 77 |
uint32_t location); |
| 78 |
|
| 79 |
uint32_t msl_output_num_components(struct nir_to_msl_ctx *ctx, |
| 80 |
uint32_t location); |
| 81 |
|
| 82 |
bool msl_src_is_float(struct nir_to_msl_ctx *ctx, nir_src *src); |
| 83 |
bool msl_def_is_sampler(struct nir_to_msl_ctx *ctx, nir_def *def); |
| 84 |
|
| 85 |
void msl_nir_lower_subgroups(nir_shader *nir); |
| 86 |
|
| 87 |
bool msl_nir_lower_algebraic_late(nir_shader *shader); |
| 88 |
|
| 89 |
bool msl_nir_lower_clip_distance(nir_shader *nir); |