From fd58b41eefb7b8651d77e264f86ceda49c8a2773 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 21 Jun 2003 16:21:31 +0000 Subject: [PATCH] fix Savage crashes in D3D --- stepmania/Data/VideoCardDefaults.ini | 26 +++++++++++++++----------- stepmania/src/RageDisplay_D3D.cpp | 16 ++++++++++++++-- stepmania/src/RageDisplay_D3D.h | 21 +++++++++++++++++++-- stepmania/src/StepMania.cpp | 7 +++---- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/stepmania/Data/VideoCardDefaults.ini b/stepmania/Data/VideoCardDefaults.ini index 9fdb462164..72eaa010ce 100644 --- a/stepmania/Data/VideoCardDefaults.ini +++ b/stepmania/Data/VideoCardDefaults.ini @@ -1,6 +1,6 @@ [0000] DriverRegex=Voodoo3|3dfx -Renderers=d3d +Renderers=d3d,opengl Width=640 Height=480 DisplayColor=16 @@ -36,25 +36,29 @@ AntiAliasing=0 [0003] DriverRegex=Savage -Renderers=d3d,opengl // OpenGL driver doesn't support EXT_texture_env_combine +// OpenGL is unusable on my Savage IV with even the latest drivers. +// It draws 30 frames of gibberish then crashes. I haven't spent time +// debugging because the d3d renderer works (mostly!). -Chris +Renderers=d3d Width=640 Height=480 DisplayColor=16 TextureColor=16 AntiAliasing=0 -[0004] -DriverRegex=OpenGL // Please add a comment. What is this supposed to match? -Chris -Renderers=opengl -Width=640 -Height=480 -DisplayColor=16 -TextureColor=16 -AntiAliasing=1 // Right now, they've got to have NVidia or ATi Cards anyway.. +#// Please add a comment. What is this supposed to match? -Chris +#[0004] +#DriverRegex=OpenGL +#Renderers=opengl +#Width=640 +#Height=480 +#DisplayColor=16 +#TextureColor=16 +#AntiAliasing=1 // Right now, they've got to have NVidia or ATi Cards anyway.. // Default graphics settings used for all cards that don't match above. // This must be the very last entry! -[0005] +[0004] DriverRegex= Renderers=opengl,d3d Width=640 diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 8d653907a5..9683686f6f 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -91,7 +91,15 @@ static void SetPalette( unsigned TexResource ) /* Load it. */ #ifndef _XBOX - g_pd3dDevice->SetPaletteEntries( iPalIndex, g_TexResourceToTexturePalette[TexResource].p ); + TexturePalette& pal = g_TexResourceToTexturePalette[TexResource]; + + // Cards that don't support palettes with alpha will crash unless + // all entires have full alpha. + if( ! (g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ) + for(int j=0; j<256; j++) + pal.p[j].peFlags = 255; + + g_pd3dDevice->SetPaletteEntries( iPalIndex, pal.p ); #else ASSERT(0); #endif @@ -529,6 +537,11 @@ void RageDisplay_D3D::EndFrame() bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt ) { + // Some cards (Savage) don't support alpha in palettes. + // Don't allow paletted textures if this is the case. + if( pixfmt == FMT_PAL && !(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ) + return false; + D3DFORMAT d3dfmt = D3DFORMATS[pixfmt]; HRESULT hr = g_pd3d->CheckDeviceFormat( D3DADAPTER_DEFAULT, @@ -717,7 +730,6 @@ void RageDisplay_D3D::SetTextureModeGlow(GlowMode m) g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - } void RageDisplay_D3D::SetTextureFiltering( bool b ) diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index ac976723de..27a689c4c9 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -1,8 +1,25 @@ #ifndef RAGEDISPLAY_D3D_H #define RAGEDISPLAY_D3D_H -class RageException_D3DNotInstalled: public exception { }; -class RageException_D3DNoAcceleration: public exception { }; +class RageException_D3DNotInstalled: public exception +{ + const char *what() { return + "DirectX 8.1 or greater is not installed. You can download it from:\n" + "http://search.microsoft.com/gomsuri.asp?n=1&c=rp_BestBets&siteid=us&target=http://www.microsoft.com/downloads/details.aspx?FamilyID=a19bed22-0b25-4e5d-a584-6389d8a3dad0&displaylang=en"; } +}; +class RageException_D3DNoAcceleration: public exception +{ + const char *what() { return + "Your system is reporting that Direct3D hardware acceleration is not available. " + "Please obtain an updated driver from your video card manufacturer.\n\n"; } +}; +class RageException_D3DNoPalettedAlpha: public exception +{ + const char *what() { return + "Your video card doesn'thardware acceleration is not available. " + "Please obtain an updated driver from your video card manufacturer.\n\n"; } +}; + class RageDisplay_D3D: public RageDisplay { diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index b2871cf6fc..699af2790b 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -267,8 +267,6 @@ static void CheckSettings() #include "archutils/Win32/VideoDriverInfo.h" #include "regex.h" -static const CString D3DURL = "http://search.microsoft.com/gomsuri.asp?n=1&c=rp_BestBets&siteid=us&target=http://www.microsoft.com/downloads/details.aspx?FamilyID=a19bed22-0b25-4e5d-a584-6389d8a3dad0&displaylang=en"; - RageDisplay *CreateDisplay() { /* We never want to bother users with having to decide which API to use. @@ -395,8 +393,9 @@ RageDisplay *CreateDisplay() error += "Initializing Direct3D...\n"; try { return new RageDisplay_D3D( params ); - } catch(RageException_D3DNotInstalled e) { - error += "DirectX 8.1 or greater is not installed. You can download it from:\n"+D3DURL+"\n\n"; + } catch(exception e) { + error += e.what(); + error += "\n\n"; } catch(RageException_D3DNoAcceleration e) { error += "Your system is reporting that Direct3D hardware acceleration is not available. " "Please obtain an updated driver from your video card manufacturer.\n\n";