From cc884e0ae6bc8fac31c8ee3b8973b66c2e9e0ee7 Mon Sep 17 00:00:00 2001 From: Oliver Stieber Date: Sat, 30 Jul 2005 19:05:58 +0000 Subject: [PATCH] Validate that the texture is no larger than the graphics cards largest supported texture. --- dlls/wined3d/device.c | 19 +++++++++++++++++-- dlls/wined3d/directx.c | 6 +++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 0a5234219c..586603b398 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -591,6 +591,12 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid MultisampleQuality=0; } + /** FIXME: Check that the format is supported + * by the device. + *******************************/ + /* TODO: add support for dxt2 and dxt4 formats */ + if (Format == D3DFMT_DXT2 || Format == D3DFMT_DXT4) return D3DERR_NOTAVAILABLE; + /* Non-power2 support */ /* Find the nearest pow2 match */ @@ -608,7 +614,17 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid } } - /** TODO: Check against the maximum texture sizes supported by the video card **/ + /** Check against the maximum texture sizes supported by the video card **/ + if (pow2Width > GL_LIMITS(texture_size) || pow2Height > GL_LIMITS(texture_size)) { + /* one of three options + 1: Do the same as we do with nonpow 2 and scale the texture, (any texture ops would require the texture to be scaled which is potentially slow) + 2: Set the texture to the maxium size (bad idea) + 3: WARN and return D3DERR_NOTAVAILABLE; + */ + WARN("(%p) Application requested a surface w %d, h %d, but the graphics card only supports %d\n", This, Width, Height, GL_LIMITS(texture_size)); + return D3DERR_NOTAVAILABLE; + } + /** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since @@ -1206,7 +1222,6 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevice* ifac object->presentParms.PresentationInterval = *(pPresentationParameters->PresentationInterval); - /* FIXME: check for any failures */ /********************* * Create the back, front and stencil buffers *******************/ diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 2b449c2ed0..eba2e364d5 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1586,9 +1586,13 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)object->updateStateBlock); /* Setup surfaces for the backbuffer, frontbuffer and depthstencil buffer */ + /* Setup some defaults for creating the implicite swapchain */ + ENTER_GL(); + IWineD3DImpl_FillGLCaps(&This->gl_info, IWineD3DImpl_GetAdapterDisplay(iface, Adapter)); + LEAVE_GL(); + /* Setup the implicit swapchain */ TRACE("Creating implicit swapchain\n"); - if (D3D_OK != D3DCB_CreateAdditionalSwapChain((IUnknown *) object->parent, pPresentationParameters, (IWineD3DSwapChain **)&swapchain) || swapchain == NULL) { WARN("Failed to create implicite swapchain\n"); goto create_device_error;