1 /*
2 * Copyright (c) 2008-2024 Broadcom. All Rights Reserved.
3 * The term “Broadcom” refers to Broadcom Inc.
4 * and/or its subsidiaries.
5 * SPDX-License-Identifier: MIT
6 */
7
8 #ifndef SVGA_TGSI_H
9 #define SVGA_TGSI_H
10
11 #include "util/compiler.h"
12 #include "svga3d_reg.h"
13
14
15 #define MAX_VGPU10_ADDR_REGS 4
16
17 struct svga_compile_key;
18 struct svga_context;
19 struct svga_shader;
20 struct svga_shader_variant;
21
22
23 /* TGSI doesn't provide use with VS input semantics (they're actually
24 * pretty meaningless), so we just generate some plausible ones here.
25 * This is called both from within the TGSI translator and when
26 * building vdecls to ensure they match up.
27 *
28 * The real use of this information is matching vertex elements to
29 * fragment shader inputs in the case where vertex shader is disabled.
30 */
svga_generate_vdecl_semantics(unsigned idx,unsigned * usage,unsigned * usage_index)31 static inline void svga_generate_vdecl_semantics( unsigned idx,
32 unsigned *usage,
33 unsigned *usage_index )
34 {
35 if (idx == 0) {
36 *usage = SVGA3D_DECLUSAGE_POSITION;
37 *usage_index = 0;
38 }
39 else {
40 *usage = SVGA3D_DECLUSAGE_TEXCOORD;
41 *usage_index = idx - 1;
42 }
43 }
44
45
46
47 struct svga_shader_variant *
48 svga_tgsi_vgpu9_translate(struct svga_context *svga,
49 const struct svga_shader *shader,
50 const struct svga_compile_key *key,
51 enum pipe_shader_type unit);
52
53 struct svga_shader_variant *
54 svga_tgsi_vgpu10_translate(struct svga_context *svga,
55 const struct svga_shader *shader,
56 const struct svga_compile_key *key,
57 enum pipe_shader_type unit);
58
59 bool svga_shader_verify(const uint32_t *tokens, unsigned nr_tokens);
60
61 void
62 svga_tgsi_scan_shader(struct svga_shader *shader);
63
64 struct svga_shader_variant *
65 svga_tgsi_compile_shader(struct svga_context *svga,
66 struct svga_shader *shader,
67 const struct svga_compile_key *key);
68 #endif
69