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
;
55 struct draw_context
*draw_create( struct pipe_context
*pipe
);
58 draw_create_gallivm(struct pipe_context
*pipe
, struct gallivm_state
*gallivm
);
60 void draw_destroy( struct draw_context
*draw
);
62 void draw_flush(struct draw_context
*draw
);
64 void draw_set_viewport_state( struct draw_context
*draw
,
65 const struct pipe_viewport_state
*viewport
);
67 void draw_set_clip_state( struct draw_context
*pipe
,
68 const struct pipe_clip_state
*clip
);
70 void draw_set_rasterizer_state( struct draw_context
*draw
,
71 const struct pipe_rasterizer_state
*raster
,
74 void draw_set_rasterize_stage( struct draw_context
*draw
,
75 struct draw_stage
*stage
);
77 void draw_wide_point_threshold(struct draw_context
*draw
, float threshold
);
79 void draw_wide_point_sprites(struct draw_context
*draw
, boolean draw_sprite
);
81 void draw_wide_line_threshold(struct draw_context
*draw
, float threshold
);
83 void draw_enable_line_stipple(struct draw_context
*draw
, boolean enable
);
85 void draw_enable_point_sprites(struct draw_context
*draw
, boolean enable
);
87 void draw_set_mrd(struct draw_context
*draw
, double mrd
);
90 draw_install_aaline_stage(struct draw_context
*draw
, struct pipe_context
*pipe
);
93 draw_install_aapoint_stage(struct draw_context
*draw
, struct pipe_context
*pipe
);
96 draw_install_pstipple_stage(struct draw_context
*draw
, struct pipe_context
*pipe
);
100 draw_find_shader_output(const struct draw_context
*draw
,
101 uint semantic_name
, uint semantic_index
);
104 draw_num_shader_outputs(const struct draw_context
*draw
);
108 draw_texture_samplers(struct draw_context
*draw
,
111 struct tgsi_sampler
**samplers
);
114 draw_set_sampler_views(struct draw_context
*draw
,
115 struct pipe_sampler_view
**views
,
118 draw_set_samplers(struct draw_context
*draw
,
119 struct pipe_sampler_state
**samplers
,
123 draw_set_mapped_texture(struct draw_context
*draw
,
124 unsigned sampler_idx
,
125 uint32_t width
, uint32_t height
, uint32_t depth
,
126 uint32_t first_level
, uint32_t last_level
,
127 uint32_t row_stride
[PIPE_MAX_TEXTURE_LEVELS
],
128 uint32_t img_stride
[PIPE_MAX_TEXTURE_LEVELS
],
129 const void *data
[PIPE_MAX_TEXTURE_LEVELS
]);
133 * Vertex shader functions
136 struct draw_vertex_shader
*
137 draw_create_vertex_shader(struct draw_context
*draw
,
138 const struct pipe_shader_state
*shader
);
139 void draw_bind_vertex_shader(struct draw_context
*draw
,
140 struct draw_vertex_shader
*dvs
);
141 void draw_delete_vertex_shader(struct draw_context
*draw
,
142 struct draw_vertex_shader
*dvs
);
146 * Fragment shader functions
148 struct draw_fragment_shader
*
149 draw_create_fragment_shader(struct draw_context
*draw
,
150 const struct pipe_shader_state
*shader
);
151 void draw_bind_fragment_shader(struct draw_context
*draw
,
152 struct draw_fragment_shader
*dvs
);
153 void draw_delete_fragment_shader(struct draw_context
*draw
,
154 struct draw_fragment_shader
*dvs
);
157 * Geometry shader functions
159 struct draw_geometry_shader
*
160 draw_create_geometry_shader(struct draw_context
*draw
,
161 const struct pipe_shader_state
*shader
);
162 void draw_bind_geometry_shader(struct draw_context
*draw
,
163 struct draw_geometry_shader
*dvs
);
164 void draw_delete_geometry_shader(struct draw_context
*draw
,
165 struct draw_geometry_shader
*dvs
);
169 * Vertex data functions
172 void draw_set_vertex_buffers(struct draw_context
*draw
,
174 const struct pipe_vertex_buffer
*buffers
);
176 void draw_set_vertex_elements(struct draw_context
*draw
,
178 const struct pipe_vertex_element
*elements
);
180 void draw_set_index_buffer(struct draw_context
*draw
,
181 const struct pipe_index_buffer
*ib
);
183 void draw_set_mapped_index_buffer(struct draw_context
*draw
,
184 const void *elements
);
186 void draw_set_mapped_vertex_buffer(struct draw_context
*draw
,
187 unsigned attr
, const void *buffer
);
190 draw_set_mapped_constant_buffer(struct draw_context
*draw
,
191 unsigned shader_type
,
197 draw_set_mapped_so_buffers(struct draw_context
*draw
,
198 void *buffers
[PIPE_MAX_SO_BUFFERS
],
199 unsigned num_buffers
);
201 draw_set_so_state(struct draw_context
*draw
,
202 struct pipe_stream_output_state
*state
);
205 /***********************************************************************
209 void draw_vbo(struct draw_context
*draw
,
210 const struct pipe_draw_info
*info
);
212 void draw_arrays(struct draw_context
*draw
, unsigned prim
,
213 unsigned start
, unsigned count
);
216 draw_arrays_instanced(struct draw_context
*draw
,
220 unsigned startInstance
,
221 unsigned instanceCount
);
224 /*******************************************************************************
225 * Driver backend interface
228 void draw_set_render( struct draw_context
*draw
,
229 struct vbuf_render
*render
);
231 void draw_set_driver_clipping( struct draw_context
*draw
,
232 boolean bypass_clip_xy
,
233 boolean bypass_clip_z
);
235 void draw_set_force_passthrough( struct draw_context
*draw
,
238 /*******************************************************************************
241 boolean
draw_need_pipeline(const struct draw_context
*draw
,
242 const struct pipe_rasterizer_state
*rasterizer
,
246 draw_get_shader_param(unsigned shader
, enum pipe_shader_cap param
)
249 case PIPE_SHADER_VERTEX
:
250 case PIPE_SHADER_GEOMETRY
:
251 return tgsi_exec_get_shader_param(param
);
257 #endif /* DRAW_CONTEXT_H */