From 1b5cc39a86256f5d3d582429924fcc6b6bd80400 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 31 May 2010 20:40:26 +0200 Subject: [PATCH] wined3d: Get rid of some dead code. --- dlls/wined3d/drawprim.c | 40 -------- dlls/wined3d/surface.c | 162 --------------------------------- dlls/wined3d/surface_base.c | 9 -- dlls/wined3d/surface_gdi.c | 136 --------------------------- dlls/wined3d/swapchain.c | 40 -------- dlls/wined3d/wined3d_private.h | 34 ------- include/wine/wined3d.idl | 3 - 7 files changed, 424 deletions(-) diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index b36ef5b49ae..1671e7b735f 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -727,46 +727,6 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT TRACE("Done all gl drawing\n"); - /* Diagnostics */ -#ifdef SHOW_FRAME_MAKEUP - { - static LONG primCounter = 0; - /* NOTE: set primCounter to the value reported by drawprim - before you want to to write frame makeup to /tmp */ - if (primCounter >= 0) { - WINED3DLOCKED_RECT r; - char buffer[80]; - IWineD3DSurface_LockRect(This->render_targets[0], &r, NULL, WINED3DLOCK_READONLY); - sprintf(buffer, "/tmp/backbuffer_%d.tga", primCounter); - TRACE("Saving screenshot %s\n", buffer); - IWineD3DSurface_SaveSnapshot(This->render_targets[0], buffer); - IWineD3DSurface_UnlockRect(This->render_targets[0]); - -#ifdef SHOW_TEXTURE_MAKEUP - { - IWineD3DSurface *pSur; - int textureNo; - for (textureNo = 0; textureNo < MAX_COMBINED_SAMPLERS; ++textureNo) { - if (This->stateBlock->textures[textureNo] != NULL) { - sprintf(buffer, "/tmp/texture_%p_%d_%d.tga", This->stateBlock->textures[textureNo], primCounter, textureNo); - TRACE("Saving texture %s\n", buffer); - if (IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo]) == WINED3DRTYPE_TEXTURE) { - IWineD3DTexture_GetSurfaceLevel(This->stateBlock->textures[textureNo], 0, &pSur); - IWineD3DSurface_SaveSnapshot(pSur, buffer); - IWineD3DSurface_Release(pSur); - } else { - FIXME("base Texture isn't of type texture %d\n", IWineD3DBaseTexture_GetType(This->stateBlock->textures[textureNo])); - } - } - } - } -#endif - } - TRACE("drawprim #%d\n", primCounter); - ++primCounter; - } -#endif - /* Control goes back to the device, stateblock values may change again */ This->isInDraw = FALSE; } diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 62c58312a91..d363feb1da0 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2555,26 +2555,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BO IWineD3DSurface_LoadLocation(iface, flag, NULL /* no partial locking for textures yet */); -#if 0 - { - static unsigned int gen = 0; - char buffer[4096]; - ++gen; - if ((gen % 10) == 0) { - snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", - This, This->texture_target, This->texture_level, gen); - IWineD3DSurfaceImpl_SaveSnapshot(iface, buffer); - } - /* - * debugging crash code - if (gen == 250) { - void** test = NULL; - *test = 0; - } - */ - } -#endif - if (!(This->Flags & SFLAG_DONOTFREE)) { HeapFree(GetProcessHeap(), 0, This->resource.heapMemory); This->resource.allocatedMemory = NULL; @@ -2640,147 +2620,6 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL } } -#include -#include -static HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename) -{ - FILE* f = NULL; - IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; - char *allocatedMemory; - const char *textureRow; - IWineD3DSwapChain *swapChain = NULL; - int width, height, i, y; - GLuint tmpTexture = 0; - DWORD color; - /*FIXME: - Textures may not be stored in ->allocatedgMemory and a GlTexture - so we should lock the surface before saving a snapshot, or at least check that - */ - /* TODO: Compressed texture images can be obtained from the GL in uncompressed form - by calling GetTexImage and in compressed form by calling - GetCompressedTexImageARB. Queried compressed images can be saved and - later reused by calling CompressedTexImage[123]DARB. Pre-compressed - texture images do not need to be processed by the GL and should - significantly improve texture loading performance relative to uncompressed - images. */ - -/* Setup the width and height to be the internal texture width and height. */ - width = This->pow2Width; - height = This->pow2Height; -/* check to see if we're a 'virtual' texture, e.g. we're not a pbuffer of texture, we're a back buffer*/ - IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapChain); - - if (This->Flags & SFLAG_INDRAWABLE && !(This->Flags & SFLAG_INTEXTURE)) { - /* if were not a real texture then read the back buffer into a real texture */ - /* we don't want to interfere with the back buffer so read the data into a temporary - * texture and then save the data out of the temporary texture - */ - GLint prevRead; - ENTER_GL(); - TRACE("(%p) Reading render target into texture\n", This); - - glGenTextures(1, &tmpTexture); - glBindTexture(GL_TEXTURE_2D, tmpTexture); - - glTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA, - width, - height, - 0/*border*/, - GL_RGBA, - GL_UNSIGNED_INT_8_8_8_8_REV, - NULL); - - glGetIntegerv(GL_READ_BUFFER, &prevRead); - checkGLcall("glGetIntegerv"); - glReadBuffer(swapChain ? GL_BACK : This->resource.device->offscreenBuffer); - checkGLcall("glReadBuffer"); - glCopyTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA, - 0, - 0, - width, - height, - 0); - - checkGLcall("glCopyTexImage2D"); - glReadBuffer(prevRead); - LEAVE_GL(); - - } else { /* bind the real texture, and make sure it up to date */ - surface_internal_preload(This, SRGB_RGB); - surface_bind_and_dirtify(This, FALSE); - } - allocatedMemory = HeapAlloc(GetProcessHeap(), 0, width * height * 4); - ENTER_GL(); - FIXME("Saving texture level %d width %d height %d\n", This->texture_level, width, height); - glGetTexImage(GL_TEXTURE_2D, This->texture_level, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, allocatedMemory); - checkGLcall("glGetTexImage"); - if (tmpTexture) { - glBindTexture(GL_TEXTURE_2D, 0); - glDeleteTextures(1, &tmpTexture); - } - LEAVE_GL(); - - f = fopen(filename, "w+"); - if (NULL == f) { - ERR("opening of %s failed with: %s\n", filename, strerror(errno)); - return WINED3DERR_INVALIDCALL; - } -/* Save the data out to a TGA file because 1: it's an easy raw format, 2: it supports an alpha channel */ - TRACE("(%p) opened %s with format %s\n", This, filename, debug_d3dformat(This->resource.format_desc->format)); -/* TGA header */ - fputc(0,f); - fputc(0,f); - fputc(2,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); - fputc(0,f); -/* short width*/ - fwrite(&width,2,1,f); -/* short height */ - fwrite(&height,2,1,f); -/* format rgba */ - fputc(0x20,f); - fputc(0x28,f); -/* raw data */ - /* if the data is upside down if we've fetched it from a back buffer, so it needs flipping again to make it the correct way up */ - if(swapChain) - textureRow = allocatedMemory + (width * (height - 1) *4); - else - textureRow = allocatedMemory; - for (y = 0 ; y < height; y++) { - for (i = 0; i < width; i++) { - color = *((const DWORD*)textureRow); - fputc((color >> 16) & 0xFF, f); /* B */ - fputc((color >> 8) & 0xFF, f); /* G */ - fputc((color >> 0) & 0xFF, f); /* R */ - fputc((color >> 24) & 0xFF, f); /* A */ - textureRow += 4; - } - /* take two rows of the pointer to the texture memory */ - if(swapChain) - (textureRow-= width << 3); - - } - TRACE("Closing file\n"); - fclose(f); - - if(swapChain) { - IWineD3DSwapChain_Release(swapChain); - } - HeapFree(GetProcessHeap(), 0, allocatedMemory); - return WINED3D_OK; -} - static HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) { IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; HRESULT hr; @@ -4766,7 +4605,6 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl = /* Internal use: */ IWineD3DSurfaceImpl_LoadTexture, IWineD3DSurfaceImpl_BindTexture, - IWineD3DSurfaceImpl_SaveSnapshot, IWineD3DSurfaceImpl_SetContainer, IWineD3DBaseSurfaceImpl_GetData, IWineD3DSurfaceImpl_SetFormat, diff --git a/dlls/wined3d/surface_base.c b/dlls/wined3d/surface_base.c index 2b6cdb41f22..10d114167f2 100644 --- a/dlls/wined3d/surface_base.c +++ b/dlls/wined3d/surface_base.c @@ -968,15 +968,6 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D DestRect->left, DestRect->top, DestRect->right, DestRect->bottom); if (SrcRect) TRACE("\tsrcrect :%dx%d-%dx%d\n", SrcRect->left, SrcRect->top, SrcRect->right, SrcRect->bottom); -#if 0 - TRACE("\tflags: "); - DDRAW_dump_DDBLT(Flags); - if (Flags & WINEDDBLT_DDFX) - { - TRACE("\tblitfx: "); - DDRAW_dump_DDBLTFX(DDBltFx->dwDDFX); - } -#endif } if ( (This->Flags & SFLAG_LOCKED) || ((Src != NULL) && (Src->Flags & SFLAG_LOCKED))) diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c index 580c88a9080..a97675ef7c6 100644 --- a/dlls/wined3d/surface_gdi.c +++ b/dlls/wined3d/surface_gdi.c @@ -176,27 +176,6 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface) return WINEDDERR_NOTLOCKED; } - /* Can be useful for debugging */ -#if 0 - { - static unsigned int gen = 0; - char buffer[4096]; - ++gen; - if ((gen % 10) == 0) { - snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", - This, This->texture_target, This->texture_level, gen); - IWineD3DSurfaceImpl_SaveSnapshot(iface, buffer); - } - /* - * debugging crash code - if (gen == 250) { - void** test = NULL; - *test = 0; - } - */ - } -#endif - /* Tell the swapchain to update the screen */ if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain))) { @@ -262,120 +241,6 @@ IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) return WINED3DERR_INVALIDCALL; } -/***************************************************************************** - * IWineD3DSurface::SaveSnapshot, GDI version - * - * This method writes the surface's contents to the in tga format to the - * file specified in filename. - * - * Params: - * filename: File to write to - * - * Returns: - * WINED3DERR_INVALIDCALL if the file couldn't be opened - * WINED3D_OK on success - * - *****************************************************************************/ -static int get_shift(DWORD color_mask) { - int shift = 0; - while (color_mask > 0xFF) { - color_mask >>= 1; - shift += 1; - } - while ((color_mask & 0x80) == 0) { - color_mask <<= 1; - shift -= 1; - } - return shift; -} - - -static HRESULT WINAPI -IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, -const char* filename) -{ - FILE* f = NULL; - UINT y = 0, x = 0; - IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; - const struct wined3d_format_desc *format_desc = This->resource.format_desc; - static char *output = NULL; - static UINT size = 0; - - if (This->pow2Width > size) { - output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pow2Width * 3); - size = This->pow2Width; - } - - - f = fopen(filename, "w+"); - if (NULL == f) { - ERR("opening of %s failed with\n", filename); - return WINED3DERR_INVALIDCALL; - } - fprintf(f, "P6\n%d %d\n255\n", This->pow2Width, This->pow2Height); - - if (This->resource.format_desc->format == WINED3DFMT_P8_UINT) - { - unsigned char table[256][3]; - int i; - - if (This->palette == NULL) { - fclose(f); - return WINED3DERR_INVALIDCALL; - } - for (i = 0; i < 256; i++) { - table[i][0] = This->palette->palents[i].peRed; - table[i][1] = This->palette->palents[i].peGreen; - table[i][2] = This->palette->palents[i].peBlue; - } - for (y = 0; y < This->pow2Height; y++) { - unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface)); - for (x = 0; x < This->pow2Width; x++) { - unsigned char color = *src; - src += 1; - - output[3 * x + 0] = table[color][0]; - output[3 * x + 1] = table[color][1]; - output[3 * x + 2] = table[color][2]; - } - fwrite(output, 3 * This->pow2Width, 1, f); - } - } else { - int red_shift, green_shift, blue_shift, pix_width; - - pix_width = format_desc->byte_count; - - red_shift = get_shift(format_desc->red_mask); - green_shift = get_shift(format_desc->green_mask); - blue_shift = get_shift(format_desc->blue_mask); - - for (y = 0; y < This->pow2Height; y++) { - const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface)); - for (x = 0; x < This->pow2Width; x++) { - unsigned int color; - unsigned int comp; - int i; - - color = 0; - for (i = 0; i < pix_width; i++) { - color |= src[i] << (8 * i); - } - src += 1 * pix_width; - - comp = color & format_desc->red_mask; - output[3 * x + 0] = red_shift > 0 ? comp >> red_shift : comp << -red_shift; - comp = color & format_desc->green_mask; - output[3 * x + 1] = green_shift > 0 ? comp >> green_shift : comp << -green_shift; - comp = color & format_desc->blue_mask; - output[3 * x + 2] = blue_shift > 0 ? comp >> blue_shift : comp << -blue_shift; - } - fwrite(output, 3 * This->pow2Width, 1, f); - } - } - fclose(f); - return WINED3D_OK; -} - static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; WINED3DLOCKED_RECT lock; @@ -683,7 +548,6 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl = /* Internal use: */ IWineGDISurfaceImpl_LoadTexture, IWineD3DBaseSurfaceImpl_BindTexture, - IWineGDISurfaceImpl_SaveSnapshot, IWineD3DBaseSurfaceImpl_SetContainer, IWineD3DBaseSurfaceImpl_GetData, IWineD3DBaseSurfaceImpl_SetFormat, diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 69d3d0d4e33..6c5326cf1c5 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -367,46 +367,6 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO } } -#if defined(FRAME_DEBUGGING) -{ - if (GetFileAttributesA("C:\\D3DTRACE") != INVALID_FILE_ATTRIBUTES) { - if (!isOn) { - isOn = TRUE; - FIXME("Enabling D3D Trace\n"); - __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 1); -#if defined(SHOW_FRAME_MAKEUP) - FIXME("Singe Frame snapshots Starting\n"); - isDumpingFrames = TRUE; - ENTER_GL(); - glClear(GL_COLOR_BUFFER_BIT); - LEAVE_GL(); -#endif - -#if defined(SINGLE_FRAME_DEBUGGING) - } else { -#if defined(SHOW_FRAME_MAKEUP) - FIXME("Singe Frame snapshots Finishing\n"); - isDumpingFrames = FALSE; -#endif - FIXME("Singe Frame trace complete\n"); - DeleteFileA("C:\\D3DTRACE"); - __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0); -#endif - } - } else { - if (isOn) { - isOn = FALSE; -#if defined(SHOW_FRAME_MAKEUP) - FIXME("Single Frame snapshots Finishing\n"); - isDumpingFrames = FALSE; -#endif - FIXME("Disabling D3D Trace\n"); - __WINE_SET_DEBUGGING(__WINE_DBCL_TRACE, __wine_dbch_d3d, 0); - } - } -} -#endif - /* This is disabled, but the code left in for debug purposes. * * Since we're allowed to modify the new back buffer on a D3DSWAPEFFECT_DISCARD flip, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 77bcf0e988d..2b048b7a1c0 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -819,40 +819,6 @@ typedef struct IWineD3DSwapChainImpl IWineD3DSwapChainImpl; /* Global variables */ extern const float identity[16] DECLSPEC_HIDDEN; -/***************************************************************************** - * Compilable extra diagnostics - */ - -/* TODO: Confirm each of these works when wined3d move completed */ -#if 0 /* NOTE: Must be 0 in cvs */ - /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start - of each frame, a check is made for the existence of C:\D3DTRACE, and if it exists d3d trace - is enabled, and if it doesn't exist it is disabled. */ -# define FRAME_DEBUGGING - /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before - the file is deleted */ -# if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */ -# define SINGLE_FRAME_DEBUGGING -# endif - /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls. - It can only be enabled when FRAME_DEBUGGING is also enabled - The contents of the back buffer are written into /tmp/backbuffer_* after each primitive - array is drawn. */ -# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */ -# define SHOW_FRAME_MAKEUP 1 -# endif - /* The following, when enabled, lets you see the makeup of the all the textures used during each - of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled. - The contents of the textures assigned to each stage are written into - /tmp/texture_*_.ppm after each primitive array is drawn. */ -# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */ -# define SHOW_TEXTURE_MAKEUP 0 -# endif -extern BOOL isOn; -extern BOOL isDumpingFrames; -extern LONG primCounter; -#endif - enum wined3d_ffp_idx { WINED3D_FFP_POSITION = 0, diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index d8eee95715b..99de560fb49 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -2481,9 +2481,6 @@ interface IWineD3DSurface : IWineD3DResource void BindTexture( [in] BOOL srgb ); - HRESULT SaveSnapshot( - [in] const char *filename - ); HRESULT SetContainer( [in] IWineD3DBase *container );