1/*
2 * Copyright © 2022 Imagination Technologies Ltd.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * 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 THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24#ifndef ROGUE_H
25#define ROGUE_H
26
27#include <stddef.h>
28#include <stdint.h>
29
30#include "compiler/shader_enums.h"
31#include "nir/nir.h"
32
33/* All registers are 32-bit in size. */
34#define ROGUE_REG_SIZE_BYTES 4
35#define ROGUE_REG_UNUSED UINT32_MAX
36
37struct nir_spirv_specialization;
38struct rogue_build_ctx;
39struct rogue_shader;
40
41enum rogue_msaa_mode {
42   ROGUE_MSAA_MODE_UNDEF = 0, /* explicitly treat 0 as undefined */
43   /* One task for all samples. */
44   ROGUE_MSAA_MODE_PIXEL,
45   /* For on-edge pixels only: separate tasks for each sample. */
46   ROGUE_MSAA_MODE_SELECTIVE,
47   /* For all pixels: separate tasks for each sample. */
48   ROGUE_MSAA_MODE_FULL,
49};
50
51/**
52 * \brief Shader binary.
53 */
54struct rogue_shader_binary {
55   size_t size;
56   uint8_t data[];
57};
58
59PUBLIC
60nir_shader *rogue_spirv_to_nir(struct rogue_build_ctx *ctx,
61                               gl_shader_stage stage,
62                               const char *entry,
63                               size_t spirv_size,
64                               const uint32_t *spirv_data,
65                               unsigned num_spec,
66                               struct nir_spirv_specialization *spec);
67
68PUBLIC
69struct rogue_shader_binary *rogue_to_binary(struct rogue_build_ctx *ctx,
70                                            const struct rogue_shader *shader);
71
72PUBLIC
73struct rogue_shader *rogue_nir_to_rogue(struct rogue_build_ctx *ctx,
74                                        const nir_shader *nir);
75#endif /* ROGUE_H */
76