2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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:
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
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.
23 #ifndef R600_CONTEXT_H
24 #define R600_CONTEXT_H
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>
33 #include "r600_shader.h"
35 /* XXX move this to a more appropriate place */
36 struct r600_vertex_elements_state
39 struct pipe_vertex_element elements
[32];
42 struct r600_pipe_shader
{
44 struct r600_shader shader
;
46 struct radeon_state
*state
;
50 struct pipe_context context
;
51 struct r600_screen
*screen
;
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
;
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
;
70 /* Convenience cast wrapper. */
71 static INLINE
struct r600_context
*r600_context(struct pipe_context
*pipe
)
73 return (struct r600_context
*)pipe
;
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
);
88 void r600_init_blit_functions(struct r600_context
*rctx
);
89 void r600_init_state_functions(struct r600_context
*rctx
);
90 void r600_init_query_functions(struct r600_context
* rctx
);
91 struct pipe_context
*r600_create_context(struct pipe_screen
*screen
, void *priv
);
93 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*rpshader
);
94 struct r600_pipe_shader
*r600_pipe_shader_create(struct pipe_context
*ctx
,
96 const struct tgsi_token
*tokens
);
97 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*rpshader
);