mesa: add support for memory object creation/import/delete
[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 GLboolean
46 _mesa_validate_transform_feedback_buffers(struct gl_context *ctx);
47
48
49 extern void
50 _mesa_init_transform_feedback_functions(struct dd_function_table *driver);
51
52 extern unsigned
53 _mesa_compute_max_transform_feedback_vertices( struct gl_context *ctx,
54 const struct gl_transform_feedback_object *obj,
55 const struct gl_transform_feedback_info *info);
56
57
58 /*** GL_EXT_transform_feedback ***/
59
60 extern void GLAPIENTRY
61 _mesa_BeginTransformFeedback(GLenum mode);
62
63 extern void GLAPIENTRY
64 _mesa_EndTransformFeedback(void);
65
66 extern bool
67 _mesa_validate_buffer_range_xfb(struct gl_context *ctx,
68 struct gl_transform_feedback_object *obj,
69 GLuint index, struct gl_buffer_object *bufObj,
70 GLintptr offset, GLsizeiptr size, bool dsa);
71
72 extern void
73 _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx,
74 struct gl_transform_feedback_object *obj,
75 GLuint index,
76 struct gl_buffer_object *bufObj,
77 bool dsa);
78
79 extern void GLAPIENTRY
80 _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
81 GLintptr offset);
82
83 extern void GLAPIENTRY
84 _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
85 const GLchar * const *varyings,
86 GLenum bufferMode);
87
88 extern void GLAPIENTRY
89 _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
90 GLsizei bufSize, GLsizei *length,
91 GLsizei *size, GLenum *type, GLchar *name);
92
93
94
95 /*** GL_ARB_transform_feedback2 ***/
96 extern void
97 _mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj,
98 GLuint name);
99
100 struct gl_transform_feedback_object *
101 _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name);
102
103 extern void GLAPIENTRY
104 _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names);
105
106 extern void GLAPIENTRY
107 _mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names);
108
109 extern GLboolean GLAPIENTRY
110 _mesa_IsTransformFeedback(GLuint name);
111
112 extern void GLAPIENTRY
113 _mesa_BindTransformFeedback(GLenum target, GLuint name);
114
115 extern void GLAPIENTRY
116 _mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names);
117
118 extern void GLAPIENTRY
119 _mesa_PauseTransformFeedback(void);
120
121 extern void GLAPIENTRY
122 _mesa_ResumeTransformFeedback(void);
123
124 static inline bool
125 _mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx)
126 {
127 return ctx->TransformFeedback.CurrentObject->Active &&
128 !ctx->TransformFeedback.CurrentObject->Paused;
129 }
130
131 extern bool
132 _mesa_transform_feedback_is_using_program(struct gl_context *ctx,
133 struct gl_shader_program *shProg);
134
135 static inline void
136 _mesa_set_transform_feedback_binding(struct gl_context *ctx,
137 struct gl_transform_feedback_object *tfObj, GLuint index,
138 struct gl_buffer_object *bufObj,
139 GLintptr offset, GLsizeiptr size)
140 {
141 _mesa_reference_buffer_object(ctx, &tfObj->Buffers[index], bufObj);
142
143 tfObj->BufferNames[index] = bufObj->Name;
144 tfObj->Offset[index] = offset;
145 tfObj->RequestedSize[index] = size;
146
147 if (bufObj != ctx->Shared->NullBufferObj)
148 bufObj->UsageHistory |= USAGE_TRANSFORM_FEEDBACK_BUFFER;
149 }
150
151 static inline void
152 _mesa_bind_buffer_range_xfb(struct gl_context *ctx,
153 struct gl_transform_feedback_object *obj,
154 GLuint index, struct gl_buffer_object *bufObj,
155 GLintptr offset, GLsizeiptr size)
156 {
157 /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because
158 * transform feedback buffers can't be changed while transform feedback is
159 * active.
160 */
161
162 /* The general binding point */
163 _mesa_reference_buffer_object(ctx,
164 &ctx->TransformFeedback.CurrentBuffer,
165 bufObj);
166
167 /* The per-attribute binding point */
168 _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size);
169 }
170
171 /*** GL_ARB_direct_state_access ***/
172
173 extern void GLAPIENTRY
174 _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer);
175
176 extern void GLAPIENTRY
177 _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
178 GLintptr offset, GLsizeiptr size);
179
180 extern void GLAPIENTRY
181 _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param);
182
183 extern void GLAPIENTRY
184 _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index,
185 GLint *param);
186
187 extern void GLAPIENTRY
188 _mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index,
189 GLint64 *param);
190
191 #endif /* TRANSFORM_FEEDBACK_H */