afe544819c8d51848475017399a0c604ed3de86b
[mesa.git] / src / gallium / drivers / r600 / r600_context.h
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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 R600_CONTEXT_H
24 #define R600_CONTEXT_H
25
26 #include <pipe/p_state.h>
27 #include <pipe/p_context.h>
28 #include <tgsi/tgsi_scan.h>
29 #include <tgsi/tgsi_parse.h>
30 #include <tgsi/tgsi_util.h>
31 #include <util/u_blitter.h>
32 #include "radeon.h"
33 #include "r600_shader.h"
34
35 struct r600_state;
36 typedef void (*r600_state_destroy_t)(struct r600_state *rstate);
37
38 struct r600_state {
39 unsigned type;
40 struct r600_atom *atom;
41 void *state;
42 unsigned nbuffers;
43 struct pipe_buffer *buffer[256];
44 unsigned nsurfaces;
45 struct pipe_surface *surface[256];
46 r600_state_destroy_t destroy;
47 };
48
49 struct r600_pipe_shader {
50 unsigned type;
51 struct r600_shader shader;
52 struct radeon_bo *bo;
53 struct radeon_state *state;
54 };
55
56 struct r600_context {
57 struct pipe_context context;
58 struct radeon_ctx *ctx;
59 struct radeon_state *cb_cntl;
60 struct radeon_state *db;
61 struct radeon_state *config;
62 struct r600_pipe_shader *ps_shader;
63 struct r600_pipe_shader *vs_shader;
64 unsigned flat_shade;
65 unsigned nvertex_buffer;
66 unsigned nvertex_element;
67 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
68 struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
69 struct blitter_context *blitter;
70 struct pipe_stencil_ref stencil_ref;
71 struct pipe_framebuffer_state fb_state;
72 struct radeon_draw *draw;
73 };
74
75 void r600_draw_arrays(struct pipe_context *ctx, unsigned mode,
76 unsigned start, unsigned count);
77 void r600_draw_elements(struct pipe_context *ctx,
78 struct pipe_buffer *index_buffer,
79 unsigned index_size, unsigned index_bias, unsigned mode,
80 unsigned start, unsigned count);
81 void r600_draw_range_elements(struct pipe_context *ctx,
82 struct pipe_buffer *index_buffer,
83 unsigned index_size, unsigned index_bias, unsigned min_index,
84 unsigned max_index, unsigned mode,
85 unsigned start, unsigned count);
86
87 void r600_state_destroy_common(struct r600_state *state);
88 struct r600_state *r600_state_new(r600_state_destroy_t destroy);
89 struct r600_state *r600_state_destroy(struct r600_state *state);
90
91 void r600_init_state_functions(struct r600_context *rctx);
92 void r600_init_query_functions(struct r600_context* rctx);
93 struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv);
94
95 void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *rpshader);
96 struct r600_pipe_shader *r600_pipe_shader_create(struct pipe_context *ctx,
97 unsigned type,
98 const struct tgsi_token *tokens);
99 int r600_pipe_shader_update(struct pipe_context *ctx, struct r600_pipe_shader *rpshader);
100
101 #endif