r600g: use cast wrappers
[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 r600_screen *screen;
52 struct radeon *rw;
53 struct radeon_ctx *ctx;
54 struct radeon_state *cb_cntl;
55 struct radeon_state *db;
56 struct radeon_state *config;
57 struct r600_pipe_shader *ps_shader;
58 struct r600_pipe_shader *vs_shader;
59 unsigned flat_shade;
60 unsigned nvertex_buffer;
61 struct r600_vertex_elements_state *vertex_elements;
62 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
63 struct blitter_context *blitter;
64 struct pipe_stencil_ref stencil_ref;
65 struct pipe_framebuffer_state fb_state;
66 struct radeon_draw *draw;
67 struct pipe_viewport_state viewport;
68 };
69
70 /* Convenience cast wrapper. */
71 static INLINE struct r600_context *r600_context(struct pipe_context *pipe)
72 {
73 return (struct r600_context*)pipe;
74 }
75
76 void r600_draw_arrays(struct pipe_context *ctx, unsigned mode,
77 unsigned start, unsigned count);
78 void r600_draw_elements(struct pipe_context *ctx,
79 struct pipe_resource *index_buffer,
80 unsigned index_size, int index_bias, unsigned mode,
81 unsigned start, unsigned count);
82 void r600_draw_range_elements(struct pipe_context *ctx,
83 struct pipe_resource *index_buffer,
84 unsigned index_size, int index_bias, unsigned min_index,
85 unsigned max_index, unsigned mode,
86 unsigned start, unsigned count);
87
88 void r600_init_state_functions(struct r600_context *rctx);
89 void r600_init_query_functions(struct r600_context* rctx);
90 struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv);
91
92 void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *rpshader);
93 struct r600_pipe_shader *r600_pipe_shader_create(struct pipe_context *ctx,
94 unsigned type,
95 const struct tgsi_token *tokens);
96 int r600_pipe_shader_update(struct pipe_context *ctx, struct r600_pipe_shader *rpshader);
97
98 #endif