1 /**************************************************************************
2 *
3 * Copyright 2004 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Keith Whitwell <[email protected]>
31 */
32
33
34 #ifndef ST_DRAW_H
35 #define ST_DRAW_H
36
37 #include "util/glheader.h"
38
39 struct gl_context;
40 struct st_context;
41
42 void st_init_draw_functions(struct pipe_screen *screen,
43 struct dd_function_table *functions);
44
45 void st_destroy_draw( struct st_context *st );
46
47 struct draw_context *st_get_draw_context(struct st_context *st);
48
49 void
50 st_feedback_draw_vbo(struct gl_context *ctx,
51 const struct pipe_draw_info *info,
52 unsigned drawid_offset,
53 const struct pipe_draw_indirect_info *indirect,
54 const struct pipe_draw_start_count_bias *draws,
55 unsigned num_draws);
56
57 void
58 st_feedback_draw_vbo_multi_mode(struct gl_context *ctx,
59 struct pipe_draw_info *info,
60 const struct pipe_draw_start_count_bias *draws,
61 const unsigned char *mode,
62 unsigned num_draws);
63
64 /**
65 * When drawing with VBOs, the addresses specified with
66 * glVertex/Color/TexCoordPointer() are really offsets into the VBO, not real
67 * addresses. At some point we need to convert those pointers to offsets.
68 * This function is basically a cast wrapper to avoid warnings when building
69 * in 64-bit mode.
70 */
71 static inline unsigned
pointer_to_offset(const void * ptr)72 pointer_to_offset(const void *ptr)
73 {
74 return (unsigned) (((GLsizeiptr) ptr) & 0xffffffffUL);
75 }
76
77 void
78 st_prepare_draw(struct gl_context *ctx, uint64_t state_mask);
79
80 void
81 st_draw_gallium(struct gl_context *ctx,
82 const struct pipe_draw_info *info,
83 unsigned drawid_offset,
84 const struct pipe_draw_indirect_info *indirect,
85 const struct pipe_draw_start_count_bias *draws,
86 unsigned num_draws);
87
88 bool
89 st_draw_quad(struct st_context *st,
90 float x0, float y0, float x1, float y1, float z,
91 float s0, float t0, float s1, float t1,
92 const float *color,
93 unsigned num_instances);
94
95 void
96 st_indirect_draw_vbo(struct gl_context *ctx,
97 GLenum mode, GLenum index_type,
98 GLintptr indirect_offset,
99 GLintptr indirect_draw_count_offset,
100 GLsizei draw_count, GLsizei stride);
101
102 bool
103 st_draw_hw_select_prepare_common(struct gl_context *ctx);
104 bool
105 st_draw_hw_select_prepare_mode(struct gl_context *ctx, struct pipe_draw_info *info);
106 void
107 st_init_hw_select_draw_functions(struct pipe_screen *screen,
108 struct dd_function_table *functions);
109
110 #endif
111