- some cleanups

- more cubetextures fixes (now d3d8 sdk cubemap sample work almost
  perfectly)
- add a new debug function "debug_d3dpool" and use it
- add a new param (the device) for the conversions functions (because
  we need to check caps to see how to convert)
- some crashes fixed in render to surface code with no stencil-depth
  surface
- a very simple cliplane fix
- a stupid palettes fix (stupid language)
- begin of anisotropic filter support
- begin of compressed textures support
- a very useful debug functions: IDirect3DSurface8Impl_SaveSnapshot to
  dump surfaces as png ;)
- many useful surfaces debug code (using SaveSnapshot)
This commit is contained in:
Raphael Junqueira 2003-06-04 22:12:34 +00:00 committed by Alexandre Julliard
parent 4e3100825f
commit 0b5e9d9feb
8 changed files with 424 additions and 211 deletions

View File

@ -135,34 +135,34 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
int i;
int j;
ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
TRACE("(%p) : About to load texture\n", This);
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->Dirty);
for (i = 0; i < This->levels; i++) {
if (i == 0 && This->surfaces[0][i]->textureName != 0 && This->Dirty == FALSE) {
if (i == 0 && This->surfaces[0][0]->textureName != 0 && This->Dirty == FALSE) {
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][i]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][0]->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][0]->textureName);
#endif
checkGLcall("glBindTexture");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, This->surfaces[0][i]->textureName);
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][0], i, This->surfaces[0][0]->textureName);
/* No need to walk through all mip-map levels, since already all assigned */
i = This->levels;
} else {
if (i == 0) {
if (This->surfaces[0][i]->textureName == 0) {
glGenTextures(1, &This->surfaces[0][i]->textureName);
if (This->surfaces[0][0]->textureName == 0) {
glGenTextures(1, &This->surfaces[0][0]->textureName);
checkGLcall("glGenTextures");
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, This->surfaces[0][i]->textureName);
TRACE("Texture %p (level %d) given name %d\n", This->surfaces[0][i], i, This->surfaces[0][0]->textureName);
}
#if defined(GL_VERSION_1_3)
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][i]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP, This->surfaces[0][0]->textureName);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][i]->textureName);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->surfaces[0][0]->textureName);
#endif
checkGLcall("glBindTexture");
TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1);
#if defined(GL_VERSION_1_3)
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, This->levels - 1);
@ -173,7 +173,7 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
}
for (j = 0; j < 6; j++) {
IDirect3DSurface8Impl_CreateGLTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i);
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[j][i], cube_targets[j], i);
#if 0
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, glFmt=%x, glType=%x, Mem=%p\n",
cube_targets[j],
@ -195,6 +195,12 @@ void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8
fmt2glType(This->format),
This->surfaces[j][i]->allocatedMemory);
checkGLcall("glTexImage2D");
#endif
#if 0
static int gen = 0;
char buffer[4096];
snprintf(buffer, sizeof(buffer), "/tmp/cube%d_face%d_level%d_%d.png", This->surfaces[0][0]->textureName, j, i, ++gen);
IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This->surfaces[j][i], buffer);
#endif
}
/* Removed glTexParameterf now TextureStageStates are initialized at startup */

View File

@ -168,6 +168,7 @@ typedef enum _GL_SupportedExt {
EXT_PALETTED_TEXTURE,
EXT_SECONDARY_COLOR,
EXT_TEXTURE_COMPRESSION_S3TC,
EXT_TEXTURE_FILTER_ANISOTROPIC,
EXT_TEXTURE_LOD,
EXT_TEXTURE_LOD_BIAS,
EXT_VERTEX_WEIGHTING,
@ -608,7 +609,8 @@ extern HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
extern HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface);
/* internal Interfaces */
extern HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
extern HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level);
extern HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename);
/* ------------------ */
@ -1228,15 +1230,11 @@ extern DWORD WINAPI IDirect3DPixelShaderImpl_GetVersion(IDirect3DPixelShaderImpl
* to see how not defined it here
*/
void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage);
SHORT bytesPerPixel(D3DFORMAT fmt);
GLint fmt2glintFmt(D3DFORMAT fmt);
GLenum fmt2glFmt(D3DFORMAT fmt);
GLenum fmt2glType(D3DFORMAT fmt);
SHORT D3DFmtGetBpp(D3DFORMAT fmt);
GLint D3DFmt2GLIntFmt(D3DFORMAT fmt);
GLenum D3DFmt2GLFmt(D3DFORMAT fmt);
GLenum D3DFmt2GLType(D3DFORMAT fmt);
SHORT D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt);
GLenum D3DFmt2GLDepthFmt(D3DFORMAT fmt);
GLenum D3DFmt2GLDepthType(D3DFORMAT fmt);
@ -1259,5 +1257,6 @@ const char* debug_d3dusage(DWORD usage);
const char* debug_d3dformat(D3DFORMAT fmt);
const char* debug_d3dressourcetype(D3DRESOURCETYPE res);
const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType);
const char* debug_d3dpool(D3DPOOL Pool);
#endif /* __WINE_D3DX8_PRIVATE_H */

