1 /*
2 * Copyright © 2024 Imagination Technologies Ltd.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 /**
8 * \file pvr_uscgen.c
9 *
10 * \brief USC shader generation.
11 */
12
13 #include "nir/nir.h"
14 #include "nir/nir_builder.h"
15 #include "pco/pco.h"
16 #include "pvr_uscgen.h"
17 #include "util/macros.h"
18
19 /**
20 * Common function to build a NIR shader and export the binary.
21 *
22 * \param ctx PCO context.
23 * \param nir NIR shader.
24 * \param binary Output shader binary.
25 */
build_shader(pco_ctx * ctx,nir_shader * nir,pco_binary ** binary)26 static void build_shader(pco_ctx *ctx, nir_shader *nir, pco_binary **binary)
27 {
28 pco_preprocess_nir(ctx, nir);
29 pco_lower_nir(ctx, nir);
30 pco_postprocess_nir(ctx, nir);
31
32 pco_shader *shader = pco_trans_nir(ctx, nir);
33 pco_process_ir(ctx, shader);
34
35 pco_binary *bin = pco_encode_ir(ctx, shader);
36 ralloc_free(shader);
37
38 pco_binary_finalize(ctx, bin);
39 *binary = bin;
40 }
41
42 /**
43 * Generate a nop (empty) shader.
44 *
45 * \param ctx PCO context.
46 * \param stage Shader stage.
47 * \param binary Output shader binary.
48 */
pvr_uscgen_nop(pco_ctx * ctx,gl_shader_stage stage,pco_binary ** binary)49 void pvr_uscgen_nop(pco_ctx *ctx, gl_shader_stage stage, pco_binary **binary)
50 {
51 unreachable("finishme: pvr_uscgen_nop");
52 }
53
54 /**
55 * Generate an end-of-tile shader.
56 *
57 * \param ctx PCO context.
58 * \param props End of tile shader properties.
59 * \param binary Output shader binary.
60 */
pvr_uscgen_eot(pco_ctx * ctx,struct pvr_eot_props * props,pco_binary ** binary)61 void pvr_uscgen_eot(pco_ctx *ctx,
62 struct pvr_eot_props *props,
63 pco_binary **binary)
64 {
65 unreachable("finishme: pvr_uscgen_eot");
66 }
67
68 /**
69 * Generate a transfer queue shader.
70 *
71 * \param ctx PCO context.
72 * \param props Transfer queue shader properties.
73 * \param binary Output shader binary.
74 */
pvr_uscgen_tq(pco_ctx * ctx,struct pvr_tq_props * props,pco_binary ** binary)75 void pvr_uscgen_tq(pco_ctx *ctx,
76 struct pvr_tq_props *props,
77 pco_binary **binary)
78 {
79 unreachable("finishme: pvr_uscgen_tq");
80 }
81