1/**********************************************************
2 * Copyright 2008-2022 VMware, Inc.  All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26#ifndef SVGA_TGSI_H
27#define SVGA_TGSI_H
28
29#include "pipe/p_compiler.h"
30#include "svga3d_reg.h"
31
32
33#define MAX_VGPU10_ADDR_REGS 4
34
35struct svga_compile_key;
36struct svga_context;
37struct svga_shader;
38struct svga_shader_variant;
39
40
41/* TGSI doesn't provide use with VS input semantics (they're actually
42 * pretty meaningless), so we just generate some plausible ones here.
43 * This is called both from within the TGSI translator and when
44 * building vdecls to ensure they match up.
45 *
46 * The real use of this information is matching vertex elements to
47 * fragment shader inputs in the case where vertex shader is disabled.
48 */
49static inline void svga_generate_vdecl_semantics( unsigned idx,
50                                                  unsigned *usage,
51                                                  unsigned *usage_index )
52{
53   if (idx == 0) {
54      *usage = SVGA3D_DECLUSAGE_POSITION;
55      *usage_index = 0;
56   }
57   else {
58      *usage = SVGA3D_DECLUSAGE_TEXCOORD;
59      *usage_index = idx - 1;
60   }
61}
62
63
64
65struct svga_shader_variant *
66svga_tgsi_vgpu9_translate(struct svga_context *svga,
67                          const struct svga_shader *shader,
68                          const struct svga_compile_key *key,
69                          enum pipe_shader_type unit);
70
71struct svga_shader_variant *
72svga_tgsi_vgpu10_translate(struct svga_context *svga,
73                           const struct svga_shader *shader,
74                           const struct svga_compile_key *key,
75                           enum pipe_shader_type unit);
76
77boolean svga_shader_verify(const uint32_t *tokens, unsigned nr_tokens);
78
79void
80svga_tgsi_scan_shader(struct svga_shader *shader);
81
82struct svga_shader_variant *
83svga_tgsi_compile_shader(struct svga_context *svga,
84                         struct svga_shader *shader,
85                         const struct svga_compile_key *key);
86#endif
87