1 | /* $Id$ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * Blitter API
|
---|
5 | */
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 | #ifndef ___cr_blitter_h__
|
---|
18 | #define ___cr_blitter_h__
|
---|
19 |
|
---|
20 | #include <iprt/cdefs.h>
|
---|
21 | #include "cr_spu.h"
|
---|
22 | #include "cr_vreg.h"
|
---|
23 |
|
---|
24 | #ifndef IN_RING0
|
---|
25 | # define VBOXBLITTERDECL(_type) DECLEXPORT(_type)
|
---|
26 | #else
|
---|
27 | # define VBOXBLITTERDECL(_type) RTDECL(_type)
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | RT_C_DECLS_BEGIN
|
---|
31 | /* GLSL Cache */
|
---|
32 | typedef struct CR_GLSL_CACHE
|
---|
33 | {
|
---|
34 | float glVersion;
|
---|
35 | GLuint uNoAlpha2DProg;
|
---|
36 | GLuint uNoAlpha2DRectProg;
|
---|
37 | SPUDispatchTable *pDispatch;
|
---|
38 | } CR_GLSL_CACHE;
|
---|
39 |
|
---|
40 | DECLINLINE(void) CrGlslInit(CR_GLSL_CACHE *pCache, SPUDispatchTable *pDispatch)
|
---|
41 | {
|
---|
42 | memset(pCache, 0, sizeof (*pCache));
|
---|
43 | pCache->glVersion = 0.0;
|
---|
44 | pCache->pDispatch = pDispatch;
|
---|
45 | }
|
---|
46 |
|
---|
47 | /* clients should set proper context before calling these funcs */
|
---|
48 | VBOXBLITTERDECL(bool) CrGlslIsSupported(CR_GLSL_CACHE *pCache);
|
---|
49 | VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(CR_GLSL_CACHE *pCache);
|
---|
50 | VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
|
---|
51 | VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
|
---|
52 | VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
|
---|
53 | VBOXBLITTERDECL(void) CrGlslProgClear(const CR_GLSL_CACHE *pCache);
|
---|
54 | VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(CR_GLSL_CACHE *pCache);
|
---|
55 | VBOXBLITTERDECL(void) CrGlslCleanup(CR_GLSL_CACHE *pCache);
|
---|
56 | VBOXBLITTERDECL(void) CrGlslTerm(CR_GLSL_CACHE *pCache);
|
---|
57 |
|
---|
58 | /* BLITTER */
|
---|
59 | typedef struct CR_BLITTER_BUFFER
|
---|
60 | {
|
---|
61 | GLuint cbBuffer;
|
---|
62 | GLvoid * pvBuffer;
|
---|
63 | } CR_BLITTER_BUFFER, *PCR_BLITTER_BUFFER;
|
---|
64 |
|
---|
65 | typedef union CR_BLITTER_FLAGS
|
---|
66 | {
|
---|
67 | struct
|
---|
68 | {
|
---|
69 | uint32_t Initialized : 1;
|
---|
70 | uint32_t CtxCreated : 1;
|
---|
71 | uint32_t SupportsFBO : 1;
|
---|
72 | uint32_t CurrentMuralChanged : 1;
|
---|
73 | uint32_t LastWasFBODraw : 1;
|
---|
74 | uint32_t ForceDrawBlit : 1;
|
---|
75 | uint32_t ShadersGloal : 1;
|
---|
76 | uint32_t Reserved : 25;
|
---|
77 | };
|
---|
78 | uint32_t Value;
|
---|
79 | } CR_BLITTER_FLAGS, *PCR_BLITTER_FLAGS;
|
---|
80 |
|
---|
81 | struct CR_BLITTER;
|
---|
82 |
|
---|
83 | typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags);
|
---|
84 | typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER;
|
---|
85 |
|
---|
86 | typedef struct CR_BLITTER_SPUITEM
|
---|
87 | {
|
---|
88 | int id;
|
---|
89 | GLint visualBits;
|
---|
90 | } CR_BLITTER_SPUITEM, *PCR_BLITTER_SPUITEM;
|
---|
91 |
|
---|
92 | typedef struct CR_BLITTER_CONTEXT
|
---|
93 | {
|
---|
94 | CR_BLITTER_SPUITEM Base;
|
---|
95 | } CR_BLITTER_CONTEXT, *PCR_BLITTER_CONTEXT;
|
---|
96 |
|
---|
97 | typedef struct CR_BLITTER_WINDOW
|
---|
98 | {
|
---|
99 | CR_BLITTER_SPUITEM Base;
|
---|
100 | GLuint width, height;
|
---|
101 | } CR_BLITTER_WINDOW, *PCR_BLITTER_WINDOW;
|
---|
102 |
|
---|
103 | typedef struct CR_BLITTER_IMG
|
---|
104 | {
|
---|
105 | void *pvData;
|
---|
106 | GLuint cbData;
|
---|
107 | GLenum enmFormat;
|
---|
108 | GLuint width, height;
|
---|
109 | GLuint bpp;
|
---|
110 | GLuint pitch;
|
---|
111 | } CR_BLITTER_IMG, *PCR_BLITTER_IMG;
|
---|
112 |
|
---|
113 | typedef struct CR_BLITTER
|
---|
114 | {
|
---|
115 | GLuint idFBO;
|
---|
116 | CR_BLITTER_FLAGS Flags;
|
---|
117 | PFNCRBLT_BLITTER pfnBlt;
|
---|
118 | CR_BLITTER_BUFFER Verticies;
|
---|
119 | CR_BLITTER_BUFFER Indicies;
|
---|
120 | RTRECTSIZE CurrentSetSize;
|
---|
121 | CR_BLITTER_WINDOW CurrentMural;
|
---|
122 | CR_BLITTER_CONTEXT CtxInfo;
|
---|
123 | const CR_BLITTER_CONTEXT *pRestoreCtxInfo;
|
---|
124 | const CR_BLITTER_WINDOW *pRestoreMural;
|
---|
125 | int32_t i32MakeCurrentUserData;
|
---|
126 | SPUDispatchTable *pDispatch;
|
---|
127 | const CR_GLSL_CACHE *pGlslCache;
|
---|
128 | CR_GLSL_CACHE LocalGlslCache;
|
---|
129 | } CR_BLITTER, *PCR_BLITTER;
|
---|
130 |
|
---|
131 | DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter)
|
---|
132 | {
|
---|
133 | return !!pBlitter->pDispatch;
|
---|
134 | }
|
---|
135 |
|
---|
136 | VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, const CR_GLSL_CACHE *pShaders, SPUDispatchTable *pDispatch);
|
---|
137 |
|
---|
138 | VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter);
|
---|
139 |
|
---|
140 | VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural);
|
---|
141 |
|
---|
142 | DECLINLINE(GLboolean) CrBltSupportsTexTex(PCR_BLITTER pBlitter)
|
---|
143 | {
|
---|
144 | return pBlitter->Flags.SupportsFBO;
|
---|
145 | }
|
---|
146 |
|
---|
147 | DECLINLINE(GLboolean) CrBltIsEntered(PCR_BLITTER pBlitter)
|
---|
148 | {
|
---|
149 | return !!pBlitter->pRestoreCtxInfo;
|
---|
150 | }
|
---|
151 |
|
---|
152 | DECLINLINE(GLint) CrBltGetVisBits(PCR_BLITTER pBlitter)
|
---|
153 | {
|
---|
154 | return pBlitter->CtxInfo.Base.visualBits;
|
---|
155 | }
|
---|
156 |
|
---|
157 |
|
---|
158 | DECLINLINE(GLboolean) CrBltIsEverEntered(PCR_BLITTER pBlitter)
|
---|
159 | {
|
---|
160 | return !!pBlitter->Flags.Initialized;
|
---|
161 | }
|
---|
162 |
|
---|
163 | DECLINLINE(void) CrBltSetMakeCurrentUserData(PCR_BLITTER pBlitter, int32_t i32MakeCurrentUserData)
|
---|
164 | {
|
---|
165 | pBlitter->i32MakeCurrentUserData = i32MakeCurrentUserData;
|
---|
166 | }
|
---|
167 |
|
---|
168 | VBOXBLITTERDECL(int) CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural);
|
---|
169 | DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter)
|
---|
170 | {
|
---|
171 | return &pBlitter->CurrentMural;
|
---|
172 | }
|
---|
173 |
|
---|
174 | VBOXBLITTERDECL(void) CrBltCheckUpdateViewport(PCR_BLITTER pBlitter);
|
---|
175 |
|
---|
176 | VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter);
|
---|
177 | VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural);
|
---|
178 | VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);
|
---|
179 | VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags);
|
---|
180 | VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst);
|
---|
181 |
|
---|
182 | VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst);
|
---|
183 | VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst);
|
---|
184 | VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter);
|
---|
185 | /* */
|
---|
186 |
|
---|
187 | RT_C_DECLS_END
|
---|
188 |
|
---|
189 | #endif /* #ifndef ___cr_blitter_h__ */
|
---|