From e49cc9f973e811b1ad2354eea65ef85a8df2bd3b Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 6 Nov 2006 19:18:47 +0000 Subject: [PATCH] fix incorrect matchup between mouse and display --- panda/src/dxgsg8/config_dxgsg8.cxx | 6 - panda/src/dxgsg8/config_dxgsg8.h | 1 - panda/src/dxgsg8/wdxGraphicsWindow8.cxx | 192 ++++-------------------- panda/src/dxgsg9/config_dxgsg9.cxx | 6 - panda/src/dxgsg9/config_dxgsg9.h | 1 - panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 191 ++++------------------- 6 files changed, 62 insertions(+), 335 deletions(-) diff --git a/panda/src/dxgsg8/config_dxgsg8.cxx b/panda/src/dxgsg8/config_dxgsg8.cxx index df184e7864..930fba0d13 100644 --- a/panda/src/dxgsg8/config_dxgsg8.cxx +++ b/panda/src/dxgsg8/config_dxgsg8.cxx @@ -105,12 +105,6 @@ ConfigVariableBool dx_do_vidmemsize_check ConfigVariableBool dx_preserve_fpu_state ("dx-preserve-fpu-state", true); -// if true, override win-width/height and use driver vidmem info to -// pick what will be a fullscreen window size close to the best perf -// capability of card, based on a heuristic -ConfigVariableBool dx_pick_best_screenres -("pick-best-screenres", false); - ConfigVariableInt dx_preferred_device_id ("dx-preferred-device-id", -1); diff --git a/panda/src/dxgsg8/config_dxgsg8.h b/panda/src/dxgsg8/config_dxgsg8.h index a2cfb29e05..7318ae4b48 100644 --- a/panda/src/dxgsg8/config_dxgsg8.h +++ b/panda/src/dxgsg8/config_dxgsg8.h @@ -49,7 +49,6 @@ extern ConfigVariableBool dx_force_anisotropic_filtering; extern ConfigVariableBool dx_force_16bpp_zbuffer; extern ConfigVariableBool dx_do_vidmemsize_check; extern ConfigVariableBool dx_preserve_fpu_state; -extern ConfigVariableBool dx_pick_best_screenres; extern ConfigVariableInt dx_preferred_device_id; #ifndef NDEBUG diff --git a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx index 7e8e599965..a6bfda62c5 100644 --- a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx @@ -515,11 +515,6 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer wdxGraphicsPipe8 *dxpipe; DCAST_INTO_R(dxpipe, _pipe, false); - // only want dx_pick_best_screenres to apply to initial startup, and - // since the initial res has already been picked, dont use - // auto-res-select in any future init sequence. - dx_pick_best_screenres = false; - DWORD dwRenderWidth = display._display_mode.Width; DWORD dwRenderHeight = display._display_mode.Height; DWORD dwBehaviorFlags = 0x0; @@ -949,7 +944,7 @@ search_for_device(wdxGraphicsPipe8 *dxpipe, DXDeviceInfo *device_info) { // bugbug: wouldnt we like to do GetAVailVidMem so we can do // upper-limit memory computation for dx8 cards too? otherwise // verify_window_sizes cant do much - if ((_d3dcaps.MaxStreams == 0) || dx_pick_best_screenres) { + if (_d3dcaps.MaxStreams == 0) { if (wdxdisplay8_cat.is_debug()) { wdxdisplay8_cat.debug() << "checking vidmem size\n"; @@ -1003,154 +998,30 @@ search_for_device(wdxGraphicsPipe8 *dxpipe, DXDeviceInfo *device_info) { if (is_fullscreen()) { bool bCouldntFindValidZBuf; - if (!_wcontext._is_low_memory_card) { - bool bUseDefaultSize = dx_pick_best_screenres && - ((_wcontext._max_available_video_memory == UNKNOWN_VIDMEM_SIZE) || - is_badvidmem_card(&_wcontext._dx_device_id)); - - if (dx_pick_best_screenres && !bUseDefaultSize) { - typedef struct { - UINT memlimit; - DWORD scrnX, scrnY; - } Memlimres; - - const Memlimres MemRes[] = { - { 0, 640, 480}, - { 8000000, 800, 600}, - - // unfortunately the 32MB card perf varies greatly (TNT2-GF2), - // so we need to be conservative since frame rate difference - // can change from 15->30fps when going from 1280x1024->800x600 - // on low-end 32mb cards - {16000000, 800, 600}, - {32000000, 800, 600}, // 32MB+ cards will choose this - - // some monitors have trouble w/1600x1200, so dont pick this by deflt, - // even though 64MB cards should handle it - {64000000, 1280, 1024} // 64MB+ cards will choose this - }; - const int NumResLims = (sizeof(MemRes)/sizeof(Memlimres)); - - for(int i = NumResLims - 1; i >= 0; i--) { - // find biggest slot card can handle - if (_wcontext._max_available_video_memory > MemRes[i].memlimit) { - dwRenderWidth = MemRes[i].scrnX; - dwRenderHeight = MemRes[i].scrnY; - - wdxdisplay8_cat.info() - << "pick_best_screenres: trying " << dwRenderWidth - << "x" << dwRenderHeight << " based on " - << _wcontext._max_available_video_memory << " bytes avail\n"; - - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer); - - // note I'm not saving refresh rate, will just use adapter - // default at given res for now - - if (pixFmt != D3DFMT_UNKNOWN) { - break; - } - - wdxdisplay8_cat.info() - << "skipping scrnres; " - << (bCouldntFindValidZBuf ? "Couldnt find valid zbuffer format to go with FullScreen mode" : "No supported FullScreen modes") - << " at " << dwRenderWidth << "x" << dwRenderHeight - << " for device #" << _wcontext._card_id << endl; - } - } - // otherwise just go with whatever was specified (we probably shouldve marked this card as lowmem if it gets to end of loop w/o breaking - } - - if (pixFmt == D3DFMT_UNKNOWN) { - if (bUseDefaultSize) { - wdxdisplay8_cat.info() - << "pick_best_screenres: defaulted 800x600 based on no reliable vidmem size\n"; - dwRenderWidth = 800; - dwRenderHeight = 600; - } - - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer); - - // note I'm not saving refresh rate, will just use adapter - // default at given res for now - - if (pixFmt == D3DFMT_UNKNOWN) { - wdxdisplay8_cat.error() - << (bCouldntFindValidZBuf ? "Couldnt find valid zbuffer format to go with FullScreen mode" : "No supported FullScreen modes") - << " at " << dwRenderWidth << "x" << dwRenderHeight << " for device #" << _wcontext._card_id << endl; - - // if it failed because of a size constraints (for non-default case), try with default size - if (!bUseDefaultSize) { - wdxdisplay8_cat.info() << "was not a default: but trying 800x600 size in verbose mode\n"; - dwRenderWidth = 800; - dwRenderHeight = 600; - } - - // run it again in verbose mode to get more dbg info to log - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer, true); - - // if still D3DFMT_UNKNOWN return false - if (pixFmt == D3DFMT_UNKNOWN) - return false; - } - } - } else { - // Low Memory card - dwRenderWidth = 640; - dwRenderHeight = 480; - dx_force_16bpptextures = true; - - // need to autoforce 16bpp zbuf? or let user use that extra mem - // for textures/framebuf res/etc? most lowmem cards only do - // 16bpp Z anyway, but we wont force it for now - + dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, + bNeedZBuffer, bWantStencil, + &_wcontext._supported_screen_depths_mask, + &bCouldntFindValidZBuf, + &pixFmt, dx_force_16bpp_zbuffer); + + // note I'm not saving refresh rate, will just use adapter + // default at given res for now + + if (pixFmt == D3DFMT_UNKNOWN) { + wdxdisplay8_cat.error() + << (bCouldntFindValidZBuf ? "Couldnt find valid zbuffer format to go with FullScreen mode" : "No supported FullScreen modes") + << " at " << dwRenderWidth << "x" << dwRenderHeight << " for device #" << _wcontext._card_id << endl; + + // run it again in verbose mode to get more dbg info to log dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, bNeedZBuffer, bWantStencil, &_wcontext._supported_screen_depths_mask, &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer); - - // hack: figuring out exactly what res to use is tricky, instead I will - // just use 640x480 if we have < 3 meg avail - - if (_wcontext._supported_screen_depths_mask & R5G6B5_FLAG) { - pixFmt = D3DFMT_R5G6B5; - } else if (_wcontext._supported_screen_depths_mask & X1R5G5B5_FLAG) { - pixFmt = D3DFMT_X1R5G5B5; - } else { - wdxdisplay8_cat.fatal() - << "Low Memory VidCard has no supported FullScreen 16bpp resolutions at " - << dwRenderWidth << "x" << dwRenderHeight << " for device #" - << device_info->cardID << " (" - << _wcontext._dx_device_id.Description << "), skipping device...\n"; - - // run it again in verbose mode to get more dbg info to log - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer, - true /* verbose mode on*/); + &pixFmt, dx_force_16bpp_zbuffer, true); + + // if still D3DFMT_UNKNOWN return false + if (pixFmt == D3DFMT_UNKNOWN) return false; - } - - if (wdxdisplay8_cat.is_info()) { - wdxdisplay8_cat.info() - << "Available VidMem (" << _wcontext._max_available_video_memory - << ") is under threshold, using 640x480 16bpp rendertargets to save tex vidmem.\n"; - } } } else { // Windowed Mode @@ -1174,18 +1045,17 @@ search_for_device(wdxGraphicsPipe8 *dxpipe, DXDeviceInfo *device_info) { if (dwRenderWidth != properties.get_x_size() || dwRenderHeight != properties.get_y_size()) { - // This is probably not the best place to put this; I'm just putting - // it here for now because if dx_pick_best_screenres is true, the - // code above might have changed the size of the window - // unexpectedly. This code gets called when make_gsg() is called, - // which means it is called in the draw thread, but this method - // should really be called from the window thread. In DirectX those - // may always be the same threads anyway, so we may be all right. - // Still, it's a little strange that the window may change size - // after it has already been opened, at the time we create the GSG - // for it; it would be better if we could find a way to do this - // resolution-selection logic earlier, say at the time the window is - // created. + // This is probably not the best place to put this; I'm just + // putting it here for now because the code above might have + // changed the size of the window unexpectedly. This code gets + // called when make_gsg() is called, which means it is called in + // the draw thread, but this method should really be called from + // the window thread. In DirectX those may always be the same + // threads anyway, so we may be all right. Still, it's a little + // strange that the window may change size after it has already + // been opened, at the time we create the GSG for it; it would be + // better if we could find a way to do this resolution-selection + // logic earlier, say at the time the window is created. system_changed_size(dwRenderWidth, dwRenderHeight); WindowProperties resized_props; resized_props.set_size(dwRenderWidth, dwRenderHeight); diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index 9b7bd51678..da3c2065b2 100755 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -106,12 +106,6 @@ ConfigVariableBool dx_do_vidmemsize_check ConfigVariableBool dx_preserve_fpu_state ("dx-preserve-fpu-state", true); -// if true, override win-width/height and use driver vidmem info to -// pick what will be a fullscreen window size close to the best perf -// capability of card, based on a heuristic -ConfigVariableBool dx_pick_best_screenres -("pick-best-screenres", false); - ConfigVariableInt dx_preferred_device_id ("dx-preferred-device-id", -1); diff --git a/panda/src/dxgsg9/config_dxgsg9.h b/panda/src/dxgsg9/config_dxgsg9.h index 14d038aed1..63b6e6e783 100755 --- a/panda/src/dxgsg9/config_dxgsg9.h +++ b/panda/src/dxgsg9/config_dxgsg9.h @@ -48,7 +48,6 @@ extern ConfigVariableBool dx_force_anisotropic_filtering; extern ConfigVariableBool dx_force_16bpp_zbuffer; extern ConfigVariableBool dx_do_vidmemsize_check; extern ConfigVariableBool dx_preserve_fpu_state; -extern ConfigVariableBool dx_pick_best_screenres; extern ConfigVariableInt dx_preferred_device_id; #ifndef NDEBUG diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index 8dbc208bf0..1fc91615ec 100755 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -513,11 +513,6 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer wdxGraphicsPipe9 *dxpipe; DCAST_INTO_R(dxpipe, _pipe, false); - // only want dx_pick_best_screenres to apply to initial startup, and - // since the initial res has already been picked, dont use - // auto-res-select in any future init sequence. - dx_pick_best_screenres = false; - DWORD dwRenderWidth = display._display_mode.Width; DWORD dwRenderHeight = display._display_mode.Height; DWORD dwBehaviorFlags = 0x0; @@ -1013,7 +1008,7 @@ search_for_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { // bugbug: wouldnt we like to do GetAVailVidMem so we can do // upper-limit memory computation for dx8 cards too? otherwise // verify_window_sizes cant do much - if ((_d3dcaps.MaxStreams == 0) || dx_pick_best_screenres) { + if (_d3dcaps.MaxStreams == 0) { if (wdxdisplay9_cat.is_debug()) { wdxdisplay9_cat.debug() << "checking vidmem size\n"; @@ -1067,154 +1062,31 @@ search_for_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { if (is_fullscreen()) { bool bCouldntFindValidZBuf; - if (!_wcontext._is_low_memory_card) { - bool bUseDefaultSize = dx_pick_best_screenres && - ((_wcontext._max_available_video_memory == UNKNOWN_VIDMEM_SIZE) || - is_badvidmem_card(&_wcontext._dx_device_id)); - - if (dx_pick_best_screenres && !bUseDefaultSize) { - typedef struct { - UINT memlimit; - DWORD scrnX, scrnY; - } Memlimres; - - const Memlimres MemRes[] = { - { 0, 640, 480}, - { 8000000, 800, 600}, - - // unfortunately the 32MB card perf varies greatly (TNT2-GF2), - // so we need to be conservative since frame rate difference - // can change from 15->30fps when going from 1280x1024->800x600 - // on low-end 32mb cards - {16000000, 800, 600}, - {32000000, 800, 600}, // 32MB+ cards will choose this - - // some monitors have trouble w/1600x1200, so dont pick this by deflt, - // even though 64MB cards should handle it - {64000000, 1280, 1024} // 64MB+ cards will choose this - }; - const int NumResLims = (sizeof(MemRes)/sizeof(Memlimres)); - - for(int i = NumResLims - 1; i >= 0; i--) { - // find biggest slot card can handle - if (_wcontext._max_available_video_memory > MemRes[i].memlimit) { - dwRenderWidth = MemRes[i].scrnX; - dwRenderHeight = MemRes[i].scrnY; - - wdxdisplay9_cat.info() - << "pick_best_screenres: trying " << dwRenderWidth - << "x" << dwRenderHeight << " based on " - << _wcontext._max_available_video_memory << " bytes avail\n"; - - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer, true); - - // note I'm not saving refresh rate, will just use adapter - // default at given res for now - - if (pixFmt != D3DFMT_UNKNOWN) { - break; - } - - wdxdisplay9_cat.info() - << "skipping scrnres; " - << (bCouldntFindValidZBuf ? "Couldnt find valid zbuffer format to go with FullScreen mode" : "No supported FullScreen modes") - << " at " << dwRenderWidth << "x" << dwRenderHeight - << " for device #" << _wcontext._card_id << endl; - } - } - // otherwise just go with whatever was specified (we probably shouldve marked this card as lowmem if it gets to end of loop w/o breaking - } - - if (pixFmt == D3DFMT_UNKNOWN) { - if (bUseDefaultSize) { - wdxdisplay9_cat.info() - << "pick_best_screenres: defaulted 800x600 based on no reliable vidmem size\n"; - dwRenderWidth = 800; - dwRenderHeight = 600; - } - - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer, true); - - // note I'm not saving refresh rate, will just use adapter - // default at given res for now - - if (pixFmt == D3DFMT_UNKNOWN) { - wdxdisplay9_cat.error() - << (bCouldntFindValidZBuf ? "Couldnt find valid zbuffer format to go with FullScreen mode" : "No supported FullScreen modes") - << " at " << dwRenderWidth << "x" << dwRenderHeight << " for device #" << _wcontext._card_id << endl; - - // if it failed because of a size constraints (for non-default case), try with default size - if (!bUseDefaultSize) { - wdxdisplay9_cat.info() << "was not a default: but trying 800x600 size in verbose mode\n"; - dwRenderWidth = 800; - dwRenderHeight = 600; - } - - // run it again in verbose mode to get more dbg info to log - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer, true); - - // if still D3DFMT_UNKNOWN return false - if (pixFmt == D3DFMT_UNKNOWN) - return false; - } - } - } else { - // Low Memory card - dwRenderWidth = 640; - dwRenderHeight = 480; - dx_force_16bpptextures = true; - - // need to autoforce 16bpp zbuf? or let user use that extra mem - // for textures/framebuf res/etc? most lowmem cards only do - // 16bpp Z anyway, but we wont force it for now - + + dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, + bNeedZBuffer, bWantStencil, + &_wcontext._supported_screen_depths_mask, + &bCouldntFindValidZBuf, + &pixFmt, dx_force_16bpp_zbuffer, true); + + // note I'm not saving refresh rate, will just use adapter + // default at given res for now + + if (pixFmt == D3DFMT_UNKNOWN) { + wdxdisplay9_cat.error() + << (bCouldntFindValidZBuf ? "Couldnt find valid zbuffer format to go with FullScreen mode" : "No supported FullScreen modes") + << " at " << dwRenderWidth << "x" << dwRenderHeight << " for device #" << _wcontext._card_id << endl; + + // run it again in verbose mode to get more dbg info to log dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, bNeedZBuffer, bWantStencil, &_wcontext._supported_screen_depths_mask, &bCouldntFindValidZBuf, &pixFmt, dx_force_16bpp_zbuffer, true); - - // hack: figuring out exactly what res to use is tricky, instead I will - // just use 640x480 if we have < 3 meg avail - - if (_wcontext._supported_screen_depths_mask & R5G6B5_FLAG) { - pixFmt = D3DFMT_R5G6B5; - } else if (_wcontext._supported_screen_depths_mask & X1R5G5B5_FLAG) { - pixFmt = D3DFMT_X1R5G5B5; - } else { - wdxdisplay9_cat.fatal() - << "Low Memory VidCard has no supported FullScreen 16bpp resolutions at " - << dwRenderWidth << "x" << dwRenderHeight << " for device #" - << device_info->cardID << " (" - << _wcontext._dx_device_id.Description << "), skipping device...\n"; - - // run it again in verbose mode to get more dbg info to log - dxpipe->search_for_valid_displaymode(_wcontext, dwRenderWidth, dwRenderHeight, - bNeedZBuffer, bWantStencil, - &_wcontext._supported_screen_depths_mask, - &bCouldntFindValidZBuf, - &pixFmt, dx_force_16bpp_zbuffer, - true /* verbose mode on*/); + + // if still D3DFMT_UNKNOWN return false + if (pixFmt == D3DFMT_UNKNOWN) return false; - } - - if (wdxdisplay9_cat.is_info()) { - wdxdisplay9_cat.info() - << "Available VidMem (" << _wcontext._max_available_video_memory - << ") is under threshold, using 640x480 16bpp rendertargets to save tex vidmem.\n"; - } } } else { // Windowed Mode @@ -1238,18 +1110,17 @@ search_for_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { if (dwRenderWidth != properties.get_x_size() || dwRenderHeight != properties.get_y_size()) { - // This is probably not the best place to put this; I'm just putting - // it here for now because if dx_pick_best_screenres is true, the - // code above might have changed the size of the window - // unexpectedly. This code gets called when make_gsg() is called, - // which means it is called in the draw thread, but this method - // should really be called from the window thread. In DirectX those - // may always be the same threads anyway, so we may be all right. - // Still, it's a little strange that the window may change size - // after it has already been opened, at the time we create the GSG - // for it; it would be better if we could find a way to do this - // resolution-selection logic earlier, say at the time the window is - // created. + // This is probably not the best place to put this; I'm just + // putting it here for now because the code above might have + // changed the size of the window unexpectedly. This code gets + // called when make_gsg() is called, which means it is called in + // the draw thread, but this method should really be called from + // the window thread. In DirectX those may always be the same + // threads anyway, so we may be all right. Still, it's a little + // strange that the window may change size after it has already + // been opened, at the time we create the GSG for it; it would be + // better if we could find a way to do this resolution-selection + // logic earlier, say at the time the window is created. system_changed_size(dwRenderWidth, dwRenderHeight); WindowProperties resized_props; resized_props.set_size(dwRenderWidth, dwRenderHeight);