iris: framebuffers
[mesa.git] / src / gallium / drivers / iris / iris_context.h
1 /*
2 * Copyright © 2017 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #ifndef IRIS_CONTEXT_H
24 #define IRIS_CONTEXT_H
25
26 #include "pipe/p_context.h"
27 #include "pipe/p_state.h"
28 #include "util/u_debug.h"
29 #include "intel/common/gen_debug.h"
30 #include "iris_screen.h"
31
32 struct iris_bo;
33 struct iris_batch;
34
35 #define IRIS_MAX_TEXTURE_SAMPLERS 32
36 #define IRIS_MAX_VIEWPORTS 16
37
38 enum iris_dirty {
39 IRIS_DIRTY_COLOR_CALC_STATE = (1ull << 0),
40 IRIS_DIRTY_POLYGON_STIPPLE = (1ull << 1),
41 IRIS_DIRTY_SCISSOR_RECT = (1ull << 2),
42 IRIS_DIRTY_WM_DEPTH_STENCIL = (1ull << 3),
43 IRIS_DIRTY_CC_VIEWPORT = (1ull << 4),
44 IRIS_DIRTY_SF_CL_VIEWPORT = (1ull << 5),
45 IRIS_DIRTY_PS_BLEND = (1ull << 6),
46 IRIS_DIRTY_BLEND_STATE = (1ull << 7),
47 IRIS_DIRTY_RASTER = (1ull << 8),
48 IRIS_DIRTY_CLIP = (1ull << 9),
49 IRIS_DIRTY_SCISSOR = (1ull << 10),
50 IRIS_DIRTY_LINE_STIPPLE = (1ull << 11),
51 IRIS_DIRTY_VERTEX_ELEMENTS = (1ull << 12),
52 IRIS_DIRTY_MULTISAMPLE = (1ull << 13),
53 };
54
55 struct iris_depth_stencil_alpha_state;
56
57 struct iris_context {
58 struct pipe_context ctx;
59
60 struct pipe_debug_callback dbg;
61
62 struct {
63 uint64_t dirty;
64 unsigned num_viewports; // XXX: can viewports + scissors be different?
65 unsigned num_scissors;
66 struct iris_blend_state *cso_blend;
67 struct iris_rasterizer_state *cso_rast;
68 struct iris_depth_stencil_alpha_state *cso_zsa;
69 struct iris_vertex_element_state *cso_vertex_elements;
70 struct iris_viewport_state *cso_vp;
71 struct pipe_blend_color blend_color;
72 struct pipe_poly_stipple poly_stipple;
73 struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS];
74 struct pipe_stencil_ref stencil_ref;
75 struct pipe_framebuffer_state framebuffer;
76 } state;
77 };
78
79 #define perf_debug(dbg, ...) do { \
80 if (INTEL_DEBUG & DEBUG_PERF) \
81 dbg_printf(__VA_ARGS__); \
82 if (unlikely(dbg)) \
83 pipe_debug_message(dbg, PERF_INFO, __VA_ARGS__); \
84 } while(0)
85
86 double get_time(void);
87
88 struct pipe_context *
89 iris_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
90
91 void iris_init_program_functions(struct pipe_context *ctx);
92 void iris_init_state_functions(struct pipe_context *ctx);
93
94 void iris_upload_render_state(struct iris_context *ice, struct iris_batch *batch);
95 void iris_destroy_state(struct iris_context *ice);
96
97 #endif