14a49301eSmrg/**********************************************************
24a49301eSmrg * Copyright 2008-2009 VMware, Inc.  All rights reserved.
34a49301eSmrg *
44a49301eSmrg * Permission is hereby granted, free of charge, to any person
54a49301eSmrg * obtaining a copy of this software and associated documentation
64a49301eSmrg * files (the "Software"), to deal in the Software without
74a49301eSmrg * restriction, including without limitation the rights to use, copy,
84a49301eSmrg * modify, merge, publish, distribute, sublicense, and/or sell copies
94a49301eSmrg * of the Software, and to permit persons to whom the Software is
104a49301eSmrg * furnished to do so, subject to the following conditions:
114a49301eSmrg *
124a49301eSmrg * The above copyright notice and this permission notice shall be
134a49301eSmrg * included in all copies or substantial portions of the Software.
144a49301eSmrg *
154a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
164a49301eSmrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
174a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
184a49301eSmrg * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
194a49301eSmrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
204a49301eSmrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
214a49301eSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
224a49301eSmrg * SOFTWARE.
234a49301eSmrg *
244a49301eSmrg **********************************************************/
254a49301eSmrg
264a49301eSmrg#ifndef SVGA_TGSI_H
274a49301eSmrg#define SVGA_TGSI_H
284a49301eSmrg
2901e04c3fSmrg#include "pipe/p_compiler.h"
3001e04c3fSmrg#include "svga3d_reg.h"
314a49301eSmrg
324a49301eSmrg
337ec681f3Smrg#define MAX_VGPU10_ADDR_REGS 4
34af69d88dSmrg
3501e04c3fSmrgstruct svga_compile_key;
3601e04c3fSmrgstruct svga_context;
374a49301eSmrgstruct svga_shader;
3801e04c3fSmrgstruct svga_shader_variant;
394a49301eSmrg
404a49301eSmrg
414a49301eSmrg/* TGSI doesn't provide use with VS input semantics (they're actually
424a49301eSmrg * pretty meaningless), so we just generate some plausible ones here.
434a49301eSmrg * This is called both from within the TGSI translator and when
444a49301eSmrg * building vdecls to ensure they match up.
454a49301eSmrg *
464a49301eSmrg * The real use of this information is matching vertex elements to
474a49301eSmrg * fragment shader inputs in the case where vertex shader is disabled.
484a49301eSmrg */
4901e04c3fSmrgstatic inline void svga_generate_vdecl_semantics( unsigned idx,
504a49301eSmrg                                                  unsigned *usage,
514a49301eSmrg                                                  unsigned *usage_index )
524a49301eSmrg{
534a49301eSmrg   if (idx == 0) {
544a49301eSmrg      *usage = SVGA3D_DECLUSAGE_POSITION;
554a49301eSmrg      *usage_index = 0;
564a49301eSmrg   }
574a49301eSmrg   else {
584a49301eSmrg      *usage = SVGA3D_DECLUSAGE_TEXCOORD;
594a49301eSmrg      *usage_index = idx - 1;
604a49301eSmrg   }
614a49301eSmrg}
624a49301eSmrg
634a49301eSmrg
644a49301eSmrg
65af69d88dSmrgstruct svga_shader_variant *
6601e04c3fSmrgsvga_tgsi_vgpu9_translate(struct svga_context *svga,
6701e04c3fSmrg                          const struct svga_shader *shader,
6801e04c3fSmrg                          const struct svga_compile_key *key,
6901e04c3fSmrg                          enum pipe_shader_type unit);
704a49301eSmrg
71af69d88dSmrgstruct svga_shader_variant *
7201e04c3fSmrgsvga_tgsi_vgpu10_translate(struct svga_context *svga,
7301e04c3fSmrg                           const struct svga_shader *shader,
7401e04c3fSmrg                           const struct svga_compile_key *key,
7501e04c3fSmrg                           enum pipe_shader_type unit);
76af69d88dSmrg
7701e04c3fSmrgboolean svga_shader_verify(const uint32_t *tokens, unsigned nr_tokens);
784a49301eSmrg
794a49301eSmrg#endif
80