Tidy up some comments and formatting.

This commit is contained in:
Oliver Stieber 2005-07-13 14:15:54 +00:00 committed by Alexandre Julliard
parent 1ed9bac896
commit 9253e0e39c
18 changed files with 1094 additions and 1071 deletions

View File

@ -278,6 +278,7 @@ UINT WINAPI IWineD3DBaseTextureImpl_GetTextureDimensions(IWineD3DBaseTexture *if
static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl = static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
{ {
/* IUnknown */
IWineD3DBaseTextureImpl_QueryInterface, IWineD3DBaseTextureImpl_QueryInterface,
IWineD3DBaseTextureImpl_AddRef, IWineD3DBaseTextureImpl_AddRef,
IWineD3DBaseTextureImpl_Release, IWineD3DBaseTextureImpl_Release,

View File

@ -78,7 +78,7 @@ ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
int i,j; int i,j;
TRACE("(%p) : Cleaning up\n",This); TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
if (This->surfaces[j][i] != NULL) { if (This->surfaces[j][i] != NULL) {
/* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */ /* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
IUnknown* surfaceParent; IUnknown* surfaceParent;
@ -132,13 +132,13 @@ void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
unsigned int i,j; unsigned int i,j;
BOOL setGlTextureDesc = FALSE; BOOL setGlTextureDesc = FALSE;
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface; IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty); TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty);
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE; if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
IWineD3DCubeTexture_BindTexture(iface); IWineD3DCubeTexture_BindTexture(iface);
ENTER_GL(); ENTER_GL();
/* If were dirty then reload the surfaces */ /* If were dirty then reload the surfaces */
if (This->baseTexture.dirty != FALSE) { if (This->baseTexture.dirty != FALSE) {
@ -215,7 +215,7 @@ HRESULT WINAPI IWineD3DCubeTextureImpl_UnBindTexture(IWineD3DCubeTexture *iface)
UINT WINAPI IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture *iface){ UINT WINAPI IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture *iface){
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface; IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) \n", This); TRACE("(%p) \n", This);
return GLTEXTURECUBEMAP; return GLTEXTURECUBEMAP;
} }
@ -224,7 +224,7 @@ UINT WINAPI IWineD3DCubeTextureImpl_GetTextureDimensions(IWineD3DCubeTexture *if
******************************************* */ ******************************************* */
HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) { HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface; IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
if (Level < This->baseTexture.levels) { if (Level < This->baseTexture.levels) {
TRACE("(%p) level (%d)\n", This, Level); TRACE("(%p) level (%d)\n", This, Level);
return IWineD3DSurface_GetDesc((IWineD3DSurface *) This->surfaces[0][Level], pDesc); return IWineD3DSurface_GetDesc((IWineD3DSurface *) This->surfaces[0][Level], pDesc);
@ -277,7 +277,7 @@ HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface, D3
HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) { HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface; IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType); TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
return IWineD3DSurface_AddDirtyRect((IWineD3DSurface *) This->surfaces[FaceType][0], pDirtyRect); return IWineD3DSurface_AddDirtyRect((IWineD3DSurface *) This->surfaces[FaceType][0], pDirtyRect);
} }
@ -298,7 +298,7 @@ const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
IWineD3DCubeTextureImpl_GetPriority, IWineD3DCubeTextureImpl_GetPriority,
IWineD3DCubeTextureImpl_PreLoad, IWineD3DCubeTextureImpl_PreLoad,
IWineD3DCubeTextureImpl_GetType, IWineD3DCubeTextureImpl_GetType,
/*base texture */ /* IWineD3DBaseTexture */
IWineD3DCubeTextureImpl_SetLOD, IWineD3DCubeTextureImpl_SetLOD,
IWineD3DCubeTextureImpl_GetLOD, IWineD3DCubeTextureImpl_GetLOD,
IWineD3DCubeTextureImpl_GetLevelCount, IWineD3DCubeTextureImpl_GetLevelCount,
@ -309,8 +309,8 @@ const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
IWineD3DCubeTextureImpl_GetDirty, IWineD3DCubeTextureImpl_GetDirty,
IWineD3DCubeTextureImpl_BindTexture, IWineD3DCubeTextureImpl_BindTexture,
IWineD3DCubeTextureImpl_UnBindTexture, IWineD3DCubeTextureImpl_UnBindTexture,
IWineD3DCubeTextureImpl_GetTextureDimensions, IWineD3DCubeTextureImpl_GetTextureDimensions,
/* cube texture */ /* IWineD3DCubeTexture */
IWineD3DCubeTextureImpl_GetLevelDesc, IWineD3DCubeTextureImpl_GetLevelDesc,
IWineD3DCubeTextureImpl_GetCubeMapSurface, IWineD3DCubeTextureImpl_GetCubeMapSurface,
IWineD3DCubeTextureImpl_LockRect, IWineD3DCubeTextureImpl_LockRect,

File diff suppressed because it is too large Load Diff

View File

@ -60,9 +60,9 @@ inline static Display *get_display( HDC hdc )
/** /**
* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
* ie there is no GL Context - Get a default rendering context to enable the * ie there is no GL Context - Get a default rendering context to enable the
* function query some info from GL * function query some info from GL
*/ */
static WineD3D_Context* WineD3D_CreateFakeGLContext(void) { static WineD3D_Context* WineD3D_CreateFakeGLContext(void) {
static WineD3D_Context ctx = { NULL, NULL, NULL, 0, 0 }; static WineD3D_Context ctx = { NULL, NULL, NULL, 0, 0 };
WineD3D_Context* ret = NULL; WineD3D_Context* ret = NULL;
@ -76,7 +76,7 @@ static WineD3D_Context* WineD3D_CreateFakeGLContext(void) {
BOOL failed = FALSE; BOOL failed = FALSE;
int num; int num;
XWindowAttributes win_attr; XWindowAttributes win_attr;
TRACE_(d3d_caps)("Creating Fake GL Context\n"); TRACE_(d3d_caps)("Creating Fake GL Context\n");
ctx.drawable = (Drawable) GetPropA(GetDesktopWindow(), "__wine_x11_whole_window"); ctx.drawable = (Drawable) GetPropA(GetDesktopWindow(), "__wine_x11_whole_window");
@ -85,7 +85,7 @@ static WineD3D_Context* WineD3D_CreateFakeGLContext(void) {
device_context = GetDC(0); device_context = GetDC(0);
ctx.display = get_display(device_context); ctx.display = get_display(device_context);
ReleaseDC(0, device_context); ReleaseDC(0, device_context);
/* Get the X visual */ /* Get the X visual */
ENTER_GL(); ENTER_GL();
if (XGetWindowAttributes(ctx.display, ctx.drawable, &win_attr)) { if (XGetWindowAttributes(ctx.display, ctx.drawable, &win_attr)) {
@ -100,26 +100,26 @@ static WineD3D_Context* WineD3D_CreateFakeGLContext(void) {
WARN_(d3d_caps)("Error creating visual info for capabilities initialization\n"); WARN_(d3d_caps)("Error creating visual info for capabilities initialization\n");
failed = TRUE; failed = TRUE;
} }
/* Create a GL context */ /* Create a GL context */
if (!failed) { if (!failed) {
ctx.glCtx = glXCreateContext(ctx.display, ctx.visInfo, NULL, GL_TRUE); ctx.glCtx = glXCreateContext(ctx.display, ctx.visInfo, NULL, GL_TRUE);
if (ctx.glCtx == NULL) { if (ctx.glCtx == NULL) {
LEAVE_GL(); LEAVE_GL();
WARN_(d3d_caps)("Error creating default context for capabilities initialization\n"); WARN_(d3d_caps)("Error creating default context for capabilities initialization\n");
failed = TRUE; failed = TRUE;
} }
} }
/* Make it the current GL context */ /* Make it the current GL context */
if (!failed && glXMakeCurrent(ctx.display, ctx.drawable, ctx.glCtx) == False) { if (!failed && glXMakeCurrent(ctx.display, ctx.drawable, ctx.glCtx) == False) {
glXDestroyContext(ctx.display, ctx.glCtx); glXDestroyContext(ctx.display, ctx.glCtx);
LEAVE_GL(); LEAVE_GL();
WARN_(d3d_caps)("Error setting default context as current for capabilities initialization\n"); WARN_(d3d_caps)("Error setting default context as current for capabilities initialization\n");
failed = TRUE; failed = TRUE;
} }
/* It worked! Wow... */ /* It worked! Wow... */
if (!failed) { if (!failed) {
gotContext = TRUE; gotContext = TRUE;
@ -158,15 +158,15 @@ HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *p
{ {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
/* FIXME: This needs to extend an IWineD3DBaseObject */ /* FIXME: This needs to extend an IWineD3DBaseObject */
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj); TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown) if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DDevice)) { || IsEqualGUID(riid, &IID_IWineD3DDevice)) {
IUnknown_AddRef(iface); IUnknown_AddRef(iface);
*ppobj = This; *ppobj = This;
return D3D_OK; return D3D_OK;
} }
return E_NOINTERFACE; return E_NOINTERFACE;
} }
@ -186,7 +186,7 @@ ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
} }
@ -256,17 +256,17 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
if (*gl_string_cursor) { if (*gl_string_cursor) {
char tmp[16]; char tmp[16];
int cursor = 0; int cursor = 0;
while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') { while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') {
tmp[cursor++] = *gl_string_cursor; tmp[cursor++] = *gl_string_cursor;
++gl_string_cursor; ++gl_string_cursor;
} }
tmp[cursor] = 0; tmp[cursor] = 0;
major = atoi(tmp); major = atoi(tmp);
if (*gl_string_cursor != '.') WARN_(d3d_caps)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string)); if (*gl_string_cursor != '.') WARN_(d3d_caps)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string));
++gl_string_cursor; ++gl_string_cursor;
while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') { while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') {
tmp[cursor++] = *gl_string_cursor; tmp[cursor++] = *gl_string_cursor;
++gl_string_cursor; ++gl_string_cursor;
@ -275,14 +275,14 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
minor = atoi(tmp); minor = atoi(tmp);
} }
break; break;
case VENDOR_ATI: case VENDOR_ATI:
major = minor = 0; major = minor = 0;
gl_string_cursor = strchr(gl_string, '-'); gl_string_cursor = strchr(gl_string, '-');
if (gl_string_cursor) { if (gl_string_cursor) {
int error = 0; int error = 0;
gl_string_cursor++; gl_string_cursor++;
/* Check if version number is of the form x.y.z */ /* Check if version number is of the form x.y.z */
if (*gl_string_cursor > '9' && *gl_string_cursor < '0') if (*gl_string_cursor > '9' && *gl_string_cursor < '0')
error = 1; error = 1;
@ -292,31 +292,31 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
error = 1; error = 1;
if (!error && *(gl_string_cursor+1) != '.' && *(gl_string_cursor+3) != '.') if (!error && *(gl_string_cursor+1) != '.' && *(gl_string_cursor+3) != '.')
error = 1; error = 1;
/* Mark version number as malformed */ /* Mark version number as malformed */
if (error) if (error)
gl_string_cursor = 0; gl_string_cursor = 0;
} }
if (!gl_string_cursor) if (!gl_string_cursor)
WARN_(d3d_caps)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string)); WARN_(d3d_caps)("malformed GL_VERSION (%s)\n", debugstr_a(gl_string));
else { else {
major = *gl_string_cursor - '0'; major = *gl_string_cursor - '0';
minor = (*(gl_string_cursor+2) - '0') * 256 + (*(gl_string_cursor+4) - '0'); minor = (*(gl_string_cursor+2) - '0') * 256 + (*(gl_string_cursor+4) - '0');
} }
break; break;
default: default:
major = 0; major = 0;
minor = 9; minor = 9;
} }
gl_info->gl_driver_version = MAKEDWORD_VERSION(major, minor); gl_info->gl_driver_version = MAKEDWORD_VERSION(major, minor);
TRACE_(d3d_caps)("found GL_VERSION (%s)->(0x%08lx)\n", debugstr_a(gl_string), gl_info->gl_driver_version); TRACE_(d3d_caps)("found GL_VERSION (%s)->(0x%08lx)\n", debugstr_a(gl_string), gl_info->gl_driver_version);
/* Fill in the renderer information */ /* Fill in the renderer information */
gl_string = glGetString(GL_RENDERER); gl_string = glGetString(GL_RENDERER);
strcpy(gl_info->gl_renderer, gl_string); strcpy(gl_info->gl_renderer, gl_string);
switch (gl_info->gl_vendor) { switch (gl_info->gl_vendor) {
case VENDOR_NVIDIA: case VENDOR_NVIDIA:
if (strstr(gl_info->gl_renderer, "GeForce4 Ti")) { if (strstr(gl_info->gl_renderer, "GeForce4 Ti")) {
@ -327,7 +327,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
gl_info->gl_card = CARD_NVIDIA_GEFORCE4_TI4600; gl_info->gl_card = CARD_NVIDIA_GEFORCE4_TI4600;
} }
break; break;
case VENDOR_ATI: case VENDOR_ATI:
if (strstr(gl_info->gl_renderer, "RADEON 9800 PRO")) { if (strstr(gl_info->gl_renderer, "RADEON 9800 PRO")) {
gl_info->gl_card = CARD_ATI_RADEON_9800PRO; gl_info->gl_card = CARD_ATI_RADEON_9800PRO;
@ -337,7 +337,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
gl_info->gl_card = CARD_ATI_RADEON_8500; gl_info->gl_card = CARD_ATI_RADEON_8500;
} }
break; break;
default: default:
gl_info->gl_card = CARD_WINE; gl_info->gl_card = CARD_WINE;
break; break;
@ -384,10 +384,10 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
/* Parse the gl supported features, in theory enabling parts of our code appropriately */ /* Parse the gl supported features, in theory enabling parts of our code appropriately */
GL_Extensions = glGetString(GL_EXTENSIONS); GL_Extensions = glGetString(GL_EXTENSIONS);
TRACE_(d3d_caps)("GL_Extensions reported:\n"); TRACE_(d3d_caps)("GL_Extensions reported:\n");
if (NULL == GL_Extensions) { if (NULL == GL_Extensions) {
ERR(" GL_Extensions returns NULL\n"); ERR(" GL_Extensions returns NULL\n");
} else { } else {
while (*GL_Extensions != 0x00) { while (*GL_Extensions != 0x00) {
const char *Start = GL_Extensions; const char *Start = GL_Extensions;
@ -401,7 +401,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
TRACE_(d3d_caps)("- %s\n", ThisExtn); TRACE_(d3d_caps)("- %s\n", ThisExtn);
/** /**
* ARB * ARB
*/ */
if (strcmp(ThisExtn, "GL_ARB_fragment_program") == 0) { if (strcmp(ThisExtn, "GL_ARB_fragment_program") == 0) {
gl_info->ps_arb_version = PS_VERSION_11; gl_info->ps_arb_version = PS_VERSION_11;
@ -506,7 +506,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
gl_info->supported[EXT_VERTEX_WEIGHTING] = TRUE; gl_info->supported[EXT_VERTEX_WEIGHTING] = TRUE;
/** /**
* NVIDIA * NVIDIA
*/ */
} else if (strstr(ThisExtn, "GL_NV_fog_distance")) { } else if (strstr(ThisExtn, "GL_NV_fog_distance")) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Fog Distance support\n"); TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Fog Distance support\n");
@ -568,15 +568,15 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
if (display != NULL) { if (display != NULL) {
GLX_Extensions = glXQueryExtensionsString(display, DefaultScreen(display)); GLX_Extensions = glXQueryExtensionsString(display, DefaultScreen(display));
TRACE_(d3d_caps)("GLX_Extensions reported:\n"); TRACE_(d3d_caps)("GLX_Extensions reported:\n");
if (NULL == GLX_Extensions) { if (NULL == GLX_Extensions) {
ERR(" GLX_Extensions returns NULL\n"); ERR(" GLX_Extensions returns NULL\n");
} else { } else {
while (*GLX_Extensions != 0x00) { while (*GLX_Extensions != 0x00) {
const char *Start = GLX_Extensions; const char *Start = GLX_Extensions;
char ThisExtn[256]; char ThisExtn[256];
memset(ThisExtn, 0x00, sizeof(ThisExtn)); memset(ThisExtn, 0x00, sizeof(ThisExtn));
while (*GLX_Extensions != ' ' && *GLX_Extensions != 0x00) { while (*GLX_Extensions != ' ' && *GLX_Extensions != 0x00) {
GLX_Extensions++; GLX_Extensions++;
@ -630,7 +630,7 @@ HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) {
return D3D_OK; return D3D_OK;
} }
/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
of the same bpp but different resolutions */ of the same bpp but different resolutions */
/* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */ /* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
@ -657,18 +657,18 @@ UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter,
j++; j++;
switch (Format) switch (Format)
{ {
case D3DFMT_UNKNOWN: case D3DFMT_UNKNOWN:
i++; i++;
break; break;
case D3DFMT_X8R8G8B8: case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8: case D3DFMT_A8R8G8B8:
if (min(DevModeW.dmBitsPerPel, bpp) == 32) i++; if (min(DevModeW.dmBitsPerPel, bpp) == 32) i++;
if (min(DevModeW.dmBitsPerPel, bpp) == 24) i++; if (min(DevModeW.dmBitsPerPel, bpp) == 24) i++;
break; break;
case D3DFMT_X1R5G5B5: case D3DFMT_X1R5G5B5:
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
if (min(DevModeW.dmBitsPerPel, bpp) == 16) i++; if (min(DevModeW.dmBitsPerPel, bpp) == 16) i++;
break; break;
default: default:
/* Skip other modes as they do not match requested format */ /* Skip other modes as they do not match requested format */
@ -693,7 +693,7 @@ HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINE
TRACE_(d3d_caps)("(%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s)\n", This, Adapter, Mode, pMode, debug_d3dformat(Format)); TRACE_(d3d_caps)("(%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s)\n", This, Adapter, Mode, pMode, debug_d3dformat(Format));
/* Validate the parameters as much as possible */ /* Validate the parameters as much as possible */
if (NULL == pMode || if (NULL == pMode ||
Adapter >= IWineD3DImpl_GetAdapterCount(iface) || Adapter >= IWineD3DImpl_GetAdapterCount(iface) ||
Mode >= IWineD3DImpl_GetAdapterModeCount(iface, Adapter, Format)) { Mode >= IWineD3DImpl_GetAdapterModeCount(iface, Adapter, Format)) {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
@ -703,7 +703,7 @@ HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINE
#if !defined( DEBUG_SINGLE_MODE ) #if !defined( DEBUG_SINGLE_MODE )
DEVMODEW DevModeW; DEVMODEW DevModeW;
int ModeIdx = 0; int ModeIdx = 0;
/* Work out the current screen bpp */ /* Work out the current screen bpp */
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
int bpp = GetDeviceCaps(hdc, BITSPIXEL); int bpp = GetDeviceCaps(hdc, BITSPIXEL);
@ -711,7 +711,7 @@ HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINE
/* If we are filtering to a specific format, then need to skip all unrelated /* If we are filtering to a specific format, then need to skip all unrelated
modes, but if mode is irrelevant, then we can use the index directly */ modes, but if mode is irrelevant, then we can use the index directly */
if (Format == D3DFMT_UNKNOWN) if (Format == D3DFMT_UNKNOWN)
{ {
ModeIdx = Mode; ModeIdx = Mode;
} else { } else {
@ -724,18 +724,18 @@ HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINE
j++; j++;
switch (Format) switch (Format)
{ {
case D3DFMT_UNKNOWN: case D3DFMT_UNKNOWN:
i++; i++;
break; break;
case D3DFMT_X8R8G8B8: case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8: case D3DFMT_A8R8G8B8:
if (min(DevModeWtmp.dmBitsPerPel, bpp) == 32) i++; if (min(DevModeWtmp.dmBitsPerPel, bpp) == 32) i++;
if (min(DevModeWtmp.dmBitsPerPel, bpp) == 24) i++; if (min(DevModeWtmp.dmBitsPerPel, bpp) == 24) i++;
break; break;
case D3DFMT_X1R5G5B5: case D3DFMT_X1R5G5B5:
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
if (min(DevModeWtmp.dmBitsPerPel, bpp) == 16) i++; if (min(DevModeWtmp.dmBitsPerPel, bpp) == 16) i++;
break; break;
default: default:
/* Skip other modes as they do not match requested format */ /* Skip other modes as they do not match requested format */
@ -746,7 +746,7 @@ HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINE
} }
/* Now get the display mode via the calculated index */ /* Now get the display mode via the calculated index */
if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0)) if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0))
{ {
pMode->Width = DevModeW.dmPelsWidth; pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight; pMode->Height = DevModeW.dmPelsHeight;
@ -782,10 +782,10 @@ HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, WINE
pMode->Width = 800; pMode->Width = 800;
pMode->Height = 600; pMode->Height = 600;
pMode->RefreshRate = D3DADAPTER_DEFAULT; pMode->RefreshRate = D3DADAPTER_DEFAULT;
pMode->Format = (Format==D3DFMT_UNKNOWN)?D3DFMT_A8R8G8B8:Format; pMode->Format = (Format == D3DFMT_UNKNOWN) ? D3DFMT_A8R8G8B8 : Format;
bpp = 32; bpp = 32;
#endif #endif
TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode->Width, pMode->Height, TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode->Width, pMode->Height,
pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format), bpp); pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format), bpp);
} else { } else {
@ -799,7 +799,7 @@ HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT Adapter,
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode); TRACE_(d3d_caps)("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode);
if (NULL == pMode || if (NULL == pMode ||
Adapter >= IWineD3D_GetAdapterCount(iface)) { Adapter >= IWineD3D_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
@ -849,7 +849,7 @@ static Display * WINAPI IWineD3DImpl_GetAdapterDisplay(IWineD3D *iface, UINT Ada
/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER, /* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
and fields being inserted in the middle, a new structure is used in place */ and fields being inserted in the middle, a new structure is used in place */
HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags, HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags,
WINED3DADAPTER_IDENTIFIER* pIdentifier) { WINED3DADAPTER_IDENTIFIER* pIdentifier) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
@ -860,10 +860,10 @@ HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter,
} }
if (Adapter == 0) { /* Display - only device supported for now */ if (Adapter == 0) { /* Display - only device supported for now */
BOOL isGLInfoValid = This->isGLInfoValid; BOOL isGLInfoValid = This->isGLInfoValid;
/* FillGLCaps updates gl_info, but we only want to store and /* FillGLCaps updates gl_info, but we only want to store and
reuse the values once we have a context which is valid. Values from reuse the values once we have a context which is valid. Values from
a temporary context may differ from the final ones */ a temporary context may differ from the final ones */
if (isGLInfoValid == FALSE) { if (isGLInfoValid == FALSE) {
@ -927,7 +927,7 @@ static BOOL IWineD3DImpl_IsGLXFBConfigCompatibleWithRenderFmt(WineD3D_Context* c
gl_test = glXGetFBConfigAttrib(ctx->display, cfgs, GLX_BUFFER_SIZE, &buf_sz); gl_test = glXGetFBConfigAttrib(ctx->display, cfgs, GLX_BUFFER_SIZE, &buf_sz);
switch (Format) { switch (Format) {
case WINED3DFMT_X8R8G8B8: case WINED3DFMT_X8R8G8B8:
case WINED3DFMT_R8G8B8: case WINED3DFMT_R8G8B8:
if (8 == rb && 8 == gb && 8 == bb) return TRUE; if (8 == rb && 8 == gb && 8 == bb) return TRUE;
break; break;
@ -962,7 +962,7 @@ static BOOL IWineD3DImpl_IsGLXFBConfigCompatibleWithRenderFmt(WineD3D_Context* c
static BOOL IWineD3DImpl_IsGLXFBConfigCompatibleWithDepthFmt(WineD3D_Context* ctx, GLXFBConfig cfgs, WINED3DFORMAT Format) { static BOOL IWineD3DImpl_IsGLXFBConfigCompatibleWithDepthFmt(WineD3D_Context* ctx, GLXFBConfig cfgs, WINED3DFORMAT Format) {
int gl_test; int gl_test;
int db, sb; int db, sb;
gl_test = glXGetFBConfigAttrib(ctx->display, cfgs, GLX_DEPTH_SIZE, &db); gl_test = glXGetFBConfigAttrib(ctx->display, cfgs, GLX_DEPTH_SIZE, &db);
gl_test = glXGetFBConfigAttrib(ctx->display, cfgs, GLX_STENCIL_SIZE, &sb); gl_test = glXGetFBConfigAttrib(ctx->display, cfgs, GLX_STENCIL_SIZE, &sb);
@ -996,16 +996,16 @@ static BOOL IWineD3DImpl_IsGLXFBConfigCompatibleWithDepthFmt(WineD3D_Context* ct
return FALSE; return FALSE;
} }
HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType,
WINED3DFORMAT AdapterFormat, WINED3DFORMAT AdapterFormat,
WINED3DFORMAT RenderTargetFormat, WINED3DFORMAT RenderTargetFormat,
WINED3DFORMAT DepthStencilFormat) { WINED3DFORMAT DepthStencilFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n", WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
This, Adapter, This, Adapter,
DeviceType, debug_d3ddevicetype(DeviceType), DeviceType, debug_d3ddevicetype(DeviceType),
AdapterFormat, debug_d3dformat(AdapterFormat), AdapterFormat, debug_d3dformat(AdapterFormat),
RenderTargetFormat, debug_d3dformat(RenderTargetFormat), RenderTargetFormat, debug_d3dformat(RenderTargetFormat),
DepthStencilFormat, debug_d3dformat(DepthStencilFormat)); DepthStencilFormat, debug_d3dformat(DepthStencilFormat));
if (Adapter >= IWineD3D_GetAdapterCount(iface)) { if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
@ -1017,66 +1017,66 @@ HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter
int nCfgs = 0; int nCfgs = 0;
int it; int it;
HRESULT hr = D3DERR_NOTAVAILABLE; HRESULT hr = D3DERR_NOTAVAILABLE;
WineD3D_Context* ctx = WineD3D_CreateFakeGLContext(); WineD3D_Context* ctx = WineD3D_CreateFakeGLContext();
if (NULL != ctx) { if (NULL != ctx) {
cfgs = glXGetFBConfigs(ctx->display, DefaultScreen(ctx->display), &nCfgs); cfgs = glXGetFBConfigs(ctx->display, DefaultScreen(ctx->display), &nCfgs);
for (it = 0; it < nCfgs; ++it) { for (it = 0; it < nCfgs; ++it) {
if (IWineD3DImpl_IsGLXFBConfigCompatibleWithRenderFmt(ctx, cfgs[it], RenderTargetFormat)) { if (IWineD3DImpl_IsGLXFBConfigCompatibleWithRenderFmt(ctx, cfgs[it], RenderTargetFormat)) {
if (IWineD3DImpl_IsGLXFBConfigCompatibleWithDepthFmt(ctx, cfgs[it], DepthStencilFormat)) { if (IWineD3DImpl_IsGLXFBConfigCompatibleWithDepthFmt(ctx, cfgs[it], DepthStencilFormat)) {
hr = D3D_OK; hr = D3D_OK;
break ; break ;
} }
} }
} }
XFree(cfgs); XFree(cfgs);
WineD3D_ReleaseFakeGLContext(ctx); WineD3D_ReleaseFakeGLContext(ctx);
return hr; return hr;
} }
} }
return D3DERR_NOTAVAILABLE; return D3DERR_NOTAVAILABLE;
} }
HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType,
WINED3DFORMAT SurfaceFormat, WINED3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) { BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n", TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
This, This,
Adapter, Adapter,
DeviceType, debug_d3ddevicetype(DeviceType), DeviceType, debug_d3ddevicetype(DeviceType),
SurfaceFormat, debug_d3dformat(SurfaceFormat), SurfaceFormat, debug_d3dformat(SurfaceFormat),
Windowed, Windowed,
MultiSampleType, MultiSampleType,
pQualityLevels); pQualityLevels);
if (Adapter >= IWineD3D_GetAdapterCount(iface)) { if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
if (pQualityLevels != NULL) { if (pQualityLevels != NULL) {
static int s_single_shot = 0; static int s_single_shot = 0;
if (!s_single_shot) { if (!s_single_shot) {
FIXME("Quality levels unsupported at present\n"); FIXME("Quality levels unsupported at present\n");
s_single_shot = 1; s_single_shot = 1;
} }
*pQualityLevels = 1; /* Guess at a value! */ *pQualityLevels = 1; /* Guess at a value! */
} }
if (D3DMULTISAMPLE_NONE == MultiSampleType) return D3D_OK; if (D3DMULTISAMPLE_NONE == MultiSampleType) return D3D_OK;
return D3DERR_NOTAVAILABLE; return D3DERR_NOTAVAILABLE;
} }
HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, D3DDEVTYPE CheckType, HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, D3DDEVTYPE CheckType,
WINED3DFORMAT DisplayFormat, WINED3DFORMAT BackBufferFormat, BOOL Windowed) { WINED3DFORMAT DisplayFormat, WINED3DFORMAT BackBufferFormat, BOOL Windowed) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n", TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
This, This,
Adapter, Adapter,
CheckType, debug_d3ddevicetype(CheckType), CheckType, debug_d3ddevicetype(CheckType),
DisplayFormat, debug_d3dformat(DisplayFormat), DisplayFormat, debug_d3dformat(DisplayFormat),
BackBufferFormat, debug_d3dformat(BackBufferFormat), BackBufferFormat, debug_d3dformat(BackBufferFormat),
@ -1091,20 +1091,20 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, D3DDE
int nCfgs = 0; int nCfgs = 0;
int it; int it;
HRESULT hr = D3DERR_NOTAVAILABLE; HRESULT hr = D3DERR_NOTAVAILABLE;
WineD3D_Context* ctx = WineD3D_CreateFakeGLContext(); WineD3D_Context* ctx = WineD3D_CreateFakeGLContext();
if (NULL != ctx) { if (NULL != ctx) {
cfgs = glXGetFBConfigs(ctx->display, DefaultScreen(ctx->display), &nCfgs); cfgs = glXGetFBConfigs(ctx->display, DefaultScreen(ctx->display), &nCfgs);
for (it = 0; it < nCfgs; ++it) { for (it = 0; it < nCfgs; ++it) {
if (IWineD3DImpl_IsGLXFBConfigCompatibleWithRenderFmt(ctx, cfgs[it], DisplayFormat)) { if (IWineD3DImpl_IsGLXFBConfigCompatibleWithRenderFmt(ctx, cfgs[it], DisplayFormat)) {
hr = D3D_OK; hr = D3D_OK;
break ; break ;
} }
} }
XFree(cfgs); XFree(cfgs);
WineD3D_ReleaseFakeGLContext(ctx); WineD3D_ReleaseFakeGLContext(ctx);
return hr; return hr;
} }
} }
@ -1112,15 +1112,15 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, D3DDE
} }
HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType,
WINED3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) { WINED3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s)) ", TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), AdptFmt:(%u,%s), Use:(%lu,%s), ResTyp:(%x,%s), CheckFmt:(%u,%s)) ",
This, This,
Adapter, Adapter,
DeviceType, debug_d3ddevicetype(DeviceType), DeviceType, debug_d3ddevicetype(DeviceType),
AdapterFormat, debug_d3dformat(AdapterFormat), AdapterFormat, debug_d3dformat(AdapterFormat),
Usage, debug_d3dusage(Usage), Usage, debug_d3dusage(Usage),
RType, debug_d3dresourcetype(RType), RType, debug_d3dresourcetype(RType),
CheckFormat, debug_d3dformat(CheckFormat)); CheckFormat, debug_d3dformat(CheckFormat));
if (Adapter >= IWineD3D_GetAdapterCount(iface)) { if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
@ -1141,16 +1141,16 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3D
switch (CheckFormat) { switch (CheckFormat) {
/***** /*****
* check supported using GL_SUPPORT * check supported using GL_SUPPORT
*/ */
case D3DFMT_DXT1: case D3DFMT_DXT1:
case D3DFMT_DXT2: case D3DFMT_DXT2:
case D3DFMT_DXT3: case D3DFMT_DXT3:
case D3DFMT_DXT4: case D3DFMT_DXT4:
case D3DFMT_DXT5: case D3DFMT_DXT5:
/***** /*****
* supported * supported
*/ */
/*case D3DFMT_R5G6B5: */ /*case D3DFMT_R5G6B5: */
/*case D3DFMT_X1R5G5B5:*/ /*case D3DFMT_X1R5G5B5:*/
@ -1158,7 +1158,7 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3D
/*case D3DFMT_A4R4G4B4:*/ /*case D3DFMT_A4R4G4B4:*/
/***** /*****
* unsupported * unsupported
*/ */
/* color buffer */ /* color buffer */
@ -1185,7 +1185,7 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3D
case D3DFMT_W11V11U10: case D3DFMT_W11V11U10:
/**** /****
* currently hard to support * currently hard to support
*/ */
case D3DFMT_UYVY: case D3DFMT_UYVY:
case D3DFMT_YUY2: case D3DFMT_YUY2:
@ -1201,21 +1201,21 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3D
return D3D_OK; return D3D_OK;
} }
HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType,
WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) { WINED3DFORMAT SourceFormat, WINED3DFORMAT TargetFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
FIXME_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))", FIXME_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%u,%s), SrcFmt:(%u,%s), TgtFmt:(%u,%s))",
This, This,
Adapter, Adapter,
DeviceType, debug_d3ddevicetype(DeviceType), DeviceType, debug_d3ddevicetype(DeviceType),
SourceFormat, debug_d3dformat(SourceFormat), SourceFormat, debug_d3dformat(SourceFormat),
TargetFormat, debug_d3dformat(TargetFormat)); TargetFormat, debug_d3dformat(TargetFormat));
return D3D_OK; return D3D_OK;
} }
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
subset of a D3DCAPS9 structure. However, it has to come via a void * subset of a D3DCAPS9 structure. However, it has to come via a void *
as the d3d8 interface cannot import the d3d9 header */ as the d3d8 interface cannot import the d3d9 header */
HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS* pCaps) { HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS* pCaps) {
@ -1416,12 +1416,12 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVT
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA | D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM; D3DTEXOPCAPS_BLENDTEXTUREALPHAPM;
} }
#if 0 #if 0
*pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP; *pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP;
/* FIXME: Add /* FIXME: Add
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
D3DTEXOPCAPS_PREMODULATE */ D3DTEXOPCAPS_PREMODULATE */
#endif #endif
*pCaps->MaxTextureBlendStages = GL_LIMITS(textures); *pCaps->MaxTextureBlendStages = GL_LIMITS(textures);
@ -1443,8 +1443,8 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVT
*pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS | *pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
D3DVTXPCAPS_MATERIALSOURCE7 | D3DVTXPCAPS_MATERIALSOURCE7 |
D3DVTXPCAPS_POSITIONALLIGHTS | D3DVTXPCAPS_POSITIONALLIGHTS |
D3DVTXPCAPS_LOCALVIEWER | D3DVTXPCAPS_LOCALVIEWER |
D3DVTXPCAPS_TEXGEN; D3DVTXPCAPS_TEXGEN;
/* FIXME: Add /* FIXME: Add
@ -1465,15 +1465,15 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVT
*pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS; *pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS;
} }
} else { } else {
*pCaps->VertexShaderVersion = 0; *pCaps->VertexShaderVersion = 0;
*pCaps->MaxVertexShaderConst = 0; *pCaps->MaxVertexShaderConst = 0;
} }
if ((ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType != D3DDEVTYPE_REF)) { if ((ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType != D3DDEVTYPE_REF)) {
*pCaps->PixelShaderVersion = D3DPS_VERSION(1,4); *pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
*pCaps->PixelShader1xMaxValue = 1.0; *pCaps->PixelShader1xMaxValue = 1.0;
} else { } else {
*pCaps->PixelShaderVersion = 0; *pCaps->PixelShaderVersion = 0;
*pCaps->PixelShader1xMaxValue = 0.0; *pCaps->PixelShader1xMaxValue = 0.0;
} }
/* TODO: ARB_FRAGMENT_PROGRAM_100 */ /* TODO: ARB_FRAGMENT_PROGRAM_100 */
@ -1482,7 +1482,7 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVT
The following fields apply to d3d9 only The following fields apply to d3d9 only
------------------------------------------------ */ ------------------------------------------------ */
if (This->dxVersion > 8) { if (This->dxVersion > 8) {
GLint max_buffers=1; GLint max_buffers = 1;
FIXME("Caps support for directx9 is nonexistent at the moment!\n"); FIXME("Caps support for directx9 is nonexistent at the moment!\n");
*pCaps->DevCaps2 = 0; *pCaps->DevCaps2 = 0;
/* TODO: D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES */ /* TODO: D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES */
@ -1494,7 +1494,7 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVT
#if 0 /*FIXME: Simultaneous render targets*/ #if 0 /*FIXME: Simultaneous render targets*/
GL_MAX_DRAW_BUFFERS_ATI 0x00008824 GL_MAX_DRAW_BUFFERS_ATI 0x00008824
if (GL_SUPPORT(GL_MAX_DRAW_BUFFERS_ATI)) { if (GL_SUPPORT(GL_MAX_DRAW_BUFFERS_ATI)) {
ENTER_GL(); ENTER_GL();
glEnable(GL_MAX_DRAW_BUFFERS_ATI); glEnable(GL_MAX_DRAW_BUFFERS_ATI);
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, &max_buffers); glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, &max_buffers);
glDisable(GL_MAX_DRAW_BUFFERS_ATI); glDisable(GL_MAX_DRAW_BUFFERS_ATI);
@ -1552,10 +1552,10 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
object->wineD3D = iface; object->wineD3D = iface;
IWineD3D_AddRef(object->wineD3D); IWineD3D_AddRef(object->wineD3D);
object->parent = parent; object->parent = parent;
TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType, TRACE("(%p)->(Adptr:%d, DevType: %x, FocusHwnd: %p, BehFlags: %lx, PresParms: %p, RetDevInt: %p)\n", This, Adapter, DeviceType,
hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface); hFocusWindow, BehaviourFlags, pPresentationParameters, ppReturnedDeviceInterface);
TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This, TRACE("(%p)->(DepthStencil:(%u,%s), BackBufferFormat:(%u,%s))\n", This,
*(pPresentationParameters->AutoDepthStencilFormat), debug_d3dformat(*(pPresentationParameters->AutoDepthStencilFormat)), *(pPresentationParameters->AutoDepthStencilFormat), debug_d3dformat(*(pPresentationParameters->AutoDepthStencilFormat)),
*(pPresentationParameters->BackBufferFormat), debug_d3dformat(*(pPresentationParameters->BackBufferFormat))); *(pPresentationParameters->BackBufferFormat), debug_d3dformat(*(pPresentationParameters->BackBufferFormat)));
@ -1594,15 +1594,15 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
if (NULL != object->stencilBufferTarget) { if (NULL != object->stencilBufferTarget) {
IWineD3DSurface_AddRef(object->stencilBufferTarget); IWineD3DSurface_AddRef(object->stencilBufferTarget);
} }
/* Set up some starting GL setup */ /* Set up some starting GL setup */
ENTER_GL(); ENTER_GL();
/* /*
* Initialize openGL extension related variables * Initialize openGL extension related variables
* with Default values * with Default values
*/ */
This->isGLInfoValid = IWineD3DImpl_FillGLCaps(&This->gl_info, swapchain->display); This->isGLInfoValid = IWineD3DImpl_FillGLCaps(&This->gl_info, swapchain->display);
/* Setup all the devices defaults */ /* Setup all the devices defaults */
IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)object->stateBlock); IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)object->stateBlock);
@ -1610,7 +1610,7 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
IWineD3DImpl_CheckGraphicsMemory(); IWineD3DImpl_CheckGraphicsMemory();
#endif #endif
LEAVE_GL(); LEAVE_GL();
{ /* Set a default viewport */ { /* Set a default viewport */
D3DVIEWPORT9 vp; D3DVIEWPORT9 vp;
vp.X = 0; vp.X = 0;
@ -1621,8 +1621,8 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
vp.MaxZ = 1.0f; vp.MaxZ = 1.0f;
IWineD3DDevice_SetViewport((IWineD3DDevice *)object, &vp); IWineD3DDevice_SetViewport((IWineD3DDevice *)object, &vp);
} }
/* Initialize the current view state */ /* Initialize the current view state */
object->modelview_valid = 1; object->modelview_valid = 1;
object->proj_valid = 0; object->proj_valid = 0;
@ -1630,7 +1630,7 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
object->last_was_rhw = 0; object->last_was_rhw = 0;
glGetIntegerv(GL_MAX_LIGHTS, &object->maxConcurrentLights); glGetIntegerv(GL_MAX_LIGHTS, &object->maxConcurrentLights);
TRACE("(%p,%d) All defaults now set up, leaving CreateDevice with %p\n", This, Adapter, object); TRACE("(%p,%d) All defaults now set up, leaving CreateDevice with %p\n", This, Adapter, object);
/* Clear the screen */ /* Clear the screen */
IWineD3DDevice_Clear((IWineD3DDevice *) object, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0); IWineD3DDevice_Clear((IWineD3DDevice *) object, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
} else { /* couldn't create swapchain */ } else { /* couldn't create swapchain */
@ -1665,9 +1665,11 @@ HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent) {
const IWineD3DVtbl IWineD3D_Vtbl = const IWineD3DVtbl IWineD3D_Vtbl =
{ {
/* IUnknown */
IWineD3DImpl_QueryInterface, IWineD3DImpl_QueryInterface,
IWineD3DImpl_AddRef, IWineD3DImpl_AddRef,
IWineD3DImpl_Release, IWineD3DImpl_Release,
/* IWineD3D */
IWineD3DImpl_GetParent, IWineD3DImpl_GetParent,
IWineD3DImpl_GetAdapterCount, IWineD3DImpl_GetAdapterCount,
IWineD3DImpl_RegisterSoftwareDevice, IWineD3DImpl_RegisterSoftwareDevice,

View File

@ -3,7 +3,7 @@
* *
* Copyright 2002-2004 Jason Edmeades * Copyright 2002-2004 Jason Edmeades
* Copyright 2002-2004 Raphael Junqueira * Copyright 2002-2004 Raphael Junqueira
* Copyright 2004 Christian Costa * Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber * Copyright 2005 Oliver Stieber
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -36,11 +36,11 @@ extern IDirect3DPixelShaderImpl* PixelShaders[64];
#undef GL_VERSION_1_4 /* To be fixed, caused by mesa headers */ #undef GL_VERSION_1_4 /* To be fixed, caused by mesa headers */
#endif #endif
/* Returns bits for what is expected from the fixed function pipeline, and whether /* Returns bits for what is expected from the fixed function pipeline, and whether
a vertex shader will be in use. Note the fvf bits returned may be split over a vertex shader will be in use. Note the fvf bits returned may be split over
multiple streams only if the vertex shader was created, otherwise it all relates multiple streams only if the vertex shader was created, otherwise it all relates
to stream 0 */ to stream 0 */
BOOL initializeFVF(IWineD3DDevice *iface, BOOL initializeFVF(IWineD3DDevice *iface,
DWORD *FVFbits, /* What to expect in the FVF across all streams */ DWORD *FVFbits, /* What to expect in the FVF across all streams */
BOOL *useVertexShaderFunction) /* Should we use the vertex shader */ BOOL *useVertexShaderFunction) /* Should we use the vertex shader */
{ {
@ -48,11 +48,11 @@ BOOL initializeFVF(IWineD3DDevice *iface,
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
#if 0 /* TODO: d3d8 call setvertexshader needs to set the FVF in the state block when implemented */ #if 0 /* TODO: d3d8 call setvertexshader needs to set the FVF in the state block when implemented */
/* The first thing to work out is if we are using the fixed function pipeline /* The first thing to work out is if we are using the fixed function pipeline
which is either SetVertexShader with < VS_HIGHESTFIXEDFXF - in which case this which is either SetVertexShader with < VS_HIGHESTFIXEDFXF - in which case this
is the FVF, or with a shader which was created with no function - in which is the FVF, or with a shader which was created with no function - in which
case there is an FVF per declared stream. If this occurs, we also maintain case there is an FVF per declared stream. If this occurs, we also maintain
an 'OR' of all the FVF's together so we know what to expect across all the an 'OR' of all the FVF's together so we know what to expect across all the
streams */ streams */
#endif #endif
@ -83,7 +83,7 @@ BOOL initializeFVF(IWineD3DDevice *iface,
if (vertex_shader->function == NULL) { if (vertex_shader->function == NULL) {
/* No function, so many streams supplied plus FVF definition pre stream */ /* No function, so many streams supplied plus FVF definition pre stream */
*useVertexShaderFunction = FALSE; *useVertexShaderFunction = FALSE;
TRACE("vertex shader (%lx) declared without program, using fixed function pipeline with FVF=%lx\n", TRACE("vertex shader (%lx) declared without program, using fixed function pipeline with FVF=%lx\n",
This->stateBlock->VertexShader, *FVFbits); This->stateBlock->VertexShader, *FVFbits);
} else { } else {
/* Vertex shader needs calling */ /* Vertex shader needs calling */
@ -146,7 +146,7 @@ DWORD primitiveToGl(D3DPRIMITIVETYPE PrimitiveType,
FIXME("Unhandled primitive\n"); FIXME("Unhandled primitive\n");
*primType = GL_POINTS; *primType = GL_POINTS;
break; break;
} }
return NumVertexes; return NumVertexes;
} }
@ -164,7 +164,7 @@ void init_materials(IWineD3DDevice *iface, BOOL isDiffuseSupplied) {
TRACE("glColorMaterial Parm=%x\n", This->tracking_parm); TRACE("glColorMaterial Parm=%x\n", This->tracking_parm);
glColorMaterial(GL_FRONT_AND_BACK, This->tracking_parm); glColorMaterial(GL_FRONT_AND_BACK, This->tracking_parm);
checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)"); checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
checkGLcall("glEnable GL_COLOR_MATERIAL"); checkGLcall("glEnable GL_COLOR_MATERIAL");
This->tracking_color = IS_TRACKING; This->tracking_color = IS_TRACKING;
requires_material_reset = TRUE; /* Restore material settings as will be used */ requires_material_reset = TRUE; /* Restore material settings as will be used */
@ -215,7 +215,7 @@ static GLfloat invymat[16]={
0.0f, 0.0f, 0.0f, 1.0f}; 0.0f, 0.0f, 0.0f, 1.0f};
/* Setup views - Transformed & lit if RHW, else untransformed. /* Setup views - Transformed & lit if RHW, else untransformed.
Only unlit if Normals are supplied Only unlit if Normals are supplied
Returns: Whether to restore lighting afterwards */ Returns: Whether to restore lighting afterwards */
BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_lit, BOOL useVS) { BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_lit, BOOL useVS) {
@ -240,7 +240,7 @@ BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_li
This->last_was_rhw = TRUE; This->last_was_rhw = TRUE;
/* Transformed already into viewport coordinates, so we do not need transform /* Transformed already into viewport coordinates, so we do not need transform
matrices. Reset all matrices to identity and leave the default matrix in world matrices. Reset all matrices to identity and leave the default matrix in world
mode. */ mode. */
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode"); checkGLcall("glMatrixMode");
@ -321,8 +321,8 @@ BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_li
} }
/* Vertex Shader output is already transformed, so set up identity matrices */ /* Vertex Shader output is already transformed, so set up identity matrices */
/* FIXME: Actually, only true for software emulated ones, so when h/w ones /* FIXME: Actually, only true for software emulated ones, so when h/w ones
come along this needs to take into account whether s/w ones were come along this needs to take into account whether s/w ones were
requested or not */ requested or not */
if (useVS) { if (useVS) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
@ -341,7 +341,7 @@ BOOL primitiveInitState(IWineD3DDevice *iface, BOOL vtx_transformed, BOOL vtx_li
} }
This->modelview_valid = FALSE; This->modelview_valid = FALSE;
This->proj_valid = FALSE; This->proj_valid = FALSE;
} }
This->last_was_rhw = FALSE; This->last_was_rhw = FALSE;
} }
return isLightingOn; return isLightingOn;
@ -546,8 +546,8 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedD
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
/* OK, Now to setup the data locations /* OK, Now to setup the data locations
For the non-created vertex shaders, the VertexShader var holds the real For the non-created vertex shaders, the VertexShader var holds the real
FVF and only stream 0 matters FVF and only stream 0 matters
For the created vertex shaders, there is an FVF per stream */ For the created vertex shaders, there is an FVF per stream */
if (!This->stateBlock->streamIsUP && !(This->stateBlock->vertexShader == NULL)) { if (!This->stateBlock->streamIsUP && !(This->stateBlock->vertexShader == NULL)) {
@ -589,7 +589,7 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedD
data = data + (BaseVertexIndex * stride); data = data + (BaseVertexIndex * stride);
/* Either 3 or 4 floats depending on the FVF */ /* Either 3 or 4 floats depending on the FVF */
/* FIXME: Can blending data be in a different stream to the position data? /* FIXME: Can blending data be in a different stream to the position data?
and if so using the fixed pipeline how do we handle it */ and if so using the fixed pipeline how do we handle it */
if (thisFVF & D3DFVF_POSITION_MASK) { if (thisFVF & D3DFVF_POSITION_MASK) {
strided->u.s.position.lpData = data; strided->u.s.position.lpData = data;
@ -604,10 +604,10 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedD
/* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */ /* Blending is numBlends * FLOATs followed by a DWORD for UBYTE4 */
/** do we have to Check This->stateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */ /** do we have to Check This->stateBlock->renderState[D3DRS_INDEXEDVERTEXBLENDENABLE] ? */
numBlends = ((thisFVF & D3DFVF_POSITION_MASK) >> 1) - 2 + numBlends = ((thisFVF & D3DFVF_POSITION_MASK) >> 1) - 2 +
((FALSE == (thisFVF & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1); /* WARNING can be < 0 because -2 */ ((FALSE == (thisFVF & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1); /* WARNING can be < 0 because -2 */
if (numBlends > 0) { if (numBlends > 0) {
canDoViaGLPointers = FALSE; canDoViaGLPointers = FALSE;
strided->u.s.blendWeights.lpData = data; strided->u.s.blendWeights.lpData = data;
strided->u.s.blendWeights.dwType = D3DDECLTYPE_FLOAT1 + (numBlends - 1); strided->u.s.blendWeights.dwType = D3DDECLTYPE_FLOAT1 + (numBlends - 1);
strided->u.s.blendWeights.dwStride = stride; strided->u.s.blendWeights.dwStride = stride;
@ -615,8 +615,8 @@ void primitiveConvertToStridedData(IWineD3DDevice *iface, Direct3DVertexStridedD
if (thisFVF & D3DFVF_LASTBETA_UBYTE4) { if (thisFVF & D3DFVF_LASTBETA_UBYTE4) {
strided->u.s.blendMatrixIndices.lpData = data; strided->u.s.blendMatrixIndices.lpData = data;
strided->u.s.blendMatrixIndices.dwType = D3DDECLTYPE_UBYTE4; strided->u.s.blendMatrixIndices.dwType = D3DDECLTYPE_UBYTE4;
strided->u.s.blendMatrixIndices.dwStride= stride; strided->u.s.blendMatrixIndices.dwStride= stride;
data += sizeof(DWORD); data += sizeof(DWORD);
} }
} }
@ -723,7 +723,7 @@ void draw_vertex(IWineD3DDevice *iface, /* interfac
if (isNormal) { if (isNormal) {
VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", nx,ny,nz)); VTRACE(("glNormal:nx,ny,nz=%f,%f,%f\n", nx,ny,nz));
glNormal3f(nx, ny, nz); glNormal3f(nx, ny, nz);
} }
/* Point Size ----------------------------------------------*/ /* Point Size ----------------------------------------------*/
if (isPtSize) { if (isPtSize) {
@ -762,7 +762,7 @@ void draw_vertex(IWineD3DDevice *iface, /* interfac
case 4: q = texcoords[coordIdx].w; /* drop through */ case 4: q = texcoords[coordIdx].w; /* drop through */
case 3: r = texcoords[coordIdx].z; /* drop through */ case 3: r = texcoords[coordIdx].z; /* drop through */
case 2: t = texcoords[coordIdx].y; /* drop through */ case 2: t = texcoords[coordIdx].y; /* drop through */
case 1: s = texcoords[coordIdx].x; case 1: s = texcoords[coordIdx].x;
} }
switch (numcoords[coordIdx]) { /* Supply the provided texture coords */ switch (numcoords[coordIdx]) { /* Supply the provided texture coords */
@ -819,12 +819,12 @@ void draw_vertex(IWineD3DDevice *iface, /* interfac
} }
} }
/* /*
* Actually draw using the supplied information. * Actually draw using the supplied information.
* Faster GL version using pointers to data, harder to debug though * Faster GL version using pointers to data, harder to debug though
* Note does not handle vertex shaders yet * Note does not handle vertex shaders yet
*/ */
void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd, void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
int PrimitiveType, ULONG NumPrimitives, int PrimitiveType, ULONG NumPrimitives,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
unsigned int textureNo = 0; unsigned int textureNo = 0;
@ -838,17 +838,17 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
if (sd->u.s.position.lpData != NULL) { if (sd->u.s.position.lpData != NULL) {
/* Note dwType == float3 or float4 == 2 or 3 */ /* Note dwType == float3 or float4 == 2 or 3 */
VTRACE(("glVertexPointer(%ld, GL_FLOAT, %ld, %p)\n", VTRACE(("glVertexPointer(%ld, GL_FLOAT, %ld, %p)\n",
sd->u.s.position.dwStride, sd->u.s.position.dwStride,
sd->u.s.position.dwType + 1, sd->u.s.position.dwType + 1,
sd->u.s.position.lpData)); sd->u.s.position.lpData));
/* Disable RHW mode as 'w' coord handling for rhw mode should /* Disable RHW mode as 'w' coord handling for rhw mode should
not impact screen position whereas in GL it does. This may not impact screen position whereas in GL it does. This may
result in very slightly distored textures in rhw mode, but result in very slightly distored textures in rhw mode, but
a very minimal different */ a very minimal different */
glVertexPointer(3, GL_FLOAT, /* RHW: Was 'sd->u.s.position.dwType + 1' */ glVertexPointer(3, GL_FLOAT, /* RHW: Was 'sd->u.s.position.dwType + 1' */
sd->u.s.position.dwStride, sd->u.s.position.dwStride,
sd->u.s.position.lpData); sd->u.s.position.lpData);
checkGLcall("glVertexPointer(...)"); checkGLcall("glVertexPointer(...)");
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
@ -861,29 +861,28 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
} }
/* Blend Data ----------------------------------------------*/ /* Blend Data ----------------------------------------------*/
if ((sd->u.s.blendWeights.lpData != NULL) || if ((sd->u.s.blendWeights.lpData != NULL) ||
(sd->u.s.blendMatrixIndices.lpData != NULL)) { (sd->u.s.blendMatrixIndices.lpData != NULL)) {
#if 1 /* Vertex blend support needs to be added */ #if 1 /* Vertex blend support needs to be added */
if (GL_SUPPORT(ARB_VERTEX_BLEND)) { if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
DWORD fvf = (sd->u.s.blendWeights.dwType - D3DDECLTYPE_FLOAT1) + 1; DWORD fvf = (sd->u.s.blendWeights.dwType - D3DDECLTYPE_FLOAT1) + 1;
int numBlends = ((fvf & D3DFVF_POSITION_MASK) >> 1) - 2 + ((FALSE == (fvf & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1); int numBlends = ((fvf & D3DFVF_POSITION_MASK) >> 1) - 2 + ((FALSE == (fvf & D3DFVF_LASTBETA_UBYTE4)) ? 0 : -1);
/*FIXME("TODO\n");*/ /* Note dwType == float3 or float4 == 2 or 3 */
/* Note dwType == float3 or float4 == 2 or 3 */ VTRACE(("glWeightPointerARB(%ld, GL_FLOAT, %ld, %p)\n",
VTRACE(("glWeightPointerARB(%ld, GL_FLOAT, %ld, %p)\n", numBlends,
numBlends, sd->u.s.blendWeights.dwStride,
sd->u.s.blendWeights.dwStride, sd->u.s.blendWeights.lpData));
sd->u.s.blendWeights.lpData)); GL_EXTCALL(glWeightPointerARB)(numBlends, GL_FLOAT,
GL_EXTCALL(glWeightPointerARB)(numBlends, GL_FLOAT, sd->u.s.blendWeights.dwStride,
sd->u.s.blendWeights.dwStride, sd->u.s.blendWeights.lpData);
sd->u.s.blendWeights.lpData); checkGLcall("glWeightPointerARB(...)");
checkGLcall("glWeightPointerARB(...)"); glEnableClientState(GL_WEIGHT_ARRAY_ARB);
glEnableClientState(GL_WEIGHT_ARRAY_ARB); checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
} else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) { } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
/*FIXME("TODO\n");*/ /*FIXME("TODO\n");*/
/* /*
GLExtCall(glVertexWeightPointerEXT)(numBlends, GL_FLOAT, skip, curPos); GLExtCall(glVertexWeightPointerEXT)(numBlends, GL_FLOAT, skip, curPos);
checkGLcall("glVertexWeightPointerEXT(numBlends, ...)"); checkGLcall("glVertexWeightPointerEXT(numBlends, ...)");
glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT); glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)"); checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
@ -911,11 +910,11 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
if (sd->u.s.normal.lpData != NULL) { if (sd->u.s.normal.lpData != NULL) {
/* Note dwType == float3 or float4 == 2 or 3 */ /* Note dwType == float3 or float4 == 2 or 3 */
VTRACE(("glNormalPointer(GL_FLOAT, %ld, %p)\n", VTRACE(("glNormalPointer(GL_FLOAT, %ld, %p)\n",
sd->u.s.normal.dwStride, sd->u.s.normal.dwStride,
sd->u.s.normal.lpData)); sd->u.s.normal.lpData));
glNormalPointer(GL_FLOAT, glNormalPointer(GL_FLOAT,
sd->u.s.normal.dwStride, sd->u.s.normal.dwStride,
sd->u.s.normal.lpData); sd->u.s.normal.lpData);
checkGLcall("glNormalPointer(...)"); checkGLcall("glNormalPointer(...)");
glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_NORMAL_ARRAY);
@ -944,11 +943,11 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
if (sd->u.s.diffuse.lpData != NULL) { if (sd->u.s.diffuse.lpData != NULL) {
/* Note dwType == float3 or float4 == 2 or 3 */ /* Note dwType == float3 or float4 == 2 or 3 */
VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %ld, %p)\n", VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %ld, %p)\n",
sd->u.s.diffuse.dwStride, sd->u.s.diffuse.dwStride,
sd->u.s.diffuse.lpData)); sd->u.s.diffuse.lpData));
glColorPointer(4, GL_UNSIGNED_BYTE, glColorPointer(4, GL_UNSIGNED_BYTE,
sd->u.s.diffuse.dwStride, sd->u.s.diffuse.dwStride,
sd->u.s.diffuse.lpData); sd->u.s.diffuse.lpData);
checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)"); checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
@ -966,13 +965,13 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
if (sd->u.s.specular.lpData != NULL) { if (sd->u.s.specular.lpData != NULL) {
/* Note dwType == float3 or float4 == 2 or 3 */ /* Note dwType == float3 or float4 == 2 or 3 */
VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %ld, %p)\n", VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %ld, %p)\n",
sd->u.s.specular.dwStride, sd->u.s.specular.dwStride,
sd->u.s.specular.lpData)); sd->u.s.specular.lpData));
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE,
sd->u.s.specular.dwStride, sd->u.s.specular.dwStride,
sd->u.s.specular.lpData); sd->u.s.specular.lpData);
vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)"); vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
@ -1029,27 +1028,27 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
GLenum type; GLenum type;
switch (sd->u.s.texCoords[coordIdx].dwType) { switch (sd->u.s.texCoords[coordIdx].dwType) {
case D3DDECLTYPE_FLOAT1: size = 1, type = GL_FLOAT; break; case D3DDECLTYPE_FLOAT1: size = 1, type = GL_FLOAT; break;
case D3DDECLTYPE_FLOAT2: size = 2, type = GL_FLOAT; break; case D3DDECLTYPE_FLOAT2: size = 2, type = GL_FLOAT; break;
case D3DDECLTYPE_FLOAT3: size = 3, type = GL_FLOAT; break; case D3DDECLTYPE_FLOAT3: size = 3, type = GL_FLOAT; break;
case D3DDECLTYPE_FLOAT4: size = 4, type = GL_FLOAT; break; case D3DDECLTYPE_FLOAT4: size = 4, type = GL_FLOAT; break;
case D3DDECLTYPE_SHORT2: size = 2, type = GL_SHORT; break; case D3DDECLTYPE_SHORT2: size = 2, type = GL_SHORT; break;
case D3DDECLTYPE_SHORT4: size = 4, type = GL_SHORT; break; case D3DDECLTYPE_SHORT4: size = 4, type = GL_SHORT; break;
case D3DDECLTYPE_UBYTE4: size = 4, type = GL_UNSIGNED_BYTE; break; case D3DDECLTYPE_UBYTE4: size = 4, type = GL_UNSIGNED_BYTE; break;
default: FIXME("Unrecognized data type %ld\n", sd->u.s.texCoords[coordIdx].dwType); default: FIXME("Unrecognized data type %ld\n", sd->u.s.texCoords[coordIdx].dwType);
size = 4; type = GL_UNSIGNED_BYTE; size = 4; type = GL_UNSIGNED_BYTE;
} }
glTexCoordPointer(size, type, sd->u.s.texCoords[coordIdx].dwStride, sd->u.s.texCoords[coordIdx].lpData); glTexCoordPointer(size, type, sd->u.s.texCoords[coordIdx].dwStride, sd->u.s.texCoords[coordIdx].lpData);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
} }
} else { } else {
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
GLMULTITEXCOORD4F(textureNo, 0, 0, 0, 1); GLMULTITEXCOORD4F(textureNo, 0, 0, 0, 1);
} }
} }
/* Ok, Work out which primitive is requested and how many vertexes that /* Ok, Work out which primitive is requested and how many vertexes that
will be */ will be */
NumVertexes = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType); NumVertexes = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
@ -1061,8 +1060,8 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
glDrawElements(glPrimType, NumVertexes, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT, glDrawElements(glPrimType, NumVertexes, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT,
(const char *)idxData+(idxSize * startIdx)); (const char *)idxData+(idxSize * startIdx));
#else #else
glDrawRangeElements(glPrimType, minIndex, minIndex+NumVertexes-1, NumVertexes, glDrawRangeElements(glPrimType, minIndex, minIndex+NumVertexes-1, NumVertexes,
idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT,
(const char *)idxData+(idxSize * startIdx)); (const char *)idxData+(idxSize * startIdx));
#endif #endif
checkGLcall("glDrawRangeElements"); checkGLcall("glDrawRangeElements");
@ -1077,11 +1076,11 @@ void drawStridedFast(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
} }
} }
/* /*
* Actually draw using the supplied information. * Actually draw using the supplied information.
* Slower GL version which extracts info about each vertex in turn * Slower GL version which extracts info about each vertex in turn
*/ */
void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd, void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
int PrimitiveType, ULONG NumPrimitives, int PrimitiveType, ULONG NumPrimitives,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
@ -1226,7 +1225,7 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
case 4: q = ptrToCoords[3]; /* drop through */ case 4: q = ptrToCoords[3]; /* drop through */
case 3: r = ptrToCoords[2]; /* drop through */ case 3: r = ptrToCoords[2]; /* drop through */
case 2: t = ptrToCoords[1]; /* drop through */ case 2: t = ptrToCoords[1]; /* drop through */
case 1: s = ptrToCoords[0]; case 1: s = ptrToCoords[0];
} }
/* Projected is more 'fun' - Move the last coord to the 'q' /* Projected is more 'fun' - Move the last coord to the 'q'
@ -1253,7 +1252,7 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
case 4: /* Nop here */ case 4: /* Nop here */
break; break;
default: default:
FIXME("Unexpected D3DTSS_TEXTURETRANSFORMFLAGS value of %ld\n", FIXME("Unexpected D3DTSS_TEXTURETRANSFORMFLAGS value of %ld\n",
This->stateBlock->textureState[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED); This->stateBlock->textureState[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] & D3DTTFF_PROJECTED);
} }
} }
@ -1311,10 +1310,10 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
(diffuseColor >> 8) & 0xFF, (diffuseColor >> 8) & 0xFF,
(diffuseColor >> 0) & 0xFF, (diffuseColor >> 0) & 0xFF,
(diffuseColor >> 24) & 0xFF); (diffuseColor >> 24) & 0xFF);
VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n", VTRACE(("glColor4f: r,g,b,a=%f,%f,%f,%f\n",
((diffuseColor >> 16) & 0xFF) / 255.0f, ((diffuseColor >> 16) & 0xFF) / 255.0f,
((diffuseColor >> 8) & 0xFF) / 255.0f, ((diffuseColor >> 8) & 0xFF) / 255.0f,
((diffuseColor >> 0) & 0xFF) / 255.0f, ((diffuseColor >> 0) & 0xFF) / 255.0f,
((diffuseColor >> 24) & 0xFF) / 255.0f)); ((diffuseColor >> 24) & 0xFF) / 255.0f));
} else { } else {
if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (vx_index == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
@ -1322,8 +1321,8 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
/* Specular ------------------------------- */ /* Specular ------------------------------- */
if (sd->u.s.diffuse.lpData != NULL) { if (sd->u.s.diffuse.lpData != NULL) {
VTRACE(("glSecondaryColor4ub: r,g,b=%f,%f,%f\n", VTRACE(("glSecondaryColor4ub: r,g,b=%f,%f,%f\n",
((specularColor >> 16) & 0xFF) / 255.0f, ((specularColor >> 16) & 0xFF) / 255.0f,
((specularColor >> 8) & 0xFF) / 255.0f, ((specularColor >> 8) & 0xFF) / 255.0f,
((specularColor >> 0) & 0xFF) / 255.0f)); ((specularColor >> 0) & 0xFF) / 255.0f));
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
@ -1332,18 +1331,18 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
(specularColor >> 8) & 0xFF, (specularColor >> 8) & 0xFF,
(specularColor >> 0) & 0xFF); (specularColor >> 0) & 0xFF);
} else { } else {
/* Do not worry if specular colour missing and disable request */ /* Do not worry if specular colour missing and disable request */
VTRACE(("Specular color extensions not supplied\n")); VTRACE(("Specular color extensions not supplied\n"));
} }
} else { } else {
if (vx_index == 0) { if (vx_index == 0) {
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0); GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
} else { } else {
/* Do not worry if specular colour missing and disable request */ /* Do not worry if specular colour missing and disable request */
VTRACE(("Specular color extensions not supplied\n")); VTRACE(("Specular color extensions not supplied\n"));
} }
} }
} }
/* Normal -------------------------------- */ /* Normal -------------------------------- */
@ -1353,7 +1352,7 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
} else { } else {
if (vx_index == 0) glNormal3f(0, 0, 1); if (vx_index == 0) glNormal3f(0, 0, 1);
} }
/* Position -------------------------------- */ /* Position -------------------------------- */
if (sd->u.s.position.lpData != NULL) { if (sd->u.s.position.lpData != NULL) {
if (1.0f == rhw || ((rhw < 0.0001f) && (rhw > -0.0001f))) { if (1.0f == rhw || ((rhw < 0.0001f) && (rhw > -0.0001f))) {
@ -1377,12 +1376,12 @@ void drawStridedSlow(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
} }
#if 0 /* TODO: Software/Hardware vertex blending support */ #if 0 /* TODO: Software/Hardware vertex blending support */
/* /*
* Draw with emulated vertex shaders * Draw with emulated vertex shaders
* Note: strided data is uninitialized, as we need to pass the vertex * Note: strided data is uninitialized, as we need to pass the vertex
* shader directly as ordering irs yet * shader directly as ordering irs yet
*/ */
void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd, void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
int PrimitiveType, ULONG NumPrimitives, int PrimitiveType, ULONG NumPrimitives,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
@ -1444,7 +1443,7 @@ void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
vertex_shader->output.oD[0].x = 1.0; vertex_shader->output.oD[0].x = 1.0;
vertex_shader->output.oD[0].y = 1.0; vertex_shader->output.oD[0].y = 1.0;
vertex_shader->output.oD[0].z = 1.0; vertex_shader->output.oD[0].z = 1.0;
vertex_shader->output.oD[0].w = 1.0; vertex_shader->output.oD[0].w = 1.0;
/* Now execute the vertex shader */ /* Now execute the vertex shader */
IDirect3DVertexShaderImpl_ExecuteSW(vertex_shader, &vertex_shader->input, &vertex_shader->output); IDirect3DVertexShaderImpl_ExecuteSW(vertex_shader, &vertex_shader->input, &vertex_shader->output);
@ -1479,30 +1478,30 @@ void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
memset(numcoords, 0x00, sizeof(numcoords)); memset(numcoords, 0x00, sizeof(numcoords));
for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) { for (textureNo = 0; textureNo < GL_LIMITS(textures); ++textureNo) {
if (This->stateBlock->textures[textureNo] != NULL) { if (This->stateBlock->textures[textureNo] != NULL) {
texcoords[textureNo].x = vertex_shader->output.oT[textureNo].x; texcoords[textureNo].x = vertex_shader->output.oT[textureNo].x;
texcoords[textureNo].y = vertex_shader->output.oT[textureNo].y; texcoords[textureNo].y = vertex_shader->output.oT[textureNo].y;
texcoords[textureNo].z = vertex_shader->output.oT[textureNo].z; texcoords[textureNo].z = vertex_shader->output.oT[textureNo].z;
texcoords[textureNo].w = vertex_shader->output.oT[textureNo].w; texcoords[textureNo].w = vertex_shader->output.oT[textureNo].w;
if (This->stateBlock->texture_state[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] != D3DTTFF_DISABLE) { if (This->stateBlock->texture_state[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] != D3DTTFF_DISABLE) {
numcoords[textureNo] = This->stateBlock->texture_state[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] & ~D3DTTFF_PROJECTED; numcoords[textureNo] = This->stateBlock->texture_state[textureNo][D3DTSS_TEXTURETRANSFORMFLAGS] & ~D3DTTFF_PROJECTED;
} else { } else {
switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) This->stateBlock->textures[textureNo])) { switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) This->stateBlock->textures[textureNo])) {
case D3DRTYPE_TEXTURE: numcoords[textureNo] = 2; break; case D3DRTYPE_TEXTURE: numcoords[textureNo] = 2; break;
case D3DRTYPE_VOLUMETEXTURE: numcoords[textureNo] = 3; break; case D3DRTYPE_VOLUMETEXTURE: numcoords[textureNo] = 3; break;
default: numcoords[textureNo] = 4; default: numcoords[textureNo] = 4;
} }
} }
} else { } else {
numcoords[textureNo] = 0; numcoords[textureNo] = 0;
} }
} }
/* Draw using this information */ /* Draw using this information */
draw_vertex(iface, draw_vertex(iface,
TRUE, x, y, z, rhw, TRUE, x, y, z, rhw,
TRUE, 0.0f, 0.0f, 1.0f, TRUE, 0.0f, 0.0f, 1.0f,
TRUE, (float*) &vertex_shader->output.oD[0], TRUE, (float*) &vertex_shader->output.oD[0],
TRUE, (float*) &vertex_shader->output.oD[1], TRUE, (float*) &vertex_shader->output.oD[1],
FALSE, ptSize, /* FIXME: Change back when supported */ FALSE, ptSize, /* FIXME: Change back when supported */
texcoords, numcoords); texcoords, numcoords);
@ -1517,7 +1516,7 @@ void drawStridedSoftwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
checkGLcall("glEnd and previous calls"); checkGLcall("glEnd and previous calls");
} }
void drawStridedHardwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd, void drawStridedHardwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
int PrimitiveType, ULONG NumPrimitives, int PrimitiveType, ULONG NumPrimitives,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) {
@ -1548,7 +1547,7 @@ void drawStridedHardwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
/* Set up the vertex.attr[n] inputs */ /* Set up the vertex.attr[n] inputs */
IDirect3DDeviceImpl_FillVertexShaderInputArbHW(This, vertex_shader, 0); IDirect3DDeviceImpl_FillVertexShaderInputArbHW(This, vertex_shader, 0);
/* Ok, Work out which primitive is requested and how many vertexes that /* Ok, Work out which primitive is requested and how many vertexes that
will be */ will be */
NumVertexes = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType); NumVertexes = primitiveToGl(PrimitiveType, NumPrimitives, &glPrimType);
@ -1560,8 +1559,8 @@ void drawStridedHardwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
glDrawElements(glPrimType, NumVertexes, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT, glDrawElements(glPrimType, NumVertexes, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT,
(const char *)idxData+(idxSize * startIdx)); (const char *)idxData+(idxSize * startIdx));
#else #else
glDrawRangeElements(glPrimType, minIndex, minIndex+NumVertexes-1, NumVertexes, glDrawRangeElements(glPrimType, minIndex, minIndex+NumVertexes-1, NumVertexes,
idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT, idxSize==2?GL_UNSIGNED_SHORT:GL_UNSIGNED_INT,
(const char *)idxData+(idxSize * startIdx)); (const char *)idxData+(idxSize * startIdx));
#endif #endif
checkGLcall("glDrawRangeElements"); checkGLcall("glDrawRangeElements");
@ -1574,7 +1573,7 @@ void drawStridedHardwareVS(IWineD3DDevice *iface, Direct3DVertexStridedData *sd,
checkGLcall("glDrawArrays"); checkGLcall("glDrawArrays");
} }
{ {
GLint errPos; GLint errPos;
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos ); glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errPos );
@ -1653,17 +1652,17 @@ void drawPrimitive(IWineD3DDevice *iface,
} else { } else {
TRACE("(%p) : using vertex declaration %p \n", iface, This->stateBlock->vertexDecl); TRACE("(%p) : using vertex declaration %p \n", iface, This->stateBlock->vertexDecl);
} }
/* If we will be using a vertex shader, do some initialization for it */ /* If we will be using a vertex shader, do some initialization for it */
if (useVertexShaderFunction) { if (useVertexShaderFunction) {
#if 0 /* TODO: vertex and pixel shaders */ #if 0 /* TODO: vertex and pixel shaders */
vertex_shader = VERTEX_SHADER(This->stateBlock->VertexShader); vertex_shader = VERTEX_SHADER(This->stateBlock->VertexShader);
memset(&vertex_shader->input, 0, sizeof(VSHADERINPUTDATA8)); memset(&vertex_shader->input, 0, sizeof(VSHADERINPUTDATA8));
useHW = (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) && useHW = (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) &&
This->devType != D3DDEVTYPE_REF && This->devType != D3DDEVTYPE_REF &&
!This->stateBlock->renderState[D3DRS_SOFTWAREVERTEXPROCESSING] && !This->stateBlock->renderState[D3DRS_SOFTWAREVERTEXPROCESSING] &&
vertex_shader->usage != D3DUSAGE_SOFTWAREPROCESSING); vertex_shader->usage != D3DUSAGE_SOFTWAREPROCESSING);
/** init Constants */ /** init Constants */
if (This->stateBlock->Changed.vertexShaderConstant) { if (This->stateBlock->Changed.vertexShaderConstant) {
@ -1685,7 +1684,7 @@ void drawPrimitive(IWineD3DDevice *iface,
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixel_shader->prgId)); GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixel_shader->prgId));
checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixel_shader->prgId);"); checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixel_shader->prgId);");
glEnable(GL_FRAGMENT_PROGRAM_ARB); glEnable(GL_FRAGMENT_PROGRAM_ARB);
checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);"); checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);");
/* init Constants */ /* init Constants */
if (This->stateBlock->Changed.pixelShaderConstant) { if (This->stateBlock->Changed.pixelShaderConstant) {
@ -1721,15 +1720,15 @@ void drawPrimitive(IWineD3DDevice *iface,
/* Setup transform matrices and sort out */ /* Setup transform matrices and sort out */
if (useHW) { if (useHW) {
/* Lighting is not completely bypassed with ATI drivers although it should be. Mesa is ok from this respect... /* Lighting is not completely bypassed with ATI drivers although it should be. Mesa is ok from this respect...
So make sure lighting is disabled. */ So make sure lighting is disabled. */
isLightingOn = glIsEnabled(GL_LIGHTING); isLightingOn = glIsEnabled(GL_LIGHTING);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
checkGLcall("glDisable(GL_LIGHTING);"); checkGLcall("glDisable(GL_LIGHTING);");
TRACE("Disabled lighting as no normals supplied, old state = %d\n", isLightingOn); TRACE("Disabled lighting as no normals supplied, old state = %d\n", isLightingOn);
} else { } else {
isLightingOn = primitiveInitState(iface, isLightingOn = primitiveInitState(iface,
fvf & D3DFVF_XYZRHW, fvf & D3DFVF_XYZRHW,
!(fvf & D3DFVF_NORMAL), !(fvf & D3DFVF_NORMAL),
useVertexShaderFunction); useVertexShaderFunction);
} }
@ -1767,36 +1766,36 @@ void drawPrimitive(IWineD3DDevice *iface,
if (useHW) { if (useHW) {
TRACE("Swap HW vertex shader\n"); TRACE("Swap HW vertex shader\n");
#if 0 /* TODO: vertex and pixel shaders */ #if 0 /* TODO: vertex and pixel shaders */
drawStridedHardwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives, drawStridedHardwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives,
idxData, idxSize, minIndex, StartIdx); idxData, idxSize, minIndex, StartIdx);
#endif #endif
} else { } else {
/* We will have to use the very, very slow emulation layer */ /* We will have to use the very, very slow emulation layer */
TRACE("Swap SW vertex shader\n"); TRACE("Swap SW vertex shader\n");
#if 0 /* TODO: vertex and pixel shaders */ #if 0 /* TODO: vertex and pixel shaders */
drawStridedSoftwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives, drawStridedSoftwareVS(iface, &dataLocations, PrimitiveType, NumPrimitives,
idxData, idxSize, minIndex, StartIdx); idxData, idxSize, minIndex, StartIdx);
#endif #endif
} }
} else if ((dataLocations.u.s.pSize.lpData != NULL) } else if ((dataLocations.u.s.pSize.lpData != NULL)
|| (dataLocations.u.s.diffuse.lpData != NULL) || (dataLocations.u.s.diffuse.lpData != NULL)
|| nonPower2 || nonPower2
/*|| (dataLocations.u.s.blendWeights.lpData != NULL)*/) { /*|| (dataLocations.u.s.blendWeights.lpData != NULL)*/) {
/* Fixme, Ideally, only use the per-vertex code for software HAL /* Fixme, Ideally, only use the per-vertex code for software HAL
but until opengl supports all the functions returned to setup but until opengl supports all the functions returned to setup
vertex arrays, we need to drop down to the slow mechanism for vertex arrays, we need to drop down to the slow mechanism for
certain functions */ certain functions */
/* We will have to use the slow version of GL per vertex setup */ /* We will have to use the slow version of GL per vertex setup */
drawStridedSlow(iface, &dataLocations, PrimitiveType, NumPrimitives, drawStridedSlow(iface, &dataLocations, PrimitiveType, NumPrimitives,
idxData, idxSize, minIndex, StartIdx); idxData, idxSize, minIndex, StartIdx);
} else { } else {
/* We can use the fast version of GL pointers */ /* We can use the fast version of GL pointers */
drawStridedFast(iface, &dataLocations, PrimitiveType, NumPrimitives, drawStridedFast(iface, &dataLocations, PrimitiveType, NumPrimitives,
idxData, idxSize, minIndex, StartIdx); idxData, idxSize, minIndex, StartIdx);
} }
@ -1816,10 +1815,10 @@ void drawPrimitive(IWineD3DDevice *iface,
if (errPos != -1) if (errPos != -1)
FIXME("HW PixelShader Error at position: %d\n%s\n", errPos, glGetString( GL_PROGRAM_ERROR_STRING_ARB) ); FIXME("HW PixelShader Error at position: %d\n%s\n", errPos, glGetString( GL_PROGRAM_ERROR_STRING_ARB) );
#endif #endif
glDisable(GL_FRAGMENT_PROGRAM_ARB); glDisable(GL_FRAGMENT_PROGRAM_ARB);
} }
#endif #endif
/* Finshed updating the screen, restore lock */ /* Finshed updating the screen, restore lock */
LEAVE_GL(); LEAVE_GL();
TRACE("Done all gl drawing\n"); TRACE("Done all gl drawing\n");
@ -1851,7 +1850,7 @@ void drawPrimitive(IWineD3DDevice *iface,
} }
} }
#endif #endif
primCounter = primCounter + 1; primCounter = primCounter + 1;
} }
} }
#endif #endif

