1 | /* $Id: cr_dump.h 46368 2013-06-03 17:24:51Z 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 | RTStrPrintfV(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 | RTStrPrintfV(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 | typedef struct CR_DBGPRINT_DUMPER
|
---|
88 | {
|
---|
89 | CR_DUMPER Base;
|
---|
90 | } CR_DBGPRINT_DUMPER;
|
---|
91 |
|
---|
92 | typedef struct CR_HTML_DUMPER
|
---|
93 | {
|
---|
94 | CR_DUMPER Base;
|
---|
95 | const char* pszFile;
|
---|
96 | const char* pszDir;
|
---|
97 | FILE *pFile;
|
---|
98 | uint32_t cImg;
|
---|
99 | } CR_HTML_DUMPER;
|
---|
100 |
|
---|
101 | DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile);
|
---|
102 |
|
---|
103 | DECLINLINE(void) crDmpDbgPrintInit(CR_DBGPRINT_DUMPER *pDumper)
|
---|
104 | {
|
---|
105 | pDumper->Base.pfnDumpImg = crDmpDumpImgDmlBreak;
|
---|
106 | pDumper->Base.pfnDumpStr = crDmpDumpStrDbgPrint;
|
---|
107 | }
|
---|
108 |
|
---|
109 | typedef struct CR_RECORDER
|
---|
110 | {
|
---|
111 | CR_BLITTER *pBlitter;
|
---|
112 | SPUDispatchTable *pDispatch;
|
---|
113 | CR_DUMPER *pDumper;
|
---|
114 | } CR_RECORDER;
|
---|
115 |
|
---|
116 | DECLINLINE(void) crRecInit(CR_RECORDER *pRec, CR_BLITTER *pBlitter, SPUDispatchTable *pDispatch, CR_DUMPER *pDumper)
|
---|
117 | {
|
---|
118 | pRec->pBlitter = pBlitter;
|
---|
119 | pRec->pDispatch = pDispatch;
|
---|
120 | pRec->pDumper = pDumper;
|
---|
121 | }
|
---|
122 |
|
---|
123 | VBOXDUMPDECL(void) crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex);
|
---|
124 | VBOXDUMPDECL(void) crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin);
|
---|
125 | VBOXDUMPDECL(void) crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
|
---|
126 | VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
|
---|
127 | VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx);
|
---|
128 |
|
---|
129 |
|
---|
130 | typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj);
|
---|
131 | void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey);
|
---|
132 |
|
---|
133 | RT_C_DECLS_END
|
---|
134 |
|
---|
135 | #endif /* VBOX_WITH_CRDUMPER */
|
---|
136 | /* */
|
---|
137 |
|
---|
138 | #endif /* #ifndef ___cr_dump_h__ */
|
---|