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 35struct _glapi_table; 36struct dd_function_table; 37struct gl_context; 38 39extern void 40_mesa_init_transform_feedback(struct gl_context *ctx); 41 42extern void 43_mesa_free_transform_feedback(struct gl_context *ctx); 44 45extern void 46_mesa_init_transform_feedback_functions(struct dd_function_table *driver); 47 48extern 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 56void GLAPIENTRY 57_mesa_BeginTransformFeedback_no_error(GLenum mode); 58 59extern void GLAPIENTRY 60_mesa_BeginTransformFeedback(GLenum mode); 61 62void GLAPIENTRY 63_mesa_EndTransformFeedback_no_error(void); 64 65extern void GLAPIENTRY 66_mesa_EndTransformFeedback(void); 67 68extern bool 69_mesa_validate_buffer_range_xfb(struct gl_context *ctx, 70 struct gl_transform_feedback_object *obj, 71 GLuint index, struct gl_buffer_object *bufObj, 72 GLintptr offset, GLsizeiptr size, bool dsa); 73 74extern void 75_mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx, 76 struct gl_transform_feedback_object *obj, 77 GLuint index, 78 struct gl_buffer_object *bufObj, 79 bool dsa); 80 81void GLAPIENTRY 82_mesa_BindBufferOffsetEXT_no_error(GLenum target, GLuint index, GLuint buffer, 83 GLintptr offset); 84 85extern void GLAPIENTRY 86_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, 87 GLintptr offset); 88 89void GLAPIENTRY 90_mesa_TransformFeedbackVaryings_no_error(GLuint program, GLsizei count, 91 const GLchar *const *varyings, 92 GLenum bufferMode); 93 94extern void GLAPIENTRY 95_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, 96 const GLchar * const *varyings, 97 GLenum bufferMode); 98 99extern void GLAPIENTRY 100_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, 101 GLsizei bufSize, GLsizei *length, 102 GLsizei *size, GLenum *type, GLchar *name); 103 104 105 106/*** GL_ARB_transform_feedback2 ***/ 107extern void 108_mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj, 109 GLuint name); 110 111extern void 112_mesa_delete_transform_feedback_object(struct gl_context *ctx, 113 struct gl_transform_feedback_object 114 *obj); 115 116struct gl_transform_feedback_object * 117_mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name); 118 119extern void GLAPIENTRY 120_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names); 121 122extern void GLAPIENTRY 123_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names); 124 125extern GLboolean GLAPIENTRY 126_mesa_IsTransformFeedback(GLuint name); 127 128void GLAPIENTRY 129_mesa_BindTransformFeedback_no_error(GLenum target, GLuint name); 130 131extern void GLAPIENTRY 132_mesa_BindTransformFeedback(GLenum target, GLuint name); 133 134extern void GLAPIENTRY 135_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names); 136 137void GLAPIENTRY 138_mesa_PauseTransformFeedback_no_error(void); 139 140extern void GLAPIENTRY 141_mesa_PauseTransformFeedback(void); 142 143void GLAPIENTRY 144_mesa_ResumeTransformFeedback_no_error(void); 145 146extern void GLAPIENTRY 147_mesa_ResumeTransformFeedback(void); 148 149static inline bool 150_mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx) 151{ 152 return ctx->TransformFeedback.CurrentObject->Active && 153 !ctx->TransformFeedback.CurrentObject->Paused; 154} 155 156extern bool 157_mesa_transform_feedback_is_using_program(struct gl_context *ctx, 158 struct gl_shader_program *shProg); 159 160static inline void 161_mesa_set_transform_feedback_binding(struct gl_context *ctx, 162 struct gl_transform_feedback_object *tfObj, GLuint index, 163 struct gl_buffer_object *bufObj, 164 GLintptr offset, GLsizeiptr size) 165{ 166 _mesa_reference_buffer_object(ctx, &tfObj->Buffers[index], bufObj); 167 168 tfObj->BufferNames[index] = bufObj ? bufObj->Name : 0; 169 tfObj->Offset[index] = offset; 170 tfObj->RequestedSize[index] = size; 171 172 if (bufObj) 173 bufObj->UsageHistory |= USAGE_TRANSFORM_FEEDBACK_BUFFER; 174} 175 176static inline void 177_mesa_bind_buffer_range_xfb(struct gl_context *ctx, 178 struct gl_transform_feedback_object *obj, 179 GLuint index, struct gl_buffer_object *bufObj, 180 GLintptr offset, GLsizeiptr size) 181{ 182 /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because 183 * transform feedback buffers can't be changed while transform feedback is 184 * active. 185 */ 186 187 /* The general binding point */ 188 _mesa_reference_buffer_object(ctx, 189 &ctx->TransformFeedback.CurrentBuffer, 190 bufObj); 191 192 /* The per-attribute binding point */ 193 _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size); 194} 195 196/*** GL_ARB_direct_state_access ***/ 197 198extern void GLAPIENTRY 199_mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer); 200 201extern void GLAPIENTRY 202_mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, 203 GLintptr offset, GLsizeiptr size); 204 205extern void GLAPIENTRY 206_mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param); 207 208extern void GLAPIENTRY 209_mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, 210 GLint *param); 211 212extern void GLAPIENTRY 213_mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index, 214 GLint64 *param); 215 216#endif /* TRANSFORM_FEEDBACK_H */ 217