View File

@ -4,6 +4,7 @@
* Copyright 2002-2004 Jason Edmeades * Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira * Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa * Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -47,7 +48,7 @@ ULONG WINAPI IWineD3DIndexBufferImpl_AddRef(IWineD3DIndexBuffer *iface) {
IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface; IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
ULONG ref = InterlockedIncrement(&This->resource.ref); ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1); TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
return ref; return ref;
} }
ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface) { ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface) {
@ -128,9 +129,11 @@ HRESULT WINAPI IWineD3DIndexBufferImpl_GetDesc(IWineD3DIndexBuffer *ifac
const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl = const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl =
{ {
/* IUnknown */
IWineD3DIndexBufferImpl_QueryInterface, IWineD3DIndexBufferImpl_QueryInterface,
IWineD3DIndexBufferImpl_AddRef, IWineD3DIndexBufferImpl_AddRef,
IWineD3DIndexBufferImpl_Release, IWineD3DIndexBufferImpl_Release,
/* IWineD3DResource */
IWineD3DIndexBufferImpl_GetParent, IWineD3DIndexBufferImpl_GetParent,
IWineD3DIndexBufferImpl_GetDevice, IWineD3DIndexBufferImpl_GetDevice,
IWineD3DIndexBufferImpl_SetPrivateData, IWineD3DIndexBufferImpl_SetPrivateData,
@ -140,6 +143,7 @@ const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl =
IWineD3DIndexBufferImpl_GetPriority, IWineD3DIndexBufferImpl_GetPriority,
IWineD3DIndexBufferImpl_PreLoad, IWineD3DIndexBufferImpl_PreLoad,
IWineD3DIndexBufferImpl_GetType, IWineD3DIndexBufferImpl_GetType,
/* IWineD3DIndexBuffer */
IWineD3DIndexBufferImpl_Lock, IWineD3DIndexBufferImpl_Lock,
IWineD3DIndexBufferImpl_Unlock, IWineD3DIndexBufferImpl_Unlock,
IWineD3DIndexBufferImpl_GetDesc IWineD3DIndexBufferImpl_GetDesc

View File

@ -4,6 +4,7 @@
* Copyright 2002-2004 Jason Edmeades * Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira * Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa * Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -26,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
/* IDirect3DResource IUnknown parts follow: */ /* IWineD3DResource IUnknown parts follow: */
HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, LPVOID *ppobj) HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, LPVOID *ppobj)
{ {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
@ -71,7 +72,7 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
This->resource.allocatedMemory = 0; This->resource.allocatedMemory = 0;
} }
/* IDirect3DResource Interface follow: */ /* IWineD3DResource Interface follow: */
HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) { HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice); TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice);
@ -128,9 +129,11 @@ HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown
static const IWineD3DResourceVtbl IWineD3DResource_Vtbl = static const IWineD3DResourceVtbl IWineD3DResource_Vtbl =
{ {
/* IUnknown */
IWineD3DResourceImpl_QueryInterface, IWineD3DResourceImpl_QueryInterface,
IWineD3DResourceImpl_AddRef, IWineD3DResourceImpl_AddRef,
IWineD3DResourceImpl_Release, IWineD3DResourceImpl_Release,
/* IWineD3DResource */
IWineD3DResourceImpl_GetParent, IWineD3DResourceImpl_GetParent,
IWineD3DResourceImpl_GetDevice, IWineD3DResourceImpl_GetDevice,
IWineD3DResourceImpl_SetPrivateData, IWineD3DResourceImpl_SetPrivateData,

View File

@ -454,7 +454,7 @@ HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock*
unsigned int i; unsigned int i;
/* Note this may have a large overhead but it should only be executed /* Note this may have a large overhead but it should only be executed
once, in order to initialize the complete state of the device and once, in order to initialize the complete state of the device and
all opengl equivalents */ all opengl equivalents */
TRACE("-----------------------> Setting up device defaults...\n"); TRACE("-----------------------> Setting up device defaults...\n");
This->blockType = D3DSBT_ALL; This->blockType = D3DSBT_ALL;
@ -634,7 +634,7 @@ HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock*
/* Sampler states*/ /* Sampler states*/
for (i = 0 ; i < MAX_SAMPLERS; i++) { for (i = 0 ; i < MAX_SAMPLERS; i++) {
TRACE("Setting up default samplers states for sampler %d\n", i); TRACE("Setting up default samplers states for sampler %d\n", i);
This->samplerState[i][WINED3DSAMP_ADDRESSU ] = D3DTADDRESS_WRAP; This->samplerState[i][WINED3DSAMP_ADDRESSU ] = D3DTADDRESS_WRAP;
This->samplerState[i][WINED3DSAMP_ADDRESSV ] = D3DTADDRESS_WRAP; This->samplerState[i][WINED3DSAMP_ADDRESSV ] = D3DTADDRESS_WRAP;
This->samplerState[i][WINED3DSAMP_ADDRESSW ] = D3DTADDRESS_WRAP; This->samplerState[i][WINED3DSAMP_ADDRESSW ] = D3DTADDRESS_WRAP;
@ -714,9 +714,11 @@ HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock*
const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl = const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl =
{ {
/* IUnknown */
IWineD3DStateBlockImpl_QueryInterface, IWineD3DStateBlockImpl_QueryInterface,
IWineD3DStateBlockImpl_AddRef, IWineD3DStateBlockImpl_AddRef,
IWineD3DStateBlockImpl_Release, IWineD3DStateBlockImpl_Release,
/* IWineD3DStateBlock */
IWineD3DStateBlockImpl_GetParent, IWineD3DStateBlockImpl_GetParent,
IWineD3DStateBlockImpl_GetDevice, IWineD3DStateBlockImpl_GetDevice,
IWineD3DStateBlockImpl_Capture, IWineD3DStateBlockImpl_Capture,

View File

@ -4,7 +4,7 @@
* Copyright 2002-2005 Jason Edmeades * Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2003 Raphael Junqueira * Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Christian Costa * Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber * Copyright 2005 Oliver Stieber
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -107,7 +107,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
/* TODO: re-write the way textures and managed, /* TODO: re-write the way textures and managed,
* use a 'opengl context manager' to manage RenderTarget surfaces * use a 'opengl context manager' to manage RenderTarget surfaces
** *********************************************************/ ** *********************************************************/
/* TODO: check for locks */ /* TODO: check for locks */
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL; IWineD3DBaseTexture *baseTexture = NULL;
@ -116,7 +116,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
TRACE("Passing to conatiner\n"); TRACE("Passing to conatiner\n");
IWineD3DBaseTexture_PreLoad(baseTexture); IWineD3DBaseTexture_PreLoad(baseTexture);
IWineD3DBaseTexture_Release(baseTexture); IWineD3DBaseTexture_Release(baseTexture);
} else{ } else {
TRACE("(%p) : About to load surface\n", This); TRACE("(%p) : About to load surface\n", This);
ENTER_GL(); ENTER_GL();
#if 0 /* TODO: context manager support */ #if 0 /* TODO: context manager support */
@ -131,7 +131,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
checkGLcall("glBindTexture"); checkGLcall("glBindTexture");
IWineD3DSurface_LoadTexture(iface); IWineD3DSurface_LoadTexture(iface);
/* This is where we should be reducing the amount of GLMemoryUsed */ /* This is where we should be reducing the amount of GLMemoryUsed */
}else { } else {
if (This->glDescription.level == 0) { if (This->glDescription.level == 0) {
glBindTexture(This->glDescription.target, This->glDescription.textureName); glBindTexture(This->glDescription.target, This->glDescription.textureName);
checkGLcall("glBindTexture"); checkGLcall("glBindTexture");
@ -158,10 +158,12 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
} }
D3DRESOURCETYPE WINAPI IWineD3DSurfaceImpl_GetType(IWineD3DSurface *iface) { D3DRESOURCETYPE WINAPI IWineD3DSurfaceImpl_GetType(IWineD3DSurface *iface) {
TRACE("(%p) : calling resourceimpl_GetType\n", iface);
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
} }
HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) { HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) {
TRACE("(%p) : calling resourceimpl_GetParent\n", iface);
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
} }
@ -202,7 +204,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFAC
return D3D_OK; return D3D_OK;
} }
void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target){ void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : setting textureName %u, target %i\n", This, textureName, target); TRACE("(%p) : setting textureName %u, target %i\n", This, textureName, target);
if (This->glDescription.textureName == 0 && textureName != 0) { if (This->glDescription.textureName == 0 && textureName != 0) {
@ -213,7 +215,7 @@ void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT te
This->glDescription.target = target; This->glDescription.target = target;
} }
void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription){ void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : returning %p\n", This, &This->glDescription); TRACE("(%p) : returning %p\n", This, &This->glDescription);
*glDescription = &This->glDescription; *glDescription = &This->glDescription;
@ -243,36 +245,38 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
} }
if (FALSE == This->lockable) { if (FALSE == This->lockable) {
/* Note: UpdateTextures calls CopyRects which calls this routine to populate the /* Note: UpdateTextures calls CopyRects which calls this routine to populate the
texture regions, and since the destination is an unlockable region we need texture regions, and since the destination is an unlockable region we need
to tolerate this */ to tolerate this */
TRACE("Warning: trying to lock unlockable surf@%p\n", This); TRACE("Warning: trying to lock unlockable surf@%p\n", This);
/*return D3DERR_INVALIDCALL; */ /*return D3DERR_INVALIDCALL; */
} }
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain); if (This->resource.usage & D3DUSAGE_RENDERTARGET) {
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain);
if (swapchain != NULL || iface == myDevice->renderTarget || iface == myDevice->depthStencilBuffer) { if (swapchain != NULL || iface == myDevice->renderTarget || iface == myDevice->depthStencilBuffer) {
if (swapchain != NULL && iface == swapchain->backBuffer) { if (swapchain != NULL && iface == swapchain->backBuffer) {
TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory); TRACE("(%p, backBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (swapchain != NULL && iface == swapchain->frontBuffer) { } else if (swapchain != NULL && iface == swapchain->frontBuffer) {
TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory); TRACE("(%p, frontBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == myDevice->renderTarget) { } else if (iface == myDevice->renderTarget) {
TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory); TRACE("(%p, renderTarget) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == myDevice->depthStencilBuffer) { } else if (iface == myDevice->depthStencilBuffer) {
TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory); TRACE("(%p, stencilBuffer) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} }
if (NULL != swapchain) { if (NULL != swapchain) {
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain); IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
}
swapchain = NULL;
} }
swapchain = NULL;
} else { } else {
TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory); TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} }
/* DXTn formats don't have exact pitches as they are to the new row of blocks, /* DXTn formats don't have exact pitches as they are to the new row of blocks,
where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt3/5) where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt3/5)
ie pitch = (width/4) * bytes per block */ ie pitch = (width/4) * bytes per block */
if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */ if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 3; pLockedRect->Pitch = (This->currentDesc.Width >> 2) << 3;
@ -302,7 +306,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
This->lockedRect.bottom = pRect->bottom; This->lockedRect.bottom = pRect->bottom;
} }
if(This->nonpow2){ if (This->nonpow2) {
TRACE("Locking non-power 2 texture\n"); TRACE("Locking non-power 2 texture\n");
} }
@ -407,31 +411,31 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
if (iface == myDevice->renderTarget || iface == swapchain->backBuffer) { if (iface == myDevice->renderTarget || iface == swapchain->backBuffer) {
TRACE("locking back buffer\n"); TRACE("locking back buffer\n");
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
}else if (iface == swapchain->frontBuffer) { } else if (iface == swapchain->frontBuffer) {
TRACE("locking front\n"); TRACE("locking front\n");
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
}else if (iface == myDevice->depthStencilBuffer) { } else if (iface == myDevice->depthStencilBuffer) {
FIXME("Stencil Buffer lock unsupported for now\n"); FIXME("Stencil Buffer lock unsupported for now\n");
} else{ } else {
FIXME("(%p) Shouldn't have got here!\n", This); FIXME("(%p) Shouldn't have got here!\n", This);
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
} }
}else if (swapchain != NULL) { } else if (swapchain != NULL) {
IWineD3DSwapChainImpl *implSwapChain; IWineD3DSwapChainImpl *implSwapChain;
IWineD3DDevice_GetSwapChain((IWineD3DDevice *)myDevice, 0, (IWineD3DSwapChain **)&implSwapChain); IWineD3DDevice_GetSwapChain((IWineD3DDevice *)myDevice, 0, (IWineD3DSwapChain **)&implSwapChain);
if (swapchain->glCtx == implSwapChain->render_ctx && swapchain->drawable == implSwapChain->win) { if (swapchain->glCtx == implSwapChain->render_ctx && swapchain->drawable == implSwapChain->win) {
/* This will fail for the implicit swapchain, which is why there needs to be a context manager */ /* This will fail for the implicit swapchain, which is why there needs to be a context manager */
if (iface == swapchain->backBuffer) { if (iface == swapchain->backBuffer) {
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
}else if (iface == swapchain->frontBuffer) { } else if (iface == swapchain->frontBuffer) {
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
} else if (iface == myDevice->depthStencilBuffer) { } else if (iface == myDevice->depthStencilBuffer) {
FIXME("Stencil Buffer lock unsupported for now\n"); FIXME("Stencil Buffer lock unsupported for now\n");
} else{ } else {
FIXME("Should have got here!\n"); FIXME("Should have got here!\n");
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
} }
}else{ } else {
/* We need to switch contexts to be able to read the buffer!!! */ /* We need to switch contexts to be able to read the buffer!!! */
FIXME("The buffer requested isn't in the current openGL context\n"); FIXME("The buffer requested isn't in the current openGL context\n");
notInContext = TRUE; notInContext = TRUE;
@ -468,7 +472,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
BOOL ati_performance_hack = FALSE; BOOL ati_performance_hack = FALSE;
ati_performance_hack = (This->lockedRect.bottom - This->lockedRect.top > 10) || (This->lockedRect.right - This->lockedRect.left > 10)? TRUE: FALSE; ati_performance_hack = (This->lockedRect.bottom - This->lockedRect.top > 10) || (This->lockedRect.right - This->lockedRect.left > 10)? TRUE: FALSE;
#endif #endif
if ((This->lockedRect.left ==0 && This->lockedRect.top ==0 && if ((This->lockedRect.left == 0 && This->lockedRect.top == 0 &&
This->lockedRect.right == This->currentDesc.Width This->lockedRect.right == This->currentDesc.Width
&& This->lockedRect.bottom == This->currentDesc.Height)) { && This->lockedRect.bottom == This->currentDesc.Height)) {
glReadPixels(0, 0, glReadPixels(0, 0,
@ -477,7 +481,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
This->glDescription.glFormat, This->glDescription.glFormat,
This->glDescription.glType, This->glDescription.glType,
(char *)pLockedRect->pBits); (char *)pLockedRect->pBits);
}else if (This->lockedRect.left ==0 && This->lockedRect.right == This->currentDesc.Width) { } else if (This->lockedRect.left == 0 && This->lockedRect.right == This->currentDesc.Width) {
glReadPixels(0, glReadPixels(0,
This->lockedRect.top, This->lockedRect.top,
This->currentDesc.Width, This->currentDesc.Width,
@ -507,19 +511,19 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
} else if (D3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */ } else if (D3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */
if(!messages & 1){ if (!messages & 1) {
FIXME("TODO stencil depth surface locking surf%p usage(%lu)\n", This, This->resource.usage); FIXME("TODO stencil depth surface locking surf%p usage(%lu)\n", This, This->resource.usage);
/* /*
glReadPixels(This->lockedRect.left, glReadPixels(This->lockedRect.left,
This->lockedRect.bottom - j - 1, This->lockedRect.bottom - j - 1,
This->lockedRect.right - This->lockedRect.left, This->lockedRect.right - This->lockedRect.left,
1, 1,
GL_STENCIL_INDEX or GL_DEPTH_COMPONENT GL_STENCIL_INDEX or GL_DEPTH_COMPONENT
) )
*/ */
messages |=1; messages |= 1;
} }
} else { } else {
FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, This->resource.usage); FIXME("unsupported locking to surface surf@%p usage(%lu)\n", This, This->resource.usage);
@ -540,7 +544,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RE
TRACE("Making container dirty\n"); TRACE("Making container dirty\n");
IWineD3DBaseTexture_SetDirty(pBaseTexture, TRUE); IWineD3DBaseTexture_SetDirty(pBaseTexture, TRUE);
IWineD3DBaseTexture_Release(pBaseTexture); IWineD3DBaseTexture_Release(pBaseTexture);
}else{ } else {
TRACE("Surface is standalone, no need to dirty the container\n"); TRACE("Surface is standalone, no need to dirty the container\n");
} }
} }
@ -563,16 +567,18 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain); if (D3DUSAGE_RENDERTARGET & This->resource.usage) {
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain);
if ((swapchain != NULL) && iface == swapchain->backBuffer) { if ((swapchain != NULL) && iface == swapchain->backBuffer) {
buffername = "backBuffer"; buffername = "backBuffer";
} else if ((swapchain != NULL) && iface == swapchain->frontBuffer) { } else if ((swapchain != NULL) && iface == swapchain->frontBuffer) {
buffername = "frontBuffer"; buffername = "frontBuffer";
} else if (iface == myDevice->depthStencilBuffer) { } else if (iface == myDevice->depthStencilBuffer) {
buffername = "depthStencilBuffer"; buffername = "depthStencilBuffer";
} else if (iface == myDevice->renderTarget) { } else if (iface == myDevice->renderTarget) {
buffername = "renderTarget"; buffername = "renderTarget";
}
} }
if (swapchain != NULL) { if (swapchain != NULL) {
@ -621,7 +627,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
vcheckGLcall("glPixelZoom"); vcheckGLcall("glPixelZoom");
/* glDrawPixels transforms the raster position as though it was a vertex - /* glDrawPixels transforms the raster position as though it was a vertex -
we want to draw at screen position 0,0 - Set up ortho (rhw) mode as we want to draw at screen position 0,0 - Set up ortho (rhw) mode as
per drawprim (and leave set - it will sort itself out due to last_was_rhw */ per drawprim (and leave set - it will sort itself out due to last_was_rhw */
if (!myDevice->last_was_rhw) { if (!myDevice->last_was_rhw) {
@ -629,7 +635,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
myDevice->last_was_rhw = TRUE; myDevice->last_was_rhw = TRUE;
/* Transformed already into viewport coordinates, so we do not need transform /* Transformed already into viewport coordinates, so we do not need transform
matrices. Reset all matrices to identity and leave the default matrix in world matrices. Reset all matrices to identity and leave the default matrix in world
mode. */ mode. */
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode"); checkGLcall("glMatrixMode");
@ -819,7 +825,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
if ((This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) && if ((This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8) &&
!GL_SUPPORT(EXT_PALETTED_TEXTURE)) { !GL_SUPPORT(EXT_PALETTED_TEXTURE)) {
/** /**
* wanted a paletted texture and not really support it in HW * wanted a paletted texture and not really support it in HW
* so software emulation code begin * so software emulation code begin
*/ */
UINT i; UINT i;
@ -836,7 +842,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
if (This->resource.format == WINED3DFMT_A8P8) if (This->resource.format == WINED3DFMT_A8P8)
*dst++ = pal[color].peFlags; *dst++ = pal[color].peFlags;
else else
*dst++ = 0xFF; *dst++ = 0xFF;
} }
ENTER_GL(); ENTER_GL();
@ -845,9 +851,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
This->glDescription.target, This->glDescription.target,
This->glDescription.level, This->glDescription.level,
GL_RGBA, GL_RGBA,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0, 0,
GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
surface); surface);
@ -865,7 +871,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
LEAVE_GL(); LEAVE_GL();
return D3D_OK; return D3D_OK;
} }
/* TODO: Compressed non-power 2 support */ /* TODO: Compressed non-power 2 support */
@ -878,9 +884,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
This->glDescription.target, This->glDescription.target,
This->glDescription.level, This->glDescription.level,
This->glDescription.glFormatInternal, This->glDescription.glFormatInternal,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0, 0,
This->resource.size, This->resource.size,
This->resource.allocatedMemory); This->resource.allocatedMemory);
@ -963,7 +969,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
This->glDescription.glFormatInternal, This->glDescription.glFormatInternal,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0, 0,
This->glDescription.glFormat, This->glDescription.glFormat,
This->glDescription.glType, This->glDescription.glType,
This->resource.allocatedMemory); This->resource.allocatedMemory);
@ -1084,7 +1090,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
} }
} }
break; break;
default: default:
FIXME("Unimplemented dump mode format(%u,%s)\n", This->resource.format, debug_d3dformat(This->resource.format)); FIXME("Unimplemented dump mode format(%u,%s)\n", This->resource.format, debug_d3dformat(This->resource.format));
} }
fclose(f); fclose(f);
@ -1098,7 +1104,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface *iface) {
This->dirtyRect.top = This->currentDesc.Height; This->dirtyRect.top = This->currentDesc.Height;
This->dirtyRect.right = 0; This->dirtyRect.right = 0;
This->dirtyRect.bottom = 0; This->dirtyRect.bottom = 0;
TRACE("(%p) : Dirty?%d, Rect:(%ld,%ld,%ld,%ld)\n", This, This->Dirty, This->dirtyRect.left, TRACE("(%p) : Dirty?%d, Rect:(%ld,%ld,%ld,%ld)\n", This, This->Dirty, This->dirtyRect.left,
This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom); This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom);
return D3D_OK; return D3D_OK;
} }
@ -1121,7 +1127,7 @@ extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, C
This->dirtyRect.right = This->currentDesc.Width; This->dirtyRect.right = This->currentDesc.Width;
This->dirtyRect.bottom = This->currentDesc.Height; This->dirtyRect.bottom = This->currentDesc.Height;
} }
TRACE("(%p) : Dirty?%d, Rect:(%ld,%ld,%ld,%ld)\n", This, This->Dirty, This->dirtyRect.left, TRACE("(%p) : Dirty?%d, Rect:(%ld,%ld,%ld,%ld)\n", This, This->Dirty, This->dirtyRect.left,
This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom); This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom);
/* if the container is a basetexture then mark it dirty. */ /* if the container is a basetexture then mark it dirty. */
if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == D3D_OK) { if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == D3D_OK) {
@ -1136,13 +1142,13 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IUnknown
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("Setting container to %p from %p\n", container, This->container); TRACE("Setting container to %p from %p\n", container, This->container);
This->container = container; This->container = container;
return D3D_OK; return D3D_OK;
} }
/* TODO: replace this function with context management routines */ /* TODO: replace this function with context management routines */
HRESULT WINAPI IWineD3DSurfaceImpl_SetPBufferState(IWineD3DSurface *iface, BOOL inPBuffer, BOOL inTexture) { HRESULT WINAPI IWineD3DSurfaceImpl_SetPBufferState(IWineD3DSurface *iface, BOOL inPBuffer, BOOL inTexture) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
This->inPBuffer = inPBuffer; This->inPBuffer = inPBuffer;
This->inTexture = inTexture; This->inTexture = inTexture;
return D3D_OK; return D3D_OK;
@ -1164,7 +1170,7 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
IWineD3DSurfaceImpl_GetPriority, IWineD3DSurfaceImpl_GetPriority,
IWineD3DSurfaceImpl_PreLoad, IWineD3DSurfaceImpl_PreLoad,
IWineD3DSurfaceImpl_GetType, IWineD3DSurfaceImpl_GetType,
/* IWineD3DSurface */ /* IWineD3DSurface */
IWineD3DSurfaceImpl_GetContainer, IWineD3DSurfaceImpl_GetContainer,
IWineD3DSurfaceImpl_GetDesc, IWineD3DSurfaceImpl_GetDesc,
IWineD3DSurfaceImpl_LockRect, IWineD3DSurfaceImpl_LockRect,

View File

@ -45,11 +45,11 @@ inline static Display *get_display( HDC hdc )
return display; return display;
} }
/*TODO: some of the additional parameters may be required to /*TODO: some of the additional parameters may be required to
set the gamma ramp (for some weird reason microsoft have left swap gammaramp in device set the gamma ramp (for some weird reason microsoft have left swap gammaramp in device
but it operates on a swapchain, it may be a good idea to move it to IWineD3DSwapChain for IWineD3D)*/ but it operates on a swapchain, it may be a good idea to move it to IWineD3DSwapChain for IWineD3D)*/
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_fps); WINE_DECLARE_DEBUG_CHANNEL(d3d_fps);
@ -75,14 +75,14 @@ HRESULT WINAPI IWineD3DSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, RE
} }
*ppobj = This; *ppobj = This;
return D3D_OK; return D3D_OK;
} }
return E_NOINTERFACE; return E_NOINTERFACE;
} }
ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) { ULONG WINAPI IWineD3DSwapChainImpl_Release(IWineD3DSwapChain *iface) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
DWORD refCount; DWORD refCount;
refCount = InterlockedDecrement(&This->ref); refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %ld\n", This, refCount); TRACE("(%p) : ReleaseRef to %ld\n", This, refCount);
if (refCount == 0) { if (refCount == 0) {
@ -125,20 +125,20 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknow
/*IWineD3DSwapChain parts follow: */ /*IWineD3DSwapChain parts follow: */
HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) { HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
ENTER_GL(); ENTER_GL();
if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect); if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
/* TODO: If only source rect or dest rect are supplied then clip the window to match */ /* TODO: If only source rect or dest rect are supplied then clip the window to match */
TRACE("preseting display %p, drawable %ld\n", This->display, This->drawable); TRACE("preseting display %p, drawable %ld\n", This->display, This->drawable);
/* Don't call checkGLcall, as glGetError is not applicable here */ /* Don't call checkGLcall, as glGetError is not applicable here */
if (hDestWindowOverride && This->win_handle != hDestWindowOverride) { if (hDestWindowOverride && This->win_handle != hDestWindowOverride) {
/* Set this swapchain up to point to the new destination.. */ /* Set this swapchain up to point to the new destination.. */
#ifdef USE_CONTEXT_MANAGER #ifdef USE_CONTEXT_MANAGER
/* TODO: use a context mamager */ /* TODO: use a context mamager */
#endif #endif
/* FIXME: Never access */ /* FIXME: Never access */
IWineD3DSwapChainImpl *swapChainImpl; IWineD3DSwapChainImpl *swapChainImpl;
IWineD3DDevice_GetSwapChain((IWineD3DDevice *)This->wineD3DDevice, 0 , (IWineD3DSwapChain **)&swapChainImpl); IWineD3DDevice_GetSwapChain((IWineD3DDevice *)This->wineD3DDevice, 0 , (IWineD3DSwapChain **)&swapChainImpl);
@ -152,11 +152,11 @@ HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST REC
int num; int num;
Display *oldDisplay = This->display; Display *oldDisplay = This->display;
GLXContext oldContext = This->glCtx; GLXContext oldContext = This->glCtx;
IUnknown* tmp; IUnknown* tmp;
GLXContext currentContext; GLXContext currentContext;
Drawable currentDrawable; Drawable currentDrawable;
hDc = GetDC(hDestWindowOverride); hDc = GetDC(hDestWindowOverride);
This->win_handle = hDestWindowOverride; This->win_handle = hDestWindowOverride;
This->win = (Window)GetPropA( hDestWindowOverride, "__wine_x11_whole_window" ); This->win = (Window)GetPropA( hDestWindowOverride, "__wine_x11_whole_window" );
TRACE("Creating a new context for the window %p \n", hDestWindowOverride); TRACE("Creating a new context for the window %p \n", hDestWindowOverride);
@ -174,7 +174,7 @@ HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST REC
template.visualid = (VisualID)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id"); template.visualid = (VisualID)GetPropA(GetDesktopWindow(), "__wine_x11_visual_id");
This->visInfo = XGetVisualInfo(This->display, VisualIDMask, &template, &num); This->visInfo = XGetVisualInfo(This->display, VisualIDMask, &template, &num);
if (NULL == This->visInfo) { if (NULL == This->visInfo) {
ERR("cannot really get XVisual\n"); ERR("cannot really get XVisual\n");
LEAVE_GL(); LEAVE_GL();
return D3DERR_NOTAVAILABLE; return D3DERR_NOTAVAILABLE;
} }
@ -185,7 +185,7 @@ HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST REC
This->glCtx = glXCreateContext(This->display, This->visInfo, swapChainImpl->glCtx, GL_TRUE); This->glCtx = glXCreateContext(This->display, This->visInfo, swapChainImpl->glCtx, GL_TRUE);
if (NULL == This->glCtx) { if (NULL == This->glCtx) {
ERR("cannot create glxContext\n"); ERR("cannot create glxContext\n");
} }
This->drawable = This->win; This->drawable = This->win;
This->render_ctx = This->glCtx; This->render_ctx = This->glCtx;
@ -206,25 +206,25 @@ HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST REC
glClearIndex(0); glClearIndex(0);
glClearDepth(1); glClearDepth(1);
glClearStencil(0); glClearStencil(0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
checkGLcall("glClear"); checkGLcall("glClear");
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
checkGLcall("glColor3f"); checkGLcall("glColor3f");
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
checkGLcall("glEnable"); checkGLcall("glEnable");
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);"); checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
checkGLcall("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); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);"); checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
/* If this swapchain is currently the active context then make this swapchain active */ /* If this swapchain is currently the active context then make this swapchain active */
if(IWineD3DSurface_GetContainer((IWineD3DSurface *)This->wineD3DDevice->renderTarget, &IID_IWineD3DSwapChain, (void **)&tmp) == D3D_OK){ if(IWineD3DSurface_GetContainer((IWineD3DSurface *)This->wineD3DDevice->renderTarget, &IID_IWineD3DSwapChain, (void **)&tmp) == D3D_OK){
if(tmp != (IUnknown *)This){ if(tmp != (IUnknown *)This){
@ -235,21 +235,21 @@ HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST REC
}else{ }else{
/* reset the context */ /* reset the context */
glXMakeCurrent(This->display, currentDrawable, currentContext); glXMakeCurrent(This->display, currentDrawable, currentContext);
checkGLcall("glXMakeCurrent"); checkGLcall("glXMakeCurrent");
} }
/* delete the old contxt*/ /* delete the old contxt*/
glXDestroyContext(oldDisplay, oldContext); /* Should this happen on an active context? seems a bad idea */ glXDestroyContext(oldDisplay, oldContext); /* Should this happen on an active context? seems a bad idea */
LEAVE_GL(); LEAVE_GL();
} }
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapChainImpl); IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapChainImpl);
} }
/* TODO: The slow way, save the data to memory, create a new context for the destination window, transfer the data cleanup, it may be a good idea to the move this swapchain over to the using the target winows context so that it runs faster in feature. */ /* TODO: The slow way, save the data to memory, create a new context for the destination window, transfer the data cleanup, it may be a good idea to the move this swapchain over to the using the target winows context so that it runs faster in feature. */
glXSwapBuffers(This->display, This->drawable); /* TODO: cycle through the swapchain buffers */ glXSwapBuffers(This->display, This->drawable); /* TODO: cycle through the swapchain buffers */
TRACE("glXSwapBuffers called, Starting new frame\n"); TRACE("glXSwapBuffers called, Starting new frame\n");
/* FPS support */ /* FPS support */
if (TRACE_ON(d3d_fps)) if (TRACE_ON(d3d_fps))
@ -308,8 +308,8 @@ HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST REC
/* Although this is not strictly required, a simple demo showed this does occur /* Although this is not strictly required, a simple demo showed this does occur
on (at least non-debug) d3d */ on (at least non-debug) d3d */
if (This->presentParms.SwapEffect & D3DSWAPEFFECT_DISCARD) { if (This->presentParms.SwapEffect & D3DSWAPEFFECT_DISCARD) {
TRACE("Clearing\n"); TRACE("Clearing\n");
IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0); IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0x00, 1.0, 0);
@ -323,7 +323,7 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)pDestSurface; IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)pDestSurface;
GLenum format; GLenum format;
GLenum type; GLenum type;
TRACE("(%p) : iface(%p) pDestSurface(%p) \n", This, iface, pDestSurface); TRACE("(%p) : iface(%p) pDestSurface(%p) \n", This, iface, pDestSurface);
ENTER_GL(); ENTER_GL();
@ -331,21 +331,21 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface
format = D3DFmt2GLFmt(This->wineD3DDevice, surface->resource.format); format = D3DFmt2GLFmt(This->wineD3DDevice, surface->resource.format);
type = D3DFmt2GLType(This->wineD3DDevice, surface->resource.format); type = D3DFmt2GLType(This->wineD3DDevice, surface->resource.format);
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
glReadPixels(0, glReadPixels(0,
0, 0,
surface->currentDesc.Width, surface->currentDesc.Width,
surface->currentDesc.Height, surface->currentDesc.Height,
format, format,
type, type,
surface->resource.allocatedMemory); surface->resource.allocatedMemory);
LEAVE_GL(); LEAVE_GL();
return D3D_OK; return D3D_OK;
} }
HRESULT WINAPI IWineD3DSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) { HRESULT WINAPI IWineD3DSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
*ppBackBuffer = (IWineD3DSurface *) This->backBuffer; *ppBackBuffer = (IWineD3DSurface *) This->backBuffer;
TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, iBackBuffer, Type, *ppBackBuffer); TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, iBackBuffer, Type, *ppBackBuffer);
@ -355,13 +355,13 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UIN
} }
/* Note inc ref on returned surface */ /* Note inc ref on returned surface */
IWineD3DSurface_AddRef(*ppBackBuffer); IWineD3DSurface_AddRef(*ppBackBuffer);
return D3D_OK; return D3D_OK;
} }
HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, D3DRASTER_STATUS*pRasterStatus) { HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, D3DRASTER_STATUS*pRasterStatus) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
pRasterStatus->InVBlank = TRUE; pRasterStatus->InVBlank = TRUE;
pRasterStatus->ScanLine = 0; pRasterStatus->ScanLine = 0;
FIXME("(%p) : stub\n", This); FIXME("(%p) : stub\n", This);
@ -369,7 +369,7 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, D
} }
HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, D3DDISPLAYMODE*pMode) { HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, D3DDISPLAYMODE*pMode) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
HDC hdc; HDC hdc;
int bpp = 0; int bpp = 0;
@ -386,22 +386,22 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, D3
case 16: pMode->Format = D3DFMT_R5G6B5; break; case 16: pMode->Format = D3DFMT_R5G6B5; break;
case 24: /*pMode->Format = D3DFMT_R8G8B8; break; */ /* 32bpp and 24bpp can be aliased for X */ case 24: /*pMode->Format = D3DFMT_R8G8B8; break; */ /* 32bpp and 24bpp can be aliased for X */
case 32: pMode->Format = D3DFMT_A8R8G8B8; break; case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
default: default:
FIXME("Unrecognized display mode format\n"); FIXME("Unrecognized display mode format\n");
pMode->Format = D3DFMT_UNKNOWN; pMode->Format = D3DFMT_UNKNOWN;
} }
TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate, TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
pMode->Format, debug_d3dformat(pMode->Format)); pMode->Format, debug_d3dformat(pMode->Format));
return D3D_OK; return D3D_OK;
} }
HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) { HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
*ppDevice = (IWineD3DDevice *) This->wineD3DDevice; *ppDevice = (IWineD3DDevice *) This->wineD3DDevice;
/* Note Calling this method will increase the internal reference count /* Note Calling this method will increase the internal reference count
on the IDirect3DDevice9 interface. */ on the IDirect3DDevice9 interface. */
IWineD3DDevice_AddRef(*ppDevice); IWineD3DDevice_AddRef(*ppDevice);
TRACE("(%p) : returning %p\n", This, *ppDevice); TRACE("(%p) : returning %p\n", This, *ppDevice);
@ -410,7 +410,7 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3
HRESULT WINAPI IWineD3DSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, D3DPRESENT_PARAMETERS *pPresentationParameters) { HRESULT WINAPI IWineD3DSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, D3DPRESENT_PARAMETERS *pPresentationParameters) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
FIXME("(%p) : copy\n", This); FIXME("(%p) : copy\n", This);
memcpy(pPresentationParameters, &This->presentParms, sizeof(D3DPRESENT_PARAMETERS)); memcpy(pPresentationParameters, &This->presentParms, sizeof(D3DPRESENT_PARAMETERS));
return D3D_OK; return D3D_OK;
} }
@ -424,7 +424,7 @@ HRESULT WINAPI IWineD3DSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWOR
SetDeviceGammaRamp(hDC, (LPVOID)pRamp); SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
ReleaseDC(This->win_handle, hDC); ReleaseDC(This->win_handle, hDC);
return D3D_OK; return D3D_OK;
} }
HRESULT WINAPI IWineD3DSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, D3DGAMMARAMP *pRamp){ HRESULT WINAPI IWineD3DSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, D3DGAMMARAMP *pRamp){
@ -436,15 +436,17 @@ HRESULT WINAPI IWineD3DSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, D3DG
GetDeviceGammaRamp(hDC, pRamp); GetDeviceGammaRamp(hDC, pRamp);
ReleaseDC(This->win_handle, hDC); ReleaseDC(This->win_handle, hDC);
return D3D_OK; return D3D_OK;
} }
IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl = IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
{ {
/* IUnknown */
IWineD3DSwapChainImpl_QueryInterface, IWineD3DSwapChainImpl_QueryInterface,
IWineD3DSwapChainImpl_AddRef, IWineD3DSwapChainImpl_AddRef,
IWineD3DSwapChainImpl_Release, IWineD3DSwapChainImpl_Release,
/* IWineD3DSwapChain */
IWineD3DSwapChainImpl_GetParent, IWineD3DSwapChainImpl_GetParent,
IWineD3DSwapChainImpl_GetDevice, IWineD3DSwapChainImpl_GetDevice,
IWineD3DSwapChainImpl_Present, IWineD3DSwapChainImpl_Present,
@ -454,5 +456,5 @@ IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
IWineD3DSwapChainImpl_GetDisplayMode, IWineD3DSwapChainImpl_GetDisplayMode,
IWineD3DSwapChainImpl_GetPresentParameters, IWineD3DSwapChainImpl_GetPresentParameters,
IWineD3DSwapChainImpl_SetGammaRamp, IWineD3DSwapChainImpl_SetGammaRamp,
IWineD3DSwapChainImpl_GetGammaRamp IWineD3DSwapChainImpl_GetGammaRamp
}; };

