• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "util/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 unsigned
46 _mesa_compute_max_transform_feedback_vertices( struct gl_context *ctx,
47       const struct gl_transform_feedback_object *obj,
48       const struct gl_transform_feedback_info *info);
49 
50 
51 /*** GL_EXT_transform_feedback ***/
52 
53 extern bool
54 _mesa_validate_buffer_range_xfb(struct gl_context *ctx,
55                                 struct gl_transform_feedback_object *obj,
56                                 GLuint index, struct gl_buffer_object *bufObj,
57                                 GLintptr offset, GLsizeiptr size, bool dsa);
58 
59 extern void
60 _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx,
61 					  struct gl_transform_feedback_object *obj,
62 					  GLuint index,
63 					  struct gl_buffer_object *bufObj,
64 					  bool dsa);
65 
66 /*** GL_ARB_transform_feedback2 ***/
67 extern void
68 _mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj,
69                                      GLuint name);
70 
71 extern void
72 _mesa_delete_transform_feedback_object(struct gl_context *ctx,
73                                        struct gl_transform_feedback_object
74                                               *obj);
75 
76 struct gl_transform_feedback_object *
77 _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name);
78 
79 static inline bool
_mesa_is_xfb_active_and_unpaused(const struct gl_context * ctx)80 _mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx)
81 {
82    return ctx->TransformFeedback.CurrentObject->Active &&
83       !ctx->TransformFeedback.CurrentObject->Paused;
84 }
85 
86 extern bool
87 _mesa_transform_feedback_is_using_program(struct gl_context *ctx,
88                                           struct gl_shader_program *shProg);
89 
90 static inline void
_mesa_set_transform_feedback_binding(struct gl_context * ctx,struct gl_transform_feedback_object * tfObj,GLuint index,struct gl_buffer_object * bufObj,GLintptr offset,GLsizeiptr size)91 _mesa_set_transform_feedback_binding(struct gl_context *ctx,
92                                      struct gl_transform_feedback_object *tfObj, GLuint index,
93                                      struct gl_buffer_object *bufObj,
94                                      GLintptr offset, GLsizeiptr size)
95 {
96    _mesa_reference_buffer_object(ctx, &tfObj->Buffers[index], bufObj);
97 
98    tfObj->BufferNames[index]   = bufObj ? bufObj->Name : 0;
99    tfObj->Offset[index]        = offset;
100    tfObj->RequestedSize[index] = size;
101 
102    if (bufObj)
103       bufObj->UsageHistory |= USAGE_TRANSFORM_FEEDBACK_BUFFER;
104 }
105 
106 static inline void
_mesa_bind_buffer_range_xfb(struct gl_context * ctx,struct gl_transform_feedback_object * obj,GLuint index,struct gl_buffer_object * bufObj,GLintptr offset,GLsizeiptr size)107 _mesa_bind_buffer_range_xfb(struct gl_context *ctx,
108                             struct gl_transform_feedback_object *obj,
109                             GLuint index, struct gl_buffer_object *bufObj,
110                             GLintptr offset, GLsizeiptr size)
111 {
112    /* Note: no need to FLUSH_VERTICES because
113     * transform feedback buffers can't be changed while transform feedback is
114     * active.
115     */
116 
117    /* The general binding point */
118    _mesa_reference_buffer_object(ctx,
119                                  &ctx->TransformFeedback.CurrentBuffer,
120                                  bufObj);
121 
122    /* The per-attribute binding point */
123    _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size);
124 }
125 
126 #endif /* TRANSFORM_FEEDBACK_H */
127