ilo: switch to ilo states for shaders and resources
[mesa.git] / src / gallium / drivers / ilo / ilo_gpe.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2013 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28 #ifndef ILO_GPE_H
29 #define ILO_GPE_H
30
31 #include "ilo_common.h"
32
33 /**
34 * \see brw_context.h
35 */
36 #define ILO_MAX_DRAW_BUFFERS 8
37 #define ILO_MAX_CONST_BUFFERS (1 + 12)
38 #define ILO_MAX_SAMPLER_VIEWS 16
39 #define ILO_MAX_SAMPLERS 16
40 #define ILO_MAX_SO_BINDINGS 64
41 #define ILO_MAX_SO_BUFFERS 4
42 #define ILO_MAX_VIEWPORTS 1
43
44 #define ILO_MAX_VS_SURFACES (ILO_MAX_CONST_BUFFERS + ILO_MAX_SAMPLER_VIEWS)
45 #define ILO_VS_CONST_SURFACE(i) (i)
46 #define ILO_VS_TEXTURE_SURFACE(i) (ILO_MAX_CONST_BUFFERS + i)
47
48 #define ILO_MAX_GS_SURFACES (ILO_MAX_SO_BINDINGS)
49 #define ILO_GS_SO_SURFACE(i) (i)
50
51 #define ILO_MAX_WM_SURFACES (ILO_MAX_DRAW_BUFFERS + ILO_MAX_CONST_BUFFERS + ILO_MAX_SAMPLER_VIEWS)
52 #define ILO_WM_DRAW_SURFACE(i) (i)
53 #define ILO_WM_CONST_SURFACE(i) (ILO_MAX_DRAW_BUFFERS + i)
54 #define ILO_WM_TEXTURE_SURFACE(i) (ILO_MAX_DRAW_BUFFERS + ILO_MAX_CONST_BUFFERS + i)
55
56 struct ilo_vb_state {
57 struct pipe_vertex_buffer states[PIPE_MAX_ATTRIBS];
58 uint32_t enabled_mask;
59 };
60
61 struct ilo_ib_state {
62 struct pipe_index_buffer state;
63 };
64
65 struct ilo_ve_state {
66 struct pipe_vertex_element states[PIPE_MAX_ATTRIBS];
67 unsigned count;
68 };
69
70 struct ilo_so_state {
71 struct pipe_stream_output_target *states[ILO_MAX_SO_BUFFERS];
72 unsigned count;
73 unsigned append_bitmask;
74
75 bool enabled;
76 };
77
78 struct ilo_viewport_state {
79 struct pipe_viewport_state states[ILO_MAX_VIEWPORTS];
80 unsigned count;
81 };
82
83 struct ilo_scissor_state {
84 struct pipe_scissor_state states[ILO_MAX_VIEWPORTS];
85 };
86
87 struct ilo_rasterizer_state {
88 struct pipe_rasterizer_state state;
89 };
90
91 struct ilo_dsa_state {
92 struct pipe_depth_stencil_alpha_state state;
93 };
94
95 struct ilo_blend_state {
96 struct pipe_blend_state state;
97 };
98
99 struct ilo_sampler_state {
100 struct pipe_sampler_state *states[ILO_MAX_SAMPLERS];
101 unsigned count;
102 };
103
104 struct ilo_view_state {
105 struct pipe_sampler_view *states[ILO_MAX_SAMPLER_VIEWS];
106 unsigned count;
107 };
108
109 struct ilo_cbuf_state {
110 struct pipe_constant_buffer states[ILO_MAX_CONST_BUFFERS];
111 unsigned count;
112 };
113
114 struct ilo_resource_state {
115 struct pipe_surface *states[PIPE_MAX_SHADER_RESOURCES];
116 unsigned count;
117 };
118
119 struct ilo_fb_state {
120 struct pipe_framebuffer_state state;
121
122 unsigned num_samples;
123 };
124
125 struct ilo_global_binding {
126 /*
127 * XXX These should not be treated as real resources (and there could be
128 * thousands of them). They should be treated as regions in GLOBAL
129 * resource, which is the only real resource.
130 *
131 * That is, a resource here should instead be
132 *
133 * struct ilo_global_region {
134 * struct pipe_resource base;
135 * int offset;
136 * int size;
137 * };
138 *
139 * and it describes the region [offset, offset + size) in GLOBAL
140 * resource.
141 */
142 struct pipe_resource *resources[PIPE_MAX_SHADER_RESOURCES];
143 uint32_t *handles[PIPE_MAX_SHADER_RESOURCES];
144 unsigned count;
145 };
146
147 #endif /* ILO_GPE_H */