DevVGA-SVGA3d-win.cpp revision 0ffa3979e9b800f5931dd30c51ec3c0aadc3a1f1
/** @file
* DevVMWare - VMWare SVGA device
*/
/*
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
#include <iprt/semaphore.h>
#include <VBox/VBoxVideo.h>
#include <VBox/bioslogo.h>
/* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
#include "DevVGA.h"
#include "DevVGA-SVGA.h"
#include "DevVGA-SVGA3d.h"
#include "vmsvga/svga_reg.h"
#include "vmsvga/svga3d_reg.h"
#include "vmsvga/svga3d_shaderdefs.h"
#include <d3d9.h>
/* Enable to disassemble defined shaders. */
#if defined(DEBUG) && 0 /* Disabled as we don't have the DirectX SDK avaible atm. */
#define DUMP_SHADER_DISASSEMBLY
#endif
#ifdef DUMP_SHADER_DISASSEMBLY
#include <d3dx9shader.h>
#endif
/* Enable to render the result of DrawPrimitive in a seperate window. */
//#define DEBUG_GFX_WINDOW
/* Enable to use Wine to convert D3D to opengl */
//#define VBOX_VMSVGA3D_WITH_OPENGL
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
typedef struct
{
void *pSurfaceData;
bool fDirty;
/**
* SSM descriptor table for the VMSVGA3DMIPMAPLEVEL structure.
*/
static SSMFIELD const g_aVMSVGA3DMIPMAPLEVELFields[] =
{
};
typedef struct
{
/* Key is context id. */
union
{
} u;
typedef struct
{
/* Dirty state; surface was manually updated. */
bool fDirty;
/* Handle for shared objects (currently only textures & render targets). */
/** Event query inserted after each GPU operation that updates or uses this surface. */
union
{
} u;
union
{
} bounce;
bool fStencilAsTexture;
/**
* SSM descriptor table for the VMSVGA3DSURFACE structure.
*/
static SSMFIELD const g_aVMSVGA3DSURFACEFields[] =
{
};
typedef struct
{
void *pShaderProgram;
union
{
} u;
/**
* SSM descriptor table for the VMSVGA3DSHADER structure.
*/
static SSMFIELD const g_aVMSVGA3DSHADERFields[] =
{
};
typedef struct
{
bool fValid;
float matrix[16];
typedef struct
{
bool fValid;
typedef struct
{
bool fValid;
float plane[4];
typedef struct
{
bool fEnabled;
bool fValidData;
typedef struct
{
bool fValid;
/**
* SSM descriptor table for the VMSVGASHADERCONST structure.
*/
static SSMFIELD const g_aVMSVGASHADERCONSTFields[] =
{
};
#define VMSVGA3D_UPDATE_SCISSORRECT RT_BIT(0)
typedef struct
{
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
#else
#endif
/* Current active render target (if any) */
/* Current selected texture surfaces (if any) */
/* Per context pixel and vertex shaders. */
/* Keep track of the internal state to be able to recreate the context properly (save/restore, window resize). */
struct
{
} state;
/**
* SSM descriptor table for the VMSVGA3DCONTEXT structure.
*/
static SSMFIELD const g_aVMSVGA3DCONTEXTFields[] =
{
};
typedef struct
{
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
#else
#endif
/** Window Thread. */
/** Window request semaphore. */
/** The size of papContexts. */
/** The size of papSurfaces. */
/** Contexts indexed by ID. Grown as needed. */
/** Surfaces indexed by ID. Grown as needed. */
bool fSupportedSurfaceINTZ;
bool fSupportedSurfaceNULL;
/**
* SSM descriptor table for the VMSVGA3DSTATE structure.
*/
static SSMFIELD const g_aVMSVGA3DSTATEFields[] =
{
};
typedef struct
{
{
{
0,
},
{
(SVGA3dFormatOp) (SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET | SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET),
},
{
},
{
},
{
0,
},
{
0,
},
{
0,
},
{
},
{
},
{
},
{
}
};
{
{
},
{
},
{
D3DRTYPE_TEXTURE, /* ?? */
},
};
static int vmsvga3dCreateTexture(PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface);
{
int rc;
/* Create event semaphore. */
if (RT_FAILURE(rc))
{
return rc;
}
/* Create the async IO thread. */
rc = RTThreadCreate(&pState->pWindowThread, vmsvga3dWindowThread, pState->WndRequestSem, 0, RTTHREADTYPE_GUI, 0, "VMSVGA3DWND");
if (RT_FAILURE(rc))
{
AssertMsgFailed(("%s: Async IO Thread creation for 3d window handling failed rc=%d\n", __FUNCTION__, rc));
return rc;
}
return VINF_SUCCESS;
}
{
return VINF_SUCCESS; /* already initialized (load state) */
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
#else
/* Direct3DCreate9Ex was introduced in Vista, so resolve it dynamically. */
PFNDIRECT3DCREATE9EX pfnDirect3dCreate9Ex = (PFNDIRECT3DCREATE9EX)RTLdrGetSystemSymbol("d3d9.dll", "Direct3DCreate9Ex");
if (!pfnDirect3dCreate9Ex)
"vmsvga3d: Unable to locate Direct3DCreate9Ex. This feature requires Vista and later.");
#endif
/* Check if INTZ is supported. */
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
0,
{
/* INTZ support is essential to support depth surfaces used as textures. */
LogRel(("VMSVGA: texture format INTZ not supported!!!\n"));
}
else
pState->fSupportedSurfaceINTZ = true;
/* Check if NULL is supported. */
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
{
/* NULL is a dummy surface which can be used as a render target to save memory. */
LogRel(("VMSVGA: surface format NULL not supported!!!\n"));
}
else
pState->fSupportedSurfaceNULL = true;
/* Check if DX9 depth stencil textures are supported */
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
{
LogRel(("VMSVGA: texture format D3DFMT_D16 not supported\n"));
}
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
{
LogRel(("VMSVGA: texture format D3DFMT_D24X8 not supported\n"));
}
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
{
LogRel(("VMSVGA: texture format D3DFMT_D24S8 not supported\n"));
}
return VINF_SUCCESS;
}
{
/* Destroy all leftover surfaces. */
{
}
/* Destroy all leftover contexts. */
{
}
return VINF_SUCCESS;
}
{
/* Terminate the window creation thread. */
rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_EXIT, 0, 0);
return VINF_SUCCESS;
}
/* Shared functions that depend on private structure definitions. */
#define VMSVGA3D_DIRECT3D
#include "DevVGA-SVGA3d-shared.h"
static uint32_t vmsvga3dGetSurfaceFormatSupport(PVMSVGA3DSTATE pState3D, uint32_t idx3dCaps, D3DFORMAT format)
{
/* Try if the format can be used for the primary display. */
0,
format);
for (unsigned i = 0; i < RT_ELEMENTS(aFormatSupport); i++)
{
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
aFormatSupport[i].Usage,
format);
}
/* Check for features only if the format is supported in any form. */
if (result)
{
for (unsigned i = 0; i < RT_ELEMENTS(aFeatureReject); i++)
{
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
aFeatureReject[i].Usage,
format);
}
}
/* @todo missing:
*
* SVGA3DFORMAT_OP_PIXELSIZE
*/
switch (idx3dCaps)
{
| SVGA3DFORMAT_OP_DISPLAYMODE /* Should not be set for alpha formats. */
| SVGA3DFORMAT_OP_3DACCELERATION; /* implies OP_DISPLAYMODE */
break;
break;
}
return result;
}
static uint32_t vmsvga3dGetDepthFormatSupport(PVMSVGA3DSTATE pState3D, uint32_t idx3dCaps, D3DFORMAT format)
{
D3DFMT_X8R8G8B8, /* assume standard 32-bit display mode */
format);
| SVGA3DFORMAT_OP_TEXTURE /* Necessary for Ubuntu Unity */;
return result;
}
{
int rc = VINF_SUCCESS;
*pu32Val = 0;
switch (idx3dCaps)
{
case SVGA3D_DEVCAP_3D:
break;
case SVGA3D_DEVCAP_MAX_LIGHTS:
break;
break;
break;
switch (pCaps->VertexShaderVersion)
{
break;
case D3DVS_VERSION(2,0):
break;
case D3DVS_VERSION(3,0):
break;
case D3DVS_VERSION(4,0):
break;
default:
break;
}
break;
/* boolean? */
*pu32Val = 1;
break;
switch (pCaps->PixelShaderVersion)
{
break;
break;
break;
break;
case D3DPS_VERSION(2,0):
break;
case D3DPS_VERSION(3,0):
break;
case D3DPS_VERSION(4,0):
break;
default:
break;
}
break;
/* boolean? */
*pu32Val = 1;
break;
/* Must be obsolete by now; surface format caps specify the same thing. */
break;
break;
/*
* 2. The BUFFER_FORMAT capabilities are deprecated, and they always
* return TRUE. Even on physical hardware that does not support
* these formats natively, the SVGA3D device will provide an emulation
* which should be invisible to the guest OS.
*/
*pu32Val = 1;
break;
break;
break;
AssertCompile(sizeof(uint32_t) == sizeof(float));
break;
/* @todo ?? */
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
case SVGA3D_DEVCAP_MAX_RENDER_TARGETS: /* @todo same thing? */
break;
/*
* This is the maximum number of SVGA context IDs that the guest
* can define using SVGA_3D_CMD_CONTEXT_DEFINE.
*/
break;
/*
* This is the maximum number of SVGA surface IDs that the guest
* can define using SVGA_3D_CMD_SURFACE_DEFINE*.
*/
break;
/* Supported surface formats. */
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
case SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT: /* @todo not correct */
break;
break;
/* @todo supposed to be floating-point, but unable to find a match for D3D9... */
*pu32Val = 0;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
*pu32Val = vmsvga3dGetSurfaceFormatSupport(pState, idx3dCaps, (D3DFORMAT)MAKEFOURCC('N', 'V', '1', '2'));
break;
*pu32Val = vmsvga3dGetSurfaceFormatSupport(pState, idx3dCaps, (D3DFORMAT)MAKEFOURCC('A', 'Y', 'U', 'V'));
break;
/* Unknown; only in DX10 & 11 */
*pu32Val = 0;
break;
default:
break;
}
#if 0
/* Dump of VMWare Player caps (from their log); for debugging purposes */
switch (idx3dCaps)
{
case 0:
*pu32Val = 0x00000001;
break;
case 1:
*pu32Val = 0x0000000a;
break;
case 2:
*pu32Val = 0x00000008;
break;
default:
// Log(("CAPS: Unexpected CAP %d\n", idx3dCaps));
// rc = VERR_INVALID_PARAMETER;
break;
}
#endif
return rc;
}
/**
* Convert SVGA format value to its D3D equivalent
*/
{
switch (format)
{
case SVGA3D_X8R8G8B8:
return D3DFMT_X8R8G8B8;
case SVGA3D_A8R8G8B8:
return D3DFMT_A8R8G8B8;
case SVGA3D_R5G6B5:
return D3DFMT_R5G6B5;
case SVGA3D_X1R5G5B5:
return D3DFMT_X1R5G5B5;
case SVGA3D_A1R5G5B5:
return D3DFMT_A1R5G5B5;
case SVGA3D_A4R4G4B4:
return D3DFMT_A4R4G4B4;
case SVGA3D_Z_D32:
return D3DFMT_D32;
case SVGA3D_Z_D16:
return D3DFMT_D16;
case SVGA3D_Z_D24S8_INT: /* @todo not correct */
case SVGA3D_Z_D24S8:
return D3DFMT_D24S8;
case SVGA3D_Z_D15S1:
return D3DFMT_D15S1;
case SVGA3D_Z_D24X8:
return D3DFMT_D24X8;
/* Advanced D3D9 depth formats. */
case SVGA3D_Z_DF16:
/* @todo supposed to be floating-point, but unable to find a match for D3D9... */
case SVGA3D_Z_DF24:
return D3DFMT_D24FS8;
case SVGA3D_LUMINANCE8:
return D3DFMT_L8;
case SVGA3D_LUMINANCE4_ALPHA4:
return D3DFMT_A4L4;
case SVGA3D_LUMINANCE16:
return D3DFMT_L16;
case SVGA3D_LUMINANCE8_ALPHA8:
return D3DFMT_A8L8;
case SVGA3D_DXT1:
return D3DFMT_DXT1;
case SVGA3D_DXT2:
return D3DFMT_DXT2;
case SVGA3D_DXT3:
return D3DFMT_DXT3;
case SVGA3D_DXT4:
return D3DFMT_DXT4;
case SVGA3D_DXT5:
return D3DFMT_DXT5;
/* Bump-map formats */
case SVGA3D_BUMPU8V8:
return D3DFMT_V8U8;
case SVGA3D_BUMPL6V5U5:
return D3DFMT_L6V5U5;
case SVGA3D_BUMPX8L8V8U8:
return D3DFMT_X8L8V8U8;
case SVGA3D_BUMPL8V8U8:
/* No corresponding D3D9 equivalent. */
/* signed bump-map formats */
case SVGA3D_V8U8:
return D3DFMT_V8U8;
case SVGA3D_Q8W8V8U8:
return D3DFMT_Q8W8V8U8;
case SVGA3D_CxV8U8:
return D3DFMT_CxV8U8;
/* mixed bump-map formats */
case SVGA3D_X8L8V8U8:
return D3DFMT_X8L8V8U8;
case SVGA3D_A2W10V10U10:
return D3DFMT_A2W10V10U10;
case SVGA3D_ARGB_S10E5: /* 16-bit floating-point ARGB */
return D3DFMT_A16B16G16R16F;
case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */
return D3DFMT_A32B32G32R32F;
case SVGA3D_A2R10G10B10:
return D3DFMT_A2R10G10B10;
case SVGA3D_ALPHA8:
return D3DFMT_A8;
/* Single- and dual-component floating point formats */
case SVGA3D_R_S10E5:
return D3DFMT_R16F;
case SVGA3D_R_S23E8:
return D3DFMT_R32F;
case SVGA3D_RG_S10E5:
return D3DFMT_G16R16F;
case SVGA3D_RG_S23E8:
return D3DFMT_G32R32F;
/*
* Any surface can be used as a buffer object, but SVGA3D_BUFFER is
* the most efficient format to use when creating new surfaces
* expressly for index or vertex data.
*/
case SVGA3D_BUFFER:
return D3DFMT_UNKNOWN;
case SVGA3D_V16U16:
return D3DFMT_V16U16;
case SVGA3D_G16R16:
return D3DFMT_G16R16;
case SVGA3D_A16B16G16R16:
return D3DFMT_A16B16G16R16;
/* Packed Video formats */
case SVGA3D_UYVY:
return D3DFMT_UYVY;
case SVGA3D_YUY2:
return D3DFMT_YUY2;
/* Planar video formats */
case SVGA3D_NV12:
/* Video format with alpha */
case SVGA3D_AYUV:
case SVGA3D_BC4_UNORM:
case SVGA3D_BC5_UNORM:
/* Unknown; only in DX10 & 11 */
break;
}
}
/**
* Convert SVGA multi sample count value to its D3D equivalent
*/
{
if (multisampleCount > 16)
return D3DMULTISAMPLE_NONE;
/* @todo exact same mapping as d3d? */
return (D3DMULTISAMPLE_TYPE)multisampleCount;
}
int vmsvga3dSurfaceDefine(PVGASTATE pThis, uint32_t sid, uint32_t surfaceFlags, SVGA3dSurfaceFormat format, SVGA3dSurfaceFace face[SVGA3D_MAX_SURFACE_FACES],
uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter, uint32_t cMipLevels, SVGA3dSize *pMipLevelSize)
{
Log(("vmsvga3dSurfaceDefine: sid=%x surfaceFlags=%x format=%s (%x) multiSampleCount=%d autogenFilter=%d, cMipLevels=%d size=(%d,%d,%d)\n",
sid, surfaceFlags, vmsvgaSurfaceType2String(format), format, multisampleCount, autogenFilter, cMipLevels, pMipLevelSize->width, pMipLevelSize->height, pMipLevelSize->depth));
/* Assuming all faces have the same nr of mipmaps. */
AssertReturn(!(surfaceFlags & SVGA3D_SURFACE_CUBEMAP) || cMipLevels == face[0].numMipLevels * 6, VERR_INVALID_PARAMETER);
AssertReturn((surfaceFlags & SVGA3D_SURFACE_CUBEMAP) || cMipLevels == face[0].numMipLevels, VERR_INVALID_PARAMETER);
{
/* Grow the array. */
{
}
}
/* If one already exists with this id, then destroy it now. */
/* The surface type is sort of undefined now, even though the hints and format can help to clear that up.
* In some case we'll have to wait until the surface is used to create the D3D object.
*/
switch (format)
{
case SVGA3D_Z_D32:
case SVGA3D_Z_D16:
case SVGA3D_Z_D24S8:
case SVGA3D_Z_D15S1:
case SVGA3D_Z_D24X8:
case SVGA3D_Z_DF16:
case SVGA3D_Z_DF24:
case SVGA3D_Z_D24S8_INT:
break;
/* Texture compression formats */
case SVGA3D_DXT1:
case SVGA3D_DXT2:
case SVGA3D_DXT3:
case SVGA3D_DXT4:
case SVGA3D_DXT5:
/* Bump-map formats */
case SVGA3D_BUMPU8V8:
case SVGA3D_BUMPL6V5U5:
case SVGA3D_BUMPX8L8V8U8:
case SVGA3D_BUMPL8V8U8:
case SVGA3D_V8U8:
case SVGA3D_Q8W8V8U8:
case SVGA3D_CxV8U8:
case SVGA3D_X8L8V8U8:
case SVGA3D_A2W10V10U10:
case SVGA3D_V16U16:
/* Typical render target formats; we should allow render target buffers to be used as textures. */
case SVGA3D_X8R8G8B8:
case SVGA3D_A8R8G8B8:
case SVGA3D_R5G6B5:
case SVGA3D_X1R5G5B5:
case SVGA3D_A1R5G5B5:
case SVGA3D_A4R4G4B4:
break;
case SVGA3D_LUMINANCE8:
case SVGA3D_LUMINANCE4_ALPHA4:
case SVGA3D_LUMINANCE16:
case SVGA3D_LUMINANCE8_ALPHA8:
case SVGA3D_ARGB_S10E5: /* 16-bit floating-point ARGB */
case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */
case SVGA3D_A2R10G10B10:
case SVGA3D_ALPHA8:
case SVGA3D_R_S10E5:
case SVGA3D_R_S23E8:
case SVGA3D_RG_S10E5:
case SVGA3D_RG_S23E8:
case SVGA3D_G16R16:
case SVGA3D_A16B16G16R16:
case SVGA3D_UYVY:
case SVGA3D_YUY2:
case SVGA3D_NV12:
case SVGA3D_AYUV:
case SVGA3D_BC4_UNORM:
case SVGA3D_BC5_UNORM:
break;
/*
* Any surface can be used as a buffer object, but SVGA3D_BUFFER is
* the most efficient format to use when creating new surfaces
* expressly for index or vertex data.
*/
case SVGA3D_BUFFER:
break;
}
pSurface->pMipmapLevels = (PVMSVGA3DMIPMAPLEVEL)RTMemAllocZ(cMipLevels * sizeof(VMSVGA3DMIPMAPLEVEL));
for (uint32_t i=0; i < cMipLevels; i++)
/* Translate the format and usage flags to D3D. */
switch (surfaceFlags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP))
{
case SVGA3D_SURFACE_CUBEMAP:
Log(("SVGA3D_SURFACE_CUBEMAP\n"));
break;
Log(("SVGA3D_SURFACE_HINT_INDEXBUFFER\n"));
/* else type unknown at this time; postpone buffer creation */
break;
Log(("SVGA3D_SURFACE_HINT_VERTEXBUFFER\n"));
/* Type unknown at this time; postpone buffer creation */
break;
Log(("SVGA3D_SURFACE_HINT_TEXTURE\n"));
break;
Log(("SVGA3D_SURFACE_HINT_RENDERTARGET\n"));
break;
Log(("SVGA3D_SURFACE_HINT_DEPTHSTENCIL\n"));
break;
default:
/* Unknown; decide later. */
break;
}
/* Allocate buffer to hold the surface data until we can move it into a D3D object */
{
{
Log(("vmsvga3dSurfaceDefine: face %d mip level %d (%d,%d,%d)\n", iFace, i, pSurface->pMipmapLevels[idx].size.width, pSurface->pMipmapLevels[idx].size.height, pSurface->pMipmapLevels[idx].size.depth));
Log(("vmsvga3dSurfaceDefine: cbPitch=%x cbBlock=%x \n", pSurface->cbBlock * pSurface->pMipmapLevels[idx].size.width, pSurface->cbBlock));
pSurface->pMipmapLevels[idx].cbSurfacePitch = pSurface->cbBlock * pSurface->pMipmapLevels[idx].size.width;
pSurface->pMipmapLevels[idx].cbSurface = pSurface->pMipmapLevels[idx].cbSurfacePitch * pSurface->pMipmapLevels[idx].size.height * pSurface->pMipmapLevels[idx].size.depth;
}
}
return VINF_SUCCESS;
}
/*
* Release all shared surface objects.
*/
{
switch (pSurface->flags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP))
{
if (pSharedSurface->u.pTexture)
break;
default:
AssertFailed();
break;
}
return 0;
}
{
{
/* Check all contexts if this surface is used as a render target or active texture. */
{
{
{
}
}
}
{
case SVGA3D_SURFACE_CUBEMAP:
AssertFailed(); /* @todo */
break;
if (pSurface->u.pIndexBuffer)
break;
if (pSurface->u.pVertexBuffer)
break;
break;
case SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_HINT_TEXTURE: /* @todo actual texture surface not supported */
if (pSurface->fStencilAsTexture)
else
break;
default:
AssertMsg(!pSurface->u.pSurface, ("type=%x\n", (pSurface->flags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP))));
break;
}
if (pSurface->pMipmapLevels)
{
{
{
}
}
}
}
else
return VINF_SUCCESS;
}
/* Get the shared surface copy or create a new one. */
static PVMSVGA3DSHAREDSURFACE vmsvga3dSurfaceGetSharedCopy(PVGASTATE pThis, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface)
{
PVMSVGA3DSHAREDSURFACE pSharedSurface = (PVMSVGA3DSHAREDSURFACE)RTAvlU32Get(&pSurface->pSharedObjectTree, pContext->id);
if (!pSharedSurface)
{
bool ret;
Log(("vmsvga3dSurfaceGetSharedCopy: Create shared texture copy d3d (%d,%d) cMip=%d usage %x format %x.\n",
/* Create shadow copy of the original shared texture. Shared d3d resources require Vista+ and have some restrictions. */
&pSharedSurface->u.pTexture,
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceGetSharedCopy: CreateTexture failed with %x\n", hr), NULL);
}
return pSharedSurface;
}
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
#define vmsvga3dSurfaceTrackUsage(a, b, c)
#define vmsvga3dSurfaceFlush(a, b)
#else
/* Inject a query event into the D3D pipeline so we can check when usage of this surface has finished.
* (D3D does not synchronize shared surface usage)
*/
{
AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
/* Nothing to do if this surface hasn't been shared. */
return VINF_SUCCESS;
/* Release the previous query object. */
{
Log(("vmsvga3dSurfaceTrackUsage: release old query object\n"));
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceTrackUsage: CreateQuery failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceTrackUsage: Issue failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
/* Wait for all drawing, that uses this surface, to finish. */
{
{
LogFlow(("vmsvga3dSurfaceFlush: no query object\n"));
return VINF_SUCCESS; /* nothing to wait for */
}
while (true)
{
RTThreadSleep(1);
}
AssertMsgReturn(hr == S_OK, ("vmsvga3dSurfaceFinishDrawing: GetData failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
#endif /* VBOX_VMSVGA3D_WITH_OPENGL */
int vmsvga3dSurfaceCopy(PVGASTATE pThis, SVGA3dSurfaceImageId dest, SVGA3dSurfaceImageId src, uint32_t cCopyBoxes, SVGA3dCopyBox *pBox)
{
int rc = VINF_SUCCESS;
AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
// AssertMsgReturn(pSurfaceSrc->format == pSurfaceDest->format, ("Format mismatch (%d vs %d)!!\n", pSurfaceSrc->format, pSurfaceDest->format), VERR_INVALID_PARAMETER);
if ( fDestTexture
&& !pSurfaceDest->u.pSurface
&& pSurfaceSrc->u.pSurface)
{
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dSurfaceCopy invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
Log(("vmsvga3dSurfaceCopy: create texture surface id=%x type=%d format=%d -> create texture\n", sidDest, pSurfaceDest->flags, pSurfaceDest->format));
}
if ( pSurfaceSrc->u.pSurface
&& pSurfaceDest->u.pSurface)
{
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dSurfaceCopy invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
/* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
#ifndef VBOX_VMSVGA3D_WITH_OPENGL
if ( fSrcTexture
{
Log(("vmsvga3dSurfaceCopy; using texture %x created for another context (%d vs %d)\n", sidSrc, pSurfaceSrc->idAssociatedContext, cid));
}
#endif
for (uint32_t i = 0; i < cCopyBoxes; i++)
{
Log(("vmsvga3dSurfaceCopy: (StretchRect) copy src sid=%x face=%d mipmap=%d (%d,%d)(%d,%d) to dest sid=%x face=%d mipmap=%d (%d,%d)\n", sidSrc, src.face, src.mipmap, RectSrc.left, RectSrc.top, RectSrc.right, RectSrc.bottom, sidDest, dest.face, dest.mipmap, pBox[i].x, pBox[i].y));
{
Log(("vmsvga3dSurfaceCopy: redundant copy to the same surface at the same coordinates. Ignore. \n"));
continue;
}
if (fSrcTexture)
{
&pSrc);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
if (fDestTexture)
{
&pDest);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
/* UpdateSurface is too picky; use StretchRect instead */
/* GetSurfaceLevel increases the reference count; release the objects again. */
if (fDestTexture)
if (fSrcTexture)
/* Track the StretchRect operation. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: UpdateSurface failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
else
for (uint32_t i = 0; i < cCopyBoxes; i++)
{
Log(("vmsvga3dSurfaceCopy: (manual) copy src=%x src=%x face=%d (%d,%d)(%d,%d) to dest=%x src=%x face=%d (%d,%d)\n", sidSrc, src.face, src.mipmap, Rect.left, Rect.top, Rect.right, Rect.bottom, sidDest, dest.face, dest.mipmap, pBox[i].x, pBox[i].y));
if (!pSurfaceSrc->u.pSurface)
{
}
else
{
/* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
if (fSrcTexture)
{
&Rect,
}
else
&Rect,
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: LockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
if (!pSurfaceDest->u.pSurface)
{
}
else
{
/* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
if (fDestTexture)
{
&Rect,
0);
}
else
&Rect,
0);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: LockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
uint8_t *pDest = (uint8_t *)LockedDestRect.pBits + LockedDestRect.Pitch * pBox[i].y + pBox[i].x * pSurfaceDest->cbBlock;
uint8_t *pSrc = (uint8_t *)LockedSrcRect.pBits + LockedSrcRect.Pitch * pBox[i].srcy + pBox[i].srcx * pSurfaceSrc->cbBlock;
{
}
if (pSurfaceDest->u.pSurface)
{
if (fDestTexture)
else
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: Unlock failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
if (pSurfaceSrc->u.pSurface)
{
if (fSrcTexture)
else
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceCopy: Unlock failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
return VINF_SUCCESS;
}
/* Create D3D texture object for the specified surface. */
static int vmsvga3dCreateTexture(PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface)
{
{
1,
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCreateTexture: CreateTexture INTZ failed with %x\n", hr), VERR_INTERNAL_ERROR);
pSurface->fStencilAsTexture = true;
}
else
{
{
/* Create another texture object to serve as a bounce buffer as the above texture surface can't be locked. */
NULL);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCreateTexture: CreateTexture (systemmem) failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
{
Log(("Format not accepted -> try old method\n"));
/* The format was probably not accepted; fall back to our old mode. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCreateTexture: CreateTexture failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
{
/* Set the mip map generation filter settings. */
}
{
Log(("vmsvga3dCreateTexture: sync dirty texture\n"));
{
{
NULL, /* entire texture */
0);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCreateTexture: LockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
Log(("vmsvga3dCreateTexture: sync dirty texture mipmap level %d (pitch %x vs %x)\n", i, LockedRect.Pitch, pSurface->pMipmapLevels[i].cbSurfacePitch));
{
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCreateTexture: UnlockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
{
Log(("vmsvga3dCreateTexture: sync dirty texture from bounce buffer\n"));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCreateTexture: UpdateTexture failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* We will now use the bounce texture for all memory accesses, so free our surface memory buffer. */
{
}
}
}
return VINF_SUCCESS;
}
int vmsvga3dSurfaceStretchBlt(PVGASTATE pThis, SVGA3dSurfaceImageId dest, SVGA3dBox destBox, SVGA3dSurfaceImageId src, SVGA3dBox srcBox, SVGA3dStretchBltMode mode)
{
int rc = VINF_SUCCESS;
AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
Log(("vmsvga3dSurfaceStretchBlt: src sid=%x (%d,%d)(%d,%d) dest sid=%x (%d,%d)(%d,%d) mode=%x\n", src.sid, srcBox.x, srcBox.y, srcBox.x + srcBox.w, srcBox.y + srcBox.h, dest.sid, destBox.x, destBox.y, destBox.x + destBox.w, destBox.y + destBox.h, mode));
/* @todo stricter checks for associated context */
if (cid == SVGA3D_INVALID_ID)
{
Log(("vmsvga3dSurfaceStretchBlt invalid context id!\n"));
}
if (!pSurfaceSrc->u.pSurface)
{
/* Unknown surface type; turn it into a texture, which can be used for other purposes too. */
Log(("vmsvga3dSurfaceStretchBlt: unknown src surface id=%x type=%d format=%d -> create texture\n", sidSrc, pSurfaceSrc->flags, pSurfaceSrc->format));
}
if (!pSurfaceDest->u.pSurface)
{
/* Unknown surface type; turn it into a texture, which can be used for other purposes too. */
Log(("vmsvga3dSurfaceStretchBlt: unknown dest surface id=%x type=%d format=%d -> create texture\n", sidDest, pSurfaceDest->flags, pSurfaceDest->format));
}
/* Flush the drawing pipeline for this surface as it could be used in a shared context. */
if (fSrcTexture)
{
&pSrc);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceStretchBlt: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
if (fDestTexture)
{
&pDest);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceStretchBlt: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
switch (mode)
{
case SVGA3D_STRETCH_BLT_POINT:
break;
break;
default:
AssertFailed();
break;
}
/* GetSurfaceLevel increases the reference count; release the objects again. */
if (fDestTexture)
if (fSrcTexture)
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceStretchBlt: StretchRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* Track the StretchRect operation. */
return VINF_SUCCESS;
}
int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer,
{
int rc = VINF_SUCCESS;
AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
Log(("vmsvga3dSurfaceDMA TEXTURE guestptr gmr=%x offset=%x pitch=%x host sid=%x face=%d mipmap=%d transfer=%s cCopyBoxes=%d\n", guest.ptr.gmrId, guest.ptr.offset, guest.pitch, host.sid, host.face, host.mipmap, (transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", cCopyBoxes));
else
Log(("vmsvga3dSurfaceDMA guestptr gmr=%x offset=%x pitch=%x host sid=%x face=%d mipmap=%d transfer=%s cCopyBoxes=%d\n", guest.ptr.gmrId, guest.ptr.offset, guest.pitch, host.sid, host.face, host.mipmap, (transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", cCopyBoxes));
{
for (unsigned i = 0; i < cCopyBoxes; i++)
{
unsigned uDestOffset;
unsigned cbSrcPitch;
Log(("Copy box %d (%d,%d,%d)(%d,%d,%d)\n", i, pBoxes[i].srcx, pBoxes[i].srcy, pBoxes[i].srcz, pBoxes[i].w, pBoxes[i].h, pBoxes[i].d));
/* Apparently we're supposed to clip it (gmr test sample) */
if ( !pBoxes[i].w
|| !pBoxes[i].h
|| !pBoxes[i].d
{
Log(("Empty box; skip\n"));
continue;
}
uDestOffset = pBoxes[i].x * pSurface->cbBlock + pBoxes[i].y * pMipLevel->cbSurfacePitch + pBoxes[i].z * pMipLevel->size.height * pMipLevel->cbSurfacePitch;
AssertReturn(uDestOffset + pBoxes[i].w * pSurface->cbBlock * pBoxes[i].h * pBoxes[i].d <= pMipLevel->cbSurface, VERR_INTERNAL_ERROR);
}
}
else
{
/* Flush the drawing pipeline for this surface as it could be used in a shared context. */
if (transfer == SVGA3D_READ_HOST_VRAM)
for (unsigned i = 0; i < cCopyBoxes; i++)
{
bool fTexture = false;
bool fVertex = false;
bool fRenderTargetTexture = false;
unsigned cbSrcPitch;
/* Apparently we're supposed to clip it (gmr test sample) */
if ( !pBoxes[i].w
|| !pBoxes[i].h
{
Log(("Empty box; skip\n"));
continue;
}
switch (pSurface->flags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP))
{
fRenderTargetTexture = true;
/* no break */
fTexture = true;
/* no break */
if (pSurface->fStencilAsTexture)
fTexture = true;
/* no break */
{
/* @todo inefficient for VRAM buffers!! */
if (fTexture)
{
{
if ( transfer == SVGA3D_READ_HOST_VRAM
&& i == 0 /* only the first time */)
{
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dSurfaceDMA invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->papContexts[cid]->id));
}
/* @todo only sync when something was actually rendered (since the last sync) */
Log(("vmsvga3dSurfaceDMA: sync bounce buffer\n"));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: GetRenderTargetData failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
&Rect,
dwFlags);
}
else
&Rect,
dwFlags);
}
else
&Rect,
dwFlags);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: LockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
if (fTexture)
Log(("Lock TEXTURE (bounce=%d) memory for rectangle (%d,%d)(%d,%d)\n", !!(pSurface->bounce.pTexture), Rect.left, Rect.top, Rect.right, Rect.bottom));
else
Log(("Lock %s memory for rectangle (%d,%d)(%d,%d)\n", (pSurface->flags & SVGA3D_SURFACE_HINT_DEPTHSTENCIL) ? "DEPTH-STENCIL" : "RENDERTARGET", Rect.left, Rect.top, Rect.right, Rect.bottom));
pBoxes[i].h);
if (fTexture)
{
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: UnlockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
if (transfer == SVGA3D_WRITE_HOST_VRAM)
{
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dSurfaceDMA invalid context id!\n"));
}
Log(("vmsvga3dSurfaceDMA: sync texture from bounce buffer\n"));
/* Copy the new contents to the actual texture object. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: UpdateTexture failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* Track the copy operation. */
}
}
else
}
else
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceDMA: UnlockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
}
fVertex = true;
/* no break */
{
unsigned uDestOffset;
uDestOffset = pBoxes[i].x * pSurface->cbBlock + pBoxes[i].y * pSurface->pMipmapLevels[host.mipmap].cbSurfacePitch;
AssertReturn(uDestOffset + pBoxes[i].w * pSurface->cbBlock + (pBoxes[i].h - 1) * pSurface->pMipmapLevels[host.mipmap].cbSurfacePitch <= pSurface->pMipmapLevels[host.mipmap].cbSurface, VERR_INTERNAL_ERROR);
/** @todo lock only as much as we really need */
if (fVertex)
else
AssertMsg(hr == D3D_OK, ("vmsvga3dSurfaceDMA: Lock %s failed with %x\n", (fVertex) ? "vertex" : "index", hr));
Log(("Lock %s memory for rectangle (%d,%d)(%d,%d)\n", (fVertex) ? "vertex" : "index", pBoxes[i].x, pBoxes[i].y, pBoxes[i].x + pBoxes[i].w, pBoxes[i].y + pBoxes[i].h));
pData + uDestOffset,
pBoxes[i].h);
if (fVertex)
else
AssertMsg(hr == D3D_OK, ("vmsvga3dSurfaceDMA: Unlock %s failed with %x\n", (fVertex) ? "vertex" : "index", hr));
break;
}
default:
AssertFailed();
break;
}
}
}
return rc;
}
int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect)
{
/* Requires SVGA_FIFO_CAP_SCREEN_OBJECT support */
Log(("vmsvga3dSurfaceBlitToScreen: dest=%d (%d,%d)(%d,%d) surface=%x (face=%d, mipmap=%d) (%d,%d)(%d,%d) cRects=%d\n", dest, destRect.left, destRect.top, destRect.right, destRect.bottom, src.sid, src.face, src.mipmap, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, cRects));
{
Log(("vmsvga3dSurfaceBlitToScreen: clipping rect %d (%d,%d)(%d,%d)\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom));
}
/* @todo Only screen 0 for now. */
/* @todo scaling */
AssertReturn(destRect.right - destRect.left == srcRect.right - srcRect.left && destRect.bottom - destRect.top == srcRect.bottom - srcRect.top, VERR_INVALID_PARAMETER);
if (cRects == 0)
{
/* easy case; no clipping */
box.z = 0;
box.d = 1;
return VINF_SUCCESS;
}
else
{
box.z = 0;
box.d = 1;
/* @todo merge into one SurfaceDMA call */
{
/* The clipping rectangle is relative to the top-left corner of srcRect & destRect. Adjust here. */
box.z = 0;
}
#if 0
{
AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dGenerateMipmaps invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
{
&pSrc);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceStretchBlt: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
#endif
return VINF_SUCCESS;
}
}
{
int rc = VINF_SUCCESS;
AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
{
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dGenerateMipmaps invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
/* Unknown surface type; turn it into a texture. */
Log(("vmsvga3dGenerateMipmaps: unknown src surface id=%x type=%d format=%d -> create texture\n", sid, pSurface->flags, pSurface->format));
}
else
{
}
/* Generate the mip maps. */
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
struct
{
uint32_t x;
uint32_t y;
} srcViewPort;
AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
/* @todo stricter checks for associated context */
{
Log(("vmsvga3dCommandPresent: rectangle %d src=(%d,%d) (%d,%d)(%d,%d)\n", i, pRect[i].srcx, pRect[i].srcy, pRect[i].x, pRect[i].y, pRect[i].x + pRect[i].w, pRect[i].y + pRect[i].h));
}
{
Log(("vmsvga3dCommandPresent invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCommandPresent: GetBackBuffer failed with %x\n", hr), VERR_INTERNAL_ERROR);
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCommandPresent: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
/* Source surface different size? */
{
}
else
{
}
/* @note the viewport doesn't affect blitting. */
if (cRects == 0)
{
}
else
{
{
{
/* Intersection is empty; skip */
continue;
}
rectDest.right = RT_MIN(pRect[i].x + pRect[i].w, pThis->svga.viewport.x + pThis->svga.viewport.cx) - pThis->svga.viewport.x;
rectDest.bottom = RT_MIN(pRect[i].y + pRect[i].h, pThis->svga.viewport.y + pThis->svga.viewport.cy) - pThis->svga.viewport.y;
}
}
pSurfaceD3D->Release();
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCommandPresent: StretchRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCommandPresent: Present failed with %x\n", hr), VERR_INTERNAL_ERROR);
pBackBuffer->Release();
return VINF_SUCCESS;
}
/**
* Create a new 3d context
*
* @returns VBox status code.
* @param pThis VGA device instance data.
* @param cid Context id
*/
{
int rc;
{
/* Grow the array. */
{
}
}
/* If one already exists with this id, then destroy it now. */
/* Create a context window. */
#ifdef DEBUG_GFX_WINDOW
#else
#endif
#ifdef DEBUG_GFX_WINDOW
#else
#endif
cs.x = 0;
cs.y = 0;
rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_CREATEWINDOW, (WPARAM)&pContext->hwnd, (LPARAM)&cs);
/* Changed when the function returns. */
PresParam.BackBufferWidth = 0;
PresParam.BackBufferCount = 0;
/* @todo consider using D3DPRESENT_DONOTWAIT so we don't wait for the GPU during Present calls. */
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
#else
NULL,
#endif
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dContextDefine: CreateDevice failed with %x\n", hr), VERR_INTERNAL_ERROR);
Log(("vmsvga3dContextDefine: Backbuffer (%d,%d) count=%d format=%x\n", PresParam.BackBufferWidth, PresParam.BackBufferHeight, PresParam.BackBufferCount, PresParam.BackBufferFormat));
return VINF_SUCCESS;
}
/**
* Destroy an existing 3d context
*
* @returns VBox status code.
* @param pThis VGA device instance data.
* @param cid Context id
*/
{
{
/* Check for all surfaces that are associated with this context to remove all dependencies */
{
{
int rc;
pMipLevelSize = (SVGA3dSize *)RTMemAllocZ(pSurface->faces[0].numMipLevels * pSurface->cFaces * sizeof(SVGA3dSize));
{
{
}
}
/* Recreate the surface with the original settings; destroys the contents, but that seems fairly safe since the context is also destroyed. */
/** @todo not safe with shared objects */
rc = vmsvga3dSurfaceDefine(pThis, sid, surfaceFlags, format, face, multisampleCount, autogenFilter, face[0].numMipLevels * cFaces, pMipLevelSize);
}
else
{
/* Check for a shared surface object. */
PVMSVGA3DSHAREDSURFACE pSharedSurface = (PVMSVGA3DSHAREDSURFACE)RTAvlU32Get(&pSurface->pSharedObjectTree, cid);
if (pSharedSurface)
{
switch (pSurface->flags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP))
{
if (pSharedSurface->u.pTexture)
break;
default:
AssertFailed();
break;
}
}
}
}
/* Destroy all leftover pixel shaders. */
{
vmsvga3dShaderDestroy(pThis, pContext->paPixelShader[i].cid, pContext->paPixelShader[i].id, pContext->paPixelShader[i].type);
}
if (pContext->paPixelShader)
/* Destroy all leftover vertex shaders. */
{
vmsvga3dShaderDestroy(pThis, pContext->paVertexShader[i].cid, pContext->paVertexShader[i].id, pContext->paVertexShader[i].type);
}
if (pContext->paVertexShader)
/* Release the D3D device object */
/* Destroy the window we've created. */
int rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_DESTROYWINDOW, (WPARAM)pContext->hwnd, 0);
}
else
AssertFailed();
return VINF_SUCCESS;
}
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
#else
{
/* Inject fences to make sure we can track surface usage in case the client wants to reuse it in another context. */
{
}
return VINF_SUCCESS;
}
#endif
/* Handle resize */
{
/* Resize all active contexts. */
{
if (cid != SVGA3D_INVALID_ID)
{
#ifdef VMSVGA3D_DIRECT3D9_RESET
/* Sync back all surface data as everything is lost after the Reset. */
{
{
/* Reallocate our surface memory buffers. */
{
{
{
/* @todo only sync when something was actually rendered (since the last sync) */
Log(("vmsvga3dChangeMode: sync bounce buffer (level %d)\n", i));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: GetRenderTargetData failed with %x\n", hr), VERR_INTERNAL_ERROR);
NULL,
}
else
NULL,
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: LockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* Copy the data one line at a time in case the internal pitch is different. */
{
memcpy((uint8_t *)pMipmapLevel->pSurfaceData + j * pMipmapLevel->cbSurfacePitch, (uint8_t *)LockedRect.pBits + j * LockedRect.Pitch, pMipmapLevel->cbSurfacePitch);
}
else
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: UnlockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
switch (pSurface->flags & (SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP))
{
case SVGA3D_SURFACE_CUBEMAP:
AssertFailed(); /* @todo */
break;
break;
break;
{
}
break;
if (pSurface->fStencilAsTexture)
else
break;
default:
break;
}
pSurface->hSharedObject = 0;
}
}
#endif /* #ifdef VMSVGA3D_DIRECT3D9_RESET */
Log(("vmsvga3dChangeMode: Resize window %x of context %d to (%d,%d)\n", pContext->hwnd, pContext->id, cs.cx, cs.cy));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: GetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
Log(("vmsvga3dChangeMode: old viewport settings (%d,%d)(%d,%d) z=%d/%d\n", viewportOrg.X, viewportOrg.Y, viewportOrg.Width, viewportOrg.Height, (uint32_t)(viewportOrg.MinZ * 100.0), (uint32_t)(viewportOrg.MaxZ * 100.0)));
/* Resize the window. */
int rc = vmsvga3dSendThreadMessage(pState->pWindowThread, pState->WndRequestSem, WM_VMSVGA3D_RESIZEWINDOW, (WPARAM)pContext->hwnd, (LPARAM)&cs);
/* Changed when the function returns. */
PresParam.BackBufferWidth = 0;
PresParam.BackBufferCount = 0;
/* @todo consider using D3DPRESENT_DONOTWAIT so we don't wait for the GPU during Present calls. */
#ifdef VBOX_VMSVGA3D_WITH_OPENGL
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: Reset failed with %x\n", hr), VERR_INTERNAL_ERROR);
#else
/* ResetEx does not trash the device state */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: Reset failed with %x\n", hr), VERR_INTERNAL_ERROR);
#endif
Log(("vmsvga3dChangeMode: Backbuffer (%d,%d) count=%d format=%x\n", PresParam.BackBufferWidth, PresParam.BackBufferHeight, PresParam.BackBufferCount, PresParam.BackBufferFormat));
/* ResetEx changes the viewport; restore it again. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: SetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
#ifdef LOG_ENABLED
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dChangeMode: GetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
Log(("vmsvga3dChangeMode: changed viewport settings (%d,%d)(%d,%d) z=%d/%d\n", viewport.X, viewport.Y, viewport.Width, viewport.Height, (uint32_t)(viewport.MinZ * 100.0), (uint32_t)(viewport.MaxZ * 100.0)));
}
#endif
/* First set the render targets as they change the internal state (reset viewport etc) */
Log(("vmsvga3dChangeMode: Recreate render targets BEGIN\n"));
{
{
}
}
#ifdef VMSVGA3D_DIRECT3D9_RESET
/* Recreate the render state */
Log(("vmsvga3dChangeMode: Recreate render state BEGIN\n"));
{
}
Log(("vmsvga3dChangeMode: Recreate render state END\n"));
/* Recreate the texture state */
Log(("vmsvga3dChangeMode: Recreate texture state BEGIN\n"));
{
for (uint32_t j = 0; j < SVGA3D_TS_MAX; j++)
{
}
}
Log(("vmsvga3dChangeMode: Recreate texture state END\n"));
/** @todo restore more state data */
#endif /* #ifdef VMSVGA3D_DIRECT3D9_RESET */
}
}
return VINF_SUCCESS;
}
{
{
Log(("vmsvga3dSetTransform invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
switch (type)
{
case SVGA3D_TRANSFORM_VIEW:
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
case SVGA3D_TRANSFORM_WORLD:
break;
case SVGA3D_TRANSFORM_WORLD1:
break;
case SVGA3D_TRANSFORM_WORLD2:
break;
case SVGA3D_TRANSFORM_WORLD3:
break;
default:
Log(("vmsvga3dSetTransform: unknown type!!\n"));
return VERR_INVALID_PARAMETER;
}
memcpy(pContext->state.aTransformState[type].matrix, matrix, sizeof(pContext->state.aTransformState[type].matrix));
Log(("Matrix [%d %d %d %d]\n", (int)(matrix[0] * 10.0), (int)(matrix[1] * 10.0), (int)(matrix[2] * 10.0), (int)(matrix[3] * 10.0)));
Log((" [%d %d %d %d]\n", (int)(matrix[4] * 10.0), (int)(matrix[5] * 10.0), (int)(matrix[6] * 10.0), (int)(matrix[7] * 10.0)));
Log((" [%d %d %d %d]\n", (int)(matrix[8] * 10.0), (int)(matrix[9] * 10.0), (int)(matrix[10] * 10.0), (int)(matrix[11] * 10.0)));
Log((" [%d %d %d %d]\n", (int)(matrix[12] * 10.0), (int)(matrix[13] * 10.0), (int)(matrix[14] * 10.0), (int)(matrix[15] * 10.0)));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetTransform: SetTransform failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
{
Log(("vmsvga3dSetZRange %x min=%d max=%d\n", cid, (uint32_t)(zRange.min * 100.0), (uint32_t)(zRange.max * 100.0)));
{
Log(("vmsvga3dSetZRange invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetZRange: GetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
Log(("vmsvga3dSetZRange: old viewport settings (%d,%d)(%d,%d) z=%d/%d\n", viewport.X, viewport.Y, viewport.Width, viewport.Height, (uint32_t)(viewport.MinZ * 100.0), (uint32_t)(viewport.MaxZ * 100.0)));
/* @todo convert the depth range from -1-1 to 0-1 although we shouldn't be getting such values in the first place... */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetZRange: SetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
/**
* Convert SVGA blend op value to its D3D equivalent
*/
{
switch (blendOp)
{
case SVGA3D_BLENDOP_ZERO:
return D3DBLEND_ZERO;
case SVGA3D_BLENDOP_ONE:
return D3DBLEND_ONE;
case SVGA3D_BLENDOP_SRCCOLOR:
return D3DBLEND_SRCCOLOR;
return D3DBLEND_INVSRCCOLOR;
case SVGA3D_BLENDOP_SRCALPHA:
return D3DBLEND_SRCALPHA;
return D3DBLEND_INVSRCALPHA;
case SVGA3D_BLENDOP_DESTALPHA:
return D3DBLEND_DESTALPHA;
return D3DBLEND_INVDESTALPHA;
case SVGA3D_BLENDOP_DESTCOLOR:
return D3DBLEND_DESTCOLOR;
return D3DBLEND_INVDESTCOLOR;
return D3DBLEND_SRCALPHASAT;
return D3DBLEND_BLENDFACTOR;
return D3DBLEND_INVBLENDFACTOR;
default:
AssertFailed();
return defaultBlendOp;
}
}
int vmsvga3dSetRenderState(PVGASTATE pThis, uint32_t cid, uint32_t cRenderStates, SVGA3dRenderState *pRenderState)
{
{
Log(("vmsvga3dSetRenderState invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
for (unsigned i = 0; i < cRenderStates; i++)
{
Log(("vmsvga3dSetRenderState: state=%s (%d) val=%x\n", vmsvga3dGetRenderStateName(pRenderState[i].state), pRenderState[i].state, pRenderState[i].uintValue));
/* Save the render state for vm state saving. */
switch (pRenderState[i].state)
{
case SVGA3D_RS_ZENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_ZWRITEENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_ALPHATESTENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_DITHERENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_BLENDENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_FOGENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_SPECULARENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_LIGHTINGENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_NORMALIZENORMALS: /* SVGA3dBool */
break;
case SVGA3D_RS_POINTSPRITEENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_POINTSCALEENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_POINTSIZE: /* float */
break;
case SVGA3D_RS_POINTSIZEMIN: /* float */
break;
case SVGA3D_RS_POINTSIZEMAX: /* float */
break;
case SVGA3D_RS_POINTSCALE_A: /* float */
break;
case SVGA3D_RS_POINTSCALE_B: /* float */
break;
case SVGA3D_RS_POINTSCALE_C: /* float */
break;
case SVGA3D_RS_AMBIENT: /* SVGA3dColor - identical */
break;
case SVGA3D_RS_CLIPPLANEENABLE: /* SVGA3dClipPlanes - identical */
break;
case SVGA3D_RS_FOGCOLOR: /* SVGA3dColor - identical */
break;
case SVGA3D_RS_FOGSTART: /* float */
break;
case SVGA3D_RS_FOGEND: /* float */
break;
case SVGA3D_RS_FOGDENSITY: /* float */
break;
case SVGA3D_RS_RANGEFOGENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_FOGMODE: /* SVGA3dFogMode */
{
{
case SVGA3D_FOGFUNC_INVALID:
val = D3DFOG_NONE;
break;
case SVGA3D_FOGFUNC_EXP:
val = D3DFOG_EXP;
break;
case SVGA3D_FOGFUNC_EXP2:
val = D3DFOG_EXP2;
break;
case SVGA3D_FOGFUNC_LINEAR:
val = D3DFOG_LINEAR;
break;
case SVGA3D_FOGFUNC_PER_VERTEX: /* unable to find a d3d9 equivalent */
AssertMsgFailedReturn(("Unsupported fog function SVGA3D_FOGFUNC_PER_VERTEX\n"), VERR_INTERNAL_ERROR);
break;
default:
break;
}
/* The fog type determines the render state. */
{
case SVGA3D_FOGTYPE_VERTEX:
break;
case SVGA3D_FOGTYPE_PIXEL:
break;
default:
break;
}
/* Set the fog base to depth or range. */
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderState: SetRenderState SVGA3D_FOGBASE_DEPTHBASED failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderState: SetRenderState SVGA3D_FOGBASE_RANGEBASED failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
default:
/* ignore */
break;
}
break;
}
case SVGA3D_RS_FILLMODE: /* SVGA3dFillMode */
{
{
case SVGA3D_FILLMODE_POINT:
val = D3DFILL_POINT;
break;
case SVGA3D_FILLMODE_LINE:
break;
case SVGA3D_FILLMODE_FILL:
val = D3DFILL_SOLID;
break;
default:
break;
}
/* @todo ignoring face for now. */
break;
}
case SVGA3D_RS_SHADEMODE: /* SVGA3dShadeMode */
break;
case SVGA3D_RS_LINEPATTERN: /* SVGA3dLinePattern */
/* No longer supported by d3d; mesagl comments suggest not all backends support it */
/* @todo */
/*
renderState = D3DRS_LINEPATTERN;
val = pRenderState[i].uintValue;
*/
break;
case SVGA3D_RS_SRCBLEND: /* SVGA3dBlendOp */
break;
case SVGA3D_RS_DSTBLEND: /* SVGA3dBlendOp */
break;
case SVGA3D_RS_BLENDEQUATION: /* SVGA3dBlendEquation - identical */
break;
case SVGA3D_RS_CULLMODE: /* SVGA3dFace */
{
switch (pRenderState[i].uintValue)
{
case SVGA3D_FACE_NONE:
val = D3DCULL_NONE;
break;
case SVGA3D_FACE_FRONT:
val = D3DCULL_CW;
break;
case SVGA3D_FACE_BACK:
val = D3DCULL_CCW;
break;
case SVGA3D_FACE_FRONT_BACK:
AssertFailed();
val = D3DCULL_CW;
break;
default:
AssertMsgFailedReturn(("Unexpected cull mode %d\n", pRenderState[i].uintValue), VERR_INTERNAL_ERROR);
break;
}
break;
}
case SVGA3D_RS_ZFUNC: /* SVGA3dCmpFunc - identical */
break;
case SVGA3D_RS_ALPHAFUNC: /* SVGA3dCmpFunc - identical */
break;
case SVGA3D_RS_STENCILENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_STENCILREF: /* uint32_t */
break;
case SVGA3D_RS_STENCILMASK: /* uint32_t */
break;
case SVGA3D_RS_STENCILWRITEMASK: /* uint32_t */
break;
case SVGA3D_RS_STENCILFUNC: /* SVGA3dCmpFunc - identical */
break;
case SVGA3D_RS_STENCILFAIL: /* SVGA3dStencilOp - identical */
break;
case SVGA3D_RS_STENCILZFAIL: /* SVGA3dStencilOp - identical */
break;
case SVGA3D_RS_STENCILPASS: /* SVGA3dStencilOp - identical */
break;
case SVGA3D_RS_ALPHAREF: /* float (0.0 .. 1.0) */
break;
case SVGA3D_RS_FRONTWINDING: /* SVGA3dFrontWinding */
/*
renderState = D3DRS_FRONTWINDING; //D3DRS_TWOSIDEDSTENCILMODE
val = pRenderState[i].uintValue;
*/
break;
case SVGA3D_RS_COORDINATETYPE: /* SVGA3dCoordinateType */
/* @todo setup a view matrix to scale the world space by -1 in the z-direction for right handed coordinates. */
/*
renderState = D3DRS_COORDINATETYPE;
val = pRenderState[i].uintValue;
*/
break;
case SVGA3D_RS_ZBIAS: /* float */
/* @todo unknown meaning; depth bias is not identical
renderState = D3DRS_DEPTHBIAS;
val = pRenderState[i].uintValue;
*/
Log(("vmsvga3dSetRenderState: WARNING unsupported SVGA3D_RS_ZBIAS\n"));
break;
case SVGA3D_RS_SLOPESCALEDEPTHBIAS: /* float */
break;
case SVGA3D_RS_DEPTHBIAS: /* float */
break;
case SVGA3D_RS_COLORWRITEENABLE: /* SVGA3dColorMask - identical to D3DCOLORWRITEENABLE_* */
break;
case SVGA3D_RS_VERTEXMATERIALENABLE: /* SVGA3dBool */
//AssertFailed();
break;
case SVGA3D_RS_DIFFUSEMATERIALSOURCE: /* SVGA3dVertexMaterial - identical */
break;
case SVGA3D_RS_SPECULARMATERIALSOURCE: /* SVGA3dVertexMaterial - identical */
break;
case SVGA3D_RS_AMBIENTMATERIALSOURCE: /* SVGA3dVertexMaterial - identical */
break;
case SVGA3D_RS_EMISSIVEMATERIALSOURCE: /* SVGA3dVertexMaterial - identical */
break;
case SVGA3D_RS_TEXTUREFACTOR: /* SVGA3dColor - identical */
break;
case SVGA3D_RS_LOCALVIEWER: /* SVGA3dBool */
break;
case SVGA3D_RS_SCISSORTESTENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_BLENDCOLOR: /* SVGA3dColor - identical */
break;
case SVGA3D_RS_STENCILENABLE2SIDED: /* SVGA3dBool */
break;
case SVGA3D_RS_CCWSTENCILFUNC: /* SVGA3dCmpFunc - identical */
break;
case SVGA3D_RS_CCWSTENCILFAIL: /* SVGA3dStencilOp - identical */
break;
case SVGA3D_RS_CCWSTENCILZFAIL: /* SVGA3dStencilOp - identical */
break;
case SVGA3D_RS_CCWSTENCILPASS: /* SVGA3dStencilOp - identical */
break;
case SVGA3D_RS_VERTEXBLEND: /* SVGA3dVertexBlendFlags - identical */
break;
case SVGA3D_RS_OUTPUTGAMMA: /* float */
//AssertFailed();
/*
D3DRS_SRGBWRITEENABLE ??
renderState = D3DRS_OUTPUTGAMMA;
val = pRenderState[i].uintValue;
*/
break;
case SVGA3D_RS_ZVISIBLE: /* SVGA3dBool */
AssertFailed();
/*
renderState = D3DRS_ZVISIBLE;
val = pRenderState[i].uintValue;
*/
break;
case SVGA3D_RS_LASTPIXEL: /* SVGA3dBool */
break;
case SVGA3D_RS_CLIPPING: /* SVGA3dBool */
break;
case SVGA3D_RS_WRAP0: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP1: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP2: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP3: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP4: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP5: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP6: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP7: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP8: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP9: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP10: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP11: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP12: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP13: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP14: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_WRAP15: /* SVGA3dWrapFlags - identical */
break;
case SVGA3D_RS_MULTISAMPLEANTIALIAS: /* SVGA3dBool */
break;
case SVGA3D_RS_MULTISAMPLEMASK: /* uint32_t */
break;
case SVGA3D_RS_INDEXEDVERTEXBLENDENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_TWEENFACTOR: /* float */
break;
case SVGA3D_RS_ANTIALIASEDLINEENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_COLORWRITEENABLE1: /* SVGA3dColorMask - identical to D3DCOLORWRITEENABLE_* */
break;
case SVGA3D_RS_COLORWRITEENABLE2: /* SVGA3dColorMask - identical to D3DCOLORWRITEENABLE_* */
break;
case SVGA3D_RS_COLORWRITEENABLE3: /* SVGA3dColorMask - identical to D3DCOLORWRITEENABLE_* */
break;
case SVGA3D_RS_SEPARATEALPHABLENDENABLE: /* SVGA3dBool */
break;
case SVGA3D_RS_SRCBLENDALPHA: /* SVGA3dBlendOp */
break;
case SVGA3D_RS_DSTBLENDALPHA: /* SVGA3dBlendOp */
break;
case SVGA3D_RS_BLENDEQUATIONALPHA: /* SVGA3dBlendEquation - identical */
break;
case SVGA3D_RS_TRANSPARENCYANTIALIAS: /* SVGA3dTransparencyAntialiasType */
AssertFailed();
/*
renderState = D3DRS_TRANSPARENCYANTIALIAS;
val = pRenderState[i].uintValue;
*/
break;
case SVGA3D_RS_LINEAA: /* SVGA3dBool */
break;
case SVGA3D_RS_LINEWIDTH: /* float */
AssertFailed();
/*
renderState = D3DRS_LINEWIDTH;
val = pRenderState[i].uintValue;
*/
break;
}
if (renderState != D3DRS_FORCE_DWORD)
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderState: SetRenderState failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
return VINF_SUCCESS;
}
int vmsvga3dSetRenderTarget(PVGASTATE pThis, uint32_t cid, SVGA3dRenderTargetType type, SVGA3dSurfaceImageId target)
{
{
Log(("vmsvga3dSetRenderTarget invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
{
/* Disable render target. */
switch (type)
{
case SVGA3D_RT_DEPTH:
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: SetDepthStencilSurface failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
case SVGA3D_RT_STENCIL:
/* ignore; correct?? */
break;
case SVGA3D_RT_COLOR0:
case SVGA3D_RT_COLOR1:
case SVGA3D_RT_COLOR2:
case SVGA3D_RT_COLOR3:
case SVGA3D_RT_COLOR4:
case SVGA3D_RT_COLOR5:
case SVGA3D_RT_COLOR6:
case SVGA3D_RT_COLOR7:
if (pState->fSupportedSurfaceNULL)
{
/* Create a dummy render target to satisfy D3D. This path is usually taken only to render into a depth buffer without
* wishing to update an actual color render target
*/
0,
NULL);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: CreateRenderTarget failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: SetRenderTarget failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
default:
}
return VINF_SUCCESS;
}
AssertReturn(target.sid < pState->cSurfaces && pState->papSurfaces[target.sid]->id == target.sid, VERR_INVALID_PARAMETER);
switch (type)
{
case SVGA3D_RT_DEPTH:
case SVGA3D_RT_STENCIL:
if (!pRenderTarget->u.pSurface)
{
DWORD cQualityLevels = 0;
/* Query the nr of quality levels for this particular format */
{
TRUE, /* Windowed */
}
if ( pState->fSupportedSurfaceINTZ
{
Log(("vmsvga3dSetRenderTarget: Creating stencil surface as texture!\n"));
}
if (!pRenderTarget->fStencilAsTexture)
{
FALSE, /* not discardable */
&pRenderTarget->u.pSurface,
NULL);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: CreateDepthStencilSurface failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
#if 0 /* doesn't work */
if ( !pRenderTarget->fStencilAsTexture
&& pRenderTarget->fDirty)
{
{
{
NULL, /* entire surface */
0);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: LockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
Log(("vmsvga3dSetRenderTarget: sync dirty texture mipmap level %d (pitch %x vs %x)\n", i, LockedRect.Pitch, pRenderTarget->pMipmapLevels[i].cbSurfacePitch));
{
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: UnlockRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
}
#endif
}
/* @todo Assert(!pRenderTarget->fDirty); */
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: SetDepthStencilSurface failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: SetDepthStencilSurface failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
break;
case SVGA3D_RT_COLOR0:
case SVGA3D_RT_COLOR1:
case SVGA3D_RT_COLOR2:
case SVGA3D_RT_COLOR3:
case SVGA3D_RT_COLOR4:
case SVGA3D_RT_COLOR5:
case SVGA3D_RT_COLOR6:
case SVGA3D_RT_COLOR7:
{
bool fTexture = false;
bool fShared = false;
/* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
{
fTexture = true;
/* A texture surface can be used as a render target to fill it and later on used as a texture. */
if (!pRenderTarget->u.pTexture)
{
Log(("vmsvga3dSetRenderTarget: create texture to be used as render target; surface id=%x type=%d format=%d -> create texture\n", target.sid, pRenderTarget->flags, pRenderTarget->format));
}
#ifndef VBOX_VMSVGA3D_WITH_OPENGL
{
Log(("vmsvga3dSetRenderTarget; using texture %x created for another context (%d vs %d)\n", target.sid, pRenderTarget->idAssociatedContext, cid));
PVMSVGA3DSHAREDSURFACE pSharedSurface = vmsvga3dSurfaceGetSharedCopy(pThis, pContext, pRenderTarget);
&pSurface);
fShared = true;
}
else
#endif
&pSurface);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: GetSurfaceLevel failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
{
if (!pRenderTarget->u.pSurface)
{
DWORD cQualityLevels = 0;
/* Query the nr of quality levels for this particular format */
{
TRUE, /* Windowed */
}
Log(("Create rendertarget (%d,%d) format=%x multisample=%x\n", pRenderTarget->pMipmapLevels[0].size.width, pRenderTarget->pMipmapLevels[0].size.height, pRenderTarget->formatD3D, pRenderTarget->multiSampleTypeD3D));
TRUE, /* lockable */
&pRenderTarget->u.pSurface,
NULL);
}
else
}
if (fTexture)
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetRenderTarget: SetRenderTarget failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* Changing the render target resets the viewport; restore it here. */
/* Changing the render target also resets the scissor rectangle; restore it as well. */
break;
}
default:
}
return VINF_SUCCESS;
}
/**
* Convert SVGA texture combiner value to its D3D equivalent
*/
{
switch (value)
{
case SVGA3D_TC_DISABLE:
return D3DTOP_DISABLE;
case SVGA3D_TC_SELECTARG1:
return D3DTOP_SELECTARG1;
case SVGA3D_TC_SELECTARG2:
return D3DTOP_SELECTARG2;
case SVGA3D_TC_MODULATE:
return D3DTOP_MODULATE;
case SVGA3D_TC_ADD:
return D3DTOP_ADD;
case SVGA3D_TC_ADDSIGNED:
return D3DTOP_ADDSIGNED;
case SVGA3D_TC_SUBTRACT:
return D3DTOP_SUBTRACT;
return D3DTOP_BLENDTEXTUREALPHA;
return D3DTOP_BLENDDIFFUSEALPHA;
return D3DTOP_BLENDCURRENTALPHA;
return D3DTOP_BLENDFACTORALPHA;
case SVGA3D_TC_MODULATE2X:
return D3DTOP_MODULATE2X;
case SVGA3D_TC_MODULATE4X:
return D3DTOP_MODULATE4X;
case SVGA3D_TC_DSDT:
AssertFailed(); /* @todo ??? */
return D3DTOP_DISABLE;
case SVGA3D_TC_DOTPRODUCT3:
return D3DTOP_DOTPRODUCT3;
return D3DTOP_BLENDTEXTUREALPHAPM;
case SVGA3D_TC_ADDSIGNED2X:
return D3DTOP_ADDSIGNED2X;
case SVGA3D_TC_ADDSMOOTH:
return D3DTOP_ADDSMOOTH;
case SVGA3D_TC_PREMODULATE:
return D3DTOP_PREMODULATE;
return D3DTOP_MODULATEALPHA_ADDCOLOR;
return D3DTOP_MODULATECOLOR_ADDALPHA;
return D3DTOP_MODULATEINVALPHA_ADDCOLOR;
return D3DTOP_MODULATEINVCOLOR_ADDALPHA;
return D3DTOP_BUMPENVMAPLUMINANCE;
case SVGA3D_TC_MULTIPLYADD:
return D3DTOP_MULTIPLYADD;
case SVGA3D_TC_LERP:
return D3DTOP_LERP;
default:
AssertFailed();
return D3DTOP_DISABLE;
}
}
/**
* Convert SVGA texture arg data value to its D3D equivalent
*/
{
switch (value)
{
case SVGA3D_TA_CONSTANT:
return D3DTA_CONSTANT;
case SVGA3D_TA_PREVIOUS:
return D3DTA_CURRENT; /* current = previous */
case SVGA3D_TA_DIFFUSE:
return D3DTA_DIFFUSE;
case SVGA3D_TA_TEXTURE:
return D3DTA_TEXTURE;
case SVGA3D_TA_SPECULAR:
return D3DTA_SPECULAR;
default:
AssertFailed();
return 0;
}
}
/**
* Convert SVGA texture transform flag value to its D3D equivalent
*/
{
switch (value)
{
case SVGA3D_TEX_TRANSFORM_OFF:
return D3DTTFF_DISABLE;
case SVGA3D_TEX_TRANSFORM_S:
return D3DTTFF_COUNT1; /* @todo correct? */
case SVGA3D_TEX_TRANSFORM_T:
return D3DTTFF_COUNT2; /* @todo correct? */
case SVGA3D_TEX_TRANSFORM_R:
return D3DTTFF_COUNT3; /* @todo correct? */
case SVGA3D_TEX_TRANSFORM_Q:
return D3DTTFF_COUNT4; /* @todo correct? */
case SVGA3D_TEX_PROJECTED:
return D3DTTFF_PROJECTED;
default:
AssertFailed();
return 0;
}
}
int vmsvga3dSetTextureState(PVGASTATE pThis, uint32_t cid, uint32_t cTextureStates, SVGA3dTextureState *pTextureState)
{
{
Log(("vmsvga3dSetTextureState invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
for (unsigned i = 0; i < cTextureStates; i++)
{
Log(("vmsvga3dSetTextureState: cid=%x stage=%d type=%s (%x) val=%x\n", cid, currentStage, vmsvga3dTextureStateToString(pTextureState[i].name), pTextureState[i].name, pTextureState[i].value));
/** @todo Is this the appropriate limit for all kinds of textures? It is the
{
AssertMsgFailed(("pTextureState[%d].stage=%#x name=%#x\n", i, pTextureState[i].stage, pTextureState[i].name));
continue;
}
/* Record the texture state for vm state saving. */
{
}
switch (pTextureState[i].name)
{
case SVGA3D_TS_COLOROP: /* SVGA3dTextureCombiner */
break;
case SVGA3D_TS_COLORARG0: /* SVGA3dTextureArgData */
break;
case SVGA3D_TS_COLORARG1: /* SVGA3dTextureArgData */
break;
case SVGA3D_TS_COLORARG2: /* SVGA3dTextureArgData */
break;
case SVGA3D_TS_ALPHAOP: /* SVGA3dTextureCombiner */
break;
case SVGA3D_TS_ALPHAARG0: /* SVGA3dTextureArgData */
break;
case SVGA3D_TS_ALPHAARG1: /* SVGA3dTextureArgData */
break;
case SVGA3D_TS_ALPHAARG2: /* SVGA3dTextureArgData */
break;
case SVGA3D_TS_BUMPENVMAT00: /* float */
break;
case SVGA3D_TS_BUMPENVMAT01: /* float */
break;
case SVGA3D_TS_BUMPENVMAT10: /* float */
break;
case SVGA3D_TS_BUMPENVMAT11: /* float */
break;
case SVGA3D_TS_TEXCOORDINDEX: /* uint32_t */
break;
case SVGA3D_TS_BUMPENVLSCALE: /* float */
break;
case SVGA3D_TS_BUMPENVLOFFSET: /* float */
break;
case SVGA3D_TS_TEXTURETRANSFORMFLAGS: /* SVGA3dTexTransformFlags */
break;
case SVGA3D_TS_BIND_TEXTURE: /* SVGA3dSurfaceId */
{
Log(("SVGA3D_TS_BIND_TEXTURE: stage %d, texture surface id=%x\n", currentStage, pTextureState[i].value));
/* Unselect the currently associated texture. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetTextureState: SetTexture failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
{
AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
Log(("SVGA3D_TS_BIND_TEXTURE: stage %d, texture surface id=%x (%d,%d)\n", currentStage, pTextureState[i].value, pSurface->pMipmapLevels[0].size.width, pSurface->pMipmapLevels[0].size.height));
{
Log(("CreateTexture (%d,%d) level=%d fUsage=%x format=%x\n", pSurface->pMipmapLevels[0].size.width, pSurface->pMipmapLevels[0].size.height, pSurface->faces[0].numMipLevels, pSurface->fUsageD3D, pSurface->formatD3D));
}
else
{
/* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
}
#ifndef VBOX_VMSVGA3D_WITH_OPENGL
{
Log(("vmsvga3dSetTextureState; using texture %x created for another context (%d vs %d)\n", sid, pSurface->idAssociatedContext, cid));
}
else
#endif
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetTextureState: SetTexture failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
/* Finished; continue with the next one. */
continue;
case SVGA3D_TS_ADDRESSW: /* SVGA3dTextureAddress */
break;
case SVGA3D_TS_ADDRESSU: /* SVGA3dTextureAddress */
break;
case SVGA3D_TS_ADDRESSV: /* SVGA3dTextureAddress */
break;
case SVGA3D_TS_MIPFILTER: /* SVGA3dTextureFilter */
break;
case SVGA3D_TS_MAGFILTER: /* SVGA3dTextureFilter */
break;
case SVGA3D_TS_MINFILTER: /* SVGA3dTextureFilter */
break;
case SVGA3D_TS_BORDERCOLOR: /* SVGA3dColor */
break;
case SVGA3D_TS_TEXTURE_LOD_BIAS: /* float */
break;
case SVGA3D_TS_TEXTURE_MIPMAP_LEVEL: /* uint32_t */
break;
case SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL: /* uint32_t */
break;
case SVGA3D_TS_GAMMA: /* float */
/* Boolean in D3D */
else
break;
/* Internal commands, that don't map directly to the SetTextureStageState API. */
case SVGA3D_TS_TEXCOORDGEN: /* SVGA3dTextureCoordGen */
AssertFailed();
break;
}
if (textureType != D3DTSS_FORCE_DWORD)
{
}
else
{
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetTextureState: SetTextureStageState failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
return VINF_SUCCESS;
}
{
{
Log(("vmsvga3dSetMaterial invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
/* @note face not used for D3D9 */
/* @todo ignore everything except SVGA3D_FACE_NONE? */
//Assert(face == SVGA3D_FACE_NONE);
if (face != SVGA3D_FACE_NONE)
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetMaterial: SetMaterial failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
{
{
Log(("vmsvga3dSetLightData invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
{
case SVGA3D_LIGHTTYPE_POINT:
break;
case SVGA3D_LIGHTTYPE_SPOT1: /* 1-cone, in degrees */
break;
break;
case SVGA3D_LIGHTTYPE_SPOT2: /* 2-cone, in radians */
default:
Log(("Unsupported light type!!\n"));
return VERR_INVALID_PARAMETER;
}
if (index < SVGA3D_MAX_LIGHTS)
{
}
else
AssertFailed();
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetLightData: SetLight failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
{
{
Log(("vmsvga3dSetLightEnabled invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
if (index < SVGA3D_MAX_LIGHTS)
else
AssertFailed();
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetLightEnabled: LightEnable failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
{
{
Log(("vmsvga3dSetViewPort invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetViewPort: GetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* viewPort.MinZ & MaxZ are not changed from the current setting. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetViewPort: SetViewport failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
{
Log(("vmsvga3dSetClipPlane %x %d (%d,%d)(%d,%d)\n", cid, index, (unsigned)(plane[0] * 100.0), (unsigned)(plane[1] * 100.0), (unsigned)(plane[2] * 100.0), (unsigned)(plane[3] * 100.0)));
{
Log(("vmsvga3dSetClipPlane invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetClipPlane: SetClipPlane failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
int vmsvga3dCommandClear(PVGASTATE pThis, uint32_t cid, SVGA3dClearFlag clearFlag, uint32_t color, float depth, uint32_t stencil, uint32_t cRects, SVGA3dRect *pRect)
{
DWORD clearFlagD3D = 0;
Log(("vmsvga3dCommandClear %x clearFlag=%x color=%x depth=%d stencil=%x cRects=%d\n", cid, clearFlag, color, (uint32_t)(depth * 100.0), stencil, cRects));
{
Log(("vmsvga3dCommandClear invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
if (clearFlag & SVGA3D_CLEAR_COLOR)
if (clearFlag & SVGA3D_CLEAR_STENCIL)
if (clearFlag & SVGA3D_CLEAR_DEPTH)
if (cRects)
{
for (unsigned i=0; i < cRects; i++)
{
Log(("vmsvga3dCommandClear: rect %d (%d,%d)(%d,%d)\n", i, pRect[i].x, pRect[i].y, pRect[i].x + pRect[i].w, pRect[i].y + pRect[i].h));
}
}
if (pRectD3D)
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dCommandClear: Clear failed with %x\n", hr), VERR_INTERNAL_ERROR);
/* Make sure we can track drawing usage of active render targets. */
return VINF_SUCCESS;
}
/* Convert VMWare vertex declaration to its D3D equivalent. */
{
/* usage, method and type are identical; make sure. */
pVertexElement->Stream = 0;
pVertexElement->Offset = 0;
return VINF_SUCCESS;
}
/* Convert VMWare primitive type to its D3D equivalent. */
int vmsvga3dPrimitiveType2D3D(SVGA3dPrimitiveType PrimitiveType, D3DPRIMITIVETYPE *pPrimitiveTypeD3D)
{
switch (PrimitiveType)
{
break;
break;
break;
break;
break;
break;
default:
return VERR_INVALID_PARAMETER;
}
return VINF_SUCCESS;
}
int vmsvga3dDrawPrimitivesProcessVertexDecls(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl, uint32_t idStream, D3DVERTEXELEMENT9 *pVertexElement)
{
int rc;
uint32_t uVertexMaxOffset = 0;
/* Create a vertex declaration array */
{
AssertReturn(sidVertex < pState->cSurfaces && pState->papSurfaces[sidVertex]->id == sidVertex, VERR_INVALID_PARAMETER);
Log(("vmsvga3dDrawPrimitives: type=%s (%d) method=%s (%d) usage=%s (%d) usageIndex=%d stride=%d offset=%d\n", vmsvgaDeclType2String(pVertexDecl[iVertex].identity.type), pVertexDecl[iVertex].identity.type, vmsvgaDeclMethod2String(pVertexDecl[iVertex].identity.method), pVertexDecl[iVertex].identity.method, vmsvgaDeclUsage2String(pVertexDecl[iVertex].identity.usage), pVertexDecl[iVertex].identity.usage, pVertexDecl[iVertex].identity.usageIndex, pVertexDecl[iVertex].array.stride, pVertexDecl[iVertex].array.offset));
#ifdef LOG_ENABLED
Log(("vmsvga3dDrawPrimitives: stride == 0! Can be valid\n"));
#endif
/* Find the min and max vertex offset to determine the right base offset to use in the vertex declaration. */
if (!pVertexSurface->u.pVertexBuffer)
{
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY /* possible severe performance penalty otherwise (according to d3d debug output) */,
0, /* non-FVF */
NULL);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dDrawPrimitives: CreateVertexBuffer failed with %x\n", hr), VERR_INTERNAL_ERROR);
if (pVertexSurface->fDirty)
{
void *pData;
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dDrawPrimitives: Lock vertex failed with %x\n", hr), VERR_INTERNAL_ERROR);
memcpy(pData, pVertexSurface->pMipmapLevels[0].pSurfaceData, pVertexSurface->pMipmapLevels[0].cbSurface);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dDrawPrimitives: Unlock vertex failed with %x\n", hr), VERR_INTERNAL_ERROR);
pVertexSurface->fDirty = false;
}
}
else
}
/* Set the right vertex offset values for each declaration. */
{
#ifdef LOG_ENABLED
Log(("vmsvga3dDrawPrimitives: WARNING: offset > stride!!\n"));
#endif
Log(("vmsvga3dDrawPrimitives: vertex %d offset = %d (stride %d) (min=%d max=%d)\n", iVertex, pVertexDecl[iVertex].array.offset, pVertexDecl[iVertex].array.stride, uVertexMinOffset, uVertexMaxOffset));
}
Log(("vmsvga3dDrawPrimitives: SetStreamSource %d min offset=%d stride=%d\n", idStream, uVertexMinOffset, strideVertex));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dDrawPrimitives: SetStreamSource failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
int vmsvga3dDrawPrimitives(PVGASTATE pThis, uint32_t cid, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl,
{
int rc;
Log(("vmsvga3dDrawPrimitives %x numVertexDecls=%d numRanges=%d, cVertexDivisor=%d\n", cid, numVertexDecls, numRanges, cVertexDivisor));
/* @todo */
{
Log(("vmsvga3dDrawPrimitives invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
/* Begin a scene before rendering anything. */
pVertexElement = (D3DVERTEXELEMENT9 *)RTMemAllocZ(sizeof(D3DVERTEXELEMENT9) * (numVertexDecls + 1));
if (!pVertexElement)
{
goto internal_error;
}
/* Process all vertex declarations. Each vertex buffer is represented by one stream source id. */
iCurrentVertex = 0;
iCurrentStreamId = 0;
while (iCurrentVertex < numVertexDecls)
{
{
if ( ( sidVertex != SVGA_ID_INVALID
)
/* We must put vertex declarations that start at a different element in another stream as d3d only handles offsets < stride. */
|| ( uVertexMinOffset != 0xffffffff
)
)
break;
}
rc = vmsvga3dDrawPrimitivesProcessVertexDecls(pState, pContext, iVertex - iCurrentVertex, &pVertexDecl[iCurrentVertex], iCurrentStreamId, &pVertexElement[iCurrentVertex]);
if (RT_FAILURE(rc))
goto internal_error;
}
/* Mark the end. */
{
goto internal_error;
}
{
goto internal_error;
}
/* Now draw the primitives. */
{
Log(("Primitive %d: type %s\n", iPrimitive, vmsvga3dPrimitiveType2String(pRange[iPrimitive].primType)));
if (RT_FAILURE(rc))
{
goto internal_error;
}
/* Triangle strips or fans with just one primitive don't make much sense and are identical to triangle lists.
* Workaround for NVidia driver crash when encountering some of these.
*/
&& ( PrimitiveTypeD3D == D3DPT_TRIANGLESTRIP
|| PrimitiveTypeD3D == D3DPT_TRIANGLEFAN))
if (sidIndex != SVGA3D_INVALID_ID)
{
AssertMsg(pRange[iPrimitive].indexWidth == sizeof(uint32_t) || pRange[iPrimitive].indexWidth == sizeof(uint16_t), ("Unsupported primitive width %d\n", pRange[iPrimitive].indexWidth));
if ( sidIndex >= SVGA3D_MAX_SURFACE_IDS
{
goto internal_error;
}
if (!pIndexSurface->u.pIndexBuffer)
{
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY /* possible severe performance penalty otherwise (according to d3d debug output */,
NULL);
{
goto internal_error;
}
if (pIndexSurface->fDirty)
{
void *pData;
Log(("vmsvga3dDrawPrimitives: sync index buffer\n"));
memcpy(pData, pIndexSurface->pMipmapLevels[0].pSurfaceData, pIndexSurface->pMipmapLevels[0].cbSurface);
pIndexSurface->fDirty = false;
}
}
else
}
else
{
}
if (!pIndexSurface)
{
/* Render without an index buffer */
Log(("DrawPrimitive %x primitivecount=%d index index bias=%d stride=%d\n", PrimitiveTypeD3D, pRange[iPrimitive].primitiveCount, pRange[iPrimitive].indexBias, strideVertex));
{
goto internal_error;
}
}
else
{
else
numVertices = pVertexSurface->pMipmapLevels[0].cbSurface / strideVertex - pVertexDecl[0].array.offset / strideVertex - pVertexDecl[0].rangeHint.first - pRange[iPrimitive].indexBias;
/* Render with an index buffer */
Log(("DrawIndexedPrimitive %x startindex=%d numVertices=%d, primitivecount=%d index format=%d index bias=%d stride=%d\n", PrimitiveTypeD3D, pVertexDecl[0].rangeHint.first, numVertices, pRange[iPrimitive].primitiveCount, (pRange[iPrimitive].indexWidth == sizeof(uint16_t)) ? D3DFMT_INDEX16 : D3DFMT_INDEX32, pRange[iPrimitive].indexBias, strideVertex));
0, /* MinVertexIndex */
{
goto internal_error;
}
}
}
/* Clear streams above 1 as they might accidentally be reused in the future. */
if (iCurrentStreamId > 1)
{
{
Log(("vmsvga3dDrawPrimitives: clear stream %d\n", i));
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dDrawPrimitives: SetStreamSource failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
}
#if 0 /* Flush queue */
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceTrackUsage: CreateQuery failed with %x\n", hr), VERR_INTERNAL_ERROR);
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSurfaceTrackUsage: Issue failed with %x\n", hr), VERR_INTERNAL_ERROR);
while (true)
{
RTThreadSleep(1);
}
AssertMsgReturn(hr == S_OK, ("vmsvga3dSurfaceFinishDrawing: GetData failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
#endif
/* Make sure we can track drawing usage of active render targets and textures. */
#ifdef DEBUG_GFX_WINDOW
//// if (pContext->sidActiveTexture == 0x3d)
{
rect.w = 800;
rect.h = 600;
vmsvga3dCommandPresent(pThis, pContext->sidRenderTarget /*pContext->aSidActiveTexture[0] */, 0, &rect);
}
#endif
return rc;
if (pVertexDeclD3D)
if (pVertexElement)
return rc;
}
{
{
Log(("vmsvga3dSetScissorRect invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dSetScissorRect: SetScissorRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
int vmsvga3dShaderDefine(PVGASTATE pThis, uint32_t cid, uint32_t shid, SVGA3dShaderType type, uint32_t cbData, uint32_t *pShaderData)
{
Log(("vmsvga3dShaderDefine %x shid=%x type=%s cbData=%x\n", cid, shid, (type == SVGA3D_SHADERTYPE_VS) ? "VERTEX" : "PIXEL", cbData));
{
Log(("vmsvga3dShaderDefine invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
if (type == SVGA3D_SHADERTYPE_VS)
{
{
memset(&pContext->paVertexShader[pContext->cVertexShaders], 0, sizeof(VMSVGA3DSHADER) * (shid + 1 - pContext->cVertexShaders));
}
/* If one already exists with this id, then destroy it now. */
}
else
{
{
memset(&pContext->paPixelShader[pContext->cPixelShaders], 0, sizeof(VMSVGA3DSHADER) * (shid + 1 - pContext->cPixelShaders));
}
/* If one already exists with this id, then destroy it now. */
}
#ifdef DUMP_SHADER_DISASSEMBLY
{
pDisassembly->Release();
}
#endif
switch (type)
{
case SVGA3D_SHADERTYPE_VS:
break;
case SVGA3D_SHADERTYPE_PS:
break;
default:
}
{
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderDefine: CreateVertex/PixelShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
return VINF_SUCCESS;
}
{
Log(("vmsvga3dShaderDestroy %x shid=%x type=%s\n", cid, shid, (type == SVGA3D_SHADERTYPE_VS) ? "VERTEX" : "PIXEL"));
{
Log(("vmsvga3dShaderDestroy invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
if (type == SVGA3D_SHADERTYPE_VS)
{
{
}
}
else
{
{
}
}
if (pShader)
{
if (pShader->pShaderProgram)
}
else
return VINF_SUCCESS;
}
{
Log(("vmsvga3dShaderSet %x type=%s shid=%d\n", cid, (type == SVGA3D_SHADERTYPE_VS) ? "VERTEX" : "PIXEL", shid));
{
Log(("vmsvga3dShaderSet invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
if (type == SVGA3D_SHADERTYPE_VS)
{
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderSet: SetVertex/PixelShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
if (shid == SVGA_ID_INVALID)
{
/* Unselect shader. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderSet: SetVertex/PixelShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
}
else
{
{
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderSet: SetVertex/PixelShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
if (shid == SVGA_ID_INVALID)
{
/* Unselect shader. */
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderSet: SetVertex/PixelShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
}
else
}
return VINF_SUCCESS;
}
int vmsvga3dShaderSetConst(PVGASTATE pThis, uint32_t cid, uint32_t reg, SVGA3dShaderType type, SVGA3dShaderConstType ctype, uint32_t cRegisters, uint32_t *pValues)
{
Log(("vmsvga3dShaderSetConst %x reg=%x type=%s ctype=%x\n", cid, reg, (type == SVGA3D_SHADERTYPE_VS) ? "VERTEX" : "PIXEL", ctype));
{
Log(("vmsvga3dShaderSetConst invalid context id!\n"));
return VERR_INVALID_PARAMETER;
}
for (uint32_t i = 0; i < cRegisters; i++)
{
Log(("Constant %d: value=%x-%x-%x-%x\n", reg + i, pValues[i*4 + 0], pValues[i*4 + 1], pValues[i*4 + 2], pValues[i*4 + 3]));
vmsvga3dSaveShaderConst(pContext, reg + i, type, ctype, pValues[i*4 + 0], pValues[i*4 + 1], pValues[i*4 + 2], pValues[i*4 + 3]);
}
switch (type)
{
case SVGA3D_SHADERTYPE_VS:
switch (ctype)
{
case SVGA3D_CONST_TYPE_FLOAT:
break;
case SVGA3D_CONST_TYPE_INT:
break;
case SVGA3D_CONST_TYPE_BOOL:
break;
default:
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderSetConst: SetVertexShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
case SVGA3D_SHADERTYPE_PS:
switch (ctype)
{
case SVGA3D_CONST_TYPE_FLOAT:
{
break;
}
case SVGA3D_CONST_TYPE_INT:
break;
case SVGA3D_CONST_TYPE_BOOL:
break;
default:
}
AssertMsgReturn(hr == D3D_OK, ("vmsvga3dShaderSetConst: SetPixelShader failed with %x\n", hr), VERR_INTERNAL_ERROR);
break;
default:
}
return VINF_SUCCESS;
}
{
AssertFailed();
return VERR_NOT_IMPLEMENTED;
}
{
AssertFailed();
return VERR_NOT_IMPLEMENTED;
}
int vmsvga3dQueryWait(PVGASTATE pThis, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult)
{
AssertFailed();
return VERR_NOT_IMPLEMENTED;
}
{
LogRel(("\nD3D device caps: DevCaps2:\n"));
LogRel((" - D3DDEVCAPS2_ADAPTIVETESSRTPATCH\n"));
LogRel((" - D3DDEVCAPS2_ADAPTIVETESSNPATCH\n"));
LogRel((" - D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES\n"));
LogRel((" - D3DDEVCAPS2_DMAPNPATCH\n"));
LogRel((" - D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH\n"));
LogRel((" - D3DDEVCAPS2_STREAMOFFSET\n"));
LogRel((" - D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET\n"));
LogRel(("\nCaps2:\n"));
LogRel((" - D3DCAPS2_CANAUTOGENMIPMAP\n"));
LogRel((" - D3DCAPS2_CANCALIBRATEGAMMA\n"));
LogRel((" - D3DCAPS2_CANSHARERESOURCE\n"));
LogRel((" - D3DCAPS2_CANMANAGERESOURCE\n"));
LogRel((" - D3DCAPS2_DYNAMICTEXTURES\n"));
LogRel((" - D3DCAPS2_FULLSCREENGAMMA\n"));
LogRel(("\nCaps3:\n"));
LogRel((" - D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD\n"));
LogRel((" - D3DCAPS3_COPY_TO_VIDMEM\n"));
LogRel((" - D3DCAPS3_COPY_TO_SYSTEMMEM\n"));
LogRel((" - D3DCAPS3_DXVAHD\n"));
LogRel((" - D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION\n"));
LogRel(("\nPresentationIntervals:\n"));
LogRel((" - D3DPRESENT_INTERVAL_IMMEDIATE\n"));
LogRel((" - D3DPRESENT_INTERVAL_ONE\n"));
LogRel((" - D3DPRESENT_INTERVAL_TWO\n"));
LogRel((" - D3DPRESENT_INTERVAL_THREE\n"));
LogRel((" - D3DPRESENT_INTERVAL_FOUR\n"));
LogRel(("\nDevcaps:\n"));
LogRel((" - D3DDEVCAPS_CANBLTSYSTONONLOCAL\n"));
LogRel((" - D3DDEVCAPS_CANRENDERAFTERFLIP\n"));
LogRel((" - D3DDEVCAPS_DRAWPRIMITIVES2\n"));
LogRel((" - D3DDEVCAPS_DRAWPRIMITIVES2EX\n"));
LogRel((" - D3DDEVCAPS_DRAWPRIMTLVERTEX\n"));
LogRel((" - D3DDEVCAPS_EXECUTESYSTEMMEMORY\n"));
LogRel((" - D3DDEVCAPS_EXECUTEVIDEOMEMORY\n"));
LogRel((" - D3DDEVCAPS_HWRASTERIZATION\n"));
LogRel((" - D3DDEVCAPS_HWTRANSFORMANDLIGHT\n"));
LogRel((" - D3DDEVCAPS_NPATCHES\n"));
LogRel((" - D3DDEVCAPS_PUREDEVICE\n"));
LogRel((" - D3DDEVCAPS_QUINTICRTPATCHES\n"));
LogRel((" - D3DDEVCAPS_RTPATCHES\n"));
LogRel((" - D3DDEVCAPS_RTPATCHHANDLEZERO\n"));
LogRel((" - D3DDEVCAPS_SEPARATETEXTUREMEMORIES\n"));
LogRel((" - D3DDEVCAPS_TEXTURENONLOCALVIDMEM\n"));
LogRel((" - D3DDEVCAPS_TEXTURESYSTEMMEMORY\n"));
LogRel((" - D3DDEVCAPS_TEXTUREVIDEOMEMORY\n"));
LogRel((" - D3DDEVCAPS_TLVERTEXSYSTEMMEMORY\n"));
LogRel((" - D3DDEVCAPS_TLVERTEXVIDEOMEMORY\n"));
LogRel(("\nTextureCaps:\n"));
LogRel((" - D3DPTEXTURECAPS_ALPHA\n"));
LogRel((" - D3DPTEXTURECAPS_ALPHAPALETTE\n"));
LogRel((" - D3DPTEXTURECAPS_CUBEMAP\n"));
LogRel((" - D3DPTEXTURECAPS_CUBEMAP_POW2\n"));
LogRel((" - D3DPTEXTURECAPS_MIPCUBEMAP\n"));
LogRel((" - D3DPTEXTURECAPS_MIPMAP\n"));
LogRel((" - D3DPTEXTURECAPS_MIPVOLUMEMAP\n"));
LogRel((" - D3DPTEXTURECAPS_NONPOW2CONDITIONAL\n"));
LogRel((" - D3DPTEXTURECAPS_POW2\n"));
LogRel((" - D3DPTEXTURECAPS_NOPROJECTEDBUMPENV\n"));
LogRel((" - D3DPTEXTURECAPS_PERSPECTIVE\n"));
LogRel((" - D3DPTEXTURECAPS_POW2\n"));
LogRel((" - D3DPTEXTURECAPS_PROJECTED\n"));
LogRel((" - D3DPTEXTURECAPS_SQUAREONLY\n"));
LogRel((" - D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE\n"));
LogRel((" - D3DPTEXTURECAPS_VOLUMEMAP\n"));
LogRel((" - D3DPTEXTURECAPS_VOLUMEMAP_POW2\n"));
LogRel(("\nTextureFilterCaps\n"));
LogRel((" - D3DPTFILTERCAPS_CONVOLUTIONMONO\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFLINEAR\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFANISOTROPIC\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFGAUSSIANQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MINFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MINFLINEAR\n"));
LogRel((" - D3DPTFILTERCAPS_MINFANISOTROPIC\n"));
LogRel((" - D3DPTFILTERCAPS_MINFPYRAMIDALQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MINFGAUSSIANQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MIPFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MIPFLINEAR\n"));
LogRel(("\nCubeTextureFilterCaps\n"));
LogRel((" - D3DPTFILTERCAPS_CONVOLUTIONMONO\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFLINEAR\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFANISOTROPIC\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFGAUSSIANQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MINFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MINFLINEAR\n"));
LogRel((" - D3DPTFILTERCAPS_MINFANISOTROPIC\n"));
LogRel((" - D3DPTFILTERCAPS_MINFPYRAMIDALQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MINFGAUSSIANQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MIPFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MIPFLINEAR\n"));
LogRel(("\nVolumeTextureFilterCaps\n"));
LogRel((" - D3DPTFILTERCAPS_CONVOLUTIONMONO\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFLINEAR\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFANISOTROPIC\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MAGFGAUSSIANQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MINFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MINFLINEAR\n"));
LogRel((" - D3DPTFILTERCAPS_MINFANISOTROPIC\n"));
LogRel((" - D3DPTFILTERCAPS_MINFPYRAMIDALQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MINFGAUSSIANQUAD\n"));
LogRel((" - D3DPTFILTERCAPS_MIPFPOINT\n"));
LogRel((" - D3DPTFILTERCAPS_MIPFLINEAR\n"));
LogRel(("\nTextureAddressCaps:\n"));
LogRel((" - D3DPTADDRESSCAPS_BORDER\n"));
LogRel((" - D3DPTADDRESSCAPS_CLAMP\n"));
LogRel((" - D3DPTADDRESSCAPS_INDEPENDENTUV\n"));
LogRel((" - D3DPTADDRESSCAPS_MIRROR\n"));
LogRel((" - D3DPTADDRESSCAPS_MIRRORONCE\n"));
LogRel((" - D3DPTADDRESSCAPS_WRAP\n"));
LogRel(("\nTextureOpCaps:\n"));
LogRel((" - D3DTEXOPCAPS_DISABLE\n"));
LogRel((" - D3DTEXOPCAPS_SELECTARG1\n"));
LogRel((" - D3DTEXOPCAPS_SELECTARG2\n"));
LogRel((" - D3DTEXOPCAPS_MODULATE\n"));
LogRel((" - D3DTEXOPCAPS_MODULATE2X\n"));
LogRel((" - D3DTEXOPCAPS_MODULATE4X\n"));
LogRel((" - D3DTEXOPCAPS_ADD\n"));
LogRel((" - D3DTEXOPCAPS_ADDSIGNED\n"));
LogRel((" - D3DTEXOPCAPS_ADDSIGNED2X\n"));
LogRel((" - D3DTEXOPCAPS_SUBTRACT\n"));
LogRel((" - D3DTEXOPCAPS_ADDSMOOTH\n"));
LogRel((" - D3DTEXOPCAPS_BLENDDIFFUSEALPHA\n"));
LogRel((" - D3DTEXOPCAPS_BLENDTEXTUREALPHA\n"));
LogRel((" - D3DTEXOPCAPS_BLENDFACTORALPHA\n"));
LogRel((" - D3DTEXOPCAPS_BLENDTEXTUREALPHAPM\n"));
LogRel((" - D3DTEXOPCAPS_BLENDCURRENTALPHA\n"));
LogRel((" - D3DTEXOPCAPS_PREMODULATE\n"));
LogRel((" - D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR\n"));
LogRel((" - D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA\n"));
LogRel((" - D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR\n"));
LogRel((" - D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA\n"));
LogRel((" - D3DTEXOPCAPS_BUMPENVMAP\n"));
LogRel((" - D3DTEXOPCAPS_BUMPENVMAPLUMINANCE\n"));
LogRel((" - D3DTEXOPCAPS_DOTPRODUCT3\n"));
LogRel((" - D3DTEXOPCAPS_MULTIPLYADD\n"));
LogRel((" - D3DTEXOPCAPS_LERP\n"));
LogRel(("\n"));
D3DSHADER_VERSION_MAJOR(pCaps->PixelShaderVersion), D3DSHADER_VERSION_MINOR(pCaps->PixelShaderVersion)));
D3DSHADER_VERSION_MAJOR(pCaps->VertexShaderVersion), D3DSHADER_VERSION_MINOR(pCaps->VertexShaderVersion)));
LogRel(("\n"));
}