1 | /* $Id: cr_dump.h 46395 2013-06-05 15:20:56Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * Debugging: Dump 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_dump_h__
|
---|
18 | #define ___cr_dump_h__
|
---|
19 |
|
---|
20 | /* dump stuff */
|
---|
21 | //#define VBOX_WITH_CRDUMPER
|
---|
22 | #ifdef VBOX_WITH_CRDUMPER
|
---|
23 |
|
---|
24 | #include <iprt/cdefs.h>
|
---|
25 | #include <iprt/string.h>
|
---|
26 | #include <cr_spu.h>
|
---|
27 | #include <cr_glstate.h>
|
---|
28 | #include <cr_blitter.h>
|
---|
29 |
|
---|
30 | # define VBOXDUMPDECL(_type) DECLEXPORT(_type)
|
---|
31 |
|
---|
32 | RT_C_DECLS_BEGIN
|
---|
33 |
|
---|
34 | DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc);
|
---|
35 |
|
---|
36 | DECLEXPORT(void) crDmpDumpStrDbgPrint(struct CR_DUMPER * pDumper, const char*pszStr);
|
---|
37 |
|
---|
38 | struct CR_DUMPER;
|
---|
39 |
|
---|
40 | typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc);
|
---|
41 | typedef DECLCALLBACKPTR(void, PFNCRDUMPSTR)(struct CR_DUMPER * pDumper, const char*pszStr);
|
---|
42 |
|
---|
43 | typedef struct CR_DUMPER
|
---|
44 | {
|
---|
45 | PFNCRDUMPIMG pfnDumpImg;
|
---|
46 | PFNCRDUMPSTR pfnDumpStr;
|
---|
47 | } CR_DUMPER;
|
---|
48 |
|
---|
49 | #define crDmpImg(_pDumper, _pImg, _pDesc) do { \
|
---|
50 | (_pDumper)->pfnDumpImg((_pDumper), (_pImg), (_pDesc)); \
|
---|
51 | } while (0)
|
---|
52 |
|
---|
53 | #define crDmpStr(_pDumper, _pDesc) do { \
|
---|
54 | (_pDumper)->pfnDumpStr((_pDumper), (_pDesc)); \
|
---|
55 | } while (0)
|
---|
56 |
|
---|
57 | DECLINLINE(void) crDmpStrV(CR_DUMPER *pDumper, const char *pszStr, va_list pArgList)
|
---|
58 | {
|
---|
59 | char szBuffer[4096] = {0};
|
---|
60 | vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList);
|
---|
61 | crDmpStr(pDumper, szBuffer);
|
---|
62 | }
|
---|
63 |
|
---|
64 | DECLINLINE(void) crDmpStrF(CR_DUMPER *pDumper, const char *pszStr, ...)
|
---|
65 | {
|
---|
66 | va_list pArgList;
|
---|
67 | va_start(pArgList, pszStr);
|
---|
68 | crDmpStrV(pDumper, pszStr, pArgList);
|
---|
69 | va_end(pArgList);
|
---|
70 | }
|
---|
71 |
|
---|
72 | DECLINLINE(void) crDmpImgV(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, va_list pArgList)
|
---|
73 | {
|
---|
74 | char szBuffer[4096] = {0};
|
---|
75 | vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList);
|
---|
76 | crDmpImg(pDumper, pImg, szBuffer);
|
---|
77 | }
|
---|
78 |
|
---|
79 | DECLINLINE(void) crDmpImgF(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, ...)
|
---|
80 | {
|
---|
81 | va_list pArgList;
|
---|
82 | va_start(pArgList, pszStr);
|
---|
83 | crDmpImgV(pDumper, pImg, pszStr, pArgList);
|
---|
84 | va_end(pArgList);
|
---|
85 | }
|
---|
86 |
|
---|
87 | VBOXDUMPDECL(size_t) crDmpFormatArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal);
|
---|
88 | VBOXDUMPDECL(size_t) crDmpFormatRawArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal);
|
---|
89 | VBOXDUMPDECL(size_t) crDmpFormatMatrixArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cX, uint32_t cY);
|
---|
90 |
|
---|
91 | typedef struct CR_DBGPRINT_DUMPER
|
---|
92 | {
|
---|
93 | CR_DUMPER Base;
|
---|
94 | } CR_DBGPRINT_DUMPER;
|
---|
95 |
|
---|
96 | typedef struct CR_HTML_DUMPER
|
---|
97 | {
|
---|
98 | CR_DUMPER Base;
|
---|
99 | const char* pszFile;
|
---|
100 | const char* pszDir;
|
---|
101 | FILE *pFile;
|
---|
102 | uint32_t cImg;
|
---|
103 | } CR_HTML_DUMPER;
|
---|
104 |
|
---|
105 | DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile);
|
---|
106 |
|
---|
107 | DECLINLINE(void) crDmpDbgPrintInit(CR_DBGPRINT_DUMPER *pDumper)
|
---|
108 | {
|
---|
109 | pDumper->Base.pfnDumpImg = crDmpDumpImgDmlBreak;
|
---|
110 | pDumper->Base.pfnDumpStr = crDmpDumpStrDbgPrint;
|
---|
111 | }
|
---|
112 |
|
---|
113 | typedef struct CR_RECORDER
|
---|
114 | {
|
---|
115 | CR_BLITTER *pBlitter;
|
---|
116 | SPUDispatchTable *pDispatch;
|
---|
117 | CR_DUMPER *pDumper;
|
---|
118 | } CR_RECORDER;
|
---|
119 |
|
---|
120 | DECLINLINE(void) crRecInit(CR_RECORDER *pRec, CR_BLITTER *pBlitter, SPUDispatchTable *pDispatch, CR_DUMPER *pDumper)
|
---|
121 | {
|
---|
122 | pRec->pBlitter = pBlitter;
|
---|
123 | pRec->pDispatch = pDispatch;
|
---|
124 | pRec->pDumper = pDumper;
|
---|
125 | }
|
---|
126 |
|
---|
127 | VBOXDUMPDECL(void) crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex);
|
---|
128 | VBOXDUMPDECL(void) crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin);
|
---|
129 | VBOXDUMPDECL(void) crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
|
---|
130 | VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
|
---|
131 | VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx);
|
---|
132 | VBOXDUMPDECL(void) crRecDumpProgramUniforms(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
|
---|
133 | VBOXDUMPDECL(void) crRecDumpCurrentProgramUniforms(CR_RECORDER *pRec, CRContext *ctx);
|
---|
134 | VBOXDUMPDECL(void) crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx);
|
---|
135 | VBOXDUMPDECL(void) crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx);
|
---|
136 |
|
---|
137 | typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj);
|
---|
138 | void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey);
|
---|
139 |
|
---|
140 | RT_C_DECLS_END
|
---|
141 |
|
---|
142 | #endif /* VBOX_WITH_CRDUMPER */
|
---|
143 | /* */
|
---|
144 |
|
---|
145 | #endif /* #ifndef ___cr_dump_h__ */
|
---|