2 /**************************************************************************
4 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
30 * \brief Public interface into the drawing module.
33 /* Authors: Keith Whitwell <keith@tungstengraphics.com>
37 #ifndef DRAW_CONTEXT_H
38 #define DRAW_CONTEXT_H
41 #include "pipe/p_state.h"
42 #include "tgsi/tgsi_exec.h"
47 struct draw_vertex_shader
;
48 struct draw_geometry_shader
;
49 struct draw_fragment_shader
;
53 struct draw_context
*draw_create( struct pipe_context
*pipe
);
55 void draw_destroy( struct draw_context
*draw
);
57 void draw_flush(struct draw_context
*draw
);
59 void draw_set_viewport_state( struct draw_context
*draw
,
60 const struct pipe_viewport_state
*viewport
);
62 void draw_set_clip_state( struct draw_context
*pipe
,
63 const struct pipe_clip_state
*clip
);
65 void draw_set_rasterizer_state( struct draw_context
*draw
,
66 const struct pipe_rasterizer_state
*raster
,
69 void draw_set_rasterize_stage( struct draw_context
*draw
,
70 struct draw_stage
*stage
);
72 void draw_wide_point_threshold(struct draw_context
*draw
, float threshold
);
74 void draw_wide_point_sprites(struct draw_context
*draw
, boolean draw_sprite
);
76 void draw_wide_line_threshold(struct draw_context
*draw
, float threshold
);
78 void draw_enable_line_stipple(struct draw_context
*draw
, boolean enable
);
80 void draw_enable_point_sprites(struct draw_context
*draw
, boolean enable
);
82 void draw_set_mrd(struct draw_context
*draw
, double mrd
);
85 draw_install_aaline_stage(struct draw_context
*draw
, struct pipe_context
*pipe
);
88 draw_install_aapoint_stage(struct draw_context
*draw
, struct pipe_context
*pipe
);
91 draw_install_pstipple_stage(struct draw_context
*draw
, struct pipe_context
*pipe
);
95 draw_find_shader_output(const struct draw_context
*draw
,
96 uint semantic_name
, uint semantic_index
);
99 draw_num_shader_outputs(const struct draw_context
*draw
);
103 draw_texture_samplers(struct draw_context
*draw
,
106 struct tgsi_sampler
**samplers
);
109 draw_set_sampler_views(struct draw_context
*draw
,
110 struct pipe_sampler_view
**views
,
113 draw_set_samplers(struct draw_context
*draw
,
114 struct pipe_sampler_state
**samplers
,
118 draw_set_mapped_texture(struct draw_context
*draw
,
119 unsigned sampler_idx
,
120 uint32_t width
, uint32_t height
, uint32_t depth
,
122 uint32_t row_stride
[PIPE_MAX_TEXTURE_LEVELS
],
123 uint32_t img_stride
[PIPE_MAX_TEXTURE_LEVELS
],
124 const void *data
[PIPE_MAX_TEXTURE_LEVELS
]);
128 * Vertex shader functions
131 struct draw_vertex_shader
*
132 draw_create_vertex_shader(struct draw_context
*draw
,
133 const struct pipe_shader_state
*shader
);
134 void draw_bind_vertex_shader(struct draw_context
*draw
,
135 struct draw_vertex_shader
*dvs
);
136 void draw_delete_vertex_shader(struct draw_context
*draw
,
137 struct draw_vertex_shader
*dvs
);
141 * Fragment shader functions
143 struct draw_fragment_shader
*
144 draw_create_fragment_shader(struct draw_context
*draw
,
145 const struct pipe_shader_state
*shader
);
146 void draw_bind_fragment_shader(struct draw_context
*draw
,
147 struct draw_fragment_shader
*dvs
);
148 void draw_delete_fragment_shader(struct draw_context
*draw
,
149 struct draw_fragment_shader
*dvs
);
152 * Geometry shader functions
154 struct draw_geometry_shader
*
155 draw_create_geometry_shader(struct draw_context
*draw
,
156 const struct pipe_shader_state
*shader
);
157 void draw_bind_geometry_shader(struct draw_context
*draw
,
158 struct draw_geometry_shader
*dvs
);
159 void draw_delete_geometry_shader(struct draw_context
*draw
,
160 struct draw_geometry_shader
*dvs
);
164 * Vertex data functions
167 void draw_set_vertex_buffers(struct draw_context
*draw
,
169 const struct pipe_vertex_buffer
*buffers
);
171 void draw_set_vertex_elements(struct draw_context
*draw
,
173 const struct pipe_vertex_element
*elements
);
175 void draw_set_index_buffer(struct draw_context
*draw
,
176 const struct pipe_index_buffer
*ib
);
178 void draw_set_mapped_index_buffer(struct draw_context
*draw
,
179 const void *elements
);
181 void draw_set_mapped_vertex_buffer(struct draw_context
*draw
,
182 unsigned attr
, const void *buffer
);
185 draw_set_mapped_constant_buffer(struct draw_context
*draw
,
186 unsigned shader_type
,
192 draw_set_mapped_so_buffers(struct draw_context
*draw
,
193 void *buffers
[PIPE_MAX_SO_BUFFERS
],
194 unsigned num_buffers
);
196 draw_set_so_state(struct draw_context
*draw
,
197 struct pipe_stream_output_state
*state
);
200 /***********************************************************************
204 void draw_vbo(struct draw_context
*draw
,
205 const struct pipe_draw_info
*info
);
207 void draw_arrays(struct draw_context
*draw
, unsigned prim
,
208 unsigned start
, unsigned count
);
211 draw_arrays_instanced(struct draw_context
*draw
,
215 unsigned startInstance
,
216 unsigned instanceCount
);
219 /*******************************************************************************
220 * Driver backend interface
223 void draw_set_render( struct draw_context
*draw
,
224 struct vbuf_render
*render
);
226 void draw_set_driver_clipping( struct draw_context
*draw
,
227 boolean bypass_clip_xy
,
228 boolean bypass_clip_z
);
230 void draw_set_force_passthrough( struct draw_context
*draw
,
233 /*******************************************************************************
236 boolean
draw_need_pipeline(const struct draw_context
*draw
,
237 const struct pipe_rasterizer_state
*rasterizer
,
241 draw_get_shader_param(unsigned shader
, enum pipe_cap param
)
244 case PIPE_SHADER_VERTEX
:
245 case PIPE_SHADER_GEOMETRY
:
246 return tgsi_exec_get_shader_param(param
);
252 #endif /* DRAW_CONTEXT_H */