13464ebd5Sriastradh/* 23464ebd5Sriastradh * Mesa 3-D graphics library 33464ebd5Sriastradh * 43464ebd5Sriastradh * Copyright (C) 2010 VMware, Inc. All Rights Reserved. 53464ebd5Sriastradh * 63464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 73464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"), 83464ebd5Sriastradh * to deal in the Software without restriction, including without limitation 93464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 103464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the 113464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions: 123464ebd5Sriastradh * 133464ebd5Sriastradh * The above copyright notice and this permission notice shall be included 143464ebd5Sriastradh * in all copies or substantial portions of the Software. 153464ebd5Sriastradh * 163464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 173464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 183464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 233464ebd5Sriastradh */ 243464ebd5Sriastradh 253464ebd5Sriastradh 263464ebd5Sriastradh#ifndef TRANSFORM_FEEDBACK_H 273464ebd5Sriastradh#define TRANSFORM_FEEDBACK_H 283464ebd5Sriastradh 29af69d88dSmrg#include <stdbool.h> 30af69d88dSmrg#include "bufferobj.h" 317ec681f3Smrg#include "util/compiler.h" 323464ebd5Sriastradh#include "glheader.h" 33af69d88dSmrg#include "mtypes.h" 343464ebd5Sriastradh 353464ebd5Sriastradhstruct _glapi_table; 363464ebd5Sriastradhstruct dd_function_table; 373464ebd5Sriastradhstruct gl_context; 383464ebd5Sriastradh 393464ebd5Sriastradhextern void 403464ebd5Sriastradh_mesa_init_transform_feedback(struct gl_context *ctx); 413464ebd5Sriastradh 423464ebd5Sriastradhextern void 433464ebd5Sriastradh_mesa_free_transform_feedback(struct gl_context *ctx); 443464ebd5Sriastradh 453464ebd5Sriastradhextern void 463464ebd5Sriastradh_mesa_init_transform_feedback_functions(struct dd_function_table *driver); 473464ebd5Sriastradh 48af69d88dSmrgextern unsigned 4901e04c3fSmrg_mesa_compute_max_transform_feedback_vertices( struct gl_context *ctx, 50af69d88dSmrg const struct gl_transform_feedback_object *obj, 51af69d88dSmrg const struct gl_transform_feedback_info *info); 523464ebd5Sriastradh 533464ebd5Sriastradh 543464ebd5Sriastradh/*** GL_EXT_transform_feedback ***/ 553464ebd5Sriastradh 5601e04c3fSmrgvoid GLAPIENTRY 5701e04c3fSmrg_mesa_BeginTransformFeedback_no_error(GLenum mode); 5801e04c3fSmrg 593464ebd5Sriastradhextern void GLAPIENTRY 603464ebd5Sriastradh_mesa_BeginTransformFeedback(GLenum mode); 613464ebd5Sriastradh 6201e04c3fSmrgvoid GLAPIENTRY 6301e04c3fSmrg_mesa_EndTransformFeedback_no_error(void); 6401e04c3fSmrg 653464ebd5Sriastradhextern void GLAPIENTRY 663464ebd5Sriastradh_mesa_EndTransformFeedback(void); 673464ebd5Sriastradh 6801e04c3fSmrgextern bool 6901e04c3fSmrg_mesa_validate_buffer_range_xfb(struct gl_context *ctx, 7001e04c3fSmrg struct gl_transform_feedback_object *obj, 7101e04c3fSmrg GLuint index, struct gl_buffer_object *bufObj, 7201e04c3fSmrg GLintptr offset, GLsizeiptr size, bool dsa); 733464ebd5Sriastradh 74af69d88dSmrgextern void 75af69d88dSmrg_mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx, 7601e04c3fSmrg struct gl_transform_feedback_object *obj, 77af69d88dSmrg GLuint index, 7801e04c3fSmrg struct gl_buffer_object *bufObj, 7901e04c3fSmrg bool dsa); 8001e04c3fSmrg 8101e04c3fSmrgvoid GLAPIENTRY 8201e04c3fSmrg_mesa_BindBufferOffsetEXT_no_error(GLenum target, GLuint index, GLuint buffer, 8301e04c3fSmrg GLintptr offset); 843464ebd5Sriastradh 853464ebd5Sriastradhextern void GLAPIENTRY 863464ebd5Sriastradh_mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, 873464ebd5Sriastradh GLintptr offset); 883464ebd5Sriastradh 8901e04c3fSmrgvoid GLAPIENTRY 9001e04c3fSmrg_mesa_TransformFeedbackVaryings_no_error(GLuint program, GLsizei count, 9101e04c3fSmrg const GLchar *const *varyings, 9201e04c3fSmrg GLenum bufferMode); 9301e04c3fSmrg 943464ebd5Sriastradhextern void GLAPIENTRY 953464ebd5Sriastradh_mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, 96af69d88dSmrg const GLchar * const *varyings, 97af69d88dSmrg GLenum bufferMode); 983464ebd5Sriastradh 993464ebd5Sriastradhextern void GLAPIENTRY 1003464ebd5Sriastradh_mesa_GetTransformFeedbackVarying(GLuint program, GLuint index, 1013464ebd5Sriastradh GLsizei bufSize, GLsizei *length, 1023464ebd5Sriastradh GLsizei *size, GLenum *type, GLchar *name); 1033464ebd5Sriastradh 1043464ebd5Sriastradh 1053464ebd5Sriastradh 1063464ebd5Sriastradh/*** GL_ARB_transform_feedback2 ***/ 107af69d88dSmrgextern void 108af69d88dSmrg_mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj, 109af69d88dSmrg GLuint name); 110af69d88dSmrg 1117ec681f3Smrgextern void 1127ec681f3Smrg_mesa_delete_transform_feedback_object(struct gl_context *ctx, 1137ec681f3Smrg struct gl_transform_feedback_object 1147ec681f3Smrg *obj); 1157ec681f3Smrg 116af69d88dSmrgstruct gl_transform_feedback_object * 117af69d88dSmrg_mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name); 1183464ebd5Sriastradh 1193464ebd5Sriastradhextern void GLAPIENTRY 1203464ebd5Sriastradh_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names); 1213464ebd5Sriastradh 12201e04c3fSmrgextern void GLAPIENTRY 12301e04c3fSmrg_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names); 12401e04c3fSmrg 1253464ebd5Sriastradhextern GLboolean GLAPIENTRY 1263464ebd5Sriastradh_mesa_IsTransformFeedback(GLuint name); 1273464ebd5Sriastradh 12801e04c3fSmrgvoid GLAPIENTRY 12901e04c3fSmrg_mesa_BindTransformFeedback_no_error(GLenum target, GLuint name); 13001e04c3fSmrg 1313464ebd5Sriastradhextern void GLAPIENTRY 1323464ebd5Sriastradh_mesa_BindTransformFeedback(GLenum target, GLuint name); 1333464ebd5Sriastradh 1343464ebd5Sriastradhextern void GLAPIENTRY 1353464ebd5Sriastradh_mesa_DeleteTransformFeedbacks(GLsizei n, const GLuint *names); 1363464ebd5Sriastradh 13701e04c3fSmrgvoid GLAPIENTRY 13801e04c3fSmrg_mesa_PauseTransformFeedback_no_error(void); 13901e04c3fSmrg 1403464ebd5Sriastradhextern void GLAPIENTRY 1413464ebd5Sriastradh_mesa_PauseTransformFeedback(void); 1423464ebd5Sriastradh 14301e04c3fSmrgvoid GLAPIENTRY 14401e04c3fSmrg_mesa_ResumeTransformFeedback_no_error(void); 14501e04c3fSmrg 1463464ebd5Sriastradhextern void GLAPIENTRY 1473464ebd5Sriastradh_mesa_ResumeTransformFeedback(void); 1483464ebd5Sriastradh 149af69d88dSmrgstatic inline bool 150af69d88dSmrg_mesa_is_xfb_active_and_unpaused(const struct gl_context *ctx) 1513464ebd5Sriastradh{ 152af69d88dSmrg return ctx->TransformFeedback.CurrentObject->Active && 153af69d88dSmrg !ctx->TransformFeedback.CurrentObject->Paused; 1543464ebd5Sriastradh} 1553464ebd5Sriastradh 156af69d88dSmrgextern bool 157af69d88dSmrg_mesa_transform_feedback_is_using_program(struct gl_context *ctx, 158af69d88dSmrg struct gl_shader_program *shProg); 1593464ebd5Sriastradh 160af69d88dSmrgstatic inline void 161af69d88dSmrg_mesa_set_transform_feedback_binding(struct gl_context *ctx, 162af69d88dSmrg struct gl_transform_feedback_object *tfObj, GLuint index, 163af69d88dSmrg struct gl_buffer_object *bufObj, 164af69d88dSmrg GLintptr offset, GLsizeiptr size) 1653464ebd5Sriastradh{ 166af69d88dSmrg _mesa_reference_buffer_object(ctx, &tfObj->Buffers[index], bufObj); 1673464ebd5Sriastradh 1687ec681f3Smrg tfObj->BufferNames[index] = bufObj ? bufObj->Name : 0; 169af69d88dSmrg tfObj->Offset[index] = offset; 170af69d88dSmrg tfObj->RequestedSize[index] = size; 17101e04c3fSmrg 1727ec681f3Smrg if (bufObj) 17301e04c3fSmrg bufObj->UsageHistory |= USAGE_TRANSFORM_FEEDBACK_BUFFER; 1743464ebd5Sriastradh} 1753464ebd5Sriastradh 17601e04c3fSmrgstatic inline void 17701e04c3fSmrg_mesa_bind_buffer_range_xfb(struct gl_context *ctx, 17801e04c3fSmrg struct gl_transform_feedback_object *obj, 17901e04c3fSmrg GLuint index, struct gl_buffer_object *bufObj, 18001e04c3fSmrg GLintptr offset, GLsizeiptr size) 18101e04c3fSmrg{ 18201e04c3fSmrg /* Note: no need to FLUSH_VERTICES or flag NewTransformFeedback, because 18301e04c3fSmrg * transform feedback buffers can't be changed while transform feedback is 18401e04c3fSmrg * active. 18501e04c3fSmrg */ 18601e04c3fSmrg 18701e04c3fSmrg /* The general binding point */ 18801e04c3fSmrg _mesa_reference_buffer_object(ctx, 18901e04c3fSmrg &ctx->TransformFeedback.CurrentBuffer, 19001e04c3fSmrg bufObj); 19101e04c3fSmrg 19201e04c3fSmrg /* The per-attribute binding point */ 19301e04c3fSmrg _mesa_set_transform_feedback_binding(ctx, obj, index, bufObj, offset, size); 19401e04c3fSmrg} 19501e04c3fSmrg 19601e04c3fSmrg/*** GL_ARB_direct_state_access ***/ 19701e04c3fSmrg 19801e04c3fSmrgextern void GLAPIENTRY 19901e04c3fSmrg_mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer); 20001e04c3fSmrg 20101e04c3fSmrgextern void GLAPIENTRY 20201e04c3fSmrg_mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer, 20301e04c3fSmrg GLintptr offset, GLsizeiptr size); 20401e04c3fSmrg 20501e04c3fSmrgextern void GLAPIENTRY 20601e04c3fSmrg_mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param); 20701e04c3fSmrg 20801e04c3fSmrgextern void GLAPIENTRY 20901e04c3fSmrg_mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index, 21001e04c3fSmrg GLint *param); 21101e04c3fSmrg 21201e04c3fSmrgextern void GLAPIENTRY 21301e04c3fSmrg_mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index, 21401e04c3fSmrg GLint64 *param); 21501e04c3fSmrg 2163464ebd5Sriastradh#endif /* TRANSFORM_FEEDBACK_H */ 217