1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved.
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software.
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef TGSI_SCAN_H
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define TGSI_SCAN_H
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_compiler.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_shader_tokens.h"
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Shader summary info
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tgsi_shader_info
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint num_tokens;
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte num_inputs;
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte num_outputs;
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte input_interpolate[PIPE_MAX_SHADER_INPUTS];
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte input_centroid[PIPE_MAX_SHADER_INPUTS];
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte input_usage_mask[PIPE_MAX_SHADER_INPUTS];
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte input_cylindrical_wrap[PIPE_MAX_SHADER_INPUTS];
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte num_system_values;
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ubyte system_value_semantic_name[PIPE_MAX_SHADER_INPUTS];
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint file_mask[TGSI_FILE_COUNT];  /**< bitmask of declared registers */
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint file_count[TGSI_FILE_COUNT];  /**< number of declared registers */
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int file_max[TGSI_FILE_COUNT];  /**< highest index of declared registers */
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint immediate_count; /**< number of immediates declared */
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint num_instructions;
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint opcode_count[TGSI_OPCODE_LAST];  /**< opcode histogram */
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean reads_position; /**< does fragment shader read position? */
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean reads_z; /**< does fragment shader read depth? */
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean writes_z;  /**< does fragment shader write Z value? */
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean writes_stencil; /**< does fragment shader write stencil value? */
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean uses_kill;  /**< KIL or KILP instruction used? */
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean uses_instanceid;
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean uses_vertexid;
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean origin_lower_left;
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean pixel_center_integer;
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   boolean color0_writes_all_cbufs;
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   unsigned num_written_clipdistance;
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   /**
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * Bitmask indicating which register files are accessed with
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    * indirect addressing.  The bits are (1 << TGSI_FILE_x), etc.
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org    */
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   unsigned indirect_files;
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct {
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      unsigned name;
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      unsigned data[8];
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   } properties[TGSI_PROPERTY_COUNT];
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   uint num_properties;
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtgsi_scan_shader(const struct tgsi_token *tokens,
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                 struct tgsi_shader_info *info);
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern boolean
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtgsi_is_passthrough_shader(const struct tgsi_token *tokens);
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* TGSI_SCAN_H */
102