ilo: move hardware limits to ilo_gpe.h
[mesa.git] / src / gallium / drivers / ilo / ilo_context.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2012-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_CONTEXT_H
29 #define ILO_CONTEXT_H
30
31 #include "pipe/p_context.h"
32
33 #include "ilo_gpe.h"
34 #include "ilo_common.h"
35
36 struct blitter_context;
37 struct intel_winsys;
38 struct intel_bo;
39 struct ilo_3d;
40 struct ilo_cp;
41 struct ilo_screen;
42 struct ilo_shader_state;
43
44 struct ilo_vertex_element {
45 struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS];
46 unsigned num_elements;
47 };
48
49 struct ilo_context {
50 struct pipe_context base;
51
52 struct intel_winsys *winsys;
53 struct ilo_dev_info *dev;
54
55 struct ilo_cp *cp;
56 struct intel_bo *last_cp_bo;
57
58 struct ilo_shader_cache *shader_cache;
59 struct ilo_3d *hw3d;
60 struct blitter_context *blitter;
61
62 uint32_t dirty;
63
64 struct pipe_blend_state *blend;
65 struct pipe_rasterizer_state *rasterizer;
66 struct pipe_depth_stencil_alpha_state *depth_stencil_alpha;
67 struct ilo_shader_state *fs;
68 struct ilo_shader_state *vs;
69 struct ilo_shader_state *gs;
70 struct ilo_vertex_element *vertex_elements;
71
72 struct pipe_blend_color blend_color;
73 struct pipe_stencil_ref stencil_ref;
74 unsigned sample_mask;
75 struct pipe_clip_state clip;
76 struct pipe_framebuffer_state framebuffer;
77 struct pipe_poly_stipple poly_stipple;
78 struct pipe_scissor_state scissor;
79 struct pipe_viewport_state viewport;
80 struct pipe_index_buffer index_buffer;
81
82 struct {
83 struct pipe_vertex_buffer buffers[PIPE_MAX_ATTRIBS];
84 unsigned num_buffers;
85 } vertex_buffers;
86
87 struct {
88 struct pipe_sampler_state *samplers[ILO_MAX_SAMPLERS];
89 unsigned num_samplers;
90 } samplers[PIPE_SHADER_TYPES];
91
92 struct {
93 struct pipe_sampler_view *views[ILO_MAX_SAMPLER_VIEWS];
94 unsigned num_views;
95 } sampler_views[PIPE_SHADER_TYPES];
96
97 struct {
98 struct pipe_constant_buffer buffers[ILO_MAX_CONST_BUFFERS];
99 unsigned num_buffers;
100 } constant_buffers[PIPE_SHADER_TYPES];
101
102 struct {
103 struct pipe_stream_output_target *targets[ILO_MAX_SO_BUFFERS];
104 unsigned num_targets;
105 unsigned append_bitmask;
106 } stream_output_targets;
107
108 struct {
109 struct pipe_surface *surfaces[PIPE_MAX_SHADER_RESOURCES];
110 unsigned num_surfaces;
111 } shader_resources;
112
113 struct ilo_shader_state *compute;
114
115 struct {
116 struct pipe_surface *surfaces[PIPE_MAX_SHADER_RESOURCES];
117 unsigned num_surfaces;
118 } compute_resources;
119
120 struct {
121 /*
122 * XXX These should not be treated as real resources (and there could be
123 * thousands of them). They should be treated as regions in GLOBAL
124 * resource, which is the only real resource.
125 *
126 * That is, a resource here should instead be
127 *
128 * struct ilo_global_region {
129 * struct pipe_resource base;
130 * int offset;
131 * int size;
132 * };
133 *
134 * and it describes the region [offset, offset + size) in GLOBAL
135 * resource.
136 */
137 struct pipe_resource *resources[PIPE_MAX_SHADER_RESOURCES];
138 uint32_t *handles[PIPE_MAX_SHADER_RESOURCES];
139 unsigned num_resources;
140 } global_binding;
141 };
142
143 static inline struct ilo_context *
144 ilo_context(struct pipe_context *pipe)
145 {
146 return (struct ilo_context *) pipe;
147 }
148
149 void
150 ilo_init_context_functions(struct ilo_screen *is);
151
152 #endif /* ILO_CONTEXT_H */