View File

@ -1399,7 +1399,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 ifac
volume->myDesc.Type = D3DRTYPE_VOLUME;
volume->myDesc.Pool = Pool;
volume->myDesc.Usage = Usage;
volume->bytesPerPixel = D3DFmtGetBpp(Format);
volume->bytesPerPixel = D3DFmtGetBpp(This, Format);
volume->myDesc.Size = (Width * volume->bytesPerPixel) * Height * Depth;
volume->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, volume->myDesc.Size);
@ -1465,8 +1465,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface,
}
TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[j][i], object->surfaces[j][i]->allocatedMemory);
tmpW = max(1, tmpW / 2);
}
tmpW = max(1, tmpW / 2);
}
TRACE("(%p) : Iface@%p\n", This, object);
@ -1546,7 +1546,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface
object->myDesc.Usage = D3DUSAGE_RENDERTARGET;
object->myDesc.Pool = D3DPOOL_DEFAULT;
object->myDesc.MultiSampleType = MultiSample;
object->bytesPerPixel = D3DFmtGetBpp(Format);
object->bytesPerPixel = D3DFmtGetBpp(This, Format);
object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = Lockable;
@ -1579,7 +1579,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE
object->myDesc.Usage = D3DUSAGE_DEPTHSTENCIL;
object->myDesc.Pool = D3DPOOL_DEFAULT;
object->myDesc.MultiSampleType = MultiSample;
object->bytesPerPixel = D3DFmtGetBpp(Format);
object->bytesPerPixel = D3DFmtGetBpp(This, Format);
object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = (D3DFMT_D16_LOCKABLE == Format) ? TRUE : FALSE;
@ -1607,7 +1607,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface
object->myDesc.Type = D3DRTYPE_SURFACE;
object->myDesc.Usage = 0;
object->myDesc.Pool = D3DPOOL_SYSTEMMEM;
object->bytesPerPixel = D3DFmtGetBpp(Format);
object->bytesPerPixel = D3DFmtGetBpp(This, Format);
object->myDesc.Size = (Width * object->bytesPerPixel) * Height;
object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->myDesc.Size);
object->lockable = TRUE;
@ -1888,7 +1888,20 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(LPDIRECT3DDEVICE8 iface, I
IDirect3DDevice8Impl_CleanRender(iface);
if ((IDirect3DSurface8Impl*) pRenderTarget == This->frontBuffer && (IDirect3DSurface8Impl*) pNewZStencil == This->depthStencilBuffer) {
IDirect3DSurface8Impl* tmp;
TRACE("retoring SetRenderTarget defaults\n");
tmp = This->renderTarget;
This->renderTarget = (IDirect3DSurface8Impl*) This->frontBuffer;
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->renderTarget);
IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
tmp = This->stencilBufferTarget;
This->stencilBufferTarget = (IDirect3DSurface8Impl*) This->depthStencilBuffer;
if (NULL != This->stencilBufferTarget) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
if (NULL != tmp) IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
return D3D_OK;
}
@ -1917,7 +1930,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE8 i
/* Note inc ref on returned surface */
*ppZStencilSurface = (LPDIRECT3DSURFACE8) This->stencilBufferTarget;
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppZStencilSurface);
if (NULL != *ppZStencilSurface) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppZStencilSurface);
return D3D_OK;
}
@ -1941,10 +1954,36 @@ HRESULT WINAPI IDirect3DDevice8Impl_EndScene(LPDIRECT3DDEVICE8 iface) {
getchar(); */
if (This->frontBuffer != This->renderTarget) {
{
GLenum prev_read;
glGetIntegerv(GL_READ_BUFFER, &prev_read);
vcheckGLcall("glIntegerv");
glReadBuffer(GL_BACK);
vcheckGLcall("glReadBuffer");
{
long j;
long pitch = This->renderTarget->myDesc.Width * This->renderTarget->bytesPerPixel;
for (j = 0; j < This->renderTarget->myDesc.Height; ++j) {
glReadPixels(0,
This->renderTarget->myDesc.Height - j - 1,
This->renderTarget->myDesc.Width,
1,
D3DFmt2GLFmt(This, This->renderTarget->myDesc.Format),
D3DFmt2GLType(This, This->renderTarget->myDesc.Format),
This->renderTarget->allocatedMemory + j * pitch);
vcheckGLcall("glReadPixels");
}
}
glReadBuffer(prev_read);
vcheckGLcall("glReadBuffer");
}
IDirect3DBaseTexture8* cont = NULL;
HRESULT hr;
hr = IDirect3DSurface8_GetContainer((LPDIRECT3DSURFACE8) This->renderTarget, &IID_IDirect3DBaseTexture8, (void**) &cont);
if (SUCCEEDED(hr) && NULL != cont) {
/** always dirtify for now. we must find a better way to see that surface have been modified */
IDirect3DBaseTexture8Impl_SetDirty(cont, TRUE);
IDirect3DBaseTexture8_PreLoad(cont);
IDirect3DBaseTexture8_Release(cont);
cont = NULL;
@ -2680,8 +2719,11 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetClipPlane(LPDIRECT3DDEVICE8 iface, DWOR
glPushMatrix();
glLoadMatrixf((float *) &This->StateBlock->transforms[D3DTS_VIEW].u.m[0][0]);
TRACE("Clipplane [%f,%f,%f,%f]\n", This->UpdateStateBlock->clipplane[Index][0], This->UpdateStateBlock->clipplane[Index][1],
This->UpdateStateBlock->clipplane[Index][2], This->UpdateStateBlock->clipplane[Index][3]);
TRACE("Clipplane [%f,%f,%f,%f]\n",
This->UpdateStateBlock->clipplane[Index][0],
This->UpdateStateBlock->clipplane[Index][1],
This->UpdateStateBlock->clipplane[Index][2],
This->UpdateStateBlock->clipplane[Index][3]);
glClipPlane(GL_CLIP_PLANE0 + Index, This->UpdateStateBlock->clipplane[Index]);
glPopMatrix();
@ -2700,9 +2742,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_GetClipPlane(LPDIRECT3DDEVICE8 iface, DWOR
}
pPlane[0] = This->StateBlock->clipplane[Index][0];
pPlane[1] = This->StateBlock->clipplane[Index][0];
pPlane[2] = This->StateBlock->clipplane[Index][0];
pPlane[3] = This->StateBlock->clipplane[Index][0];
pPlane[1] = This->StateBlock->clipplane[Index][1];
pPlane[2] = This->StateBlock->clipplane[Index][2];
pPlane[3] = This->StateBlock->clipplane[Index][3];
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3DRENDERSTATETYPE State,DWORD Value) {
@ -2850,12 +2892,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_AMBIENT :
{
float col[4];
#if 0
col[0] = ((Value >> 16) & 0xFF) / 255.0;
col[1] = ((Value >> 8) & 0xFF) / 255.0;
col[2] = ((Value >> 0) & 0xFF) / 255.0;
col[3] = ((Value >> 24) & 0xFF) / 255.0;
#endif
D3DCOLORTOGLFLOAT4(Value, col);
TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
@ -2929,14 +2965,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
float ref = ((float) This->StateBlock->renderstate[D3DRS_ALPHAREF]) / 255.0f;
switch ((D3DCMPFUNC) Value) {
case D3DCMP_NEVER: glParm=GL_NEVER; break;
case D3DCMP_LESS: glParm=GL_LESS; break;
case D3DCMP_EQUAL: glParm=GL_EQUAL; break;
case D3DCMP_LESSEQUAL: glParm=GL_LEQUAL; break;
case D3DCMP_GREATER: glParm=GL_GREATER; break;
case D3DCMP_NOTEQUAL: glParm=GL_NOTEQUAL; break;
case D3DCMP_GREATEREQUAL: glParm=GL_GEQUAL; break;
case D3DCMP_ALWAYS: glParm=GL_ALWAYS; break;
case D3DCMP_NEVER: glParm = GL_NEVER; break;
case D3DCMP_LESS: glParm = GL_LESS; break;
case D3DCMP_EQUAL: glParm = GL_EQUAL; break;
case D3DCMP_LESSEQUAL: glParm = GL_LEQUAL; break;
case D3DCMP_GREATER: glParm = GL_GREATER; break;
case D3DCMP_NOTEQUAL: glParm = GL_NOTEQUAL; break;
case D3DCMP_GREATEREQUAL: glParm = GL_GEQUAL; break;
case D3DCMP_ALWAYS: glParm = GL_ALWAYS; break;
default:
FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value);
}
@ -3061,7 +3097,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
NOTE: If not supported dont give FIXME as very minimal impact and very few people are
yet running 1.4!
*/
if (Value) {
if (Value) {
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &This->UpdateStateBlock->material.Specular);
checkGLcall("glMaterialfv");
#if defined(GL_VERSION_1_4)
@ -3074,7 +3110,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
TRACE("Specular colors cannot be enabled in this version of opengl\n");
#endif
checkGLcall("glEnable(GL_COLOR_)\n");
} else {
} else {
float black[4] = {0.0, 0.0, 0.0, 0.0};
/* for the case of enabled lighting: */
@ -3092,7 +3128,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
TRACE("Specular colors cannot be disabled in this version of opengl\n");
#endif
checkGLcall("glDisable(GL_COLOR_)\n");
}
}
}
break;
@ -3125,8 +3161,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
FIXME("Unrecognized/Unhandled D3DCMPFUNC value %ld\n", Value);
}
TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask);
This->stencilfunc = glParm;
glStencilFunc(glParm, ref, mask);
This->stencilfunc = glParm;
glStencilFunc(glParm, ref, mask);
checkGLcall("glStencilFunc");
}
break;
@ -3477,13 +3513,13 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_COLORWRITEENABLE :
TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
Value & D3DCOLORWRITEENABLE_RED?1:0,
Value & D3DCOLORWRITEENABLE_GREEN?1:0,
Value & D3DCOLORWRITEENABLE_BLUE?1:0,
Value & D3DCOLORWRITEENABLE_ALPHA?1:0);
glColorMask(Value & D3DCOLORWRITEENABLE_RED,
Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
Value & D3DCOLORWRITEENABLE_BLUE ? 1 : 0,
Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
glColorMask(Value & D3DCOLORWRITEENABLE_RED,
Value & D3DCOLORWRITEENABLE_GREEN,
Value & D3DCOLORWRITEENABLE_BLUE,
Value & D3DCOLORWRITEENABLE_BLUE,
Value & D3DCOLORWRITEENABLE_ALPHA);
checkGLcall("glColorMask(...)\n");
break;
@ -3791,6 +3827,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
}
break;
case D3DTSS_MAXANISOTROPY :
{
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
glTexParameteri(This->StateBlock->textureDimensions[Stage], GL_TEXTURE_MAX_ANISOTROPY_EXT, This->StateBlock->texture_state[Stage][D3DTSS_MAXANISOTROPY]);
checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
}
}
break;
case D3DTSS_MAGFILTER :
if (Value == D3DTEXF_POINT) {
@ -4007,6 +4051,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
* we can use GL_SUBTRACT_ARB here
*/
#endif
case D3DTOP_ADDSMOOTH :
case D3DTOP_BLENDDIFFUSEALPHA :
case D3DTOP_BLENDTEXTUREALPHA :
@ -4264,7 +4309,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa
case D3DTSS_MIPMAPLODBIAS :
case D3DTSS_MAXMIPLEVEL :
case D3DTSS_MAXANISOTROPY :
case D3DTSS_BUMPENVLSCALE :
case D3DTSS_BUMPENVLOFFSET :
case D3DTSS_RESULTARG :
@ -4288,12 +4332,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetPaletteEntries(LPDIRECT3DDEVICE8 iface,
ICOM_THIS(IDirect3DDevice8Impl,iface);
FIXME("(%p) : setting p[%u] <= RGBA(%02x,%02x,%02x,%02x)\n", This, PaletteNumber,
pEntries->peRed, pEntries->peGreen, pEntries->peBlue, pEntries->peFlags);
memcpy(&This->palettes[PaletteNumber], pEntries, 256 * sizeof(PALETTEENTRY));
memcpy(This->palettes[PaletteNumber], pEntries, 256 * sizeof(PALETTEENTRY));
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_GetPaletteEntries(LPDIRECT3DDEVICE8 iface, UINT PaletteNumber, PALETTEENTRY* pEntries) {
ICOM_THIS(IDirect3DDevice8Impl,iface);
memcpy(pEntries, &This->palettes[PaletteNumber], 256 * sizeof(PALETTEENTRY));
memcpy(pEntries, This->palettes[PaletteNumber], 256 * sizeof(PALETTEENTRY));
FIXME("(%p) : returning p[%u] => RGBA(%02x,%02x,%02x,%02x)\n", This, PaletteNumber,
pEntries->peRed, pEntries->peGreen, pEntries->peBlue, pEntries->peFlags);
return D3D_OK;
@ -4309,7 +4353,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetCurrentTexturePalette(LPDIRECT3DDEVICE8
256, /* table size */
GL_RGBA, /* table format */
GL_UNSIGNED_BYTE, /* table type */
&This->palettes[PaletteNumber]);
This->palettes[PaletteNumber]);
checkGLcall("glColorTableEXT");
} else {
/* Delayed palette handling ... waiting for software emulation into preload code */
@ -4896,7 +4940,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
int attribs[256];
int nAttribs = 0;
D3DFORMAT BackBufferFormat = ((IDirect3DSurface8Impl*) RenderSurface)->myDesc.Format;
D3DFORMAT StencilBufferFormat = ((IDirect3DSurface8Impl*) StencilSurface)->myDesc.Format;
D3DFORMAT StencilBufferFormat = (NULL != StencilSurface) ? ((IDirect3DSurface8Impl*) StencilSurface)->myDesc.Format : 0;
UINT Width = ((IDirect3DSurface8Impl*) RenderSurface)->myDesc.Width;
UINT Height = ((IDirect3DSurface8Impl*) RenderSurface)->myDesc.Height;
IDirect3DSurface8Impl* tmp;
@ -5021,14 +5065,15 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
vcheckGLcall("glReadBuffer");
{
long j;
long pitch = This->renderTarget->myDesc.Width * This->renderTarget->bytesPerPixel;
for (j = 0; j < This->renderTarget->myDesc.Height; ++j) {
glReadPixels(0,
This->renderTarget->myDesc.Height - j - 1,
This->renderTarget->myDesc.Width,
1,
D3DFmt2GLFmt(This->renderTarget->myDesc.Format),
D3DFmt2GLType(This->renderTarget->myDesc.Format),
This->renderTarget->allocatedMemory);
D3DFmt2GLFmt(This, This->renderTarget->myDesc.Format),
D3DFmt2GLType(This, This->renderTarget->myDesc.Format),
This->renderTarget->allocatedMemory + j * pitch);
vcheckGLcall("glReadPixels");
}
}
@ -5064,8 +5109,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_ActiveRender(LPDIRECT3DDEVICE8 iface,
tmp = This->stencilBufferTarget;
This->stencilBufferTarget = (IDirect3DSurface8Impl*) StencilSurface;
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
if (NULL != This->stencilBufferTarget) IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) This->stencilBufferTarget);
if (NULL != tmp) IDirect3DSurface8Impl_Release((LPDIRECT3DSURFACE8) tmp);
return D3D_OK;

