VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_blitter.h@ 48275

Last change on this file since 48275 was 48275, checked in by vboxsync, 11 years ago

crOpenGL: basics for no-alpha blits

  • Property svn:executable set to *
File size: 6.3 KB
Line 
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
30RT_C_DECLS_BEGIN
31/* GLSL Cache */
32typedef struct CR_GLSL_CACHE
33{
34 float glVersion;
35 GLuint uNoAlpha2DProg;
36 GLuint uNoAlpha2DRectProg;
37 SPUDispatchTable *pDispatch;
38} CR_GLSL_CACHE;
39
40DECLINLINE(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 */
48VBOXBLITTERDECL(bool) CrGlslIsSupported(CR_GLSL_CACHE *pCache);
49VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(CR_GLSL_CACHE *pCache);
50VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
51VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
52VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
53VBOXBLITTERDECL(void) CrGlslProgClear(const CR_GLSL_CACHE *pCache);
54VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(CR_GLSL_CACHE *pCache);
55VBOXBLITTERDECL(void) CrGlslCleanup(CR_GLSL_CACHE *pCache);
56VBOXBLITTERDECL(void) CrGlslTerm(CR_GLSL_CACHE *pCache);
57
58/* BLITTER */
59typedef struct CR_BLITTER_BUFFER
60{
61 GLuint cbBuffer;
62 GLvoid * pvBuffer;
63} CR_BLITTER_BUFFER, *PCR_BLITTER_BUFFER;
64
65typedef 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
81struct CR_BLITTER;
82
83typedef 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);
84typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER;
85
86typedef struct CR_BLITTER_SPUITEM
87{
88 int id;
89 GLint visualBits;
90} CR_BLITTER_SPUITEM, *PCR_BLITTER_SPUITEM;
91
92typedef struct CR_BLITTER_CONTEXT
93{
94 CR_BLITTER_SPUITEM Base;
95} CR_BLITTER_CONTEXT, *PCR_BLITTER_CONTEXT;
96
97typedef struct CR_BLITTER_WINDOW
98{
99 CR_BLITTER_SPUITEM Base;
100 GLuint width, height;
101} CR_BLITTER_WINDOW, *PCR_BLITTER_WINDOW;
102
103typedef 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
113typedef 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
131DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter)
132{
133 return !!pBlitter->pDispatch;
134}
135
136VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, const CR_GLSL_CACHE *pShaders, SPUDispatchTable *pDispatch);
137
138VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter);
139
140VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural);
141
142DECLINLINE(GLboolean) CrBltSupportsTexTex(PCR_BLITTER pBlitter)
143{
144 return pBlitter->Flags.SupportsFBO;
145}
146
147DECLINLINE(GLboolean) CrBltIsEntered(PCR_BLITTER pBlitter)
148{
149 return !!pBlitter->pRestoreCtxInfo;
150}
151
152DECLINLINE(GLint) CrBltGetVisBits(PCR_BLITTER pBlitter)
153{
154 return pBlitter->CtxInfo.Base.visualBits;
155}
156
157
158DECLINLINE(GLboolean) CrBltIsEverEntered(PCR_BLITTER pBlitter)
159{
160 return !!pBlitter->Flags.Initialized;
161}
162
163DECLINLINE(void) CrBltSetMakeCurrentUserData(PCR_BLITTER pBlitter, int32_t i32MakeCurrentUserData)
164{
165 pBlitter->i32MakeCurrentUserData = i32MakeCurrentUserData;
166}
167
168VBOXBLITTERDECL(int) CrBltMuralSetCurrent(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural);
169DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter)
170{
171 return &pBlitter->CurrentMural;
172}
173
174VBOXBLITTERDECL(void) CrBltCheckUpdateViewport(PCR_BLITTER pBlitter);
175
176VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter);
177VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pRestoreCtxInfo, const CR_BLITTER_WINDOW *pRestoreMural);
178VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);
179VBOXBLITTERDECL(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);
180VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst);
181
182VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst);
183VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst);
184VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter);
185/* */
186
187RT_C_DECLS_END
188
189#endif /* #ifndef ___cr_blitter_h__ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette