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_protocol.h"
|
---|
9 |
|
---|
10 | void PACK_APIENTRY crPackBegin( GLenum mode )
|
---|
11 | {
|
---|
12 | CR_GET_PACKER_CONTEXT(pc);
|
---|
13 | unsigned char *data_ptr;
|
---|
14 | (void) pc;
|
---|
15 | if (pc->buffer.canBarf)
|
---|
16 | {
|
---|
17 | if (!pc->buffer.holds_BeginEnd)
|
---|
18 | pc->Flush( pc->flush_arg );
|
---|
19 | pc->buffer.in_BeginEnd = 1;
|
---|
20 | pc->buffer.holds_BeginEnd = 1;
|
---|
21 | }
|
---|
22 | CR_GET_BUFFERED_POINTER( pc, 4 );
|
---|
23 | CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateNone);
|
---|
24 | pc->enmBeginEndState = CRPackBeginEndStateStarted;
|
---|
25 | pc->current.begin_data = data_ptr;
|
---|
26 | pc->current.begin_op = pc->buffer.opcode_current;
|
---|
27 | pc->current.attribsUsedMask = 0;
|
---|
28 | WRITE_DATA( 0, GLenum, mode );
|
---|
29 | WRITE_OPCODE( pc, CR_BEGIN_OPCODE );
|
---|
30 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
31 | }
|
---|
32 |
|
---|
33 | void PACK_APIENTRY crPackBeginSWAP( GLenum mode )
|
---|
34 | {
|
---|
35 | CR_GET_PACKER_CONTEXT(pc);
|
---|
36 | unsigned char *data_ptr;
|
---|
37 | (void) pc;
|
---|
38 | if (pc->buffer.canBarf)
|
---|
39 | {
|
---|
40 | if (!pc->buffer.holds_BeginEnd)
|
---|
41 | pc->Flush( pc->flush_arg );
|
---|
42 | pc->buffer.in_BeginEnd = 1;
|
---|
43 | pc->buffer.holds_BeginEnd = 1;
|
---|
44 | }
|
---|
45 | CR_GET_BUFFERED_POINTER( pc, 4 );
|
---|
46 | CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateNone);
|
---|
47 | pc->enmBeginEndState = CRPackBeginEndStateStarted;
|
---|
48 | pc->current.begin_data = data_ptr;
|
---|
49 | pc->current.begin_op = pc->buffer.opcode_current;
|
---|
50 | pc->current.attribsUsedMask = 0;
|
---|
51 | WRITE_DATA( 0, GLenum, SWAP32(mode) );
|
---|
52 | WRITE_OPCODE( pc, CR_BEGIN_OPCODE );
|
---|
53 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
54 | }
|
---|
55 |
|
---|
56 | void PACK_APIENTRY crPackEnd( void )
|
---|
57 | {
|
---|
58 | CR_GET_PACKER_CONTEXT(pc);
|
---|
59 | unsigned char *data_ptr;
|
---|
60 | (void) pc;
|
---|
61 | CR_GET_BUFFERED_POINTER_NO_ARGS( pc );
|
---|
62 | WRITE_OPCODE( pc, CR_END_OPCODE );
|
---|
63 | pc->buffer.in_BeginEnd = 0;
|
---|
64 | CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateStarted
|
---|
65 | || pc->enmBeginEndState == CRPackBeginEndStateFlushDone);
|
---|
66 | if (pc->enmBeginEndState == CRPackBeginEndStateFlushDone)
|
---|
67 | {
|
---|
68 | pc->Flush( pc->flush_arg );
|
---|
69 | }
|
---|
70 | pc->enmBeginEndState = CRPackBeginEndStateNone;
|
---|
71 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
72 | }
|
---|
73 |
|
---|
74 | void PACK_APIENTRY crPackEndSWAP( void )
|
---|
75 | {
|
---|
76 | CR_GET_PACKER_CONTEXT(pc);
|
---|
77 | unsigned char *data_ptr;
|
---|
78 | (void) pc;
|
---|
79 | CR_GET_BUFFERED_POINTER_NO_ARGS( pc );
|
---|
80 | WRITE_OPCODE( pc, CR_END_OPCODE );
|
---|
81 | pc->buffer.in_BeginEnd = 0;
|
---|
82 | CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateStarted
|
---|
83 | || pc->enmBeginEndState == CRPackBeginEndStateFlushDone);
|
---|
84 | if (pc->enmBeginEndState == CRPackBeginEndStateFlushDone)
|
---|
85 | {
|
---|
86 | pc->Flush( pc->flush_arg );
|
---|
87 | }
|
---|
88 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
89 | }
|
---|
90 |
|
---|