ilo: embed ilo_state_vf in ilo_ve_state
[mesa.git] / src / gallium / drivers / ilo / core / ilo_state_3d.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2012-2014 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_STATE_3D_H
29 #define ILO_STATE_3D_H
30
31 #include "genhw/genhw.h"
32 #include "pipe/p_state.h"
33
34 #include "ilo_core.h"
35 #include "ilo_dev.h"
36 #include "ilo_state_surface.h"
37 #include "ilo_state_zs.h"
38
39 /**
40 * \see brw_context.h
41 */
42 #define ILO_MAX_DRAW_BUFFERS 8
43 #define ILO_MAX_CONST_BUFFERS (1 + 12)
44 #define ILO_MAX_SAMPLER_VIEWS 16
45 #define ILO_MAX_SAMPLERS 16
46 #define ILO_MAX_SO_BINDINGS 64
47 #define ILO_MAX_SO_BUFFERS 4
48 #define ILO_MAX_VIEWPORTS 1
49
50 #define ILO_MAX_SURFACES 256
51
52 struct intel_bo;
53 struct ilo_buffer;
54 struct ilo_image;
55 struct ilo_shader_state;
56
57 struct ilo_vb_state {
58 struct pipe_vertex_buffer states[PIPE_MAX_ATTRIBS];
59 uint32_t enabled_mask;
60 };
61
62 struct ilo_ib_state {
63 struct pipe_resource *buffer;
64 const void *user_buffer;
65 unsigned offset;
66 unsigned index_size;
67
68 /* these are not valid until the state is finalized */
69 struct pipe_resource *hw_resource;
70 unsigned hw_index_size;
71 /* an offset to be added to pipe_draw_info::start */
72 int64_t draw_start_offset;
73 };
74
75 struct ilo_so_state {
76 struct pipe_stream_output_target *states[ILO_MAX_SO_BUFFERS];
77 unsigned count;
78 unsigned append_bitmask;
79
80 bool enabled;
81 };
82
83 struct ilo_surface_cso {
84 struct pipe_surface base;
85
86 bool is_rt;
87 union {
88 struct ilo_state_surface rt;
89 struct ilo_state_zs zs;
90 } u;
91 };
92
93 struct ilo_fb_state {
94 struct pipe_framebuffer_state state;
95
96 struct ilo_state_surface null_rt;
97 struct ilo_state_zs null_zs;
98
99 struct ilo_fb_blend_caps {
100 bool is_unorm;
101 bool is_integer;
102 bool force_dst_alpha_one;
103
104 bool can_logicop;
105 bool can_blend;
106 bool can_alpha_test;
107 } blend_caps[PIPE_MAX_COLOR_BUFS];
108
109 unsigned num_samples;
110
111 bool has_integer_rt;
112 bool has_hiz;
113 enum gen_depth_format depth_offset_format;
114 };
115
116 struct ilo_shader_cso {
117 uint32_t payload[5];
118 };
119
120 void
121 ilo_gpe_init_vs_cso(const struct ilo_dev *dev,
122 const struct ilo_shader_state *vs,
123 struct ilo_shader_cso *cso);
124
125 void
126 ilo_gpe_init_gs_cso(const struct ilo_dev *dev,
127 const struct ilo_shader_state *gs,
128 struct ilo_shader_cso *cso);
129
130 void
131 ilo_gpe_init_fs_cso(const struct ilo_dev *dev,
132 const struct ilo_shader_state *fs,
133 struct ilo_shader_cso *cso);
134
135 void
136 ilo_gpe_set_fb(const struct ilo_dev *dev,
137 const struct pipe_framebuffer_state *state,
138 struct ilo_fb_state *fb);
139
140 #endif /* ILO_STATE_3D_H */