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
{
43 struct r600_shader shader
;
45 struct radeon_state
*state
;
49 struct pipe_context context
;
50 struct r600_screen
*screen
;
52 struct radeon_ctx
*ctx
;
53 struct radeon_state
*cb_cntl
;
54 struct radeon_state
*db
;
55 struct radeon_state
*config
;
56 struct r600_pipe_shader
*ps_shader
;
57 struct r600_pipe_shader
*vs_shader
;
59 unsigned nvertex_buffer
;
60 struct r600_vertex_elements_state
*vertex_elements
;
61 struct pipe_vertex_buffer vertex_buffer
[PIPE_MAX_ATTRIBS
];
62 struct blitter_context
*blitter
;
63 struct pipe_stencil_ref stencil_ref
;
64 struct pipe_framebuffer_state fb_state
;
65 struct radeon_draw
*draw
;
66 struct pipe_viewport_state viewport
;
69 /* Convenience cast wrapper. */
70 static INLINE
struct r600_context
*r600_context(struct pipe_context
*pipe
)
72 return (struct r600_context
*)pipe
;
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_resource
*index_buffer
,
79 unsigned index_size
, int index_bias
, unsigned mode
,
80 unsigned start
, unsigned count
);
81 void r600_draw_range_elements(struct pipe_context
*ctx
,
82 struct pipe_resource
*index_buffer
,
83 unsigned index_size
, int index_bias
, unsigned min_index
,
84 unsigned max_index
, unsigned mode
,
85 unsigned start
, unsigned count
);
87 void r600_init_blit_functions(struct r600_context
*rctx
);
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
);
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 const struct tgsi_token
*tokens
);
95 int r600_pipe_shader_update(struct pipe_context
*ctx
, struct r600_pipe_shader
*rpshader
);
97 #define R600_ERR(fmt, args...) \
98 fprintf(stderr, "EE %s/%s:%d - "fmt, __FILE__, __func__, __LINE__, ##args)