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 |
|
---|
13 | static 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 | CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
|
---|
23 | }
|
---|
24 |
|
---|
25 | void * PACKSPU_APIENTRY
|
---|
26 | packspu_MapBufferARB( GLenum target, GLenum access )
|
---|
27 | {
|
---|
28 | GET_CONTEXT(ctx);
|
---|
29 | void *buffer;
|
---|
30 | CRBufferObject *pBufObj;
|
---|
31 |
|
---|
32 | CRASSERT(GL_TRUE == ctx->clientState->bufferobject.retainBufferData);
|
---|
33 | buffer = crStateMapBufferARB(target, access);
|
---|
34 |
|
---|
35 | #ifdef CR_ARB_pixel_buffer_object
|
---|
36 | if (buffer)
|
---|
37 | {
|
---|
38 | pBufObj = crStateGetBoundBufferObject(target, &ctx->clientState->bufferobject);
|
---|
39 | CRASSERT(pBufObj);
|
---|
40 |
|
---|
41 | if (pBufObj->bResyncOnRead &&
|
---|
42 | access != GL_WRITE_ONLY_ARB)
|
---|
43 | {
|
---|
44 | /*fetch data from host side*/
|
---|
45 | packspu_GetHostBufferSubDataARB(target, 0, pBufObj->size, buffer);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | return buffer;
|
---|
51 | }
|
---|
52 |
|
---|
53 | void PACKSPU_APIENTRY packspu_GetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data )
|
---|
54 | {
|
---|
55 | GET_CONTEXT(ctx);
|
---|
56 |
|
---|
57 | #ifdef CR_ARB_pixel_buffer_object
|
---|
58 | CRBufferObject *pBufObj;
|
---|
59 |
|
---|
60 | pBufObj = crStateGetBoundBufferObject(target, &ctx->clientState->bufferobject);
|
---|
61 |
|
---|
62 | if (pBufObj && pBufObj->bResyncOnRead)
|
---|
63 | {
|
---|
64 | packspu_GetHostBufferSubDataARB(target, offset, size, data);
|
---|
65 | return;
|
---|
66 | }
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | crStateGetBufferSubDataARB(target, offset, size, data);
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | GLboolean PACKSPU_APIENTRY
|
---|
74 | packspu_UnmapBufferARB( GLenum target )
|
---|
75 | {
|
---|
76 | GET_CONTEXT(ctx);
|
---|
77 |
|
---|
78 | #if CR_ARB_vertex_buffer_object
|
---|
79 | CRBufferObject *bufObj;
|
---|
80 |
|
---|
81 | bufObj = crStateGetBoundBufferObject(target, &ctx->clientState->bufferobject);
|
---|
82 |
|
---|
83 | /* send new buffer contents to server */
|
---|
84 | crPackBufferDataARB( target, bufObj->size, bufObj->pointer, bufObj->usage );
|
---|
85 | #endif
|
---|
86 |
|
---|
87 | CRASSERT(GL_TRUE == ctx->clientState->bufferobject.retainBufferData);
|
---|
88 | crStateUnmapBufferARB( target );
|
---|
89 |
|
---|
90 | return GL_TRUE;
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 | void PACKSPU_APIENTRY
|
---|
95 | packspu_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
|
---|
96 | {
|
---|
97 | /*crDebug("packspu_BufferDataARB size:%d", size);*/
|
---|
98 | crStateBufferDataARB(target, size, data, usage);
|
---|
99 | crPackBufferDataARB(target, size, data, usage);
|
---|
100 | }
|
---|
101 |
|
---|
102 | void PACKSPU_APIENTRY
|
---|
103 | packspu_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
|
---|
104 | {
|
---|
105 | /*crDebug("packspu_BufferSubDataARB size:%d", size);*/
|
---|
106 | crStateBufferSubDataARB(target, offset, size, data);
|
---|
107 | crPackBufferSubDataARB(target, offset, size, data);
|
---|
108 | }
|
---|
109 |
|
---|
110 |
|
---|
111 | void PACKSPU_APIENTRY
|
---|
112 | packspu_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
|
---|
113 | {
|
---|
114 | crStateGetBufferPointervARB( target, pname, params );
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | void PACKSPU_APIENTRY
|
---|
119 | packspu_GetBufferParameterivARB( GLenum target, GLenum pname, GLint * params )
|
---|
120 | {
|
---|
121 | crStateGetBufferParameterivARB( target, pname, params );
|
---|
122 | }
|
---|
123 |
|
---|
124 | /*
|
---|
125 | * Need to update our local state for vertex arrays.
|
---|
126 | */
|
---|
127 | void PACKSPU_APIENTRY
|
---|
128 | packspu_BindBufferARB( GLenum target, GLuint buffer )
|
---|
129 | {
|
---|
130 | crStateBindBufferARB(target, buffer);
|
---|
131 | crPackBindBufferARB(target, buffer);
|
---|
132 | }
|
---|
133 |
|
---|
134 | void PACKSPU_APIENTRY packspu_GenBuffersARB( GLsizei n, GLuint * buffer )
|
---|
135 | {
|
---|
136 | GET_THREAD(thread);
|
---|
137 | int writeback = 1;
|
---|
138 | if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))
|
---|
139 | {
|
---|
140 | crError( "packspu_GenBuffersARB doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
|
---|
141 | }
|
---|
142 | if (pack_spu.swap)
|
---|
143 | {
|
---|
144 | crPackGenBuffersARBSWAP( n, buffer, &writeback );
|
---|
145 | }
|
---|
146 | else
|
---|
147 | {
|
---|
148 | crPackGenBuffersARB( n, buffer, &writeback );
|
---|
149 | }
|
---|
150 | packspuFlush( (void *) thread );
|
---|
151 | CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
|
---|
152 |
|
---|
153 | crStateRegBuffers(n, buffer);
|
---|
154 | }
|
---|
155 |
|
---|
156 | void PACKSPU_APIENTRY packspu_DeleteBuffersARB( GLsizei n, const GLuint * buffer )
|
---|
157 | {
|
---|
158 | crStateDeleteBuffersARB( n, buffer );
|
---|
159 | crPackDeleteBuffersARB(n, buffer);
|
---|
160 | }
|
---|