gallium: Add PIPE_SHADER_CAP_DOUBLES
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_limits.h
1 /**************************************************************************
2 *
3 * Copyright 2010-2012 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 **************************************************************************/
27
28
29 #ifndef LP_BLD_LIMITS_H_
30 #define LP_BLD_LIMITS_H_
31
32
33 #include <limits.h>
34
35 #include "pipe/p_state.h"
36 #include "pipe/p_defines.h"
37
38
39 /*
40 * TGSI translation limits.
41 *
42 * Some are slightly above SM 3.0 requirements to give some wiggle room to
43 * the state trackers.
44 */
45
46 #define LP_MAX_TGSI_TEMPS 4096
47
48 #define LP_MAX_TGSI_ADDRS 16
49
50 #define LP_MAX_TGSI_IMMEDIATES 4096
51
52 #define LP_MAX_TGSI_PREDS 16
53
54 #define LP_MAX_TGSI_CONST_BUFFERS 16
55
56 /*
57 * For quick access we cache registers in statically
58 * allocated arrays. Here we define the maximum size
59 * for those arrays.
60 */
61 #define LP_MAX_INLINED_TEMPS 256
62
63 #define LP_MAX_INLINED_IMMEDIATES 256
64
65 /**
66 * Maximum control flow nesting
67 *
68 * SM4.0 requires 64 (per subroutine actually, subroutine nesting itself is 32)
69 * SM3.0 requires 24 (most likely per subroutine too)
70 * add 2 more (some translation could add one more)
71 */
72 #define LP_MAX_TGSI_NESTING 66
73
74 /**
75 * Maximum iterations before loop termination
76 * Shared between every loop in a TGSI shader
77 */
78 #define LP_MAX_TGSI_LOOP_ITERATIONS 65535
79
80
81 /**
82 * Some of these limits are actually infinite (i.e., only limited by available
83 * memory), however advertising INT_MAX would cause some test problems to
84 * actually try to allocate the maximum and run out of memory and crash. So
85 * stick with something reasonable here.
86 */
87 static INLINE int
88 gallivm_get_shader_param(enum pipe_shader_cap param)
89 {
90 switch(param) {
91 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
92 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
93 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
94 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
95 return 1 * 1024 * 1024;
96 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
97 return LP_MAX_TGSI_NESTING;
98 case PIPE_SHADER_CAP_MAX_INPUTS:
99 return PIPE_MAX_SHADER_INPUTS;
100 case PIPE_SHADER_CAP_MAX_CONSTS:
101 return 16 * 2024;
102 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
103 return PIPE_MAX_CONSTANT_BUFFERS;
104 case PIPE_SHADER_CAP_MAX_TEMPS:
105 return LP_MAX_TGSI_TEMPS;
106 case PIPE_SHADER_CAP_MAX_ADDRS:
107 return LP_MAX_TGSI_ADDRS;
108 case PIPE_SHADER_CAP_MAX_PREDS:
109 return LP_MAX_TGSI_PREDS;
110 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
111 return 1;
112 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
113 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
114 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
115 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
116 return 1;
117 case PIPE_SHADER_CAP_SUBROUTINES:
118 return 1;
119 case PIPE_SHADER_CAP_INTEGERS:
120 return 1;
121 case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
122 return PIPE_MAX_SAMPLERS;
123 case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
124 return PIPE_MAX_SHADER_SAMPLER_VIEWS;
125 case PIPE_SHADER_CAP_PREFERRED_IR:
126 return PIPE_SHADER_IR_TGSI;
127 case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
128 return 1;
129 case PIPE_SHADER_CAP_DOUBLES:
130 return 0;
131 }
132 /* if we get here, we missed a shader cap above (and should have seen
133 * a compiler warning.)
134 */
135 return 0;
136 }
137
138
139 #endif /* LP_BLD_LIMITS_H_ */