From b9aa4f24482d32fb945fbfc2b979f86efa950370 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 13 Jan 2020 16:22:04 +0100 Subject: [PATCH] dxgsg9: fix debug messages not protected by is_debug() check --- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 32 +++++++++++++------ panda/src/dxgsg9/dxTextureContext9.cxx | 6 ++-- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index bd36f99da3..e1efd0374b 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -1001,8 +1001,10 @@ begin_frame(Thread *current_thread) { GraphicsStateGuardian::begin_frame(current_thread); if (_d3d_device == nullptr) { - dxgsg9_cat.debug() - << this << "::begin_frame(): no device.\n"; + if (dxgsg9_cat.is_debug()) { + dxgsg9_cat.debug() + << this << "::begin_frame(): no device.\n"; + } return false; } @@ -1955,9 +1957,11 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, tex_level_0, &src_rect, filter); if (FAILED(hr)) { - dxgsg9_cat.debug() - << "StretchRect failed in framebuffer_copy_to_texture" - << D3DERRORSTRING(hr); + if (dxgsg9_cat.is_debug()) { + dxgsg9_cat.debug() + << "StretchRect failed in framebuffer_copy_to_texture" + << D3DERRORSTRING(hr); + } okflag = false; } @@ -2399,7 +2403,7 @@ reset() { hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, nullptr); _supports_occlusion_query = !FAILED(hr); - if (dxgsg9_cat.is_error()) { + if (dxgsg9_cat.is_debug()) { dxgsg9_cat.debug() << "\nHwTransformAndLight = " << ((d3d_caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0) << "\nMaxTextureWidth = " << d3d_caps.MaxTextureWidth @@ -4628,8 +4632,10 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, // release the old swapchain and create a new one if (_screen && _screen->_swap_chain) { _screen->_swap_chain->Release(); - wdxdisplay9_cat.debug() - << "swap chain " << _screen->_swap_chain << " is released\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() + << "swap chain " << _screen->_swap_chain << " is released\n"; + } _screen->_swap_chain = nullptr; hr = _d3d_device->CreateAdditionalSwapChain(presentation_params, &_screen->_swap_chain); } @@ -4749,7 +4755,10 @@ create_swap_chain(DXScreenData *new_context) { HRESULT hr; hr = new_context->_d3d_device->CreateAdditionalSwapChain(&new_context->_presentation_params, &new_context->_swap_chain); if (FAILED(hr)) { - wdxdisplay9_cat.debug() << "Swapchain creation failed :"<_swap_chain) { hr = new_context->_swap_chain->Release(); if (FAILED(hr)) { - wdxdisplay9_cat.debug() << "Swapchain release failed:" << D3DERRORSTRING(hr) << "\n"; + if (wdxdisplay9_cat.is_debug()) { + wdxdisplay9_cat.debug() + << "Swapchain release failed:" << D3DERRORSTRING(hr) << "\n"; + } return false; } } diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index d130acd959..2c90a56910 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -2014,8 +2014,10 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { // on the fly int miplevel_count = _d3d_texture->GetLevelCount(); if (miplevel_count <= tex->get_num_loadable_ram_mipmap_images()) { - dxgsg9_cat.debug() - << "Using pre-calculated mipmap levels for texture " << tex->get_name() << "\n"; + if (dxgsg9_cat.is_debug()) { + dxgsg9_cat.debug() + << "Using pre-calculated mipmap levels for texture " << tex->get_name() << "\n"; + } for (int mip_level = 1; mip_level < miplevel_count; ++mip_level) { hr = fill_d3d_texture_mipmap_pixels(mip_level, di, source_format);