View File

@ -513,7 +513,7 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
D3DSTENCILCAPS_REPLACE |
D3DSTENCILCAPS_ZERO;
#if defined(GL_VERSION_1_4) || defined(GL_EXT_stencil_wrap)
pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
D3DSTENCILCAPS_INCR;
#endif
@ -603,8 +603,13 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface,
pCaps->MaxStreams = 2; /* HACK: Some games want at least 2 */
pCaps->MaxStreamStride = 1024;
#if 1
pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
#else
pCaps->VertexShaderVersion = 0;
pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
#endif
#if 0
pCaps->PixelShaderVersion = D3DPS_VERSION(1,1);
@ -837,9 +842,9 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
object->renderTarget = object->frontBuffer;
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->renderTarget);
object->stencilBufferTarget = object->depthStencilBuffer;
if (NULL != object->stencilBufferTarget)
if (NULL != object->stencilBufferTarget) {
IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) object->stencilBufferTarget);
}
/* Now override the surface's Flip method (if in double buffering) ?COPIED from DDRAW!?
((x11_ds_private *) surface->private)->opengl_flip = TRUE;
@ -875,8 +880,8 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
checkGLcall("glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);");
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);
checkGLcall("glLightModel (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);");
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
/*
* Initialize openGL extension related variables
@ -955,6 +960,9 @@ HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface,
} else if (strcmp(ThisExtn, "GL_EXT_texture_compression_s3tc") == 0) {
FIXME(" FOUND: EXT Texture S3TC compression support\n");
This->gl_info.supported[EXT_TEXTURE_COMPRESSION_S3TC] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_texture_filter_anisotropic") == 0) {
FIXME(" FOUND: EXT Texture Anisotropic filter support\n");
This->gl_info.supported[EXT_TEXTURE_FILTER_ANISOTROPIC] = TRUE;
} else if (strcmp(ThisExtn, "GL_EXT_texture_lod") == 0) {
FIXME(" FOUND: EXT Texture LOD support\n");
This->gl_info.supported[EXT_TEXTURE_LOD] = TRUE;

View File

@ -25,6 +25,7 @@
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include <stdio.h>
#include "d3d8_private.h"
@ -204,8 +205,8 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
This->lockedRect.bottom - j - 1,
This->lockedRect.right - This->lockedRect.left,
1,
D3DFmt2GLFmt(This->myDesc.Format),
D3DFmt2GLType(This->myDesc.Format),
D3DFmt2GLFmt(This->Device, This->myDesc.Format),
D3DFmt2GLType(This->Device, This->myDesc.Format),
pLockedRect->pBits);
vcheckGLcall("glReadPixels");
}
@ -398,12 +399,14 @@ ICOM_VTABLE(IDirect3DSurface8) Direct3DSurface8_Vtbl =
IDirect3DSurface8Impl_UnlockRect,
};
HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level) {
HRESULT WINAPI IDirect3DSurface8Impl_LoadTexture(LPDIRECT3DSURFACE8 iface, GLenum gl_target, GLenum gl_level) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8) &&
!GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)) {
if ((This->myDesc.Format == D3DFMT_P8 || This->myDesc.Format == D3DFMT_A8P8)
#if defined(GL_EXT_paletted_texture)
&& !GL_SUPPORT_DEV(EXT_PALETTED_TEXTURE, This->Device)
#endif
) {
/**
* wanted a paletted texture and not really support it in HW
* so software emulation code begin
@ -450,27 +453,133 @@ HRESULT WINAPI IDirect3DSurface8Impl_CreateGLTexture(LPDIRECT3DSURFACE8 iface, G
return D3D_OK;
}
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
gl_level,
D3DFmt2GLIntFmt(This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
D3DFmt2GLFmt(This->myDesc.Format),
D3DFmt2GLType(This->myDesc.Format),
This->allocatedMemory);
glTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
D3DFmt2GLFmt(This->myDesc.Format),
D3DFmt2GLType(This->myDesc.Format),
This->allocatedMemory);
checkGLcall("glTexImage2D");
if (This->myDesc.Format == D3DFMT_DXT1 ||
This->myDesc.Format == D3DFMT_DXT3 ||
This->myDesc.Format == D3DFMT_DXT5) {
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT_DEV(EXT_TEXTURE_COMPRESSION_S3TC, This->Device)) {
TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
This->myDesc.Size,
This->allocatedMemory);
glCompressedTexImage2DARB(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
This->myDesc.Size,
This->allocatedMemory);
checkGLcall("glCommpressedTexTexImage2D");
}
#endif
} else {
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
D3DFmt2GLFmt(This->Device, This->myDesc.Format),
D3DFmt2GLType(This->Device, This->myDesc.Format),
This->allocatedMemory);
glTexImage2D(gl_target,
gl_level,
D3DFmt2GLIntFmt(This->Device, This->myDesc.Format),
This->myDesc.Width,
This->myDesc.Height,
0,
D3DFmt2GLFmt(This->Device, This->myDesc.Format),
D3DFmt2GLType(This->Device, This->myDesc.Format),
This->allocatedMemory);
checkGLcall("glTexImage2D");
#if 0
{
static int gen = 0;
char buffer[4096];
++gen;
if ((gen % 10) == 0) {
snprintf(buffer, sizeof(buffer), "/tmp/surface%d_level%d_%d.png", gl_target, gl_level, gen);
IDirect3DSurface8Impl_SaveSnapshot((LPDIRECT3DSURFACE8) This, buffer);
}
}
#endif
}
return D3D_OK;
}
#include <errno.h>
HRESULT WINAPI IDirect3DSurface8Impl_SaveSnapshot(LPDIRECT3DSURFACE8 iface, const char* filename) {
FILE* f = NULL;
int i;
ICOM_THIS(IDirect3DSurface8Impl,iface);
f = fopen(filename, "w+");
if (NULL == f) {
ERR("opening of %s failed with: %s\n", filename, strerror(errno));
return D3DERR_INVALIDCALL;
}
TRACE("opened %s\n", filename);
fprintf(f, "P6\n%u %u\n255\n", This->myDesc.Width, This->myDesc.Height);
switch (This->myDesc.Format) {
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
{
DWORD color;
for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
color = ((DWORD*) This->allocatedMemory)[i];
fputc((color >> 16) & 0xFF, f);
fputc((color >> 8) & 0xFF, f);
fputc((color >> 0) & 0xFF, f);
}
}
break;
case D3DFMT_R8G8B8:
{
BYTE* color;
for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
color = ((BYTE*) This->allocatedMemory) + (3 * i);
fputc((color[0]) & 0xFF, f);
fputc((color[1]) & 0xFF, f);
fputc((color[2]) & 0xFF, f);
}
}
break;
case D3DFMT_A1R5G5B5:
{
WORD color;
for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
color = ((WORD*) This->allocatedMemory)[i];
fputc((color >> 10) & 0xFF, f);
fputc((color >> 5) & 0xFF, f);
fputc((color >> 0) & 0xFF, f);
}
}
break;
case D3DFMT_R5G6B5:
{
WORD color;
for (i = 0; i < This->myDesc.Width * This->myDesc.Height; i++) {
color = ((WORD*) This->allocatedMemory)[i];
fputc((color >> 11) & 0xFF, f);
fputc((color >> 5) & 0xFF, f);
fputc((color >> 0) & 0xFF, f);
}
}
break;
default:
FIXME("Unimplemented dump mode format(%u,%s)\n", This->myDesc.Format, debug_d3dformat(This->myDesc.Format));
}
fclose(f);
return D3D_OK;
}

View File

@ -31,10 +31,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
/* IDirect3DTexture8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REFIID riid,LPVOID *ppobj)
HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface, REFIID riid, LPVOID *ppobj)
{
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) : QueryInterface\n", This);
TRACE("(%p) : QueryInterface for %s\n", This, debugstr_guid(riid));
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)
@ -44,7 +44,7 @@ HRESULT WINAPI IDirect3DTexture8Impl_QueryInterface(LPDIRECT3DTEXTURE8 iface,REF
return D3D_OK;
}
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
return E_NOINTERFACE;
}
@ -134,7 +134,7 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
}
IDirect3DSurface8Impl_CreateGLTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i);
IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i);
#if 0
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_2D,
@ -194,7 +194,8 @@ HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 ifa
TRACE("(%p) Level (%d)\n", This, Level);
return IDirect3DSurface8Impl_GetDesc((LPDIRECT3DSURFACE8) This->surfaces[Level], pDesc);
} else {
FIXME("(%p) Level (%d)\n", This, Level);
FIXME("Levels seems too high?!!\n");
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
@ -218,6 +219,7 @@ HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface,
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
return D3DERR_INVALIDCALL;
}
return hr;
}
@ -230,8 +232,9 @@ HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface
TRACE("(%p) Level (%d) success(%lu)\n", This, Level, hr);
} else {
FIXME("Levels seems too high?!!\n");
return D3DERR_INVALIDCALL;
}
return D3D_OK;
return hr;
}
HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 iface, CONST RECT* pDirtyRect) {
ICOM_THIS(IDirect3DTexture8Impl,iface);

View File

@ -158,101 +158,23 @@ const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType) {
}
}
const char* debug_d3dpool(D3DPOOL Pool) {
switch (Pool) {
#define POOL_TO_STR(p) case p: return #p;
POOL_TO_STR(D3DPOOL_DEFAULT);
POOL_TO_STR(D3DPOOL_MANAGED);
POOL_TO_STR(D3DPOOL_SYSTEMMEM);
POOL_TO_STR(D3DPOOL_SCRATCH);
#undef POOL_TO_STR
default:
FIXME("Unrecognized %u D3DPOOL!\n", Pool);
return "unrecognized";
}
}
/*
* Simple utility routines used for dx -> gl mapping of byte formats
*/
SHORT bytesPerPixel(D3DFORMAT fmt) {
SHORT retVal;
switch (fmt) {
/* color buffer */
case D3DFMT_P8: retVal = 1; break;
case D3DFMT_R3G3B2: retVal = 1; break;
case D3DFMT_R5G6B5: retVal = 2; break;
case D3DFMT_X1R5G5B5: retVal = 2; break;
case D3DFMT_A4R4G4B4: retVal = 2; break;
case D3DFMT_X4R4G4B4: retVal = 2; break;
case D3DFMT_A1R5G5B5: retVal = 2; break;
case D3DFMT_R8G8B8: retVal = 3; break;
case D3DFMT_X8R8G8B8: retVal = 4; break;
case D3DFMT_A8R8G8B8: retVal = 4; break;
/* depth/stencil buffer */
case D3DFMT_D16_LOCKABLE: retVal = 2; break;
case D3DFMT_D16: retVal = 2; break;
case D3DFMT_D15S1: retVal = 2; break;
case D3DFMT_D24X4S4: retVal = 4; break;
case D3DFMT_D24S8: retVal = 4; break;
case D3DFMT_D24X8: retVal = 4; break;
case D3DFMT_D32: retVal = 4; break;
/* unknown */
case D3DFMT_UNKNOWN:
/* Guess at the highest value of the above */
TRACE("D3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt);
retVal = 4;
break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = 4;
}
TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLint fmt2glintFmt(D3DFORMAT fmt) {
GLint retVal;
switch (fmt) {
case D3DFMT_A4R4G4B4: retVal = GL_RGBA4; break;
case D3DFMT_A8R8G8B8: retVal = GL_RGBA8; break;
case D3DFMT_X8R8G8B8: retVal = GL_RGB8; break;
case D3DFMT_R8G8B8: retVal = GL_RGB8; break;
case D3DFMT_R5G6B5: retVal = GL_RGB5; break; /* fixme: internal format 6 for g? */
case D3DFMT_A1R5G5B5: retVal = GL_RGB5_A1; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_RGB8;
}
TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLenum fmt2glFmt(D3DFORMAT fmt) {
GLenum retVal;
switch (fmt) {
case D3DFMT_A4R4G4B4: retVal = GL_BGRA; break;
case D3DFMT_A8R8G8B8: retVal = GL_BGRA; break;
case D3DFMT_X8R8G8B8: retVal = GL_BGRA; break;
case D3DFMT_R8G8B8: retVal = GL_BGR; break;
case D3DFMT_R5G6B5: retVal = GL_RGB; break;
case D3DFMT_A1R5G5B5: retVal = GL_BGRA; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_BGR;
}
TRACE("fmt2glFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLenum fmt2glType(D3DFORMAT fmt) {
GLenum retVal;
switch (fmt) {
case D3DFMT_A4R4G4B4: retVal = GL_UNSIGNED_SHORT_4_4_4_4_REV; break;
case D3DFMT_A8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_X8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_R5G6B5: retVal = GL_UNSIGNED_SHORT_5_6_5; break;
case D3DFMT_R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A1R5G5B5: retVal = GL_UNSIGNED_SHORT_1_5_5_5_REV; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_UNSIGNED_BYTE;
}
TRACE("fmt2glType for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
int D3DPrimitiveListGetVertexSize(D3DPRIMITIVETYPE PrimitiveType, int iNumPrim) {
switch (PrimitiveType) {
case D3DPT_POINTLIST: return iNumPrim;
@ -328,20 +250,141 @@ GLenum D3DFmt2GLDepthType(D3DFORMAT fmt) {
return 0;
}
SHORT D3DFmtGetBpp(D3DFORMAT fmt) {
return bytesPerPixel(fmt);
SHORT D3DFmtGetBpp(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
SHORT retVal;
switch (fmt) {
/* color buffer */
case D3DFMT_P8: retVal = 1; break;
case D3DFMT_R3G3B2: retVal = 1; break;
case D3DFMT_R5G6B5: retVal = 2; break;
case D3DFMT_X1R5G5B5: retVal = 2; break;
case D3DFMT_A4R4G4B4: retVal = 2; break;
case D3DFMT_X4R4G4B4: retVal = 2; break;
case D3DFMT_A1R5G5B5: retVal = 2; break;
case D3DFMT_R8G8B8: retVal = 3; break;
case D3DFMT_X8R8G8B8: retVal = 4; break;
case D3DFMT_A8R8G8B8: retVal = 4; break;
/* depth/stencil buffer */
case D3DFMT_D16_LOCKABLE: retVal = 2; break;
case D3DFMT_D16: retVal = 2; break;
case D3DFMT_D15S1: retVal = 2; break;
case D3DFMT_D24X4S4: retVal = 4; break;
case D3DFMT_D24S8: retVal = 4; break;
case D3DFMT_D24X8: retVal = 4; break;
case D3DFMT_D32: retVal = 4; break;
/* unknown */
case D3DFMT_UNKNOWN:
/* Guess at the highest value of the above */
TRACE("D3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt);
retVal = 4;
break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = 4;
}
TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLint D3DFmt2GLIntFmt(D3DFORMAT fmt) {
return fmt2glintFmt(fmt);
GLint D3DFmt2GLIntFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLint retVal;
switch (fmt) {
case D3DFMT_P8: retVal = GL_COLOR_INDEX8_EXT; break;
case D3DFMT_A8P8: retVal = GL_COLOR_INDEX8_EXT; break;
case D3DFMT_A4R4G4B4: retVal = GL_RGBA4; break;
case D3DFMT_A8R8G8B8: retVal = GL_RGBA8; break;
case D3DFMT_X8R8G8B8: retVal = GL_RGB8; break;
case D3DFMT_R8G8B8: retVal = GL_RGB8; break;
case D3DFMT_R5G6B5: retVal = GL_RGB5; break; /* fixme: internal format 6 for g? */
case D3DFMT_A1R5G5B5: retVal = GL_RGB5_A1; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_RGB8;
}
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
switch (fmt) {
case D3DFMT_DXT1: retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
case D3DFMT_DXT3: retVal = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
case D3DFMT_DXT5: retVal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
default:
/* stupid compiler */
break;
}
}
#endif
TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLenum D3DFmt2GLFmt(D3DFORMAT fmt) {
return fmt2glFmt(fmt);
GLenum D3DFmt2GLFmt(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLenum retVal;
switch (fmt) {
case D3DFMT_P8: retVal = GL_COLOR_INDEX; break;
case D3DFMT_A8P8: retVal = GL_COLOR_INDEX; break;
case D3DFMT_A4R4G4B4: retVal = GL_BGRA; break;
case D3DFMT_A8R8G8B8: retVal = GL_BGRA; break;
case D3DFMT_X8R8G8B8: retVal = GL_BGRA; break;
case D3DFMT_R8G8B8: retVal = GL_BGR; break;
case D3DFMT_R5G6B5: retVal = GL_RGB; break;
case D3DFMT_A1R5G5B5: retVal = GL_BGRA; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_BGR;
}
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
switch (fmt) {
case D3DFMT_DXT1: retVal = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
case D3DFMT_DXT3: retVal = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
case D3DFMT_DXT5: retVal = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
default:
/* stupid compiler */
break;
}
}
#endif
TRACE("fmt2glFmt for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
GLenum D3DFmt2GLType(D3DFORMAT fmt) {
return fmt2glType(fmt);
GLenum D3DFmt2GLType(IDirect3DDevice8Impl* This, D3DFORMAT fmt) {
GLenum retVal;
switch (fmt) {
case D3DFMT_P8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A8P8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A4R4G4B4: retVal = GL_UNSIGNED_SHORT_4_4_4_4_REV; break;
case D3DFMT_A8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_X8R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_R5G6B5: retVal = GL_UNSIGNED_SHORT_5_6_5; break;
case D3DFMT_R8G8B8: retVal = GL_UNSIGNED_BYTE; break;
case D3DFMT_A1R5G5B5: retVal = GL_UNSIGNED_SHORT_1_5_5_5_REV; break;
default:
FIXME("Unhandled fmt(%u,%s)\n", fmt, debug_d3dformat(fmt));
retVal = GL_UNSIGNED_BYTE;
}
#if defined(GL_EXT_texture_compression_s3tc)
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
switch (fmt) {
case D3DFMT_DXT1: retVal = 0; break;
case D3DFMT_DXT3: retVal = 0; break;
case D3DFMT_DXT5: retVal = 0; break;
default:
/* stupid compiler */
break;
}
}
#endif
TRACE("fmt2glType for fmt(%u,%s) = %x\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
int SOURCEx_RGB_EXT(DWORD arg) {

View File

@ -140,23 +140,23 @@ void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTU
TRACE("Calling glTexImage3D %x i=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n",
GL_TEXTURE_3D,
i,
fmt2glintFmt(This->format),
D3DFmt2GLIntFmt(This->Device, This->format),
This->volumes[i]->myDesc.Width,
This->volumes[i]->myDesc.Height,
This->volumes[i]->myDesc.Depth,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
D3DFmt2GLFmt(This->Device, This->format),
D3DFmt2GLType(This->Device, This->format),
This->volumes[i]->allocatedMemory);
glTexImage3D(GL_TEXTURE_3D,
i,
fmt2glintFmt(This->format),
D3DFmt2GLIntFmt(This->Device, This->format),
This->volumes[i]->myDesc.Width,
This->volumes[i]->myDesc.Height,
This->volumes[i]->myDesc.Depth,
0,
fmt2glFmt(This->format),
fmt2glType(This->format),
D3DFmt2GLFmt(This->Device, This->format),
D3DFmt2GLType(This->Device, This->format),
This->volumes[i]->allocatedMemory);
checkGLcall("glTexImage3D");