dump.cpp revision f350d4fb2d12fd22c0905fe9c7a121499da7b52d
/* $Id$ */
/** @file
* Blitter API implementation
*/
/*
* Copyright (C) 2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "cr_blitter.h"
#include "cr_spu.h"
#include "chromium.h"
#include "cr_error.h"
#include "cr_net.h"
#include "cr_rand.h"
#include "cr_mem.h"
#include "cr_string.h"
#include <cr_dump.h>
#include "cr_pixeldata.h"
#include <stdio.h>
#ifdef VBOX_WITH_CRDUMPER
/* dump stuff */
#pragma pack(1)
typedef struct VBOX_BITMAPFILEHEADER {
typedef struct VBOX_BITMAPINFOHEADER {
#pragma pack()
{
static int sIdx = 0;
{
return;
}
if (!f)
{
crWarning("fopen failed");
return;
}
bf.bfReserved1 = 0;
bf.bfReserved2 = 0;
bi.biCompression = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrImportant = 0;
fclose (f);
}
typedef struct CRDUMPGETHWID_DATA
{
unsigned long Key;
void* pvObj;
{
return;
{
}
}
void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey)
{
CRDUMPGETHWID_DATA Data = {0};
if (pKey)
}
#if 0
typedef struct CR_SERVER_DUMP_FIND_TEX
{
{
}
#endif
return (_str); \
}
DECLINLINE(size_t) crDmpFormatVal(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbVal, const void *pvVal)
{
{
return 0;
}
switch (cbVal)
{
case 8:
case 4:
{
/* we do not care only about type specifiers, all the rest is not accepted */
switch (pszElFormat[1])
{
case 'f':
/* float would be promoted to double */
default:
}
}
case 2:
case 1:
default:
return 0;
}
}
VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
{
if (cbString < 2)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = '{';
--cbString;
{
if (i != cVal - 1)
{
}
}
if (!cbString)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = '}';
--cbString;
if (!cbString)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = '\0';
return cbInitString - cbString;
}
VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cX, uint32_t cY)
{
if (cbString < 2)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = '{';
--cbString;
{
if (i != cY - 1)
{
if (cbString < 3)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = ',';
--cbString;
*pString++ = '\n';
--cbString;
}
}
if (!cbString)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = '}';
--cbString;
if (!cbString)
{
crWarning("too few buffer size");
return 0;
}
*pString++ = '\0';
return cbInitString - cbString;
}
VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
{
switch(cVal)
{
case 1:
case 16:
case 9:
case 0:
crWarning("value array is empty");
return 0;
default:
}
}
VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
{
char aBuf[1024];
}
VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList)
{
}
{
}
void crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex)
{
CR_BLITTER_IMG Img = {0};
int rc;
if (hwBuf)
{
pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &hwTex);
pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &hwObjType);
if (hwObjType == GL_TEXTURE)
{
pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &hwTexLevel);
pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, &hwCubeFace);
if (hwCubeFace)
{
crWarning("cube face: unsupported");
return;
}
if (hwTexLevel)
{
crWarning("non-zero tex level attached, unsupported");
return;
}
}
else
{
crWarning("unsupported");
return;
}
}
else
{
crWarning("no buffer attached: unsupported");
return;
}
{
CRTextureObj *pTobj = (CRTextureObj *)crHashtableSearch(ctx->shared->textureTable, ctx->framebufferobject.drawFB->color[iColor].name);
if (!pTobj)
{
crWarning("no tobj");
return;
}
if (!RT_SUCCESS(rc))
{
return;
}
}
else
{
if (!pRedirTex)
{
crWarning("pRedirTex is expected for non-FBO state!");
return;
}
if (!RT_SUCCESS(rc))
{
return;
}
}
if (RT_SUCCESS(rc))
{
crDmpImgF(pRec->pDumper, &Img, "ctx(%d), BUFFER: id(%d) hwid(%d), width(%d), height(%d)", ctx, id, Tex.hwid, width, height);
if (g_CrDbgDumpAlphaData)
{
CR_BLITTER_IMG AlphaImg = {0};
if (RT_SUCCESS(rc))
{
}
else
{
}
}
}
else
{
}
}
{
switch (enmType)
{
}
}
{
switch (enmType)
{
}
}
{
if (!cbStr)
{
/* zero-length string */
return NULL;
}
{
crWarning("string should be null-rerminated, forcing it!");
}
if (!*pszStr)
{
*pcbStr = 0;
return NULL;
}
{
/* the string contains a single line! */
*pcbStr = 0;
return pszStr;
}
*pNewLine = '\0';
return pszStr;
}
{
char *pszCurLine;
{
}
}
{
}
{
}
/* Context activation is done by the caller. */
{
if (cbLog > 1)
{
}
}
{
GLint compileStatus = 0;
#ifndef IN_GUEST
if (!id)
{
unsigned long tstKey = 0;
pShad = (CRGLSLShader *)crDmpHashtableSearchByHwid(ctx->glsl.shaders, hwid, crDmpGetHwidShaderCB, &tstKey);
if (!pShad)
return;
}
else
{
if (!pShad)
return;
}
if (!hwid)
#else
if (!id)
else if (!hwid)
#endif
crDmpStrF(pRec->pDumper, "SHADER ctx(%d) id(%d) hwid(%d) type(%s) status(%d):", ctx->id, id, hwid, crRecDumpShaderTypeString(type, pRec->pDumper), compileStatus);
if (!pszSource)
{
crWarning("crCalloc failed");
return;
}
}
{
if (!id)
{
unsigned long tstKey = 0;
pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey);
if (!pProg)
return;
}
else
{
if (!pProg)
return;
}
if (!hwid)
crDmpStrF(pRec->pDumper, "PROGRAM ctx(%d) id(%d) hwid(%d) status(%d) shaders(%d):", ctx->id, id, hwid, linkStatus, cShaders);
if (!pShaders)
{
crWarning("crCalloc failed");
return;
}
{
if (pShaders[i])
else
}
if (cbLog)
{
}
else
{
}
}
{
GLint compileStatus = 0;
if (!id)
{
unsigned long tstKey = 0;
pShad = (CRGLSLShader *)crDmpHashtableSearchByHwid(ctx->glsl.shaders, hwid, crDmpGetHwidShaderCB, &tstKey);
if (!pShad)
return;
}
else
{
if (!pShad)
return;
}
if (!hwid)
crDmpStrF(pRec->pDumper, "==RECOMPILE SHADER ctx(%d) id(%d) hwid(%d) type(%s) status(%d)==", ctx->id, id, hwid, crRecDumpShaderTypeString(type, pRec->pDumper), compileStatus);
compileStatus = 0;
}
{
if (!id)
{
unsigned long tstKey = 0;
pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey);
if (!pProg)
return;
}
else
{
if (!pProg)
return;
}
if (!hwid)
crDmpStrF(pRec->pDumper, "==RECOMPILE PROGRAM ctx(%d) id(%d) hwid(%d) status(%d) shaders(%d)==", ctx->id, id, hwid, linkStatus, cShaders);
if (!pShaders)
{
crWarning("crCalloc failed");
return;
}
{
}
linkStatus = 0;
}
{
GLint curProgram = 0;
if (curProgram)
{
crWarning("no active program state with active hw program");
else
}
else
{
}
}
{
if (!id)
{
unsigned long tstKey = 0;
pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey);
if (!pProg)
return;
}
else
{
if (!pProg)
return;
}
if (!hwid)
if (!maxUniformLen)
{
if (activeUniforms)
{
activeUniforms = 0;
}
}
if (activeUniforms>0)
{
if (!pszName)
{
crWarning("crRecDumpProgramUniforms: out of memory");
return;
}
}
for (i=0; i<activeUniforms; ++i)
{
uniformsCount += size;
}
if (activeUniforms>0)
{
for (i=0; i<activeUniforms; ++i)
{
bool fPrintBraketsWithName = false;
if (size>1)
{
if (!pIndexStr)
{
fPrintBraketsWithName = true;
}
}
{
}
else
for (j=0; j<size; ++j)
{
if (size>1)
{
}
if (crStateIsIntUniform(type))
{
switch (uniformTypeSize)
{
case 1:
break;
case 2:
break;
case 3:
crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], location);
break;
case 4:
crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], idata[3], location);
break;
default:
for (GLint k = 0; k < uniformTypeSize; ++k)
{
}
break;
}
}
else
{
switch (uniformTypeSize)
{
case 1:
break;
case 2:
break;
case 3:
crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], location);
break;
case 4:
crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], fdata[3], location);
break;
default:
for (GLint k = 0; k < uniformTypeSize; ++k)
{
}
break;
}
}
}
}
}
}
{
if (!id)
{
unsigned long tstKey = 0;
pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey);
if (!pProg)
return;
}
else
{
if (!pProg)
return;
}
if (!hwid)
if (!maxAttribLen)
{
if (activeAttrib)
{
activeAttrib = 0;
}
}
if (activeAttrib>0)
{
if (!pszName)
{
crWarning("crRecDumpProgramAttrib: out of memory");
return;
}
}
for (i=0; i<activeAttrib; ++i)
{
attribCount += size;
}
if (activeAttrib>0)
{
for (i=0; i<activeAttrib; ++i)
{
bool fPrintBraketsWithName = false;
GLint arrayBufferBind = 0, arrayEnabled = 0, arraySize = 0, arrayStride = 0, arrayType = 0, arrayNormalized = 0, arrayInteger = 0/*, arrayDivisor = 0*/;
// pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &arrayDivisor);
if (size>1)
{
if (!pIndexStr)
{
fPrintBraketsWithName = true;
}
}
{
}
else
crDmpStrF(pRec->pDumper, "Array buff(%d), enabled(%d) size(%d), stride(%d), type(%s), normalized(%d), integer(%d)", arrayBufferBind, arrayEnabled, arraySize, arrayStride, crRecDumpVarTypeString(arrayType, pRec->pDumper), arrayNormalized, arrayInteger);
for (j=0; j<size; ++j)
{
if (size>1)
{
}
if (crStateIsIntUniform(type))
{
switch (attribTypeSize)
{
case 1:
break;
case 2:
break;
case 3:
crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], location);
break;
case 4:
crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], idata[3], location);
break;
default:
for (GLint k = 0; k < attribTypeSize; ++k)
{
}
break;
}
}
else
{
switch (attribTypeSize)
{
case 1:
break;
case 2:
break;
case 3:
crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], location);
break;
case 4:
crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], fdata[3], location);
break;
default:
for (GLint k = 0; k < attribTypeSize; ++k)
{
}
break;
}
}
}
}
}
}
{
GLint curProgram = 0;
if (curProgram)
{
crWarning("no active program state with active hw program");
else
}
else
{
}
}
{
GLint curProgram = 0;
if (curProgram)
{
crWarning("no active program state with active hw program");
else
}
else
{
}
}
{
GLint curProgram = 0;
if (curProgram)
{
crWarning("no active program state with active hw program");
else
}
else
{
}
}
{
{
return VERR_NOT_IMPLEMENTED;
}
{
crWarning("RTMemAlloc failed");
return VERR_NO_MEMORY;
}
{
{
++pu32SrcBuf;
++pu32DstBuf;
}
}
return VINF_SUCCESS;
}
{
}
void crRecDumpTextureV(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList)
{
CR_BLITTER_IMG Img = {0};
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (g_CrDbgDumpAlphaData)
{
CR_BLITTER_IMG AlphaImg = {0};
if (RT_SUCCESS(rc))
{
}
else
{
}
}
}
else
{
}
}
else
{
}
}
void crRecDumpTextureF(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, ...)
{
}
void crRecDumpTextureByIdV(CR_RECORDER *pRec, CRContext *ctx, GLint id, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList)
{
if (!pTobj)
{
return;
}
{
return;
}
}
void crRecDumpTextureByIdF(CR_RECORDER *pRec, CRContext *ctx, GLint id, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, ...)
{
}
void crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin)
{
GLint curTexUnit = 0;
GLint restoreTexUnit = 0;
GLint curProgram = 0;
int i;
for (i = 0; i < maxUnits; ++i)
{
if (i > 1)
break;
if (curTexUnit != i + GL_TEXTURE0)
{
curTexUnit = i + GL_TEXTURE0;
}
if (enabled1D)
{
crWarning("GL_TEXTURE_1D: unsupported");
}
// if (enabled2D)
{
if (hwTex)
{
{
}
crRecDumpTextureF(pRec, &Tex, pCurCtx, pCurWin, "ctx(%d), Unit %d: TEXTURE_2D id(%d) hwid(%d), width(%d), height(%d)", ctx, i, pTobj->id, pTobj->hwid, width, height);
}
// else
// {
// Assert(!pTobj || pTobj->hwid == 0);
// crWarning("no TEXTURE_2D bound!");
// }
}
#if 0
if (enabled3D)
{
crWarning("GL_TEXTURE_3D: unsupported");
}
if (enabledCubeMap)
{
crWarning("GL_TEXTURE_CUBE_MAP_ARB: unsupported");
}
// if (enabledRect)
{
CR_BLITTER_IMG Img = {0};
if (hwTex)
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
}
else
{
}
}
else
{
}
}
// else
// {
// Assert(!pTobj || pTobj->hwid == 0);
// crWarning("no TEXTURE_RECTANGLE bound!");
// }
}
#endif
}
if (curTexUnit != restoreTexUnit)
{
}
}
#ifdef RT_OS_WINDOWS
static void crDmpPrint(const char* szString, ...)
{
char szBuffer[4096] = {0};
}
{
}
void crDmpPrintDumpDmlCmd(const char* pszDesc, const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch)
{
char Cmd[1024];
}
DECLCALLBACK(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc)
{
crDmpPrintDumpDmlCmd(pszEntryDesc, pImg->pvData, pImg->width, pImg->height, pImg->bpp, pImg->pitch);
}
{
}
#endif
{
}
{
}
static DECLCALLBACK(void) crDmpHtmlDumpImg(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc)
{
char szBuffer[4096] = {0};
fprintf(pHtmlDumper->pFile, "<a href=\"%s\"><pre>%s</pre><img src=\"%s\" alt=\"%s\" width=\"150\" height=\"100\" /></a><br>\n",
}
{
}
{
}
{
}
{
}
DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile)
{
int rc = VERR_NO_MEMORY;
{
{
char szBuffer[4096] = {0};
{
return VINF_SUCCESS;
}
else
{
crWarning("open failed");
}
}
else
{
crWarning("open failed");
}
}
else
{
crWarning("open failed");
}
return rc;
}
DECLEXPORT(int) crDmpHtmlInitV(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, va_list pArgList)
{
char szBuffer[4096] = {0};
}
DECLEXPORT(int) crDmpHtmlInitF(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, ...)
{
int rc;
return rc;
}
#endif