xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/freedreno/ir3/ir3_gallium.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2014 Rob Clark <[email protected]>
3  * SPDX-License-Identifier: MIT
4  *
5  * Authors:
6  *    Rob Clark <[email protected]>
7  */
8 
9 #ifndef IR3_GALLIUM_H_
10 #define IR3_GALLIUM_H_
11 
12 #include "ir3/ir3_shader.h"
13 #include "pipe/p_screen.h"
14 #include "pipe/p_state.h"
15 
16 #include "freedreno_util.h"
17 
18 BEGINC;
19 
20 /**
21  * The ir3 hwcso type, use ir3_get_shader() to dereference the
22  * underlying ir3_shader
23  */
24 struct ir3_shader_state;
25 
26 struct ir3_shader_variant *
27 ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key,
28                    bool binning_pass, struct util_debug_callback *debug);
29 
30 void *ir3_shader_compute_state_create(struct pipe_context *pctx,
31                                       const struct pipe_compute_state *cso);
32 void *ir3_shader_state_create(struct pipe_context *pctx,
33                               const struct pipe_shader_state *cso);
34 void ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso);
35 
36 struct ir3_shader *ir3_get_shader(struct ir3_shader_state *hwcso);
37 struct shader_info *ir3_get_shader_info(struct ir3_shader_state *hwcso);
38 
39 void ir3_fixup_shader_state(struct pipe_context *pctx,
40                             struct ir3_shader_key *key) assert_dt;
41 
42 void ir3_prog_init(struct pipe_context *pctx);
43 void ir3_screen_init(struct pipe_screen *pscreen);
44 void ir3_screen_fini(struct pipe_screen *pscreen);
45 
46 /**
47  * A helper to determine if a fs input 'i' is point/sprite coord, given
48  * the specified sprite_coord_enable mask
49  */
50 static inline bool
ir3_point_sprite(const struct ir3_shader_variant * fs,int i,uint32_t sprite_coord_enable,bool * coord_mode)51 ir3_point_sprite(const struct ir3_shader_variant *fs, int i,
52                  uint32_t sprite_coord_enable, bool *coord_mode)
53 {
54    gl_varying_slot slot = (gl_varying_slot)fs->inputs[i].slot;
55    switch (slot) {
56    case VARYING_SLOT_PNTC:
57       *coord_mode = true;
58       return true;
59    case VARYING_SLOT_TEX0 ... VARYING_SLOT_TEX7:
60       return !!(sprite_coord_enable & BITFIELD_BIT(slot - VARYING_SLOT_TEX0));
61    default:
62       return false;
63    }
64 }
65 
66 void ir3_update_max_tf_vtx(struct fd_context *ctx,
67                            const struct ir3_shader_variant *v) assert_dt;
68 
69 void ir3_get_private_mem(struct fd_context *ctx,
70                          const struct ir3_shader_variant *so) assert_dt;
71 
72 ENDC;
73 
74 #endif /* IR3_GALLIUM_H_ */
75