mesa: add KHR_no_error support to glBindTransformFeedback()
[mesa.git] / src / mesa / main / transformfeedback.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2010 VMware, Inc. 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 "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #ifndef TRANSFORM_FEEDBACK_H
27 #define TRANSFORM_FEEDBACK_H
28
29 #include <stdbool.h>
30 #include "bufferobj.h"
31 #include "compiler.h"
32 #include "glheader.h"
33 #include "mtypes.h"
34
35 struct _glapi_table;
36 struct dd_function_table;
37 struct gl_context;
38
39 extern void
40 _mesa_init_transform_feedback(struct gl_context *ctx);
41
42 extern void
43 _mesa_free_transform_feedback(struct gl_context *ctx);
44
45 extern void
46 _mesa_init_transform_feedback_functions(struct dd_function_table *driver);
47
48 extern unsigned
49 _mesa_compute_max_transform_feedback_vertices( struct gl_context *ctx,
50 const struct gl_transform_feedback_object *obj,
51 const struct gl_transform_feedback_info *info);
52
53
54 /*** GL_EXT_transform_feedback ***/
55
56 extern void GLAPIENTRY
57 _mesa_BeginTransformFeedback(GLenum mode);
58
59 extern void GLAPIENTRY
60 _mesa_EndTransformFeedback(void);
61
62 extern bool
63 _mesa_validate_buffer_range_xfb(struct gl_context *ctx,
64 struct gl_transform_feedback_object *obj,
65 GLuint index, struct gl_buffer_object *bufObj,
66 GLintptr offset, GLsizeiptr size, bool dsa);
67
68 extern void
69 _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx,
70 struct gl_transform_feedback_object *obj,
71 GLuint index,
72 struct gl_buffer_object *bufObj,
73 bool dsa);
74
75 extern void GLAPIENTRY
76 _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
77 GLintptr offset);
78
79 extern void GLAPIENTRY
80 _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
81 const GLchar * const *varyings,
82 GLenum bufferMode);
83
84 extern void GLAPIENTRY
85 _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
86 GLsizei bufSize, GLsizei *length,
87 GLsizei *size, GLenum *type, GLchar *name);
88
89
90
91 /*** GL_ARB_transform_feedback2 ***/
92 extern void
93 _mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj,
94 GLuint name);
95
96 struct gl_transform_feedback_object *
97 _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name);
98
99 extern void GLAPIENTRY
100 _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names);
101
102 extern void GLAPIENTRY
103 _mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names);
104
105 extern GLboolean GLAPIENTRY
106 _mesa_IsTransformFeedback(GLuint name);
107
108 void GLAPIENTRY
109 _mesa_BindTransformFeedback_no_error(GLenum target, GLuint name);
110
111 extern void GLAPIENTRY
112 _mesa_BindTransformFeedback(GLenum target, GLuint name);
113
114 extern void GLAPIENTRY
115 _mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names);
116
117 extern void GLAPIENTRY
118 _mesa_PauseTransformFeedback(void);
119
120 extern void GLAPIENTRY
121 _mesa_ResumeTransformFeedback(void);
122
123 static inline bool
124 _mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx)
125 {
126 return ctx->TransformFeedback.CurrentObject->Active &&
127 !ctx->TransformFeedback.CurrentObject->Paused;
128 }
129
130 extern bool
131 _mesa_transform_feedback_is_using_program(struct gl_context *ctx,
132 struct gl_shader_program *shProg);
133
134 static inline void
135 _mesa_set_transform_feedback_binding(struct gl_context *ctx,
136 struct gl_transform_feedback_object *tfObj, GLuint index,
137 struct gl_buffer_object *bufObj,
138 GLintptr offset, GLsizeiptr size)
139 {
140 _mesa_reference_buffer_object(ctx, &tfObj->Buffers[index], bufObj);
141
142 tfObj->BufferNames[index] = bufObj->Name;
143 tfObj->Offset[index] = offset;
144 tfObj->RequestedSize[index] = size;
145
146 if (bufObj != ctx->Shared->NullBufferObj)
147 bufObj->UsageHistory |= USAGE_TRANSFORM_FEEDBACK_BUFFER;
148 }
149
150 static inline void
151 _mesa_bind_buffer_range_xfb(struct gl_context *ctx,
152 struct gl_transform_feedback_object *obj,
153 GLuint index, struct gl_buffer_object *bufObj,
154 GLintptr offset, GLsizeiptr size)
155 {
156 /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because
157 * transform feedback buffers can't be changed while transform feedback is
158 * active.
159 */
160
161 /* The general binding point */
162 _mesa_reference_buffer_object(ctx,
163 &ctx->TransformFeedback.CurrentBuffer,
164 bufObj);
165
166 /* The per-attribute binding point */
167 _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size);
168 }
169
170 /*** GL_ARB_direct_state_access ***/
171
172 extern void GLAPIENTRY
173 _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer);
174
175 extern void GLAPIENTRY
176 _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
177 GLintptr offset, GLsizeiptr size);
178
179 extern void GLAPIENTRY
180 _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param);
181
182 extern void GLAPIENTRY
183 _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index,
184 GLint *param);
185
186 extern void GLAPIENTRY
187 _mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index,
188 GLint64 *param);
189
190 #endif /* TRANSFORM_FEEDBACK_H */