View File

@ -231,7 +231,7 @@ HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface, UINT
return hr; return hr;
} }
HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT *pLockedRect, HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT *pLockedRect,
CONST RECT *pRect, DWORD Flags) { CONST RECT *pRect, DWORD Flags) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
HRESULT hr = D3DERR_INVALIDCALL; HRESULT hr = D3DERR_INVALIDCALL;
@ -266,7 +266,7 @@ HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UINT Level
HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, CONST RECT* pDirtyRect) { HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, CONST RECT* pDirtyRect) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
TRACE("(%p) : dirtyfication of surface Level (0)\n", This); TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
return IWineD3DSurface_AddDirtyRect((IWineD3DSurface *)This->surfaces[0], pDirtyRect); return IWineD3DSurface_AddDirtyRect((IWineD3DSurface *)This->surfaces[0], pDirtyRect);
} }

View File

@ -4,6 +4,7 @@
* Copyright 2002-2004 Jason Edmeades * Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira * Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa * Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -40,12 +41,12 @@ const char* debug_d3dformat(D3DFORMAT fmt) {
FMT_TO_STR(WINED3DFMT_A1R5G5B5); FMT_TO_STR(WINED3DFMT_A1R5G5B5);
FMT_TO_STR(WINED3DFMT_A4R4G4B4); FMT_TO_STR(WINED3DFMT_A4R4G4B4);
FMT_TO_STR(WINED3DFMT_R3G3B2); FMT_TO_STR(WINED3DFMT_R3G3B2);
FMT_TO_STR(WINED3DFMT_A8); FMT_TO_STR(WINED3DFMT_A8);
FMT_TO_STR(WINED3DFMT_A8R3G3B2); FMT_TO_STR(WINED3DFMT_A8R3G3B2);
FMT_TO_STR(WINED3DFMT_X4R4G4B4); FMT_TO_STR(WINED3DFMT_X4R4G4B4);
FMT_TO_STR(WINED3DFMT_G16R16); FMT_TO_STR(WINED3DFMT_G16R16);
FMT_TO_STR(WINED3DFMT_A2R10G10B10); FMT_TO_STR(WINED3DFMT_A2R10G10B10);
FMT_TO_STR(WINED3DFMT_A16B16G16R16); FMT_TO_STR(WINED3DFMT_A16B16G16R16);
FMT_TO_STR(WINED3DFMT_A8P8); FMT_TO_STR(WINED3DFMT_A8P8);
FMT_TO_STR(WINED3DFMT_P8); FMT_TO_STR(WINED3DFMT_P8);
FMT_TO_STR(WINED3DFMT_L8); FMT_TO_STR(WINED3DFMT_L8);
@ -57,7 +58,7 @@ const char* debug_d3dformat(D3DFORMAT fmt) {
FMT_TO_STR(WINED3DFMT_Q8W8V8U8); FMT_TO_STR(WINED3DFMT_Q8W8V8U8);
FMT_TO_STR(WINED3DFMT_V16U16); FMT_TO_STR(WINED3DFMT_V16U16);
FMT_TO_STR(WINED3DFMT_W11V11U10); FMT_TO_STR(WINED3DFMT_W11V11U10);
FMT_TO_STR(WINED3DFMT_A2W10V10U10); FMT_TO_STR(WINED3DFMT_A2W10V10U10);
FMT_TO_STR(WINED3DFMT_UYVY); FMT_TO_STR(WINED3DFMT_UYVY);
FMT_TO_STR(WINED3DFMT_YUY2); FMT_TO_STR(WINED3DFMT_YUY2);
FMT_TO_STR(WINED3DFMT_DXT1); FMT_TO_STR(WINED3DFMT_DXT1);
@ -95,7 +96,7 @@ const char* debug_d3ddevicetype(D3DDEVTYPE devtype) {
#define DEVTYPE_TO_STR(dev) case dev: return #dev #define DEVTYPE_TO_STR(dev) case dev: return #dev
DEVTYPE_TO_STR(D3DDEVTYPE_HAL); DEVTYPE_TO_STR(D3DDEVTYPE_HAL);
DEVTYPE_TO_STR(D3DDEVTYPE_REF); DEVTYPE_TO_STR(D3DDEVTYPE_REF);
DEVTYPE_TO_STR(D3DDEVTYPE_SW); DEVTYPE_TO_STR(D3DDEVTYPE_SW);
#undef DEVTYPE_TO_STR #undef DEVTYPE_TO_STR
default: default:
FIXME("Unrecognized %u D3DDEVTYPE!\n", devtype); FIXME("Unrecognized %u D3DDEVTYPE!\n", devtype);
@ -233,8 +234,8 @@ const char* debug_d3drenderstate(DWORD state) {
D3DSTATE_TO_STR(WINED3DRS_COLORWRITEENABLE ); D3DSTATE_TO_STR(WINED3DRS_COLORWRITEENABLE );
D3DSTATE_TO_STR(WINED3DRS_TWEENFACTOR ); D3DSTATE_TO_STR(WINED3DRS_TWEENFACTOR );
D3DSTATE_TO_STR(WINED3DRS_BLENDOP ); D3DSTATE_TO_STR(WINED3DRS_BLENDOP );
D3DSTATE_TO_STR(WINED3DRS_POSITIONORDER ); D3DSTATE_TO_STR(WINED3DRS_POSITIONDEGREE );
D3DSTATE_TO_STR(WINED3DRS_NORMALORDER ); D3DSTATE_TO_STR(WINED3DRS_NORMALDEGREE );
#undef D3DSTATE_TO_STR #undef D3DSTATE_TO_STR
default: default:
FIXME("Unrecognized %lu render state!\n", state); FIXME("Unrecognized %lu render state!\n", state);
@ -311,13 +312,13 @@ const char* debug_d3dpool(D3DPOOL Pool) {
* Useful functions mapping GL <-> D3D values * Useful functions mapping GL <-> D3D values
*/ */
GLenum StencilOp(DWORD op) { GLenum StencilOp(DWORD op) {
switch(op) { switch(op) {
case D3DSTENCILOP_KEEP : return GL_KEEP; case D3DSTENCILOP_KEEP : return GL_KEEP;
case D3DSTENCILOP_ZERO : return GL_ZERO; case D3DSTENCILOP_ZERO : return GL_ZERO;
case D3DSTENCILOP_REPLACE : return GL_REPLACE; case D3DSTENCILOP_REPLACE : return GL_REPLACE;
case D3DSTENCILOP_INCRSAT : return GL_INCR; case D3DSTENCILOP_INCRSAT : return GL_INCR;
case D3DSTENCILOP_DECRSAT : return GL_DECR; case D3DSTENCILOP_DECRSAT : return GL_DECR;
case D3DSTENCILOP_INVERT : return GL_INVERT; case D3DSTENCILOP_INVERT : return GL_INVERT;
case D3DSTENCILOP_INCR : return GL_INCR_WRAP_EXT; case D3DSTENCILOP_INCR : return GL_INCR_WRAP_EXT;
case D3DSTENCILOP_DECR : return GL_DECR_WRAP_EXT; case D3DSTENCILOP_DECR : return GL_DECR_WRAP_EXT;
default: default:
@ -341,8 +342,8 @@ GLenum StencilOp(DWORD op) {
#endif #endif
#if !defined(combine_ext) #if !defined(combine_ext)
void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3) void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3)
{ {
FIXME("Requires opengl combine extensions to work\n"); FIXME("Requires opengl combine extensions to work\n");
return; return;
} }
@ -367,15 +368,15 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
/* Note: Operations usually involve two ars, src0 and src1 and are operations of /* Note: Operations usually involve two ars, src0 and src1 and are operations of
the form (a1 <operation> a2). However, some of the more complex operations the form (a1 <operation> a2). However, some of the more complex operations
take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
in a third parameter called a0. Therefore these are operations of the form in a third parameter called a0. Therefore these are operations of the form
a0 <operation> a1 <operation> a2, ie the new parameter goes to the front. a0 <operation> a1 <operation> a2, ie the new parameter goes to the front.
However, below we treat the new (a0) parameter as src2/opr2, so in the actual However, below we treat the new (a0) parameter as src2/opr2, so in the actual
functions below, expect their syntax to differ slightly to those listed in the functions below, expect their syntax to differ slightly to those listed in the
manuals, ie replace arg1 with arg3, arg2 with arg1 and arg3 with arg2 manuals, ie replace arg1 with arg3, arg2 with arg1 and arg3 with arg2
This affects D3DTOP_MULTIPLYADD and D3DTOP_LERP */ This affects D3DTOP_MULTIPLYADD and D3DTOP_LERP */
if (isAlpha) { if (isAlpha) {
comb_target = useext(GL_COMBINE_ALPHA); comb_target = useext(GL_COMBINE_ALPHA);
src0_target = useext(GL_SOURCE0_ALPHA); src0_target = useext(GL_SOURCE0_ALPHA);
@ -398,17 +399,17 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
} }
/* From MSDN (WINED3DTSS_ALPHAARG1) : /* From MSDN (WINED3DTSS_ALPHAARG1) :
The default argument is D3DTA_TEXTURE. If no texture is set for this stage, The default argument is D3DTA_TEXTURE. If no texture is set for this stage,
then the default argument is D3DTA_DIFFUSE. then the default argument is D3DTA_DIFFUSE.
FIXME? If texture added/removed, may need to reset back as well? */ FIXME? If texture added/removed, may need to reset back as well? */
if (isAlpha && This->stateBlock->textures[Stage] == NULL && arg1 == D3DTA_TEXTURE) { if (isAlpha && This->stateBlock->textures[Stage] == NULL && arg1 == D3DTA_TEXTURE) {
GetSrcAndOpFromValue(D3DTA_DIFFUSE, isAlpha, &src1, &opr1); GetSrcAndOpFromValue(D3DTA_DIFFUSE, isAlpha, &src1, &opr1);
} else { } else {
GetSrcAndOpFromValue(arg1, isAlpha, &src1, &opr1); GetSrcAndOpFromValue(arg1, isAlpha, &src1, &opr1);
} }
GetSrcAndOpFromValue(arg2, isAlpha, &src2, &opr2); GetSrcAndOpFromValue(arg2, isAlpha, &src2, &opr2);
GetSrcAndOpFromValue(arg3, isAlpha, &src3, &opr3); GetSrcAndOpFromValue(arg3, isAlpha, &src3, &opr3);
TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target, src1, opr1, src2, opr2, src3, opr3); TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target, src1, opr1, src2, opr2, src3, opr3);
Handled = TRUE; /* Assume will be handled */ Handled = TRUE; /* Assume will be handled */
@ -434,60 +435,60 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
checkGLcall("GL_TEXTURE_ENV, src0_target, src1"); checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr); glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr"); checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr2_target, opr"); checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr3_target, opr"); checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
break; break;
case D3DTOP_SELECTARG1: /* = a1 * 1 + 0 * 0 */ case D3DTOP_SELECTARG1: /* = a1 * 1 + 0 * 0 */
case D3DTOP_SELECTARG2: /* = a2 * 1 + 0 * 0 */ case D3DTOP_SELECTARG2: /* = a2 * 1 + 0 * 0 */
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD); glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
if (op == D3DTOP_SELECTARG1) { if (op == D3DTOP_SELECTARG1) {
glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1"); checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1); glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
} else { } else {
glTexEnvi(GL_TEXTURE_ENV, src0_target, src2); glTexEnvi(GL_TEXTURE_ENV, src0_target, src2);
checkGLcall("GL_TEXTURE_ENV, src0_target, src2"); checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr2); glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr2);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2"); checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
} }
glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr); glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr"); checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr2_target, opr"); checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src3_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr3_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr3_target, opr"); checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
break; break;
case D3DTOP_MODULATE: case D3DTOP_MODULATE:
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD); glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */ checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1"); checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1); glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
glTexEnvi(GL_TEXTURE_ENV, src1_target, src2); glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2); glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr"); checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src2_target, src2"); checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
@ -501,15 +502,15 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
case D3DTOP_MODULATE2X: case D3DTOP_MODULATE2X:
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD); glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */ checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1"); checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1); glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
glTexEnvi(GL_TEXTURE_ENV, src1_target, src2); glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2); glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr"); checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src2_target, src2"); checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
@ -523,15 +524,15 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
case D3DTOP_MODULATE4X: case D3DTOP_MODULATE4X:
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD); glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_ADD);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */ checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1"); checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1); glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr1);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
glTexEnvi(GL_TEXTURE_ENV, src1_target, src2); glTexEnvi(GL_TEXTURE_ENV, src1_target, src2);
checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2); glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr2);
checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr"); checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src2_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src2_target, src2"); checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr); glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr);
checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
@ -738,8 +739,8 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */ checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO); glTexEnvi(GL_TEXTURE_ENV, src1_target, GL_ZERO);
checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO"); checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr); glTexEnvi(GL_TEXTURE_ENV, opr1_target, invopr);
checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr"); checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
glTexEnvi(GL_TEXTURE_ENV, src2_target, src2); /* a2 = arg2 */ glTexEnvi(GL_TEXTURE_ENV, src2_target, src2); /* a2 = arg2 */
checkGLcall("GL_TEXTURE_ENV, src2_target, src2"); checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2); glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
@ -863,7 +864,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
glTexEnvi(GL_TEXTURE_ENV, scal_target, 1); glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
checkGLcall("GL_TEXTURE_ENV, scal_target, 1"); checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
break; break;
case D3DTOP_BUMPENVMAP: case D3DTOP_BUMPENVMAP:
{ {
if (GL_SUPPORT(NV_TEXTURE_SHADER)) { if (GL_SUPPORT(NV_TEXTURE_SHADER)) {
@ -874,12 +875,12 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
texture unit 3: GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV texture unit 3: GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV
*/ */
float m[2][2]; float m[2][2];
union { union {
float f; float f;
DWORD d; DWORD d;
} tmpvalue; } tmpvalue;
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT00]; tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT00];
m[0][0] = tmpvalue.f; m[0][0] = tmpvalue.f;
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT01]; tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT01];
@ -888,7 +889,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
m[1][0] = tmpvalue.f; m[1][0] = tmpvalue.f;
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT11]; tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT11];
m[1][1] = tmpvalue.f; m[1][1] = tmpvalue.f;
/*FIXME("Stage %d matrix is (%.2f,%.2f),(%.2f,%.2f)\n", Stage, m[0][0], m[0][1], m[1][0], m[1][0]);*/ /*FIXME("Stage %d matrix is (%.2f,%.2f),(%.2f,%.2f)\n", Stage, m[0][0], m[0][1], m[1][0], m[1][0]);*/
if (FALSE == This->texture_shader_active) { if (FALSE == This->texture_shader_active) {
@ -947,7 +948,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
*/ */
LEAVE_GL(); LEAVE_GL();
return; return;
break; break;
} }
} }
@ -959,12 +960,12 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
if (Handled) { if (Handled) {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV"); checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
LEAVE_GL(); LEAVE_GL();
return; return;
} }
} /* GL_NV_texture_env_combine4 */ } /* GL_NV_texture_env_combine4 */
Handled = TRUE; /* Again, assume handled */ Handled = TRUE; /* Again, assume handled */
switch (op) { switch (op) {
case D3DTOP_DISABLE: /* Only for alpha */ case D3DTOP_DISABLE: /* Only for alpha */
@ -1172,7 +1173,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
glTexEnvi(GL_TEXTURE_ENV, scal_target, 1); glTexEnvi(GL_TEXTURE_ENV, scal_target, 1);
checkGLcall("GL_TEXTURE_ENV, scal_target, 1"); checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
break; break;
case D3DTOP_DOTPRODUCT3: case D3DTOP_DOTPRODUCT3:
if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3)) { if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3)) {
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB); glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB);
checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB"); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
@ -1402,13 +1403,13 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
BOOL combineOK = TRUE; BOOL combineOK = TRUE;
if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) { if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
DWORD op2; DWORD op2;
if (isAlpha) { if (isAlpha) {
op2 = This->stateBlock->textureState[Stage][WINED3DTSS_COLOROP]; op2 = This->stateBlock->textureState[Stage][WINED3DTSS_COLOROP];
} else { } else {
op2 = This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAOP]; op2 = This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAOP];
} }
/* Note: If COMBINE4 in effect can't go back to combine! */ /* Note: If COMBINE4 in effect can't go back to combine! */
switch (op2) { switch (op2) {
case D3DTOP_ADDSMOOTH: case D3DTOP_ADDSMOOTH:
@ -1432,21 +1433,21 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
} }
} }
} }
if (combineOK) { if (combineOK) {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE));
checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)"); checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
LEAVE_GL(); LEAVE_GL();
return; return;
} }
} }
LEAVE_GL(); LEAVE_GL();
/* After all the extensions, if still unhandled, report fixme */ /* After all the extensions, if still unhandled, report fixme */
FIXME("Unhandled texture operation %d\n", op); FIXME("Unhandled texture operation %d\n", op);
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
} }
#endif #endif
@ -1476,7 +1477,7 @@ void set_texture_matrix(const float *smat, DWORD flags)
case D3DTTFF_COUNT2: mat[2] = mat[6] = mat[10] = mat[14] = 0; case D3DTTFF_COUNT2: mat[2] = mat[6] = mat[10] = mat[14] = 0;
default: mat[3] = mat[7] = mat[11] = 0, mat[15] = 1; default: mat[3] = mat[7] = mat[11] = 0, mat[15] = 1;
} }
if (flags & D3DTTFF_PROJECTED) switch (flags & ~D3DTTFF_PROJECTED) { if (flags & D3DTTFF_PROJECTED) switch (flags & ~D3DTTFF_PROJECTED) {
case D3DTTFF_COUNT2: case D3DTTFF_COUNT2:
mat[3] = mat[1], mat[7] = mat[5], mat[11] = mat[9], mat[15] = mat[13]; mat[3] = mat[1], mat[7] = mat[5], mat[11] = mat[9], mat[15] = mat[13];
@ -1491,26 +1492,26 @@ void set_texture_matrix(const float *smat, DWORD flags)
checkGLcall("glLoadMatrixf(mat)"); checkGLcall("glLoadMatrixf(mat)");
} }
void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand) void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand)
{ {
BOOL isAlphaReplicate = FALSE; BOOL isAlphaReplicate = FALSE;
BOOL isComplement = FALSE; BOOL isComplement = FALSE;
*operand = GL_SRC_COLOR; *operand = GL_SRC_COLOR;
*source = GL_TEXTURE; *source = GL_TEXTURE;
/* Catch alpha replicate */ /* Catch alpha replicate */
if (iValue & D3DTA_ALPHAREPLICATE) { if (iValue & D3DTA_ALPHAREPLICATE) {
iValue = iValue & ~D3DTA_ALPHAREPLICATE; iValue = iValue & ~D3DTA_ALPHAREPLICATE;
isAlphaReplicate = TRUE; isAlphaReplicate = TRUE;
} }
/* Catch Complement */ /* Catch Complement */
if (iValue & D3DTA_COMPLEMENT) { if (iValue & D3DTA_COMPLEMENT) {
iValue = iValue & ~D3DTA_COMPLEMENT; iValue = iValue & ~D3DTA_COMPLEMENT;
isComplement = TRUE; isComplement = TRUE;
} }
/* Calculate the operand */ /* Calculate the operand */
if (isAlphaReplicate && !isComplement) { if (isAlphaReplicate && !isComplement) {
*operand = GL_SRC_ALPHA; *operand = GL_SRC_ALPHA;
@ -1529,7 +1530,7 @@ void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum*
*operand = GL_SRC_COLOR; *operand = GL_SRC_COLOR;
} }
} }
/* Calculate the source */ /* Calculate the source */
switch (iValue & D3DTA_SELECTMASK) { switch (iValue & D3DTA_SELECTMASK) {
case D3DTA_CURRENT: *source = GL_PREVIOUS_EXT; case D3DTA_CURRENT: *source = GL_PREVIOUS_EXT;
@ -1574,7 +1575,7 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt) {
if (retVal == 0) { if (retVal == 0) {
switch (fmt) { switch (fmt) {
/* Paletted */ /* Paletted */
case WINED3DFMT_P8: retVal = GL_COLOR_INDEX8_EXT; break; case WINED3DFMT_P8: retVal = GL_COLOR_INDEX8_EXT; break;
case WINED3DFMT_A8P8: retVal = GL_COLOR_INDEX8_EXT; break; case WINED3DFMT_A8P8: retVal = GL_COLOR_INDEX8_EXT; break;
/* Luminance */ /* Luminance */
@ -1586,7 +1587,7 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt) {
case WINED3DFMT_V16U16: retVal = GL_COLOR_INDEX; break; case WINED3DFMT_V16U16: retVal = GL_COLOR_INDEX; break;
case WINED3DFMT_L6V5U5: retVal = GL_COLOR_INDEX8_EXT; break; case WINED3DFMT_L6V5U5: retVal = GL_COLOR_INDEX8_EXT; break;
case WINED3DFMT_X8L8V8U8: retVal = GL_COLOR_INDEX; break; case WINED3DFMT_X8L8V8U8: retVal = GL_COLOR_INDEX; break;
/* color buffer */ /* color buffer */
case WINED3DFMT_R3G3B2: retVal = GL_R3_G3_B2; break; case WINED3DFMT_R3G3B2: retVal = GL_R3_G3_B2; break;
case WINED3DFMT_R5G6B5: retVal = GL_RGB5; break; /* fixme: internal format 6 for g? */ case WINED3DFMT_R5G6B5: retVal = GL_RGB5; break; /* fixme: internal format 6 for g? */
case WINED3DFMT_R8G8B8: retVal = GL_RGB8; break; case WINED3DFMT_R8G8B8: retVal = GL_RGB8; break;
@ -1741,13 +1742,13 @@ SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt) {
case WINED3DFMT_L6V5U5: retVal = 2; break; case WINED3DFMT_L6V5U5: retVal = 2; break;
case WINED3DFMT_V16U16: retVal = 4; break; case WINED3DFMT_V16U16: retVal = 4; break;
case WINED3DFMT_X8L8V8U8: retVal = 4; break; case WINED3DFMT_X8L8V8U8: retVal = 4; break;
/* Compressed */ /* Compressed */
case WINED3DFMT_DXT1: retVal = 1; break; /* Actually 8 bytes per 16 pixels - Special cased later */ case WINED3DFMT_DXT1: retVal = 1; break; /* Actually 8 bytes per 16 pixels - Special cased later */
case WINED3DFMT_DXT3: retVal = 1; break; /* Actually 16 bytes per 16 pixels */ case WINED3DFMT_DXT3: retVal = 1; break; /* Actually 16 bytes per 16 pixels */
case WINED3DFMT_DXT5: retVal = 1; break; /* Actually 16 bytes per 16 pixels */ case WINED3DFMT_DXT5: retVal = 1; break; /* Actually 16 bytes per 16 pixels */
/* to see */ /* to see */
case WINED3DFMT_A8: retVal = 1; break; case WINED3DFMT_A8: retVal = 1; break;
/* unknown */ /* unknown */
case WINED3DFMT_UNKNOWN: case WINED3DFMT_UNKNOWN:
/* Guess at the highest value of the above */ /* Guess at the highest value of the above */
TRACE("WINED3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt); TRACE("WINED3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt);
@ -1764,9 +1765,9 @@ SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt) {
/* Convertes a D3D format into a OpenGL configuration format */ /* Convertes a D3D format into a OpenGL configuration format */
int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate){ int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate){
#define PUSH1(att) attribs[(*nAttribs)++] = (att); #define PUSH1(att) attribs[(*nAttribs)++] = (att);
#define PUSH2(att,value) attribs[(*nAttribs)++] = (att); attribs[(*nAttribs)++] = (value); #define PUSH2(att,value) attribs[(*nAttribs)++] = (att); attribs[(*nAttribs)++] = (value);
/*We need to do some Card specific stuff in here at some point, /*We need to do some Card specific stuff in here at some point,
D3D now support floating point format buffers, and their are a number of different OpelGl ways on managing thease e.g. D3D now support floating point format buffers, and their are a number of different OpelGl ways on managing thease e.g.
GLX_ATI_pixel_format_float GLX_ATI_pixel_format_float
*/ */
@ -1820,7 +1821,7 @@ int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, i
break; break;
} }
if(!alternate){ if(!alternate){
switch (StencilBufferFormat) { switch (StencilBufferFormat) {
case WINED3DFMT_D16_LOCKABLE: case WINED3DFMT_D16_LOCKABLE:
case WINED3DFMT_D16: case WINED3DFMT_D16:
PUSH2(GLX_DEPTH_SIZE, 16); PUSH2(GLX_DEPTH_SIZE, 16);
@ -1829,7 +1830,7 @@ int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, i
case WINED3DFMT_D15S1: case WINED3DFMT_D15S1:
PUSH2(GLX_DEPTH_SIZE, 15); PUSH2(GLX_DEPTH_SIZE, 15);
PUSH2(GLX_STENCIL_SIZE, 1); PUSH2(GLX_STENCIL_SIZE, 1);
/*Does openGl support a 1bit stencil?, I've seen it used elsewhere /*Does openGl support a 1bit stencil?, I've seen it used elsewhere
e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/ e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/
break; break;
@ -1855,8 +1856,8 @@ int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, i
break; break;
} }
}else{ /* it the device doesn't support the 'exact' format, try to find something close */ } else { /* it the device doesn't support the 'exact' format, try to find something close */
switch (StencilBufferFormat) { switch (StencilBufferFormat) {
case WINED3DFMT_D16_LOCKABLE: case WINED3DFMT_D16_LOCKABLE:
case WINED3DFMT_D16: case WINED3DFMT_D16:
PUSH2(GLX_DEPTH_SIZE, 1); PUSH2(GLX_DEPTH_SIZE, 1);
@ -1865,7 +1866,7 @@ int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, i
case WINED3DFMT_D15S1: case WINED3DFMT_D15S1:
PUSH2(GLX_DEPTH_SIZE, 1); PUSH2(GLX_DEPTH_SIZE, 1);
PUSH2(GLX_STENCIL_SIZE, 1); PUSH2(GLX_STENCIL_SIZE, 1);
/*Does openGl support a 1bit stencil?, I've seen it used elsewhere /*Does openGl support a 1bit stencil?, I've seen it used elsewhere
e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/ e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/
break; break;

View File

@ -130,9 +130,11 @@ HRESULT WINAPI IWineD3DVertexBufferImpl_GetDesc(IWineD3DVertexBuffer *if
const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl = const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
{ {
/* IUnknown */
IWineD3DVertexBufferImpl_QueryInterface, IWineD3DVertexBufferImpl_QueryInterface,
IWineD3DVertexBufferImpl_AddRef, IWineD3DVertexBufferImpl_AddRef,
IWineD3DVertexBufferImpl_Release, IWineD3DVertexBufferImpl_Release,
/* IWineD3DResource */
IWineD3DVertexBufferImpl_GetParent, IWineD3DVertexBufferImpl_GetParent,
IWineD3DVertexBufferImpl_GetDevice, IWineD3DVertexBufferImpl_GetDevice,
IWineD3DVertexBufferImpl_SetPrivateData, IWineD3DVertexBufferImpl_SetPrivateData,
@ -142,6 +144,7 @@ const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
IWineD3DVertexBufferImpl_GetPriority, IWineD3DVertexBufferImpl_GetPriority,
IWineD3DVertexBufferImpl_PreLoad, IWineD3DVertexBufferImpl_PreLoad,
IWineD3DVertexBufferImpl_GetType, IWineD3DVertexBufferImpl_GetType,
/* IWineD3DVertexBuffer */
IWineD3DVertexBufferImpl_Lock, IWineD3DVertexBufferImpl_Lock,
IWineD3DVertexBufferImpl_Unlock, IWineD3DVertexBufferImpl_Unlock,
IWineD3DVertexBufferImpl_GetDesc IWineD3DVertexBufferImpl_GetDesc

View File

@ -55,7 +55,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_decl);
* http://developer.nvidia.com/view.asp?IO=vstovp * http://developer.nvidia.com/view.asp?IO=vstovp
* *
* NVIDIA: Memory Management with VAR * NVIDIA: Memory Management with VAR
* http://developer.nvidia.com/view.asp?IO=var_memory_management * http://developer.nvidia.com/view.asp?IO=var_memory_management
*/ */
/** Vertex Shader Declaration 8 data types tokens */ /** Vertex Shader Declaration 8 data types tokens */
@ -215,21 +215,21 @@ static DWORD IWineD3DVertexDeclarationImpl_ParseToken8(const DWORD* pToken) {
++pToken; ++pToken;
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
#if 0 #if 0
TRACE(" c[%lu] = (0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n", TRACE(" c[%lu] = (0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n",
constaddress, constaddress,
*pToken, *pToken,
*(pToken + 1), *(pToken + 1),
*(pToken + 2), *(pToken + 2),
*(pToken + 3)); *(pToken + 3));
#endif #endif
TRACE(" c[%lu] = (%8f, %8f, %8f, %8f)\n", TRACE(" c[%lu] = (%8f, %8f, %8f, %8f)\n",
constaddress, constaddress,
*(const float*) pToken, *(const float*) pToken,
*(const float*) (pToken + 1), *(const float*) (pToken + 1),
*(const float*) (pToken + 2), *(const float*) (pToken + 2),
*(const float*) (pToken + 3)); *(const float*) (pToken + 3));
pToken += 4; pToken += 4;
++constaddress; ++constaddress;
} }
tokenlen = (4 * count) + 1; tokenlen = (4 * count) + 1;
} }
@ -295,7 +295,7 @@ IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
/* Convert from a directx* declaration into a directx9 one, so we only have to deal with one type of declaration everywhere else */ /* Convert from a directx* declaration into a directx9 one, so we only have to deal with one type of declaration everywhere else */
while (D3DVSD_END() != *pToken) { while (D3DVSD_END() != *pToken) {
token = *pToken; token = *pToken;
tokenlen = IWineD3DVertexDeclarationImpl_ParseToken8(pToken); tokenlen = IWineD3DVertexDeclarationImpl_ParseToken8(pToken);
tokentype = ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT); tokentype = ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) { if (D3DVSD_TOKEN_STREAM == tokentype && 0 == (D3DVSD_STREAMTESSMASK & token)) {
@ -426,7 +426,7 @@ HRESULT WINAPI IWineD3DVertexDeclarationImpl_GetParent(IWineD3DVertexDeclaration
HRESULT WINAPI IWineD3DVertexDeclarationImpl_GetDevice(IWineD3DVertexDeclaration *iface, IWineD3DDevice** ppDevice) { HRESULT WINAPI IWineD3DVertexDeclarationImpl_GetDevice(IWineD3DVertexDeclaration *iface, IWineD3DDevice** ppDevice) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface; IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
TRACE("(%p) : returning %p\n", This, This->wineD3DDevice); TRACE("(%p) : returning %p\n", This, This->wineD3DDevice);
*ppDevice = (IWineD3DDevice *) This->wineD3DDevice; *ppDevice = (IWineD3DDevice *) This->wineD3DDevice;
IWineD3DDevice_AddRef(*ppDevice); IWineD3DDevice_AddRef(*ppDevice);

View File

@ -32,8 +32,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#if 0 /* Musxt not be 1 in cvs version */ #if 0 /* Musxt not be 1 in cvs version */
# define VSTRACE(A) TRACE A # define VSTRACE(A) TRACE A
# define TRACE_VSVECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w) # define TRACE_VSVECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w)
#else #else
# define VSTRACE(A) # define VSTRACE(A)
# define TRACE_VSVECTOR(name) # define TRACE_VSVECTOR(name)
#endif #endif
@ -68,7 +68,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
* http://developer.nvidia.com/view.asp?IO=vstovp * http://developer.nvidia.com/view.asp?IO=vstovp
* *
* NVIDIA: Memory Management with VAR * NVIDIA: Memory Management with VAR
* http://developer.nvidia.com/view.asp?IO=var_memory_management * http://developer.nvidia.com/view.asp?IO=var_memory_management
*/ */
typedef void (*shader_fct_t)(); typedef void (*shader_fct_t)();
@ -143,7 +143,7 @@ void vshader_lit(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) {
} }
void vshader_logp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { void vshader_logp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) {
float tmp_f = fabsf(s0->w); 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_VAL; d->x = d->y = d->z = d->w = (0.0f != tmp_f) ? logf(tmp_f) / logf(2.0f) : -HUGE_VAL;
VSTRACE(("executing logp: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", 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)); s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w));
@ -249,7 +249,7 @@ void vshader_exp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) {
} }
void vshader_log(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) { void vshader_log(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0) {
float tmp_f = fabsf(s0->w); 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_VAL; d->x = d->y = d->z = d->w = (0.0f != tmp_f) ? logf(tmp_f) / logf(2.0f) : -HUGE_VAL;
VSTRACE(("executing log: s0=(%f, %f, %f, %f) => d=(%f, %f, %f, %f)\n", 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)); s0->x, s0->y, s0->z, s0->w, d->x, d->y, d->z, d->w));
@ -275,7 +275,7 @@ void vshader_m4x4(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, /*D3DSHADERVECTOR* ma
* BuGGY CODE: here only if cast not work for copy/paste * BuGGY CODE: here only if cast not work for copy/paste
D3DSHADERVECTOR* mat2 = mat1 + 1; D3DSHADERVECTOR* mat2 = mat1 + 1;
D3DSHADERVECTOR* mat3 = mat1 + 2; D3DSHADERVECTOR* mat3 = mat1 + 2;
D3DSHADERVECTOR* mat4 = mat1 + 3; D3DSHADERVECTOR* mat4 = mat1 + 3;
d->x = mat1->x * s0->x + mat2->x * s0->y + mat3->x * s0->z + mat4->x * s0->w; d->x = mat1->x * s0->x + mat2->x * s0->y + mat3->x * s0->z + mat4->x * s0->w;
d->y = mat1->y * s0->x + mat2->y * s0->y + mat3->y * s0->z + mat4->y * s0->w; d->y = mat1->y * s0->x + mat2->y * s0->y + mat3->y * s0->z + mat4->y * s0->w;
d->z = mat1->z * s0->x + mat2->z * s0->y + mat3->z * s0->z + mat4->z * s0->w; d->z = mat1->z * s0->x + mat2->z * s0->y + mat3->z * s0->z + mat4->z * s0->w;
@ -336,10 +336,10 @@ void vshader_m3x2(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DMATRIX32 mat) {
* Version 2.0 specific * Version 2.0 specific
*/ */
void vshader_lrp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1, D3DSHADERVECTOR* s2, D3DSHADERVECTOR* s3) { void vshader_lrp(D3DSHADERVECTOR* d, D3DSHADERVECTOR* s0, D3DSHADERVECTOR* s1, D3DSHADERVECTOR* s2, D3DSHADERVECTOR* s3) {
d->x = s0->x * (s1->x - s2->x) + s2->x; d->x = s0->x * (s1->x - s2->x) + s2->x;
d->y = s0->y * (s1->y - s2->y) + s2->y; d->y = s0->y * (s1->y - s2->y) + s2->y;
d->z = s0->z * (s1->z - s2->z) + s2->z; d->z = s0->z * (s1->z - s2->z) + s2->z;
d->w = s0->w * (s1->w - s2->w) + s2->x; d->w = s0->w * (s1->w - s2->w) + s2->x;
} }
/** /**
@ -399,7 +399,7 @@ inline static void vshader_program_dump_param(const DWORD param, int input) {
DWORD regtype = ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); DWORD regtype = ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT);
if ((param & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) TRACE("-"); if ((param & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) TRACE("-");
switch (regtype << D3DSP_REGTYPE_SHIFT) { switch (regtype << D3DSP_REGTYPE_SHIFT) {
case D3DSPR_TEMP: case D3DSPR_TEMP:
TRACE("R[%lu]", reg); TRACE("R[%lu]", reg);
@ -446,16 +446,16 @@ inline static void vshader_program_dump_param(const DWORD param, int input) {
* WWZZYYXX * WWZZYYXX
*/ */
if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) != swizzle) { /* ! D3DVS_NOSWIZZLE == 0xE4 << D3DVS_SWIZZLE_SHIFT */ if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) != swizzle) { /* ! D3DVS_NOSWIZZLE == 0xE4 << D3DVS_SWIZZLE_SHIFT */
if (swizzle_x == swizzle_y && if (swizzle_x == swizzle_y &&
swizzle_x == swizzle_z && swizzle_x == swizzle_z &&
swizzle_x == swizzle_w) { swizzle_x == swizzle_w) {
TRACE(".%c", swizzle_reg_chars[swizzle_x]); TRACE(".%c", swizzle_reg_chars[swizzle_x]);
} else { } else {
TRACE(".%c%c%c%c", TRACE(".%c%c%c%c",
swizzle_reg_chars[swizzle_x], swizzle_reg_chars[swizzle_x],
swizzle_reg_chars[swizzle_y], swizzle_reg_chars[swizzle_y],
swizzle_reg_chars[swizzle_z], swizzle_reg_chars[swizzle_z],
swizzle_reg_chars[swizzle_w]); swizzle_reg_chars[swizzle_w]);
} }
} }
} }
@ -475,50 +475,50 @@ inline static BOOL vshader_is_comment_token(DWORD token) {
HRESULT WINAPI IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderImpl* vshader, CONST DWORD* pFunction) { HRESULT WINAPI IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderImpl* vshader, CONST DWORD* pFunction) {
const DWORD* pToken = pFunction; const DWORD* pToken = pFunction;
const SHADER_OPCODE* curOpcode = NULL; const SHADER_OPCODE* curOpcode = NULL;
DWORD len = 0; DWORD len = 0;
DWORD i; DWORD i;
if (NULL != pToken) { if (NULL != pToken) {
while (D3DVS_END() != *pToken) { while (D3DVS_END() != *pToken) {
if (vshader_is_version_token(*pToken)) { /** version */ if (vshader_is_version_token(*pToken)) { /** version */
TRACE("vs.%lu.%lu\n", (*pToken >> 8) & 0x0F, (*pToken & 0x0F)); TRACE("vs.%lu.%lu\n", (*pToken >> 8) & 0x0F, (*pToken & 0x0F));
++pToken; ++pToken;
++len; ++len;
continue; continue;
} }
if (vshader_is_comment_token(*pToken)) { /** comment */ if (vshader_is_comment_token(*pToken)) { /** comment */
DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
++pToken; ++pToken;
/*TRACE("comment[%ld] ;%s\n", comment_len, (char*)pToken);*/ /*TRACE("comment[%ld] ;%s\n", comment_len, (char*)pToken);*/
pToken += comment_len; pToken += comment_len;
len += comment_len + 1; len += comment_len + 1;
continue; continue;
} }
curOpcode = vshader_program_get_opcode(*pToken); curOpcode = vshader_program_get_opcode(*pToken);
++pToken; ++pToken;
++len; ++len;
if (NULL == curOpcode) { if (NULL == curOpcode) {
/* unkown current opcode ... */ /* unkown current opcode ... */
while (*pToken & 0x80000000) { while (*pToken & 0x80000000) {
TRACE("unrecognized opcode: %08lx\n", *pToken); TRACE("unrecognized opcode: %08lx\n", *pToken);
++pToken; ++pToken;
++len; ++len;
} }
} else { } else {
TRACE("%s ", curOpcode->name); TRACE("%s ", curOpcode->name);
if (curOpcode->num_params > 0) { if (curOpcode->num_params > 0) {
vshader_program_dump_param(*pToken, 0); vshader_program_dump_param(*pToken, 0);
++pToken; ++pToken;
++len; ++len;
for (i = 1; i < curOpcode->num_params; ++i) { for (i = 1; i < curOpcode->num_params; ++i) {
TRACE(", "); TRACE(", ");
vshader_program_dump_param(*pToken, 1); vshader_program_dump_param(*pToken, 1);
++pToken; ++pToken;
++len; ++len;
} }
} }
TRACE("\n"); TRACE("\n");
} }
} }
vshader->functionLength = (len + 1) * sizeof(DWORD); vshader->functionLength = (len + 1) * sizeof(DWORD);
} else { } else {
@ -536,9 +536,9 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderImpl*
} }
BOOL IDirect3DVertexShaderImpl_ExecuteHAL(IDirect3DVertexShaderImpl* vshader, VSHADERINPUTDATA* input, VSHADEROUTPUTDATA* output) { BOOL IDirect3DVertexShaderImpl_ExecuteHAL(IDirect3DVertexShaderImpl* vshader, VSHADERINPUTDATA* input, VSHADEROUTPUTDATA* output) {
/** /**
* TODO: use the NV_vertex_program (or 1_1) extension * TODO: use the NV_vertex_program (or 1_1) extension
* and specifics vendors (ARB_vertex_program??) variants for it * and specifics vendors (ARB_vertex_program??) variants for it
*/ */
return TRUE; return TRUE;
} }
@ -590,7 +590,7 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
/* the first dword is the version tag */ /* the first dword is the version tag */
/* TODO: parse it */ /* TODO: parse it */
if (vshader_is_version_token(*pToken)) { /** version */ if (vshader_is_version_token(*pToken)) { /** version */
++pToken; ++pToken;
} }
@ -607,149 +607,148 @@ HRESULT WINAPI IDirect3DVertexShaderImpl_ExecuteSW(IDirect3DVertexShaderImpl* vs
i = 0; i = 0;
/* unkown current opcode ... */ /* unkown current opcode ... */
while (*pToken & 0x80000000) { while (*pToken & 0x80000000) {
if (i == 0) { if (i == 0) {
TRACE("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));
} }
TRACE("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); vshader_program_dump_param(*pToken, i);
TRACE("\n"); TRACE("\n");
++i; ++i;
++pToken; ++pToken;
} }
/*return FALSE;*/ /*return FALSE;*/
} else { } else {
if (curOpcode->num_params > 0) { if (curOpcode->num_params > 0) {
/*TRACE(">> 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) { for (i = 0; i < curOpcode->num_params; ++i) {
DWORD reg = pToken[i] & 0x00001FFF; DWORD reg = pToken[i] & 0x00001FFF;
DWORD regtype = ((pToken[i] & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); DWORD regtype = ((pToken[i] & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT);
switch (regtype << D3DSP_REGTYPE_SHIFT) { switch (regtype << D3DSP_REGTYPE_SHIFT) {
case D3DSPR_TEMP: case D3DSPR_TEMP:
/*TRACE("p[%d]=R[%d]\n", i, reg);*/ /*TRACE("p[%d]=R[%d]\n", i, reg);*/
p[i] = &R[reg]; p[i] = &R[reg];
break; break;
case D3DSPR_INPUT: case D3DSPR_INPUT:
/*TRACE("p[%d]=V[%s]\n", i, VertexShaderDeclRegister[reg]);*/ /*TRACE("p[%d]=V[%s]\n", i, VertexShaderDeclRegister[reg]);*/
p[i] = &input->V[reg]; p[i] = &input->V[reg];
break; break;
case D3DSPR_CONST: case D3DSPR_CONST:
if (pToken[i] & D3DVS_ADDRMODE_RELATIVE) { if (pToken[i] & D3DVS_ADDRMODE_RELATIVE) {
p[i] = &vshader->data->C[(DWORD) A[0].x + reg]; p[i] = &vshader->data->C[(DWORD) A[0].x + reg];
} else { } else {
p[i] = &vshader->data->C[reg]; p[i] = &vshader->data->C[reg];
} }
break; break;
case D3DSPR_ADDR: /*case D3DSPR_TEXTURE:*/ case D3DSPR_ADDR: /*case D3DSPR_TEXTURE:*/
if (0 != reg) { if (0 != reg) {
ERR("cannot handle address registers != a0, forcing use of a0\n"); ERR("cannot handle address registers != a0, forcing use of a0\n");
reg = 0; reg = 0;
} }
/*TRACE("p[%d]=A[%d]\n", i, reg);*/ /*TRACE("p[%d]=A[%d]\n", i, reg);*/
p[i] = &A[reg]; p[i] = &A[reg];
break; break;
case D3DSPR_RASTOUT: case D3DSPR_RASTOUT:
switch (reg) { switch (reg) {
case D3DSRO_POSITION: case D3DSRO_POSITION:
p[i] = &output->oPos; p[i] = &output->oPos;
break; break;
case D3DSRO_FOG: case D3DSRO_FOG:
p[i] = &output->oFog; p[i] = &output->oFog;
break; break;
case D3DSRO_POINT_SIZE: case D3DSRO_POINT_SIZE:
p[i] = &output->oPts; p[i] = &output->oPts;
break; break;
} }
break; break;
case D3DSPR_ATTROUT: case D3DSPR_ATTROUT:
/*TRACE("p[%d]=oD[%d]\n", i, reg);*/ /*TRACE("p[%d]=oD[%d]\n", i, reg);*/
p[i] = &output->oD[reg]; p[i] = &output->oD[reg];
break; break;
case D3DSPR_TEXCRDOUT: case D3DSPR_TEXCRDOUT:
/*TRACE("p[%d]=oT[%d]\n", i, reg);*/ /*TRACE("p[%d]=oT[%d]\n", i, reg);*/
p[i] = &output->oT[reg]; p[i] = &output->oT[reg];
break; break;
default: default:
break; break;
} }
if (i > 0) { /* input reg */
DWORD swizzle = (pToken[i] & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
UINT isNegative = ((pToken[i] & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG);
if (!isNegative && (D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) { if (i > 0) { /* input reg */
/*TRACE("p[%d] not swizzled\n", i);*/ DWORD swizzle = (pToken[i] & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
p_send[i] = p[i]; UINT isNegative = ((pToken[i] & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG);
} else {
DWORD swizzle_x = swizzle & 0x03;
DWORD swizzle_y = (swizzle >> 2) & 0x03;
DWORD swizzle_z = (swizzle >> 4) & 0x03;
DWORD swizzle_w = (swizzle >> 6) & 0x03;
/*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];
s[i].z = (isNegative) ? -tt[swizzle_z] : tt[swizzle_z];
s[i].w = (isNegative) ? -tt[swizzle_w] : tt[swizzle_w];
p_send[i] = &s[i];
}
} else { /* output reg */
if ((pToken[i] & D3DSP_WRITEMASK_ALL) == D3DSP_WRITEMASK_ALL) {
p_send[i] = p[i];
} else {
p_send[i] = &d; /* to be post-processed for modifiers management */
}
}
}
}
switch (curOpcode->num_params) { if (!isNegative && (D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) {
case 0: /*TRACE("p[%d] not swizzled\n", i);*/
curOpcode->soft_fct(); p_send[i] = p[i];
break; } else {
case 1: DWORD swizzle_x = swizzle & 0x03;
curOpcode->soft_fct(p_send[0]); DWORD swizzle_y = (swizzle >> 2) & 0x03;
break; DWORD swizzle_z = (swizzle >> 4) & 0x03;
case 2: DWORD swizzle_w = (swizzle >> 6) & 0x03;
curOpcode->soft_fct(p_send[0], p_send[1]); /*TRACE("p[%d] swizzled\n", i);*/
break; float* tt = (float*) p[i];
case 3: s[i].x = (isNegative) ? -tt[swizzle_x] : tt[swizzle_x];
curOpcode->soft_fct(p_send[0], p_send[1], p_send[2]); s[i].y = (isNegative) ? -tt[swizzle_y] : tt[swizzle_y];
break; s[i].z = (isNegative) ? -tt[swizzle_z] : tt[swizzle_z];
case 4: s[i].w = (isNegative) ? -tt[swizzle_w] : tt[swizzle_w];
curOpcode->soft_fct(p_send[0], p_send[1], p_send[2], p_send[3]); p_send[i] = &s[i];
break; }
case 5: } else { /* output reg */
curOpcode->soft_fct(p_send[0], p_send[1], p_send[2], p_send[3], p_send[4]); if ((pToken[i] & D3DSP_WRITEMASK_ALL) == D3DSP_WRITEMASK_ALL) {
break; p_send[i] = p[i];
default: } else {
ERR("%s too many params: %u\n", curOpcode->name, curOpcode->num_params); p_send[i] = &d; /* to be post-processed for modifiers management */
} }
}
}
}
/* check if output reg modifier post-process */ switch (curOpcode->num_params) {
if (curOpcode->num_params > 0 && (pToken[0] & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) { case 0:
if (pToken[0] & D3DSP_WRITEMASK_0) p[0]->x = d.x; curOpcode->soft_fct();
if (pToken[0] & D3DSP_WRITEMASK_1) p[0]->y = d.y; break;
if (pToken[0] & D3DSP_WRITEMASK_2) p[0]->z = d.z; case 1:
if (pToken[0] & D3DSP_WRITEMASK_3) p[0]->w = d.w; curOpcode->soft_fct(p_send[0]);
} break;
case 2:
curOpcode->soft_fct(p_send[0], p_send[1]);
break;
case 3:
curOpcode->soft_fct(p_send[0], p_send[1], p_send[2]);
break;
case 4:
curOpcode->soft_fct(p_send[0], p_send[1], p_send[2], p_send[3]);
break;
case 5:
curOpcode->soft_fct(p_send[0], p_send[1], p_send[2], p_send[3], p_send[4]);
break;
default:
ERR("%s too many params: %u\n", curOpcode->name, curOpcode->num_params);
}
/* check if output reg modifier post-process */
if (curOpcode->num_params > 0 && (pToken[0] & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) {
if (pToken[0] & D3DSP_WRITEMASK_0) p[0]->x = d.x;
if (pToken[0] & D3DSP_WRITEMASK_1) p[0]->y = d.y;
if (pToken[0] & D3DSP_WRITEMASK_2) p[0]->z = d.z;
if (pToken[0] & D3DSP_WRITEMASK_3) p[0]->w = d.w;
}
#if 0 #if 0
TRACE_VSVECTOR(output->oPos); TRACE_VSVECTOR(output->oPos);
TRACE_VSVECTOR(output->oD[0]); TRACE_VSVECTOR(output->oD[0]);
TRACE_VSVECTOR(output->oD[1]); TRACE_VSVECTOR(output->oD[1]);
TRACE_VSVECTOR(output->oT[0]); TRACE_VSVECTOR(output->oT[0]);
TRACE_VSVECTOR(output->oT[1]); TRACE_VSVECTOR(output->oT[1]);
TRACE_VSVECTOR(R[0]); TRACE_VSVECTOR(R[0]);
TRACE_VSVECTOR(R[1]); TRACE_VSVECTOR(R[1]);
TRACE_VSVECTOR(R[2]); TRACE_VSVECTOR(R[2]);
TRACE_VSVECTOR(R[3]); TRACE_VSVECTOR(R[3]);
TRACE_VSVECTOR(R[4]); TRACE_VSVECTOR(R[4]);
TRACE_VSVECTOR(R[5]); TRACE_VSVECTOR(R[5]);
#endif #endif
/* to next opcode token */ /* to next opcode token */
pToken += curOpcode->num_params; pToken += curOpcode->num_params;
} }
#if 0 #if 0
TRACE("End of current instruction:\n"); TRACE("End of current instruction:\n");
@ -861,7 +860,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_QueryInterface(IWineD3DVertexShader *ifa
ULONG WINAPI IWineD3DVertexShaderImpl_AddRef(IWineD3DVertexShader *iface) { ULONG WINAPI IWineD3DVertexShaderImpl_AddRef(IWineD3DVertexShader *iface) {
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref); TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
@ -870,7 +869,7 @@ ULONG WINAPI IWineD3DVertexShaderImpl_Release(IWineD3DVertexShader *iface) {
ULONG ref; ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref); TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
@ -882,18 +881,18 @@ ULONG WINAPI IWineD3DVertexShaderImpl_Release(IWineD3DVertexShader *iface) {
HRESULT WINAPI IWineD3DVertexShaderImpl_GetParent(IWineD3DVertexShader *iface, IUnknown** parent){ HRESULT WINAPI IWineD3DVertexShaderImpl_GetParent(IWineD3DVertexShader *iface, IUnknown** parent){
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
*parent= (IUnknown*) parent; *parent= (IUnknown*) parent;
IUnknown_AddRef(*parent); IUnknown_AddRef(*parent);
TRACE("(%p) : returning %p\n", This, *parent); TRACE("(%p) : returning %p\n", This, *parent);
return D3D_OK; return D3D_OK;
} }
HRESULT WINAPI IWineD3DVertexShaderImpl_GetDevice(IWineD3DVertexShader* iface, IWineD3DDevice **pDevice){ HRESULT WINAPI IWineD3DVertexShaderImpl_GetDevice(IWineD3DVertexShader* iface, IWineD3DDevice **pDevice){
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
IWineD3DDevice_AddRef((IWineD3DDevice *)This->wineD3DDevice); IWineD3DDevice_AddRef((IWineD3DDevice *)This->wineD3DDevice);
*pDevice = (IWineD3DDevice *)This->wineD3DDevice; *pDevice = (IWineD3DDevice *)This->wineD3DDevice;
TRACE("(%p) returning %p\n", This, *pDevice); TRACE("(%p) returning %p\n", This, *pDevice);
return D3D_OK; return D3D_OK;
} }
@ -914,7 +913,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_GetFunction(IWineD3DVertexShader* impl,
(*(DWORD **) pData) = NULL; (*(DWORD **) pData) = NULL;
} else { } else {
if(This->functionLength == 0){ if(This->functionLength == 0){
} }
TRACE("(%p) : GetFunction copying to %p\n", This, pData); TRACE("(%p) : GetFunction copying to %p\n", This, pData);
memcpy(pData, This->function, This->functionLength); memcpy(pData, This->function, This->functionLength);
@ -933,5 +932,5 @@ const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
/*** IWineD3DVertexShader methods ***/ /*** IWineD3DVertexShader methods ***/
IWineD3DVertexShaderImpl_GetParent, IWineD3DVertexShaderImpl_GetParent,
IWineD3DVertexShaderImpl_GetDevice, IWineD3DVertexShaderImpl_GetDevice,
IWineD3DVertexShaderImpl_GetFunction IWineD3DVertexShaderImpl_GetFunction
}; };

View File

@ -3,7 +3,7 @@
* *
* Copyright 2002-2005 Jason Edmeades * Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira * Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber * Copyright 2005 Oliver Stieber
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -61,7 +61,7 @@ ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
} }
/* **************************************************** /* ****************************************************
IWineD3DSurface IWineD3DResource parts follow IWineD3DVolume IWineD3DResource parts follow
**************************************************** */ **************************************************** */
HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) { HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
@ -113,7 +113,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID rii
HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC* pDesc) { HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC* pDesc) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
TRACE("(%p) : copying into %p\n", This, pDesc); TRACE("(%p) : copying into %p\n", This, pDesc);
*(pDesc->Format) = This->resource.format; *(pDesc->Format) = This->resource.format;
*(pDesc->Type) = This->resource.resourceType; *(pDesc->Type) = This->resource.resourceType;
*(pDesc->Usage) = This->resource.usage; *(pDesc->Usage) = This->resource.usage;
@ -127,7 +127,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_D
HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) { HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
FIXME("(%p) : pBox=%p stub\n", This, pBox); FIXME("(%p) : pBox=%p stub\n", This, pBox);
/* fixme: should we really lock as such? */ /* fixme: should we really lock as such? */
TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory); TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->resource.allocatedMemory);
@ -145,9 +145,9 @@ HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX*
This->lockedBox.Back = This->currentDesc.Depth; This->lockedBox.Back = This->currentDesc.Depth;
} else { } else {
TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back); TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
pLockedVolume->pBits = This->resource.allocatedMemory + pLockedVolume->pBits = This->resource.allocatedMemory +
(pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */ (pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
(pLockedVolume->RowPitch * pBox->Top) + (pLockedVolume->RowPitch * pBox->Top) +
(pBox->Left * This->bytesPerPixel); (pBox->Left * This->bytesPerPixel);
This->lockedBox.Left = pBox->Left; This->lockedBox.Left = pBox->Left;
This->lockedBox.Top = pBox->Top; This->lockedBox.Top = pBox->Top;
@ -156,7 +156,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX*
This->lockedBox.Bottom = pBox->Bottom; This->lockedBox.Bottom = pBox->Bottom;
This->lockedBox.Back = pBox->Back; This->lockedBox.Back = pBox->Back;
} }
if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) { if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
/* Don't dirtify */ /* Don't dirtify */
} else { } else {
@ -169,7 +169,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX*
/** Dirtify Container if needed */ /** Dirtify Container if needed */
if (NULL != This->container) { if (NULL != This->container) {
IWineD3DVolumeTexture *cont = (IWineD3DVolumeTexture*) This->container; IWineD3DVolumeTexture *cont = (IWineD3DVolumeTexture*) This->container;
D3DRESOURCETYPE containerType = IWineD3DBaseTexture_GetType((IWineD3DBaseTexture *) cont); D3DRESOURCETYPE containerType = IWineD3DBaseTexture_GetType((IWineD3DBaseTexture *) cont);
if (containerType == D3DRTYPE_VOLUMETEXTURE) { if (containerType == D3DRTYPE_VOLUMETEXTURE) {
@ -189,7 +189,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX*
HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface) { HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
if (FALSE == This->locked) { if (FALSE == This->locked) {
ERR("trying to lock unlocked volume@%p\n", This); ERR("trying to lock unlocked volume@%p\n", This);
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
TRACE("(%p) : unlocking volume\n", This); TRACE("(%p) : unlocking volume\n", This);
@ -205,7 +205,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_CleanDirtyBox(IWineD3DVolume *iface) {
This->dirty = FALSE; This->dirty = FALSE;
This->lockedBox.Left = This->currentDesc.Width; This->lockedBox.Left = This->currentDesc.Width;
This->lockedBox.Top = This->currentDesc.Height; This->lockedBox.Top = This->currentDesc.Height;
This->lockedBox.Front = This->currentDesc.Depth; This->lockedBox.Front = This->currentDesc.Depth;
This->lockedBox.Right = 0; This->lockedBox.Right = 0;
This->lockedBox.Bottom = 0; This->lockedBox.Bottom = 0;
This->lockedBox.Back = 0; This->lockedBox.Back = 0;
@ -235,7 +235,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_AddDirtyBox(IWineD3DVolume *iface, CONST D3DBO
HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IUnknown* container){ HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IUnknown* container){
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
This->container = container; This->container = container;
return D3D_OK; return D3D_OK;
} }
@ -267,7 +267,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, GLenum gl_l
This->resource.allocatedMemory); This->resource.allocatedMemory);
checkGLcall("glTexImage3D"); checkGLcall("glTexImage3D");
return D3D_OK; return D3D_OK;
} }
const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl = const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
@ -291,7 +291,7 @@ const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
IWineD3DVolumeImpl_GetDesc, IWineD3DVolumeImpl_GetDesc,
IWineD3DVolumeImpl_LockBox, IWineD3DVolumeImpl_LockBox,
IWineD3DVolumeImpl_UnlockBox, IWineD3DVolumeImpl_UnlockBox,
/* Internal interface */ /* Internal interface */
IWineD3DVolumeImpl_AddDirtyBox, IWineD3DVolumeImpl_AddDirtyBox,
IWineD3DVolumeImpl_CleanDirtyBox, IWineD3DVolumeImpl_CleanDirtyBox,
IWineD3DVolumeImpl_LoadTexture, IWineD3DVolumeImpl_LoadTexture,

View File

@ -103,20 +103,20 @@ void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
/* Overrider the IWineD3DResource Preload method */ /* Overrider the IWineD3DResource Preload method */
UINT i; UINT i;
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface; IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : About to load texture\n", This); TRACE("(%p) : About to load texture\n", This);
IWineD3DVolumeTexture_BindTexture(iface); IWineD3DVolumeTexture_BindTexture(iface);
ENTER_GL(); ENTER_GL();
/* If were dirty then reload the volumes */ /* If were dirty then reload the volumes */
if(This->baseTexture.dirty != FALSE) { if(This->baseTexture.dirty != FALSE) {
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DVolume_LoadTexture(This->volumes[i], i); IWineD3DVolume_LoadTexture(This->volumes[i], i);
} }
/* No longer dirty */ /* No longer dirty */
This->baseTexture.dirty = FALSE; This->baseTexture.dirty = FALSE;
} }
LEAVE_GL(); LEAVE_GL();
@ -181,7 +181,7 @@ HRESULT WINAPI IWineD3DVolumeTextureImpl_UnBindTexture(IWineD3DVolumeTexture *if
UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) { UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface; IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) \n", This); TRACE("(%p) \n", This);
return GL_TEXTURE_3D; return GL_TEXTURE_3D;
} }
@ -244,7 +244,7 @@ HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture *iface,
HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST D3DBOX* pDirtyBox) { HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST D3DBOX* pDirtyBox) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface; IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
TRACE("(%p) : dirtyfication of volume Level (0)\n", This); TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
return IWineD3DVolume_AddDirtyBox((IWineD3DVolume *) This->volumes[0], pDirtyBox); return IWineD3DVolume_AddDirtyBox((IWineD3DVolume *) This->volumes[0], pDirtyBox);
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright 2002-2003 The wine-d3d team * Copyright 2002-2003 The wine-d3d team
* Copyright 2002-2003 Raphael Junqueira * Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Jason Edmeades * Copyright 2004 Jason Edmeades
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -97,24 +97,24 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{ {
if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) ) if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) )
{ {
if (!strcmp(buffer,"none")) if (!strcmp(buffer,"none"))
{ {
TRACE("Disable vertex shaders\n"); TRACE("Disable vertex shaders\n");
vs_mode = VS_NONE; vs_mode = VS_NONE;
} }
else if (!strcmp(buffer,"emulation")) else if (!strcmp(buffer,"emulation"))
{ {
TRACE("Force SW vertex shaders\n"); TRACE("Force SW vertex shaders\n");
vs_mode = VS_SW; vs_mode = VS_SW;
} }
} }
if ( !RegQueryValueExA( hkey, "PixelShaderMode", 0, NULL, buffer, &size) ) if ( !RegQueryValueExA( hkey, "PixelShaderMode", 0, NULL, buffer, &size) )
{ {
if (!strcmp(buffer,"enabled")) if (!strcmp(buffer,"enabled"))
{ {
TRACE("Allow pixel shaders\n"); TRACE("Allow pixel shaders\n");
ps_mode = PS_HW; ps_mode = PS_HW;
} }
} }
} }
if (vs_mode == VS_HW) if (vs_mode == VS_HW)