summaryrefslogtreecommitdiff
path: root/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
blob: 8584adc0080f3544a12b07b42bf408fb8ea50cda (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
/* Copyright (c) 2001, Stanford University
 * All rights reserved.
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#ifndef CR_STATE_BUFFEROBJECT_H
#define CR_STATE_BUFFEROBJECT_H

#include "cr_hash.h"
#include "state/cr_statetypes.h"
#include "state/cr_statefuncs.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
	CRbitvalue	dirty[CR_MAX_BITARRAY];
	CRbitvalue	arrayBinding[CR_MAX_BITARRAY];
	CRbitvalue	elementsBinding[CR_MAX_BITARRAY];
    CRbitvalue  packBinding[CR_MAX_BITARRAY];
    CRbitvalue  unpackBinding[CR_MAX_BITARRAY];
} CRBufferObjectBits;


/*
 * Buffer object, like a texture object, but encapsulates arbitrary
 * data (vertex, image, etc).
 */
typedef struct {
	GLuint refCount;
	GLuint id;
    GLuint hwid;
	GLenum usage;
	GLenum access;
	GLuint size;      /* buffer size in bytes */
	GLvoid *pointer;  /* only valid while buffer is mapped */
	GLvoid *data;     /* the buffer data, if retainBufferData is true */
    GLboolean bResyncOnRead; /* buffer data could be changed on server side, 
                                so we need to resync every time guest wants to read from it*/
	CRbitvalue dirty[CR_MAX_BITARRAY];  /* dirty data or state */
	GLintptrARB dirtyStart, dirtyLength; /* dirty region */
    /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
    CRbitvalue             ctxUsage[CR_MAX_BITARRAY];
} CRBufferObject;

typedef struct {
	GLboolean retainBufferData;  /* should state tracker retain buffer data? */
	CRBufferObject *arrayBuffer;
	CRBufferObject *elementsBuffer;
    CRBufferObject *packBuffer;
    CRBufferObject *unpackBuffer;

	CRBufferObject *nullBuffer;  /* name = 0 */
} CRBufferObjectState;

DECLEXPORT(CRBufferObject *) crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b);
DECLEXPORT(GLboolean) crStateIsBufferBound(GLenum target);
struct CRContext;
DECLEXPORT(GLboolean) crStateIsBufferBoundForCtx(struct CRContext *g, GLenum target);

DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(GLuint hwid);
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(GLuint id);

DECLEXPORT(void) crStateRegBuffers(GLsizei n, GLuint *buffers);
#ifdef __cplusplus
}
#endif

#endif /* CR_STATE_BUFFEROBJECT_H */