summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c
blob: e6057639dfab09d9baae3fd4e0c12bec88fb0242 (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
/* 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 (CR_CMDBLOCK_IS_STARTED(pc, CRPACKBLOCKSTATE_OP_BEGIN))
    {
        WARN(("recursive begin?"));
        return;
    }

    CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_BEGIN );
#ifndef VBOX
    if (pc->buffer.canBarf)
    {
        if (!pc->buffer.holds_BeginEnd)
            pc->Flush( pc->flush_arg );
        pc->buffer.in_BeginEnd = 1;
        pc->buffer.holds_BeginEnd = 1;
    }
#endif
    CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, 4, GL_FALSE);
    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;
#ifndef VBOX
    if (pc->buffer.canBarf)
    {
        if (!pc->buffer.holds_BeginEnd)
            pc->Flush( pc->flush_arg );
        pc->buffer.in_BeginEnd = 1;
        pc->buffer.holds_BeginEnd = 1;
    }
#endif
    CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, 4, GL_FALSE);
    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;
    CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_BEGIN );
    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;
    CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_BEGIN );
    CR_UNLOCK_PACKER_CONTEXT(pc);
}