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 "packer.h"
|
---|
8 | #include "cr_error.h"
|
---|
9 | #include "cr_string.h"
|
---|
10 | #include "cr_version.h"
|
---|
11 |
|
---|
12 |
|
---|
13 | void PACK_APIENTRY
|
---|
14 | crPackMapBufferARB( GLenum target, GLenum access,
|
---|
15 | void * return_value, int * writeback )
|
---|
16 | {
|
---|
17 | (void)writeback;
|
---|
18 | (void)return_value;
|
---|
19 | (void)target;
|
---|
20 | (void)access;
|
---|
21 | crWarning("Can't pack MapBufferARB command!");
|
---|
22 | }
|
---|
23 |
|
---|
24 |
|
---|
25 | void PACK_APIENTRY
|
---|
26 | crPackUnmapBufferARB( GLenum target, GLboolean* return_value, int * writeback )
|
---|
27 | {
|
---|
28 | (void)target;
|
---|
29 | (void)return_value;
|
---|
30 | (void)writeback;
|
---|
31 | crWarning("Can't pack UnmapBufferARB command!");
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 | void PACK_APIENTRY
|
---|
36 | crPackBufferDataARB( GLenum target, GLsizeiptrARB size,
|
---|
37 | const GLvoid * data, GLenum usage )
|
---|
38 | {
|
---|
39 | unsigned char *data_ptr, *start_ptr;
|
---|
40 | int packet_length;
|
---|
41 |
|
---|
42 | packet_length = sizeof(GLenum)
|
---|
43 | + sizeof(target) + sizeof(GLuint) + sizeof(usage) + sizeof(GLint);
|
---|
44 |
|
---|
45 | /*Note: it's valid to pass a NULL pointer here, which tells GPU drivers to allocate memory for the VBO*/
|
---|
46 | if (data) packet_length += size;
|
---|
47 |
|
---|
48 | start_ptr = data_ptr = (unsigned char *) crPackAlloc( packet_length );
|
---|
49 |
|
---|
50 | WRITE_DATA_AI(GLenum, CR_BUFFERDATAARB_EXTEND_OPCODE);
|
---|
51 | WRITE_DATA_AI(GLenum, target);
|
---|
52 | WRITE_DATA_AI(GLuint, (GLuint) size);
|
---|
53 | WRITE_DATA_AI(GLenum, usage);
|
---|
54 | WRITE_DATA_AI(GLint, (GLint) (data!=NULL));
|
---|
55 | if (data)
|
---|
56 | crMemcpy(data_ptr, data, size);
|
---|
57 |
|
---|
58 | crHugePacket( CR_EXTEND_OPCODE, start_ptr );
|
---|
59 | crPackFree( start_ptr );
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | void PACK_APIENTRY
|
---|
64 | crPackBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size,
|
---|
65 | const GLvoid * data )
|
---|
66 | {
|
---|
67 | unsigned char *data_ptr, *start_ptr;
|
---|
68 | int packet_length;
|
---|
69 |
|
---|
70 | if (!data)
|
---|
71 | return;
|
---|
72 |
|
---|
73 | packet_length = sizeof(GLenum)
|
---|
74 | + sizeof(target) + sizeof(GLuint) + sizeof(GLuint) + size;
|
---|
75 |
|
---|
76 | start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
|
---|
77 | WRITE_DATA_AI(GLenum, CR_BUFFERSUBDATAARB_EXTEND_OPCODE);
|
---|
78 | WRITE_DATA_AI(GLenum, target);
|
---|
79 | WRITE_DATA_AI(GLuint, (GLuint) offset);
|
---|
80 | WRITE_DATA_AI(GLuint, (GLuint) size);
|
---|
81 | crMemcpy(data_ptr, data, size);
|
---|
82 |
|
---|
83 | crHugePacket(CR_EXTEND_OPCODE, start_ptr);
|
---|
84 | crPackFree(start_ptr);
|
---|
85 | }
|
---|
86 |
|
---|
87 | void PACK_APIENTRY
|
---|
88 | crPackGetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data, int * writeback )
|
---|
89 | {
|
---|
90 | CR_GET_PACKER_CONTEXT(pc);
|
---|
91 | unsigned char *data_ptr;
|
---|
92 | (void) pc;
|
---|
93 | CR_GET_BUFFERED_POINTER( pc, 36 );
|
---|
94 | WRITE_DATA( 0, GLint, 36 );
|
---|
95 | WRITE_DATA( 4, GLenum, CR_GETBUFFERSUBDATAARB_EXTEND_OPCODE );
|
---|
96 | WRITE_DATA( 8, GLenum, target );
|
---|
97 | WRITE_DATA( 12, GLuint, (GLuint) offset );
|
---|
98 | WRITE_DATA( 16, GLuint, (GLuint) size );
|
---|
99 | WRITE_NETWORK_POINTER( 20, (void *) data );
|
---|
100 | WRITE_NETWORK_POINTER( 28, (void *) writeback );
|
---|
101 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
102 | CR_CMDBLOCK_CHECK_FLUSH(pc);
|
---|
103 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
104 | }
|
---|
105 |
|
---|
106 | void PACK_APIENTRY
|
---|
107 | crPackDeleteBuffersARB(GLsizei n, const GLuint * buffers)
|
---|
108 | {
|
---|
109 | unsigned char *data_ptr;
|
---|
110 | int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*buffers);
|
---|
111 |
|
---|
112 | if (!buffers)
|
---|
113 | return;
|
---|
114 |
|
---|
115 | data_ptr = (unsigned char *) crPackAlloc(packet_length);
|
---|
116 | WRITE_DATA( 0, GLenum, CR_DELETEBUFFERSARB_EXTEND_OPCODE );
|
---|
117 | WRITE_DATA( 4, GLsizei, n );
|
---|
118 | crMemcpy( data_ptr + 8, buffers, n * sizeof(*buffers) );
|
---|
119 | crHugePacket( CR_EXTEND_OPCODE, data_ptr );
|
---|
120 | crPackFree( data_ptr );
|
---|
121 | }
|
---|