From 701d7c9c504613aea5d8a6ea38f1926503295874 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 6 Oct 2008 19:09:53 +0200 Subject: d3d9: Use more reasonable texture dimensions. caps.MaxTextureWidth / caps.MaxTextureHeight can potentially be very large, which could cause a driver to run out of memory. Arguably the driver shouldn't report such large limits, but there's no reason for us to create a texture larger than 1024x1024 either. --- dlls/d3d9/tests/visual.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 6538a60..3211076 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -2971,6 +2971,7 @@ static void texture_transform_flags_test(IDirect3DDevice9 *device) D3DLOCKED_RECT lr; D3DLOCKED_BOX lb; DWORD color; + UINT w, h; IDirect3DVertexDeclaration9 *decl, *decl2, *decl3; float identity[16] = {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -3032,7 +3033,9 @@ static void texture_transform_flags_test(IDirect3DDevice9 *device) hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); ok(hr == D3D_OK, "IDirect3DDevice9_GetDeviceCaps returned %08x\n", hr); - hr = IDirect3DDevice9_CreateTexture(device, caps.MaxTextureWidth, caps.MaxTextureHeight, 1, + w = min(1024, caps.MaxTextureWidth); + h = min(1024, caps.MaxTextureHeight); + hr = IDirect3DDevice9_CreateTexture(device, w, h, 1, 0, fmt, D3DPOOL_MANAGED, &texture, NULL); ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture returned %08x\n", hr); if(!texture) { @@ -3046,10 +3049,10 @@ static void texture_transform_flags_test(IDirect3DDevice9 *device) */ hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0); ok(hr == D3D_OK, "IDirect3DTexture9_LockRect returned %08x\n", hr); - for(y = 0; y < caps.MaxTextureHeight; y++) { - for(x = 0; x < caps.MaxTextureWidth; x++) { - double r_f = (double) y / (double) caps.MaxTextureHeight; - double g_f = (double) x / (double) caps.MaxTextureWidth; + for(y = 0; y < h; y++) { + for(x = 0; x < w; x++) { + double r_f = (double) y / (double) h; + double g_f = (double) x / (double) w; if(fmt == D3DFMT_A16B16G16R16) { unsigned short r, g; unsigned short *dst = (unsigned short *) (((char *) lr.pBits) + y * lr.Pitch + x * 8); -- 1.5.6.4