From 8534f791249f59bd17d9dd027027c7d595ceee08 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Thu, 8 May 2003 03:49:04 +0000 Subject: [PATCH] - Move texture loading into PreLoad for 2D textures (needs doing for the others as well), and call when needed as well. - Change D3DFMT_R5G6B5 handling to make backdrop of Max Payne appear. - Add code to reject attempts to use invalid texture units (Max Payne did this a lot). - ValidateDevice fixme silenced as harmless but occurs frequently. - Add trace which can be compiled in to debug vertex shaders, and correct fixmes and dprintf's into appropriate trace statements. - Ensure we trace what we return when querying the device caps. - Correct bug with negative numbers in vertex shader code. --- dlls/d3d8/d3d8_private.h | 4 + dlls/d3d8/device.c | 76 +++++----------- dlls/d3d8/directx.c | 6 +- dlls/d3d8/shader.c | 192 ++++++++++++++++++++++++--------------- dlls/d3d8/texture.c | 50 +++++++++- 5 files changed, 197 insertions(+), 131 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index eb2a0d86125..00a56e7a867 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -1104,5 +1104,9 @@ 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); +DWORD fmt2glType(D3DFORMAT fmt); #endif /* __WINE_D3DX8_PRIVATE_H */ diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 9f1b3eb9592..53872c53310 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -907,7 +907,7 @@ GLenum fmt2glFmt(D3DFORMAT fmt) { 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_BGR; break; + case D3DFMT_R5G6B5: retVal = GL_RGB; break; case D3DFMT_A1R5G5B5: retVal = GL_BGRA; break; default: FIXME("Unhandled fmt %d\n", fmt); @@ -3117,6 +3117,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD oldTxt = This->UpdateStateBlock->textures[Stage]; TRACE("(%p) : Stage(%ld), Texture (%p)\n", This, Stage, pTexture); + /* Reject invalid texture units */ + if (Stage >= This->TextureUnits) { + TRACE("Attempt to access invalid texture rejected\n"); + return D3DERR_INVALIDCALL; + } + This->UpdateStateBlock->Set.textures[Stage] = TRUE; This->UpdateStateBlock->Changed.textures[Stage] = TRUE; This->UpdateStateBlock->textures[Stage] = pTexture; @@ -3152,7 +3158,6 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD if (textureType == D3DRTYPE_TEXTURE) { IDirect3DTexture8Impl *pTexture2 = (IDirect3DTexture8Impl *) pTexture; - int i; if ((void *)oldTxt == (void *)pTexture2 && pTexture2->Dirty == FALSE) { TRACE("Skipping setting texture as old == new\n"); @@ -3163,53 +3168,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, DWORD TRACE("Standard 2d texture\n"); This->UpdateStateBlock->textureDimensions[Stage] = GL_TEXTURE_2D; - for (i=0; ilevels; i++) - { - - if (i==0 && pTexture2->surfaces[i]->textureName != 0 && pTexture2->Dirty == FALSE) { - glBindTexture(GL_TEXTURE_2D, pTexture2->surfaces[i]->textureName); - checkGLcall("glBindTexture"); - TRACE("Texture %p (level %d) given name %d\n", pTexture2->surfaces[i], i, pTexture2->surfaces[i]->textureName); - /* No need to walk through all mip-map levels, since already all assigned */ - i = pTexture2->levels; - - } else { - if (i==0) { - - if (pTexture2->surfaces[i]->textureName == 0) { - glGenTextures(1, &pTexture2->surfaces[i]->textureName); - checkGLcall("glGenTextures"); - TRACE("Texture %p (level %d) given name %d\n", pTexture2->surfaces[i], i, pTexture2->surfaces[i]->textureName); - } - - glBindTexture(GL_TEXTURE_2D, pTexture2->surfaces[i]->textureName); - checkGLcall("glBindTexture"); - - TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", pTexture2->levels-1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, pTexture2->levels-1); - checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, pTexture2->levels)"); - - } - TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%lx, Mem=%p\n", - GL_TEXTURE_2D, i, fmt2glintFmt(pTexture2->format), pTexture2->surfaces[i]->myDesc.Width, - pTexture2->surfaces[i]->myDesc.Height, 0, fmt2glFmt(pTexture2->format),fmt2glType(pTexture2->format), - pTexture2->surfaces[i]->allocatedMemory); - glTexImage2D(GL_TEXTURE_2D, i, - fmt2glintFmt(pTexture2->format), - pTexture2->surfaces[i]->myDesc.Width, - pTexture2->surfaces[i]->myDesc.Height, - 0, - fmt2glFmt(pTexture2->format), - fmt2glType(pTexture2->format), - pTexture2->surfaces[i]->allocatedMemory - ); - checkGLcall("glTexImage2D"); - - /* Removed glTexParameterf now TextureStageStates are initialized at startup */ - pTexture2->Dirty = FALSE; - } - - } + /* Load up the texture now */ + IDirect3DTexture8Impl_PreLoad((LPDIRECT3DTEXTURE8)pTexture); } } else if (textureType == D3DRTYPE_VOLUMETEXTURE) { IDirect3DVolumeTexture8Impl *pTexture2 = (IDirect3DVolumeTexture8Impl *) pTexture; @@ -3301,6 +3261,12 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa TRACE("(%p) : stub, Stage=%ld, Type=%d, Value =%ld\n", This, Stage, Type, Value); + /* Reject invalid texture units */ + if (Stage >= This->TextureUnits) { + TRACE("Attempt to access invalid texture rejected\n"); + return D3DERR_INVALIDCALL; + } + This->UpdateStateBlock->Changed.texture_state[Stage][Type] = TRUE; This->UpdateStateBlock->Set.texture_state[Stage][Type] = TRUE; This->UpdateStateBlock->texture_state[Stage][Type] = Value; @@ -3715,7 +3681,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 ifa } HRESULT WINAPI IDirect3DDevice8Impl_ValidateDevice(LPDIRECT3DDEVICE8 iface, DWORD* pNumPasses) { ICOM_THIS(IDirect3DDevice8Impl,iface); - FIXME("(%p) : stub\n", This); return D3D_OK; + TRACE("(%p) : stub\n", This); /* FIXME: Needs doing, but called often and is harmless */ + return D3D_OK; } HRESULT WINAPI IDirect3DDevice8Impl_GetInfo(LPDIRECT3DDEVICE8 iface, DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) { ICOM_THIS(IDirect3DDevice8Impl,iface); @@ -3933,7 +3900,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 ICOM_THIS(IDirect3DDevice8Impl,iface); if (Register + ConstantCount > D3D8_VSHADER_MAX_CONSTANTS) { - /*ERR("(%p) : SetVertexShaderConstant C[%lu] invalid\n", This, Register);*/ + ERR("(%p) : SetVertexShaderConstant C[%lu] invalid\n", This, Register); return D3DERR_INVALIDCALL; } if (NULL == pConstantData) { @@ -3942,14 +3909,14 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 if (ConstantCount > 1) { FLOAT* f = (FLOAT*)pConstantData; UINT i; - FIXME("(%p) : SetVertexShaderConstant C[%lu..%lu]=\n", This, Register, Register + ConstantCount - 1); + TRACE("(%p) : SetVertexShaderConstant C[%lu..%lu]=\n", This, Register, Register + ConstantCount - 1); for (i = 0; i < ConstantCount; ++i) { - DPRINTF("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]); + TRACE("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]); f += 4; } } else { FLOAT* f = (FLOAT*)pConstantData; - FIXME("(%p) : SetVertexShaderConstant, C[%lu]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]); + TRACE("(%p) : SetVertexShaderConstant, C[%lu]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]); } This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE; memcpy(&This->UpdateStateBlock->vertexShaderConstant[Register], pConstantData, ConstantCount * 4 * sizeof(FLOAT)); @@ -3958,6 +3925,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEVICE8 HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEVICE8 iface, DWORD Register, void* pConstantData, DWORD ConstantCount) { ICOM_THIS(IDirect3DDevice8Impl,iface); + TRACE("(%p) : C[%lu] count=%ld\n", This, Register, ConstantCount); if (Register + ConstantCount > D3D8_VSHADER_MAX_CONSTANTS) { return D3DERR_INVALIDCALL; } diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index 947686889ab..7978b875b79 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -373,17 +373,17 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps (LPDIRECT3D8 iface, GLint gl_max; glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max); - TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max); pCaps->MaxTextureBlendStages = min(8, gl_max); pCaps->MaxSimultaneousTextures = min(8, gl_max); + TRACE("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%ld\n", pCaps->MaxTextureBlendStages); glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max); pCaps->MaxUserClipPlanes = min(MAX_CLIPPLANES, gl_max); - TRACE("GLCaps: GL_MAX_CLIP_PLANES=%d\n", gl_max); + TRACE("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps->MaxUserClipPlanes); glGetIntegerv(GL_MAX_LIGHTS, &gl_max); pCaps->MaxActiveLights = min(MAX_ACTIVE_LIGHTS, gl_max); - TRACE("GLCaps: GL_MAX_LIGHTS=%d\n", gl_max); + TRACE("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps->MaxActiveLights); } pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS | D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_TEXGEN; diff --git a/dlls/d3d8/shader.c b/dlls/d3d8/shader.c index b3b2d6076e0..2ec72759ac5 100644 --- a/dlls/d3d8/shader.c +++ b/dlls/d3d8/shader.c @@ -32,6 +32,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); +/* Shader debugging - Change the following line to enable debugging of software + vertex shaders */ +#if 0 +# define VSTRACE(A) TRACE A +# define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w) +#else +# define VSTRACE(A) +# define TRACE_VECTOR(name) +#endif + /** * DirectX9 SDK download * http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp @@ -82,19 +92,20 @@ void vshader_add(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = s0->y + s1->y; d->z = s0->z + s1->z; d->w = s0->w + s1->w; + VSTRACE(("executing add: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_dp3(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->x = d->y = d->z = d->w = s0->x * s1->x + s0->y * s1->y + s0->z * s1->z; + VSTRACE(("executing dp3: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_dp4(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->x = d->y = d->z = d->w = s0->x * s1->x + s0->y * s1->y + s0->z * s1->z + s0->w * s1->w; - - /* - DPRINTF("executing dp4: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", - s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w); - */ + VSTRACE(("executing dp4: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_dst(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -102,11 +113,8 @@ void vshader_dst(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = s0->y * s1->y; d->z = s0->z; d->w = s1->w; - - /* - DPRINTF("executing dst: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", - s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w); - */ + VSTRACE(("executing dst: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_expp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { @@ -119,11 +127,8 @@ void vshader_expp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { d->y = s0->w - tmp_f; d->z = *((float*) &tmp_d); d->w = 1.0f; - - /* - DPRINTF("executing exp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", - s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w); - */ + VSTRACE(("executing exp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_lit(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { @@ -131,16 +136,15 @@ void vshader_lit(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { d->y = (0.0f < s0->x) ? s0->x : 0.0f; d->z = (0.0f < s0->x && 0.0f < s0->y) ? powf(s0->y, s0->w) : 0.0f; d->w = 1.0f; - - /* - DPRINTF("executing lit: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", - s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w); - */ + VSTRACE(("executing lit: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_logp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { float tmp_f = fabsf(s0->w); d->x = d->y = d->z = d->w = (0.0f != tmp_f) ? logf(tmp_f) / logf(2.0f) : -HUGE; + VSTRACE(("executing logp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_mad(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1, D3DSHADERVECTOR* s2) { @@ -148,6 +152,8 @@ void vshader_mad(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1, D d->y = s0->y * s1->y + s2->y; d->z = s0->z * s1->z + s2->z; d->w = s0->w * s1->w + s2->w; + VSTRACE(("executing mad: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) s2=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, s2->x, s2->y, s2->z, s2->w, d->x, d->y, d->z, d->w)); } void vshader_max(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -155,6 +161,8 @@ void vshader_max(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = (s0->y >= s1->y) ? s0->y : s1->y; d->z = (s0->z >= s1->z) ? s0->z : s1->z; d->w = (s0->w >= s1->w) ? s0->w : s1->w; + VSTRACE(("executing max: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_min(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -162,6 +170,8 @@ void vshader_min(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = (s0->y < s1->y) ? s0->y : s1->y; d->z = (s0->z < s1->z) ? s0->z : s1->z; d->w = (s0->w < s1->w) ? s0->w : s1->w; + VSTRACE(("executing min: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_mov(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { @@ -169,11 +179,8 @@ void vshader_mov(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { d->y = s0->y; d->z = s0->z; d->w = s0->w; - - /* - DPRINTF("executing mov: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", - s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w); - */ + VSTRACE(("executing mov: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_mul(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -181,11 +188,8 @@ void vshader_mul(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = s0->y * s1->y; d->z = s0->z * s1->z; d->w = s0->w * s1->w; - - /* - DPRINTF("executing mul: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", - s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w); - */ + VSTRACE(("executing mul: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_nop(void) { @@ -194,11 +198,15 @@ void vshader_nop(void) { void vshader_rcp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { d->x = d->y = d->z = d->w = (0.0f == s0->w) ? HUGE : 1.0f / s0->w; + VSTRACE(("executing rcp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_rsq(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { float tmp_f = fabsf(s0->w); d->x = d->y = d->z = d->w = (0.0f == tmp_f) ? HUGE : ((1.0f != tmp_f) ? 1.0f / sqrtf(tmp_f) : 1.0f); + VSTRACE(("executing rsq: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_sge(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -206,6 +214,8 @@ void vshader_sge(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = (s0->y >= s1->y) ? 1.0f : 0.0f; d->z = (s0->z >= s1->z) ? 1.0f : 0.0f; d->w = (s0->w >= s1->w) ? 1.0f : 0.0f; + VSTRACE(("executing sge: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_slt(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -213,6 +223,8 @@ void vshader_slt(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = (s0->y < s1->y) ? 1.0f : 0.0f; d->z = (s0->z < s1->z) ? 1.0f : 0.0f; d->w = (s0->w < s1->w) ? 1.0f : 0.0f; + VSTRACE(("executing slt: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } void vshader_sub(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { @@ -220,6 +232,8 @@ void vshader_sub(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { d->y = s0->y - s1->y; d->z = s0->z - s1->z; d->w = s0->w - s1->w; + VSTRACE(("executing sub: s0=(%f, %f, %f, %f) s1=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, s1->x, s1->y, s1->z, s1->w, d->x, d->y, d->z, d->w)); } /** @@ -228,11 +242,15 @@ void vshader_sub(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1) { void vshader_exp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { d->x = d->y = d->z = d->w = powf(2.0f, s0->w); + VSTRACE(("executing exp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_log(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { float tmp_f = fabsf(s0->w); d->x = d->y = d->z = d->w = (0.0f != tmp_f) ? logf(tmp_f) / logf(2.0f) : -HUGE; + VSTRACE(("executing log: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } void vshader_frc(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { @@ -240,6 +258,8 @@ void vshader_frc(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { d->y = s0->y - floorf(s0->y); d->z = 0.0f; d->w = 1.0f; + VSTRACE(("executing frc: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", + s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w)); } typedef FLOAT D3DMATRIX44[4][4]; @@ -263,30 +283,43 @@ void vshader_m4x4(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, /*D3DSHADERVECTOR* ma d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z + mat[1][3] * s0->w; d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z + mat[2][3] * s0->w; d->w = mat[3][0] * s0->x + mat[3][1] * s0->y + mat[3][2] * s0->z + mat[3][3] * s0->w; + VSTRACE(("executing m4x4(1): mat=(%f, %f, %f, %f) s0=(%f) d=(%f) \n", mat[0][0], mat[0][1], mat[0][2], mat[0][3], s0->x, d->x)); + VSTRACE(("executing m4x4(2): mat=(%f, %f, %f, %f) (%f) (%f) \n", mat[1][0], mat[1][1], mat[1][2], mat[1][3], s0->y, d->y)); + VSTRACE(("executing m4x4(3): mat=(%f, %f, %f, %f) X (%f) = (%f) \n", mat[2][0], mat[2][1], mat[2][2], mat[2][3], s0->z, d->z)); + VSTRACE(("executing m4x4(4): mat=(%f, %f, %f, %f) (%f) (%f) \n", mat[3][0], mat[3][1], mat[3][2], mat[3][3], s0->w, d->w)); } void vshader_m4x3(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX43 mat) { - FIXME("check\n"); d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[0][2] * s0->z + mat[0][3] * s0->w; d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z + mat[1][3] * s0->w; d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z + mat[2][3] * s0->w; d->w = 1.0f; + VSTRACE(("executing m4x3(1): mat=(%f, %f, %f, %f) s0=(%f) d=(%f) \n", mat[0][0], mat[0][1], mat[0][2], mat[0][3], s0->x, d->x)); + VSTRACE(("executing m4x3(2): mat=(%f, %f, %f, %f) (%f) (%f) \n", mat[1][0], mat[1][1], mat[1][2], mat[1][3], s0->y, d->y)); + VSTRACE(("executing m4x3(3): mat=(%f, %f, %f, %f) X (%f) = (%f) \n", mat[2][0], mat[2][1], mat[2][2], mat[2][3], s0->z, d->z)); + VSTRACE(("executing m4x3(4): (%f) (%f) \n", s0->w, d->w)); } void vshader_m3x4(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX34 mat) { - FIXME("check\n"); d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[0][2] * s0->z; d->y = mat[2][0] * s0->x + mat[1][1] * s0->y + mat[1][2] * s0->z; d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z; d->w = mat[3][0] * s0->x + mat[3][1] * s0->y + mat[3][2] * s0->z; + VSTRACE(("executing m3x4(1): mat=(%f, %f, %f) s0=(%f) d=(%f) \n", mat[0][0], mat[0][1], mat[0][2], s0->x, d->x)); + VSTRACE(("executing m3x4(2): mat=(%f, %f, %f) (%f) (%f) \n", mat[1][0], mat[1][1], mat[1][2], s0->y, d->y)); + VSTRACE(("executing m3x4(3): mat=(%f, %f, %f) X (%f) = (%f) \n", mat[2][0], mat[2][1], mat[2][2], s0->z, d->z)); + VSTRACE(("executing m3x4(4): mat=(%f, %f, %f) (%f) (%f) \n", mat[3][0], mat[3][1], mat[3][2], s0->w, d->w)); } void vshader_m3x3(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX33 mat) { - FIXME("check\n"); d->x = mat[0][0] * s0->x + mat[0][1] * s0->y + mat[2][2] * s0->z; d->y = mat[1][0] * s0->x + mat[1][1] * s0->y + mat[2][2] * s0->z; d->z = mat[2][0] * s0->x + mat[2][1] * s0->y + mat[2][2] * s0->z; d->w = 1.0f; + VSTRACE(("executing m3x3(1): mat=(%f, %f, %f) s0=(%f) d=(%f) \n", mat[0][0], mat[0][1], mat[0][2], s0->x, d->x)); + VSTRACE(("executing m3x3(2): mat=(%f, %f, %f) (%f) (%f) \n", mat[1][0], mat[1][1], mat[1][2], s0->y, d->y)); + VSTRACE(("executing m3x3(3): mat=(%f, %f, %f) X (%f) = (%f) \n", mat[2][0], mat[2][1], mat[2][2], s0->z, d->z)); + VSTRACE(("executing m3x3(4): (%f) \n", d->w)); } void vshader_m3x2(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX32 mat) { @@ -336,7 +369,7 @@ static CONST SHADER_OPCODE vshader_ins [] = { {D3DSIO_M3x4, "m3x4", 3, vshader_m3x4}, {D3DSIO_M3x3, "m3x3", 3, vshader_m3x3}, {D3DSIO_M3x2, "m3x2", 3, vshader_m3x2}, - /** FIXME: use direct acces so add the others opcodes as stubs */ + /** FIXME: use direct access so add the others opcodes as stubs */ {D3DSIO_EXPP, "expp", 2, vshader_expp}, {D3DSIO_LOGP, "logp", 2, vshader_logp}, @@ -363,29 +396,29 @@ inline static void vshader_program_dump_param(const DWORD param, int input) { DWORD reg = param & 0x00001FFF; DWORD regtype = ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); - if ((param & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) DPRINTF("-"); + if ((param & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) TRACE("-"); switch (regtype << D3DSP_REGTYPE_SHIFT) { case D3DSPR_TEMP: - DPRINTF("R[%lu]", reg); + TRACE("R[%lu]", reg); break; case D3DSPR_INPUT: - DPRINTF("V[%lu]", reg); + TRACE("V[%lu]", reg); break; case D3DSPR_CONST: - DPRINTF("C[%s%lu]", (reg & D3DVS_ADDRMODE_RELATIVE) ? "a0.x + " : "", reg); + TRACE("C[%s%lu]", (reg & D3DVS_ADDRMODE_RELATIVE) ? "a0.x + " : "", reg); break; case D3DSPR_ADDR: /*case D3DSPR_TEXTURE:*/ - DPRINTF("a[%lu]", reg); + TRACE("a[%lu]", reg); break; case D3DSPR_RASTOUT: - DPRINTF("%s", rastout_reg_names[reg]); + TRACE("%s", rastout_reg_names[reg]); break; case D3DSPR_ATTROUT: - DPRINTF("oD[%lu]", reg); + TRACE("oD[%lu]", reg); break; case D3DSPR_TEXCRDOUT: - DPRINTF("oT[%lu]", reg); + TRACE("oT[%lu]", reg); break; default: break; @@ -394,10 +427,10 @@ inline static void vshader_program_dump_param(const DWORD param, int input) { if (!input) { /** operand output */ if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) { - if (param & D3DSP_WRITEMASK_0) DPRINTF(".x"); - if (param & D3DSP_WRITEMASK_1) DPRINTF(".y"); - if (param & D3DSP_WRITEMASK_2) DPRINTF(".z"); - if (param & D3DSP_WRITEMASK_3) DPRINTF(".w"); + if (param & D3DSP_WRITEMASK_0) TRACE(".x"); + if (param & D3DSP_WRITEMASK_1) TRACE(".y"); + if (param & D3DSP_WRITEMASK_2) TRACE(".z"); + if (param & D3DSP_WRITEMASK_3) TRACE(".w"); } } else { /** operand input */ @@ -414,9 +447,9 @@ inline static void vshader_program_dump_param(const DWORD param, int input) { if (swizzle_x == swizzle_y && swizzle_x == swizzle_z && swizzle_x == swizzle_w) { - DPRINTF(".%c", swizzle_reg_chars[swizzle_x]); + TRACE(".%c", swizzle_reg_chars[swizzle_x]); } else { - DPRINTF(".%c%c%c%c", + TRACE(".%c%c%c%c", swizzle_reg_chars[swizzle_x], swizzle_reg_chars[swizzle_y], swizzle_reg_chars[swizzle_z], @@ -446,7 +479,7 @@ inline static VOID IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderI if (NULL != pToken) { while (D3DVS_END() != *pToken) { if (vshader_is_version_token(*pToken)) { /** version */ - DPRINTF("vs.%lu.%lu\n", (*pToken >> 8) & 0x0F, (*pToken & 0x0F)); + TRACE("vs.%lu.%lu\n", (*pToken >> 8) & 0x0F, (*pToken & 0x0F)); ++pToken; ++len; continue; @@ -454,7 +487,7 @@ inline static VOID IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderI if (vshader_is_comment_token(*pToken)) { /** comment */ DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; ++pToken; - /*DPRINTF("comment[%ld] ;%s\n", comment_len, (char*)pToken);*/ + /*TRACE("comment[%ld] ;%s\n", comment_len, (char*)pToken);*/ pToken += comment_len; len += comment_len + 1; continue; @@ -465,24 +498,24 @@ inline static VOID IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderI if (NULL == curOpcode) { /* unkown current opcode ... */ while (*pToken & 0x80000000) { - DPRINTF("unrecognized opcode: %08lx\n", *pToken); + TRACE("unrecognized opcode: %08lx\n", *pToken); ++pToken; ++len; } } else { - DPRINTF("%s ", curOpcode->name); + TRACE("%s ", curOpcode->name); if (curOpcode->num_params > 0) { vshader_program_dump_param(*pToken, 0); ++pToken; ++len; for (i = 1; i < curOpcode->num_params; ++i) { - DPRINTF(", "); + TRACE(", "); vshader_program_dump_param(*pToken, 1); ++pToken; ++len; } } - DPRINTF("\n"); + TRACE("\n"); } } vshader->functionLength = (len + 1) * sizeof(DWORD); @@ -528,8 +561,6 @@ BOOL IDirect3DVertexShaderImpl_ExecuteHAL(IDirect3DVertexShaderImpl* vshader, VS return TRUE; } -#define TRACE_VECTOR(name) DPRINTF( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w) - HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vshader, VSHADERINPUTDATA8* input, VSHADEROUTPUTDATA8* output) { /** Vertex Shader Temporary Registers */ D3DSHADERVECTOR R[12]; @@ -550,13 +581,13 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs memset(R, 0, 12 * sizeof(D3DSHADERVECTOR)); /* vshader_program_parse(vshader); */ - /* +#if 0 TRACE_VECTOR(vshader->data->C[0]); TRACE_VECTOR(vshader->data->C[1]); TRACE_VECTOR(vshader->data->C[2]); TRACE_VECTOR(vshader->data->C[3]); TRACE_VECTOR(vshader->data->C[4]); - TRACE_VECTOR(vshader->data->C[5]); + TRACE_VECTOR(vshader->data->C[7]); TRACE_VECTOR(input->V[D3DVSDE_POSITION]); TRACE_VECTOR(input->V[D3DVSDE_BLENDWEIGHT]); TRACE_VECTOR(input->V[D3DVSDE_BLENDINDICES]); @@ -566,7 +597,7 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs TRACE_VECTOR(input->V[D3DVSDE_SPECULAR]); TRACE_VECTOR(input->V[D3DVSDE_TEXCOORD0]); TRACE_VECTOR(input->V[D3DVSDE_TEXCOORD1]); - */ +#endif /* the first dword is the version tag */ /* TODO: parse it */ @@ -588,29 +619,29 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs /* unkown current opcode ... */ while (*pToken & 0x80000000) { if (i == 0) { - DPRINTF("unrecognized opcode: pos=%d token=%08lX\n", (pToken - 1) - vshader->function, *(pToken - 1)); + TRACE("unrecognized opcode: pos=%d token=%08lX\n", (pToken - 1) - vshader->function, *(pToken - 1)); } - DPRINTF("unrecognized opcode param: pos=%d token=%08lX what=", pToken - vshader->function, *pToken); + TRACE("unrecognized opcode param: pos=%d token=%08lX what=", pToken - vshader->function, *pToken); vshader_program_dump_param(*pToken, i); - DPRINTF("\n"); + TRACE("\n"); ++i; ++pToken; } /*return FALSE;*/ } else { if (curOpcode->num_params > 0) { - /*DPRINTF(">> execting opcode: pos=%d opcode_name=%s token=%08lX\n", pToken - vshader->function, curOpcode->name, *pToken);*/ + /*TRACE(">> execting opcode: pos=%d opcode_name=%s token=%08lX\n", pToken - vshader->function, curOpcode->name, *pToken);*/ for (i = 0; i < curOpcode->num_params; ++i) { DWORD reg = pToken[i] & 0x00001FFF; DWORD regtype = ((pToken[i] & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); switch (regtype << D3DSP_REGTYPE_SHIFT) { case D3DSPR_TEMP: - /*DPRINTF("p[%d]=R[%d]\n", i, reg);*/ + /*TRACE("p[%d]=R[%d]\n", i, reg);*/ p[i] = &R[reg]; break; case D3DSPR_INPUT: - /*DPRINTF("p[%d]=V[%s]\n", i, VertexShaderDeclRegister[reg]);*/ + /*TRACE("p[%d]=V[%s]\n", i, VertexShaderDeclRegister[reg]);*/ p[i] = &input->V[reg]; break; case D3DSPR_CONST: @@ -625,7 +656,7 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs ERR("cannot handle address registers != a0, forcing use of a0\n"); reg = 0; } - /*DPRINTF("p[%d]=A[%d]\n", i, reg);*/ + /*TRACE("p[%d]=A[%d]\n", i, reg);*/ p[i] = &A[reg]; break; case D3DSPR_RASTOUT: @@ -642,11 +673,11 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs } break; case D3DSPR_ATTROUT: - /*DPRINTF("p[%d]=oD[%d]\n", i, reg);*/ + /*TRACE("p[%d]=oD[%d]\n", i, reg);*/ p[i] = &output->oD[reg]; break; case D3DSPR_TEXCRDOUT: - /*DPRINTF("p[%d]=oT[%d]\n", i, reg);*/ + /*TRACE("p[%d]=oT[%d]\n", i, reg);*/ p[i] = &output->oT[reg]; break; default: @@ -655,17 +686,17 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs if (i > 0) { /* input reg */ DWORD swizzle = (pToken[i] & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT; - UINT isNegative = ((*pToken & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG); + UINT isNegative = ((pToken[i] & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG); if (!isNegative && (D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) { - /*DPRINTF("p[%d] not swizzled\n", i);*/ + /*TRACE("p[%d] not swizzled\n", i);*/ p_send[i] = p[i]; } else { DWORD swizzle_x = swizzle & 0x03; DWORD swizzle_y = (swizzle >> 2) & 0x03; DWORD swizzle_z = (swizzle >> 4) & 0x03; DWORD swizzle_w = (swizzle >> 6) & 0x03; - /*DPRINTF("p[%d] swizzled\n", i);*/ + /*TRACE("p[%d] swizzled\n", i);*/ float* tt = (float*) p[i]; s[i].x = (isNegative) ? -tt[swizzle_x] : tt[swizzle_x]; s[i].y = (isNegative) ? -tt[swizzle_y] : tt[swizzle_y]; @@ -714,7 +745,7 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs if (pToken[0] & D3DSP_WRITEMASK_3) p[0]->w = d.w; } - /* +#if 0 TRACE_VECTOR(output->oPos); TRACE_VECTOR(output->oD[0]); TRACE_VECTOR(output->oD[1]); @@ -725,11 +756,26 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs TRACE_VECTOR(R[2]); TRACE_VECTOR(R[3]); TRACE_VECTOR(R[4]); - */ + TRACE_VECTOR(R[5]); +#endif /* to next opcode token */ pToken += curOpcode->num_params; } + +#if 0 + TRACE_VECTOR(output->oPos); + TRACE_VECTOR(output->oD[0]); + TRACE_VECTOR(output->oD[1]); + TRACE_VECTOR(output->oT[0]); + TRACE_VECTOR(output->oT[1]); + TRACE_VECTOR(R[0]); + TRACE_VECTOR(R[1]); + TRACE_VECTOR(R[2]); + TRACE_VECTOR(R[3]); + TRACE_VECTOR(R[4]); + TRACE_VECTOR(R[5]); +#endif } return D3D_OK; } diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index de5c0196b12..8a3535f5246 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -105,8 +105,56 @@ DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 ifac FIXME("(%p) : stub\n", This); return D3D_OK; } void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) { + int i; ICOM_THIS(IDirect3DTexture8Impl,iface); - FIXME("(%p) : stub\n", This); + TRACE("(%p) : About to load texture\n", This); + for (i=0; ilevels; i++) + { + + if (i==0 && This->surfaces[i]->textureName != 0 && This->Dirty == FALSE) { + glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName); + checkGLcall("glBindTexture"); + TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName); + /* No need to walk through all mip-map levels, since already all assigned */ + i = This->levels; + + } else { + if (i==0) { + + if (This->surfaces[i]->textureName == 0) { + glGenTextures(1, &This->surfaces[i]->textureName); + checkGLcall("glGenTextures"); + TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName); + } + + glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName); + checkGLcall("glBindTexture"); + + TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels-1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels-1); + checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)"); + + } + TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%lx, Mem=%p\n", + GL_TEXTURE_2D, i, fmt2glintFmt(This->format), This->surfaces[i]->myDesc.Width, + This->surfaces[i]->myDesc.Height, 0, fmt2glFmt(This->format),fmt2glType(This->format), + This->surfaces[i]->allocatedMemory); + glTexImage2D(GL_TEXTURE_2D, i, + fmt2glintFmt(This->format), + This->surfaces[i]->myDesc.Width, + This->surfaces[i]->myDesc.Height, + 0, + fmt2glFmt(This->format), + fmt2glType(This->format), + This->surfaces[i]->allocatedMemory + ); + checkGLcall("glTexImage2D"); + + /* Removed glTexParameterf now TextureStageStates are initialized at startup */ + This->Dirty = FALSE; + } + } + return; } D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) { ICOM_THIS(IDirect3DTexture8Impl,iface);