summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/glamo/glamo_context.h
blob: 376e0a4b67283b85b62baf1d9ad2139e39f7d22e (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
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Direct Rendering Support for SMedia Glamo 336x/337x
 *
 * (c) 2009 Thomas White <taw@bitwiz.org.uk>
 * Roughly based on sis_context.h (c) 2003 Eric Anholt
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef __GLAMO_CONTEXT_H
#define __GLAMO_CONTEXT_H


#include "dri_util.h"
#include "utils.h"
#include "tnl/t_vertex.h"

#include "glamo_screen.h"


typedef struct glamo_context glamoContext;
typedef struct glamo_context *glamoContextPtr;

struct glamo_context {

	GLcontext *glCtx;                  /* Must be first in this structure */

	int drm_fd;                        /* DRM fd */

	__DRIcontextPrivate  *driContext;  /* DRI context */
	__DRIscreenPrivate   *driScreen;   /* DRI screen */
	__DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */

	glamoScreenPtr glamoScreen;        /* Screen private DRI data */

	driOptionCache optionCache;

	uint16_t *cmdq_drm;                /* Command queue cache */
	int cmdq_drm_used;
	int cmdq_drm_size;
	int cmdq_obj_used;
	uint32_t *cmdq_objs;
	unsigned int *cmdq_obj_pos;

	/* Information about the current primitive */
	struct {
		GLuint id;
		uint32_t primitive;	/* Current hardware primitive type */
		struct glamo_bo *vb_bo;
		uint8_t *vb;
		unsigned int start_offset; /* Byte offset of start */
		unsigned int current_offset; /* Byte offset of next vertex */
		unsigned int count;	/* Number of vertices */
	} prim;

	/* Current vertex format and attributes */
	int vertex_size;
	struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];

	uint16_t col_clear;

};

#define GLAMO_CONTEXT(ctx) ((glamoContextPtr)(ctx->DriverCtx))

#define TAG(x) glamo##x
#include "tnl_dd/t_dd_vertex.h"
#undef TAG

extern GLboolean glamoCreateContext(const __GLcontextModes *glVis,
                                    __DRIcontext *driContextPriv,
                                    void *sharedContextPrivate);
extern void glamoDestroyContext(__DRIcontext *dcp);
extern GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
                                  __DRIdrawable *driDrawPriv,
                                  __DRIdrawable *driReadPriv);
extern GLboolean glamoUnbindContext(__DRIcontext *driContextPriv);
extern void glamo_update_renderbuffers(__DRIcontext *context,
                                       __DRIdrawable *drawable);

#define GLAMO_PACKCOLOR565(r, g, b) \
	((((r) & 0xf8) << 8)        \
	| (((g) & 0xfc) << 3)       \
	| (((b) & 0xf8) >> 3))


#endif   /* __GLAMO_CONTEXT_H */