summaryrefslogtreecommitdiff
path: root/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c
blob: 2beec94f303a7347d9a84d1997c109bc68ff4879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* Copyright (c) 2001, Stanford University
 * All rights reserved
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#include "packer.h"
#include "cr_protocol.h"

void PACK_APIENTRY crPackBegin( GLenum mode )
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    (void) pc;
    if (pc->buffer.canBarf)
    {
        if (!pc->buffer.holds_BeginEnd)
            pc->Flush( pc->flush_arg );
        pc->buffer.in_BeginEnd = 1;
        pc->buffer.holds_BeginEnd = 1;
    }
    CR_GET_BUFFERED_POINTER( pc, 4 );
    CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateNone);
    pc->enmBeginEndState = CRPackBeginEndStateStarted;
    pc->current.begin_data = data_ptr;
    pc->current.begin_op = pc->buffer.opcode_current;
    pc->current.attribsUsedMask = 0;
    WRITE_DATA( 0, GLenum, mode );
    WRITE_OPCODE( pc, CR_BEGIN_OPCODE );
    CR_UNLOCK_PACKER_CONTEXT(pc);
}

void PACK_APIENTRY crPackBeginSWAP( GLenum mode )
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    (void) pc;
    if (pc->buffer.canBarf)
    {
        if (!pc->buffer.holds_BeginEnd)
            pc->Flush( pc->flush_arg );
        pc->buffer.in_BeginEnd = 1;
        pc->buffer.holds_BeginEnd = 1;
    }
    CR_GET_BUFFERED_POINTER( pc, 4 );
    CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateNone);
    pc->enmBeginEndState = CRPackBeginEndStateStarted;
    pc->current.begin_data = data_ptr;
    pc->current.begin_op = pc->buffer.opcode_current;
    pc->current.attribsUsedMask = 0;
    WRITE_DATA( 0, GLenum, SWAP32(mode) );
    WRITE_OPCODE( pc, CR_BEGIN_OPCODE );
    CR_UNLOCK_PACKER_CONTEXT(pc);
}

void PACK_APIENTRY crPackEnd( void )
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    (void) pc;
    CR_GET_BUFFERED_POINTER_NO_ARGS( pc );
    WRITE_OPCODE( pc, CR_END_OPCODE );
    pc->buffer.in_BeginEnd = 0;
    CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateStarted
            || pc->enmBeginEndState == CRPackBeginEndStateFlushDone);
    if (pc->enmBeginEndState == CRPackBeginEndStateFlushDone)
    {
        pc->Flush( pc->flush_arg );
    }
    pc->enmBeginEndState = CRPackBeginEndStateNone;
    CR_UNLOCK_PACKER_CONTEXT(pc);
}

void PACK_APIENTRY crPackEndSWAP( void )
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    (void) pc;
    CR_GET_BUFFERED_POINTER_NO_ARGS( pc );
    WRITE_OPCODE( pc, CR_END_OPCODE );
    pc->buffer.in_BeginEnd = 0;
    CRASSERT(pc->enmBeginEndState == CRPackBeginEndStateStarted
            || pc->enmBeginEndState == CRPackBeginEndStateFlushDone);
    if (pc->enmBeginEndState == CRPackBeginEndStateFlushDone)
    {
        pc->Flush( pc->flush_arg );
    }
    CR_UNLOCK_PACKER_CONTEXT(pc);
}