Changeset 53590 in vbox for trunk/src/VBox/GuestHost/OpenGL
- Timestamp:
- Dec 21, 2014 4:26:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_blitter.h
r51141 r53590 1 1 /* $Id$ */ 2 3 2 /** @file 4 * Blitter API 3 * Blitter API. 5 4 */ 5 6 6 /* 7 * Copyright (C) 2013 Oracle Corporation7 * Copyright (C) 2013-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 17 18 #ifndef ___cr_blitter_h__ 18 19 #define ___cr_blitter_h__ … … 20 21 #include <iprt/cdefs.h> 21 22 #include <iprt/asm.h> 22 #include "cr_spu.h"23 #include <iprt/string.h> 23 24 #include "cr_vreg.h" 24 25 #ifdef IN_VMSVGA3D 26 # include <iprt/assert.h> 27 typedef struct TODO_VMSVGA3D_DISPATCH_TABLE SPUDispatchTable; 28 # include <OpenGL/OpenGL.h> 29 #else 30 # include "cr_spu.h" 31 #endif 32 33 /** @todo r=bird: VBOXBLITTERDECL makes no sense. */ 25 34 #ifndef IN_RING0 26 35 # define VBOXBLITTERDECL(_type) DECLEXPORT(_type) … … 38 47 GLuint bpp; 39 48 GLuint pitch; 40 } CR_BLITTER_IMG, *PCR_BLITTER_IMG; 41 42 VBOXBLITTERDECL(void) CrMClrFillImgRect(CR_BLITTER_IMG *pDst, const RTRECT *pCopyRect, uint32_t u32Color); 43 VBOXBLITTERDECL(void) CrMClrFillImg(CR_BLITTER_IMG *pImg, uint32_t cRects, const RTRECT *pRects, uint32_t u32Color); 44 VBOXBLITTERDECL(void) CrMBltImgRect(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, CR_BLITTER_IMG *pDst); 45 VBOXBLITTERDECL(void) CrMBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pPos, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst); 46 VBOXBLITTERDECL(void) CrMBltImgRectScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pPos, bool fSrcInvert, const RTRECT *pCopyRect, float strX, float strY, CR_BLITTER_IMG *pDst); 47 VBOXBLITTERDECL(void) CrMBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTRECTSIZE *pSrcRectSize, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst); 48 49 /* GLSL Cache */ 49 } CR_BLITTER_IMG; 50 typedef CR_BLITTER_IMG *PCR_BLITTER_IMG; 51 typedef CR_BLITTER_IMG const *PCCR_BLITTER_IMG; 52 53 VBOXBLITTERDECL(void) CrMClrFillImgRect(PCR_BLITTER_IMG pDst, PCRTRECT pCopyRect, uint32_t u32Color); 54 VBOXBLITTERDECL(void) CrMClrFillImg(PCR_BLITTER_IMG pImg, uint32_t cRects, PCRTRECT pRects, uint32_t u32Color); 55 VBOXBLITTERDECL(void) CrMBltImgRect(PCCR_BLITTER_IMG pSrc, PCRTPOINT pSrcDataPoint, bool fSrcInvert, PCRTRECT pCopyRect, 56 PCR_BLITTER_IMG pDst); 57 VBOXBLITTERDECL(void) CrMBltImg(PCCR_BLITTER_IMG pSrc, PCRTPOINT pPos, uint32_t cRects, PCRTRECT pRects, PCR_BLITTER_IMG pDst); 58 VBOXBLITTERDECL(void) CrMBltImgRectScaled(PCCR_BLITTER_IMG pSrc, PCRTPOINT pPos, bool fSrcInvert, PCRTRECT pCopyRect, 59 float strX, float strY, PCR_BLITTER_IMG pDst); 60 VBOXBLITTERDECL(void) CrMBltImgScaled(PCCR_BLITTER_IMG pSrc, PCRTRECTSIZE pSrcRectSize, PCRTRECT pDstRect, uint32_t cRects, 61 PCRTRECT pRects, PCR_BLITTER_IMG pDst); 62 63 /* 64 * GLSL Cache 65 */ 50 66 typedef struct CR_GLSL_CACHE 51 67 { … … 55 71 SPUDispatchTable *pDispatch; 56 72 } CR_GLSL_CACHE; 57 58 DECLINLINE(void) CrGlslInit(CR_GLSL_CACHE *pCache, SPUDispatchTable *pDispatch) 59 { 60 memset(pCache, 0, sizeof (*pCache)); 73 typedef CR_GLSL_CACHE *PCR_GLSL_CACHE; 74 typedef CR_GLSL_CACHE const *PCCR_GLSL_CACHE; 75 76 DECLINLINE(void) CrGlslInit(PCR_GLSL_CACHE pCache, SPUDispatchTable *pDispatch) 77 { 78 RT_ZERO(*pCache); 61 79 pCache->pDispatch = pDispatch; 62 80 } 63 81 64 DECLINLINE(bool) CrGlslIsInited( const CR_GLSL_CACHE *pCache)82 DECLINLINE(bool) CrGlslIsInited(PCCR_GLSL_CACHE pCache) 65 83 { 66 84 return !!pCache->pDispatch; … … 68 86 69 87 /* clients should set proper context before calling these funcs */ 70 VBOXBLITTERDECL(bool) CrGlslIsSupported(CR_GLSL_CACHE *pCache); 71 VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(CR_GLSL_CACHE *pCache); 72 VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget); 73 VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget); 74 VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget); 75 VBOXBLITTERDECL(void) CrGlslProgClear(const CR_GLSL_CACHE *pCache); 76 VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(const CR_GLSL_CACHE *pCache); 77 VBOXBLITTERDECL(void) CrGlslCleanup(CR_GLSL_CACHE *pCache); 78 VBOXBLITTERDECL(void) CrGlslTerm(CR_GLSL_CACHE *pCache); 79 80 /* BLITTER */ 88 VBOXBLITTERDECL(bool) CrGlslIsSupported(PCR_GLSL_CACHE pCache); 89 VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(PCR_GLSL_CACHE pCache); 90 VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(PCR_GLSL_CACHE pCache, GLenum enmTexTarget); 91 VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(PCR_GLSL_CACHE pCache, GLenum enmTexTarget); 92 VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(PCCR_GLSL_CACHE pCache, GLenum enmTexTarget); 93 VBOXBLITTERDECL(void) CrGlslProgClear(PCCR_GLSL_CACHE pCache); 94 VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(PCCR_GLSL_CACHE pCache); 95 VBOXBLITTERDECL(void) CrGlslCleanup(PCR_GLSL_CACHE pCache); 96 VBOXBLITTERDECL(void) CrGlslTerm(PCR_GLSL_CACHE pCache); 97 98 /* 99 * BLITTER 100 */ 81 101 typedef struct CR_BLITTER_BUFFER 82 102 { 83 103 GLuint cbBuffer; 84 GLvoid * pvBuffer; 85 } CR_BLITTER_BUFFER, *PCR_BLITTER_BUFFER; 104 GLvoid *pvBuffer; 105 } CR_BLITTER_BUFFER; 106 typedef CR_BLITTER_BUFFER *PCR_BLITTER_BUFFER; 107 typedef CR_BLITTER_BUFFER const *PCCR_BLITTER_BUFFER; 86 108 87 109 typedef union CR_BLITTER_FLAGS … … 100 122 }; 101 123 uint32_t Value; 102 } CR_BLITTER_FLAGS , *PCR_BLITTER_FLAGS;124 } CR_BLITTER_FLAGS; 103 125 104 126 struct CR_BLITTER; 105 127 106 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); 128 typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, PCVBOXVR_TEXTURE pSrc, PCRTRECT paSrcRect, 129 PCRTRECTSIZE pDstSize, PCRTRECT paDstRect, uint32_t cRects, uint32_t fFlags); 107 130 typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER; 108 131 … … 116 139 { 117 140 CR_BLITTER_SPUITEM Base; 118 } CR_BLITTER_CONTEXT, *PCR_BLITTER_CONTEXT; 141 } CR_BLITTER_CONTEXT; 142 typedef CR_BLITTER_CONTEXT *PCR_BLITTER_CONTEXT; 143 typedef CR_BLITTER_CONTEXT const *PCCR_BLITTER_CONTEXT; 119 144 120 145 typedef struct CR_BLITTER_WINDOW … … 122 147 CR_BLITTER_SPUITEM Base; 123 148 GLuint width, height; 124 } CR_BLITTER_WINDOW, *PCR_BLITTER_WINDOW; 149 } CR_BLITTER_WINDOW; 150 typedef CR_BLITTER_WINDOW *PCR_BLITTER_WINDOW; 151 typedef CR_BLITTER_WINDOW const *PCCR_BLITTER_WINDOW; 125 152 126 153 typedef struct CR_BLITTER … … 137 164 int32_t i32MakeCurrentUserData; 138 165 SPUDispatchTable *pDispatch; 139 const CR_GLSL_CACHE *pGlslCache;166 PCCR_GLSL_CACHE pGlslCache; 140 167 CR_GLSL_CACHE LocalGlslCache; 141 } CR_BLITTER, *PCR_BLITTER; 168 } CR_BLITTER; 169 typedef CR_BLITTER *PCR_BLITTER; 170 typedef CR_BLITTER const *PCCR_BLITTER; 142 171 143 172 DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter) … … 146 175 } 147 176 148 VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, const CR_GLSL_CACHE *pShaders, SPUDispatchTable *pDispatch); 177 VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, PCCR_BLITTER_CONTEXT pCtxBase, bool fCreateNewCtx, 178 bool fForceDrawBlt, PCCR_GLSL_CACHE pShaders, SPUDispatchTable *pDispatch); 149 179 150 180 VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter); 151 181 152 VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter);182 VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter); 153 183 154 184 DECLINLINE(GLboolean) CrBltSupportsTexTex(PCR_BLITTER pBlitter) … … 178 208 } 179 209 180 VBOXBLITTERDECL(int) CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural); 181 DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter) 210 VBOXBLITTERDECL(int) CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, PCCR_BLITTER_WINDOW pMural); 211 212 DECLINLINE(PCCR_BLITTER_WINDOW) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter) 182 213 { 183 214 return &pBlitter->CurrentMural; … … 188 219 VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter); 189 220 VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter); 190 VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags); 191 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); 192 VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst); 193 194 VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst); 195 VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst); 221 VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, PCVBOXVR_TEXTURE pSrc, PCRTRECT paSrcRects, 222 PCRTRECT paDstRects, uint32_t cRects, uint32_t fFlags); 223 VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, PCVBOXVR_TEXTURE pSrc, PCRTRECT pSrcRect, PCVBOXVR_TEXTURE pDst, 224 PCRTRECT pDstRect, uint32_t cRects, uint32_t fFlags); 225 VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, PCVBOXVR_TEXTURE pSrc, GLenum enmFormat, PCR_BLITTER_IMG pDst); 226 227 VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, PCR_BLITTER_IMG pDst); 228 VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, PCR_BLITTER_IMG pDst); 196 229 VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter); 197 230 /* */ … … 212 245 }; 213 246 uint32_t Value; 214 } CR_TEXDATA_FLAGS , *PCR_TEXDATA_FLAGS;247 } CR_TEXDATA_FLAGS; 215 248 216 249 … … 228 261 PFNCRTEXDATA_RELEASED pfnTextureReleased; 229 262 struct CR_TEXDATA *pScaledCache; 230 } CR_TEXDATA, *PCR_TEXDATA; 231 232 DECLINLINE(void) CrTdInit(PCR_TEXDATA pTex, const VBOXVR_TEXTURE *pVrTex, PCR_BLITTER pBlitter, PFNCRTEXDATA_RELEASED pfnTextureReleased) 263 } CR_TEXDATA; 264 typedef CR_TEXDATA *PCR_TEXDATA; 265 typedef CR_TEXDATA const *PCCR_TEXDATA; 266 267 DECLINLINE(void) CrTdInit(PCR_TEXDATA pTex, PCVBOXVR_TEXTURE pVrTex, PCR_BLITTER pBlitter, PFNCRTEXDATA_RELEASED pfnTextureReleased) 233 268 { 234 269 memset(pTex, 0, sizeof (*pTex)); … … 239 274 } 240 275 241 DECLINLINE( const VBOXVR_TEXTURE*) CrTdTexGet(const CR_TEXDATA *pTex)276 DECLINLINE(PCVBOXVR_TEXTURE) CrTdTexGet(PCCR_TEXDATA pTex) 242 277 { 243 278 return &pTex->Tex; 244 279 } 245 280 246 DECLINLINE(PCR_BLITTER) CrTdBlitterGet( CR_TEXDATA *pTex)281 DECLINLINE(PCR_BLITTER) CrTdBlitterGet(PCR_TEXDATA pTex) 247 282 { 248 283 return pTex->pBlitter; … … 252 287 { 253 288 int rc; 254 if (pTex->Flags.Entered) 255 return VERR_INVALID_STATE; 256 rc = CrBltEnter(pTex->pBlitter); 289 if (pTex->Flags.Entered) 290 return VERR_INVALID_STATE; 291 rc = CrBltEnter(pTex->pBlitter); 292 #ifdef IN_VMSVGA3D 293 AssertRCReturn(rc, rc); 294 #else 257 295 if (!RT_SUCCESS(rc)) 258 296 { … … 260 298 return rc; 261 299 } 262 pTex->Flags.Entered = 1; 263 return VINF_SUCCESS; 300 #endif 301 pTex->Flags.Entered = 1; 302 return VINF_SUCCESS; 264 303 } 265 304 266 305 DECLINLINE(bool) CrTdBltIsEntered(PCR_TEXDATA pTex) 267 306 { 268 307 return pTex->Flags.Entered; 269 308 } 270 309 271 310 DECLINLINE(void) CrTdBltLeave(PCR_TEXDATA pTex) 272 311 { 273 if (!pTex->Flags.Entered) 274 { 275 WARN(("invalid Blt Leave")); 276 return; 277 } 278 279 CrBltLeave(pTex->pBlitter); 280 281 pTex->Flags.Entered = 0; 312 #ifdef IN_VMSVGA3D 313 AssertReturnVoid(pTex->Flags.Entered); 314 #else 315 if (!pTex->Flags.Entered) 316 { 317 WARN(("invalid Blt Leave")); 318 return; 319 } 320 #endif 321 322 CrBltLeave(pTex->pBlitter); 323 324 pTex->Flags.Entered = 0; 282 325 } 283 326 284 327 /* the CrTdBltXxx calls are done with the entered blitter */ 285 /* acquire the texture data, returns the cached data in case it is cached. 286 * the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup. 287 * */ 288 VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, const CR_BLITTER_IMG**ppImg); 289 290 VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, uint32_t width, uint32_t height, const CR_BLITTER_IMG**ppImg); 291 292 VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, const CR_BLITTER_IMG *pImg); 328 /** Acquire the texture data, returns the cached data in case it is cached. 329 * The data remains cached in the CR_TEXDATA object until it is discarded with 330 * CrTdBltDataFree or CrTdBltDataCleanup. */ 331 VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, PCCR_BLITTER_IMG *ppImg); 332 333 VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, 334 uint32_t width, uint32_t height, PCCR_BLITTER_IMG *ppImg); 335 336 VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, PCCR_BLITTER_IMG pImg); 293 337 294 338 VBOXBLITTERDECL(void) CrTdBltScaleCacheMoveTo(PCR_TEXDATA pTex, PCR_TEXDATA pDstTex); 295 339 296 /* release the texture data, the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup */ 340 /** Release the texture data, the data remains cached in the CR_TEXDATA object 341 * until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup. */ 297 342 VBOXBLITTERDECL(int) CrTdBltDataRelease(PCR_TEXDATA pTex); 298 /* discard the texture data cached with previous CrTdBltDataAcquire.299 * Must be called wit data released (CrTdBltDataRelease) */343 /** Discard the texture data cached with previous CrTdBltDataAcquire. 344 * Must be called wit data released (CrTdBltDataRelease). */ 300 345 VBOXBLITTERDECL(int) CrTdBltDataFree(PCR_TEXDATA pTex); 301 346 VBOXBLITTERDECL(int) CrTdBltDataFreeNe(PCR_TEXDATA pTex); 302 347 VBOXBLITTERDECL(void) CrTdBltDataInvalidateNe(PCR_TEXDATA pTex); 303 /* does same as CrTdBltDataFree, and in addition cleans up. 304 * this is kind of a texture destructor, which clients should call on texture object destruction, e.g. from the PFNCRTEXDATA_RELEASED callback */ 348 /** Does same as CrTdBltDataFree, and in addition cleans up. 349 * This is kind of a texture destructor, which clients should call on texture object destruction, 350 * e.g. from the PFNCRTEXDATA_RELEASED callback. */ 305 351 VBOXBLITTERDECL(int) CrTdBltDataCleanup(PCR_TEXDATA pTex); 306 352 … … 321 367 else 322 368 CrTdBltDataCleanupNe(pTex); 323 369 } 324 370 325 371 return cRefs; … … 328 374 RT_C_DECLS_END 329 375 330 #endif /* #ifndef ___cr_blitter_h__ */ 376 #endif 377
Note:
See TracChangeset
for help on using the changeset viewer.