Merge branch 'gallium-newclear'
[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 /* XXX move this to a more appropriate place */
36 struct r600_vertex_elements_state
37 {
38 unsigned count;
39 struct pipe_vertex_element elements[32];
40 };
41
42 struct r600_pipe_shader {
43 unsigned type;
44 struct r600_shader shader;
45 struct radeon_bo *bo;
46 struct radeon_state *state;
47 };
48
49 struct r600_context {
50 struct pipe_context context;
51 struct radeon_ctx *ctx;
52 struct radeon_state *cb_cntl;
53 struct radeon_state *db;
54 struct radeon_state *config;
55 struct r600_pipe_shader *ps_shader;
56 struct r600_pipe_shader *vs_shader;
57 unsigned flat_shade;
58 unsigned nvertex_buffer;
59 struct r600_vertex_elements_state *vertex_elements;
60 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
61 struct blitter_context *blitter;
62 struct pipe_stencil_ref stencil_ref;
63 struct pipe_framebuffer_state fb_state;
64 struct radeon_draw *draw;
65 struct pipe_viewport_state viewport;
66 };
67
68 void r600_draw_arrays(struct pipe_context *ctx, unsigned mode,
69 unsigned start, unsigned count);
70 void r600_draw_elements(struct pipe_context *ctx,
71 struct pipe_resource *index_buffer,
72 unsigned index_size, int index_bias, unsigned mode,
73 unsigned start, unsigned count);
74 void r600_draw_range_elements(struct pipe_context *ctx,
75 struct pipe_resource *index_buffer,
76 unsigned index_size, int index_bias, unsigned min_index,
77 unsigned max_index, unsigned mode,
78 unsigned start, unsigned count);
79
80 void r600_init_state_functions(struct r600_context *rctx);
81 void r600_init_query_functions(struct r600_context* rctx);
82 struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv);
83
84 void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *rpshader);
85 struct r600_pipe_shader *r600_pipe_shader_create(struct pipe_context *ctx,
86 unsigned type,
87 const struct tgsi_token *tokens);
88 int r600_pipe_shader_update(struct pipe_context *ctx, struct r600_pipe_shader *rpshader);
89
90 #endif