1848b8605Smrg/*
2848b8605Smrg * Mesa 3-D graphics library
3848b8605Smrg *
4848b8605Smrg * Copyright (C) 2010  VMware, Inc.  All Rights Reserved.
5848b8605Smrg *
6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7848b8605Smrg * copy of this software and associated documentation files (the "Software"),
8848b8605Smrg * to deal in the Software without restriction, including without limitation
9848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the
11848b8605Smrg * Software is furnished to do so, subject to the following conditions:
12848b8605Smrg *
13848b8605Smrg * The above copyright notice and this permission notice shall be included
14848b8605Smrg * in all copies or substantial portions of the Software.
15848b8605Smrg *
16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE.
23848b8605Smrg */
24848b8605Smrg
25848b8605Smrg
26848b8605Smrg#ifndef TRANSFORM_FEEDBACK_H
27848b8605Smrg#define TRANSFORM_FEEDBACK_H
28848b8605Smrg
29848b8605Smrg#include <stdbool.h>
30848b8605Smrg#include "bufferobj.h"
31848b8605Smrg#include "compiler.h"
32848b8605Smrg#include "glheader.h"
33848b8605Smrg#include "mtypes.h"
34848b8605Smrg
35848b8605Smrgstruct _glapi_table;
36848b8605Smrgstruct dd_function_table;
37848b8605Smrgstruct gl_context;
38848b8605Smrg
39848b8605Smrgextern void
40848b8605Smrg_mesa_init_transform_feedback(struct gl_context *ctx);
41848b8605Smrg
42848b8605Smrgextern void
43848b8605Smrg_mesa_free_transform_feedback(struct gl_context *ctx);
44848b8605Smrg
45848b8605Smrgextern void
46848b8605Smrg_mesa_init_transform_feedback_functions(struct dd_function_table *driver);
47848b8605Smrg
48848b8605Smrgextern unsigned
49b8e80941Smrg_mesa_compute_max_transform_feedback_vertices( struct gl_context *ctx,
50848b8605Smrg      const struct gl_transform_feedback_object *obj,
51848b8605Smrg      const struct gl_transform_feedback_info *info);
52848b8605Smrg
53848b8605Smrg
54848b8605Smrg/*** GL_EXT_transform_feedback ***/
55848b8605Smrg
56b8e80941Smrgvoid GLAPIENTRY
57b8e80941Smrg_mesa_BeginTransformFeedback_no_error(GLenum mode);
58b8e80941Smrg
59848b8605Smrgextern void GLAPIENTRY
60848b8605Smrg_mesa_BeginTransformFeedback(GLenum mode);
61848b8605Smrg
62b8e80941Smrgvoid GLAPIENTRY
63b8e80941Smrg_mesa_EndTransformFeedback_no_error(void);
64b8e80941Smrg
65848b8605Smrgextern void GLAPIENTRY
66848b8605Smrg_mesa_EndTransformFeedback(void);
67848b8605Smrg
68b8e80941Smrgextern bool
69b8e80941Smrg_mesa_validate_buffer_range_xfb(struct gl_context *ctx,
70b8e80941Smrg                                struct gl_transform_feedback_object *obj,
71b8e80941Smrg                                GLuint index, struct gl_buffer_object *bufObj,
72b8e80941Smrg                                GLintptr offset, GLsizeiptr size, bool dsa);
73848b8605Smrg
74848b8605Smrgextern void
75848b8605Smrg_mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx,
76b8e80941Smrg					  struct gl_transform_feedback_object *obj,
77848b8605Smrg					  GLuint index,
78b8e80941Smrg					  struct gl_buffer_object *bufObj,
79b8e80941Smrg					  bool dsa);
80b8e80941Smrg
81b8e80941Smrgvoid GLAPIENTRY
82b8e80941Smrg_mesa_BindBufferOffsetEXT_no_error(GLenum target, GLuint index, GLuint buffer,
83b8e80941Smrg                                   GLintptr offset);
84848b8605Smrg
85848b8605Smrgextern void GLAPIENTRY
86848b8605Smrg_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
87848b8605Smrg                          GLintptr offset);
88848b8605Smrg
89b8e80941Smrgvoid GLAPIENTRY
90b8e80941Smrg_mesa_TransformFeedbackVaryings_no_error(GLuint program, GLsizei count,
91b8e80941Smrg                                         const GLchar *const *varyings,
92b8e80941Smrg                                         GLenum bufferMode);
93b8e80941Smrg
94848b8605Smrgextern void GLAPIENTRY
95848b8605Smrg_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
96848b8605Smrg                                const GLchar * const *varyings,
97848b8605Smrg                                GLenum bufferMode);
98848b8605Smrg
99848b8605Smrgextern void GLAPIENTRY
100848b8605Smrg_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
101848b8605Smrg                                  GLsizei bufSize, GLsizei *length,
102848b8605Smrg                                  GLsizei *size, GLenum *type, GLchar *name);
103848b8605Smrg
104848b8605Smrg
105848b8605Smrg
106848b8605Smrg/*** GL_ARB_transform_feedback2 ***/
107848b8605Smrgextern void
108848b8605Smrg_mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj,
109848b8605Smrg                                     GLuint name);
110848b8605Smrg
111848b8605Smrgstruct gl_transform_feedback_object *
112848b8605Smrg_mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name);
113848b8605Smrg
114848b8605Smrgextern void GLAPIENTRY
115848b8605Smrg_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names);
116848b8605Smrg
117b8e80941Smrgextern void GLAPIENTRY
118b8e80941Smrg_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names);
119b8e80941Smrg
120848b8605Smrgextern GLboolean GLAPIENTRY
121848b8605Smrg_mesa_IsTransformFeedback(GLuint name);
122848b8605Smrg
123b8e80941Smrgvoid GLAPIENTRY
124b8e80941Smrg_mesa_BindTransformFeedback_no_error(GLenum target, GLuint name);
125b8e80941Smrg
126848b8605Smrgextern void GLAPIENTRY
127848b8605Smrg_mesa_BindTransformFeedback(GLenum target, GLuint name);
128848b8605Smrg
129848b8605Smrgextern void GLAPIENTRY
130848b8605Smrg_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names);
131848b8605Smrg
132b8e80941Smrgvoid GLAPIENTRY
133b8e80941Smrg_mesa_PauseTransformFeedback_no_error(void);
134b8e80941Smrg
135848b8605Smrgextern void GLAPIENTRY
136848b8605Smrg_mesa_PauseTransformFeedback(void);
137848b8605Smrg
138b8e80941Smrgvoid GLAPIENTRY
139b8e80941Smrg_mesa_ResumeTransformFeedback_no_error(void);
140b8e80941Smrg
141848b8605Smrgextern void GLAPIENTRY
142848b8605Smrg_mesa_ResumeTransformFeedback(void);
143848b8605Smrg
144848b8605Smrgstatic inline bool
145848b8605Smrg_mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx)
146848b8605Smrg{
147848b8605Smrg   return ctx->TransformFeedback.CurrentObject->Active &&
148848b8605Smrg      !ctx->TransformFeedback.CurrentObject->Paused;
149848b8605Smrg}
150848b8605Smrg
151848b8605Smrgextern bool
152848b8605Smrg_mesa_transform_feedback_is_using_program(struct gl_context *ctx,
153848b8605Smrg                                          struct gl_shader_program *shProg);
154848b8605Smrg
155848b8605Smrgstatic inline void
156848b8605Smrg_mesa_set_transform_feedback_binding(struct gl_context *ctx,
157848b8605Smrg                                     struct gl_transform_feedback_object *tfObj, GLuint index,
158848b8605Smrg                                     struct gl_buffer_object *bufObj,
159848b8605Smrg                                     GLintptr offset, GLsizeiptr size)
160848b8605Smrg{
161848b8605Smrg   _mesa_reference_buffer_object(ctx, &tfObj->Buffers[index], bufObj);
162848b8605Smrg
163848b8605Smrg   tfObj->BufferNames[index]   = bufObj->Name;
164848b8605Smrg   tfObj->Offset[index]        = offset;
165848b8605Smrg   tfObj->RequestedSize[index] = size;
166b8e80941Smrg
167b8e80941Smrg   if (bufObj != ctx->Shared->NullBufferObj)
168b8e80941Smrg      bufObj->UsageHistory |= USAGE_TRANSFORM_FEEDBACK_BUFFER;
169848b8605Smrg}
170848b8605Smrg
171b8e80941Smrgstatic inline void
172b8e80941Smrg_mesa_bind_buffer_range_xfb(struct gl_context *ctx,
173b8e80941Smrg                            struct gl_transform_feedback_object *obj,
174b8e80941Smrg                            GLuint index, struct gl_buffer_object *bufObj,
175b8e80941Smrg                            GLintptr offset, GLsizeiptr size)
176b8e80941Smrg{
177b8e80941Smrg   /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because
178b8e80941Smrg    * transform feedback buffers can't be changed while transform feedback is
179b8e80941Smrg    * active.
180b8e80941Smrg    */
181b8e80941Smrg
182b8e80941Smrg   /* The general binding point */
183b8e80941Smrg   _mesa_reference_buffer_object(ctx,
184b8e80941Smrg                                 &ctx->TransformFeedback.CurrentBuffer,
185b8e80941Smrg                                 bufObj);
186b8e80941Smrg
187b8e80941Smrg   /* The per-attribute binding point */
188b8e80941Smrg   _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size);
189b8e80941Smrg}
190b8e80941Smrg
191b8e80941Smrg/*** GL_ARB_direct_state_access ***/
192b8e80941Smrg
193b8e80941Smrgextern void GLAPIENTRY
194b8e80941Smrg_mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer);
195b8e80941Smrg
196b8e80941Smrgextern void GLAPIENTRY
197b8e80941Smrg_mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
198b8e80941Smrg                                   GLintptr offset, GLsizeiptr size);
199b8e80941Smrg
200b8e80941Smrgextern void GLAPIENTRY
201b8e80941Smrg_mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param);
202b8e80941Smrg
203b8e80941Smrgextern void GLAPIENTRY
204b8e80941Smrg_mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index,
205b8e80941Smrg                              GLint *param);
206b8e80941Smrg
207b8e80941Smrgextern void GLAPIENTRY
208b8e80941Smrg_mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index,
209b8e80941Smrg                                GLint64 *param);
210b8e80941Smrg
211848b8605Smrg#endif /* TRANSFORM_FEEDBACK_H */
212