VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c@ 42227

Last change on this file since 42227 was 27091, checked in by vboxsync, 15 years ago

crOpenGL: add GL_ARB_pixel_buffer_object support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "cr_error.h"
8#include "cr_mem.h"
9#include "cr_string.h"
10#include "packspu.h"
11#include "packspu_proto.h"
12
13static void packspu_GetHostBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data )
14{
15 GET_THREAD(thread);
16 int writeback = 1;
17
18 crPackGetBufferSubDataARB(target, offset, size, data, &writeback);
19
20 packspuFlush((void *) thread);
21
22 while (writeback)
23 crNetRecv();
24}
25
26void * PACKSPU_APIENTRY
27packspu_MapBufferARB( GLenum target, GLenum access )
28{
29 GET_CONTEXT(ctx);
30 void *buffer;
31 CRBufferObject *pBufObj;
32
33 CRASSERT(GL_TRUE == ctx->clientState->bufferobject.retainBufferData);
34 buffer = crStateMapBufferARB(target, access);
35
36#ifdef CR_ARB_pixel_buffer_object
37 if (buffer)
38 {
39 pBufObj = crStateGetBoundBufferObject(target, &ctx->clientState->bufferobject);
40 CRASSERT(pBufObj);
41
42 if (pBufObj->bResyncOnRead &&
43 access != GL_WRITE_ONLY_ARB)
44 {
45 /*fetch data from host side*/
46 packspu_GetHostBufferSubDataARB(target, 0, pBufObj->size, buffer);
47 }
48 }
49#endif
50
51 return buffer;
52}
53
54void PACKSPU_APIENTRY packspu_GetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data )
55{
56 GET_CONTEXT(ctx);
57
58#ifdef CR_ARB_pixel_buffer_object
59 CRBufferObject *pBufObj;
60
61 pBufObj = crStateGetBoundBufferObject(target, &ctx->clientState->bufferobject);
62
63 if (pBufObj && pBufObj->bResyncOnRead)
64 {
65 packspu_GetHostBufferSubDataARB(target, offset, size, data);
66 return;
67 }
68#endif
69
70 crStateGetBufferSubDataARB(target, offset, size, data);
71}
72
73
74GLboolean PACKSPU_APIENTRY
75packspu_UnmapBufferARB( GLenum target )
76{
77 GET_CONTEXT(ctx);
78
79#if CR_ARB_vertex_buffer_object
80 CRBufferObject *bufObj;
81
82 bufObj = crStateGetBoundBufferObject(target, &ctx->clientState->bufferobject);
83
84 /* send new buffer contents to server */
85 crPackBufferDataARB( target, bufObj->size, bufObj->pointer, bufObj->usage );
86#endif
87
88 CRASSERT(GL_TRUE == ctx->clientState->bufferobject.retainBufferData);
89 crStateUnmapBufferARB( target );
90
91 return GL_TRUE;
92}
93
94
95void PACKSPU_APIENTRY
96packspu_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
97{
98 /*crDebug("packspu_BufferDataARB size:%d", size);*/
99 crStateBufferDataARB(target, size, data, usage);
100 crPackBufferDataARB(target, size, data, usage);
101}
102
103void PACKSPU_APIENTRY
104packspu_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
105{
106 /*crDebug("packspu_BufferSubDataARB size:%d", size);*/
107 crStateBufferSubDataARB(target, offset, size, data);
108 crPackBufferSubDataARB(target, offset, size, data);
109}
110
111
112void PACKSPU_APIENTRY
113packspu_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
114{
115 crStateGetBufferPointervARB( target, pname, params );
116}
117
118
119void PACKSPU_APIENTRY
120packspu_GetBufferParameterivARB( GLenum target, GLenum pname, GLint * params )
121{
122 crStateGetBufferParameterivARB( target, pname, params );
123}
124
125/*
126 * Need to update our local state for vertex arrays.
127 */
128void PACKSPU_APIENTRY
129packspu_BindBufferARB( GLenum target, GLuint buffer )
130{
131 crStateBindBufferARB(target, buffer);
132 crPackBindBufferARB(target, buffer);
133}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette