diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 6bd533082f..a178fd7484 100755 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -778,7 +778,6 @@ create_texture(DXScreenData &scrn) { DWORD usage; D3DPOOL pool; - usage = 0; if (tex->get_render_to_texture ( )) { // REQUIRED PARAMETERS _managed = false; @@ -801,6 +800,7 @@ create_texture(DXScreenData &scrn) { _managed = scrn._managed_textures; if (_managed) { pool = D3DPOOL_MANAGED; + usage = 0; } else { if (scrn._supports_automatic_mipmap_generation) { @@ -818,10 +818,12 @@ create_texture(DXScreenData &scrn) { // need to use UpdateTexture or UpdateSurface _managed = true; pool = D3DPOOL_MANAGED; + usage = 0; } } else { pool = D3DPOOL_DEFAULT; + usage = 0; } } } diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.I b/panda/src/dxgsg9/wdxGraphicsBuffer9.I new file mode 100644 index 0000000000..7dc69fd67b --- /dev/null +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.I @@ -0,0 +1,27 @@ +// Filename: wdxGraphicsBuffer9.I +// Created by: zhao (29Sept12) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: wdxGraphicsBuffer9::get_supports_render_texture +// Access: Published, Virtual +// Description: Returns true if this particular GraphicsOutput can +// render directly into a texture, or false if it must +// always copy-to-texture at the end of each frame to +// achieve this effect. +//////////////////////////////////////////////////////////////////// +INLINE bool wdxGraphicsBuffer9:: +get_supports_render_texture() const { + // DX9 buffers can always bind-to-texture. + return true; +} \ No newline at end of file diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx index de4ca3243e..e530e6701e 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx @@ -354,11 +354,15 @@ rebuild_bitplanes() { _color_backing_store = NULL; } if (!_color_backing_store) { - hr = _dxgsg -> _d3d_device -> - CreateOffscreenPlainSurface(bitplane_x, bitplane_y, _saved_color_desc.Format, - D3DPOOL_DEFAULT, &_color_backing_store, NULL); + hr = _dxgsg->_d3d_device->CreateRenderTarget(bitplane_x, bitplane_y, + _saved_color_desc.Format, + _saved_color_desc.MultiSampleType, + _saved_color_desc.MultiSampleQuality, + FALSE, + &_color_backing_store, + NULL); if (!SUCCEEDED(hr)) { - dxgsg9_cat.error ( ) << "CreateImageSurface " << D3DERRORSTRING(hr) FL; + dxgsg9_cat.error ( ) << "CreateRenderTarget " << D3DERRORSTRING(hr) FL; } } color_surf = _color_backing_store; @@ -456,13 +460,13 @@ rebuild_bitplanes() { if (depth_ctx) { if (!depth_ctx->create_texture(*_dxgsg->_screen)) { dxgsg9_cat.error() - << "Unable to re-create texture " << *color_ctx->get_texture() << endl; + << "Unable to re-create texture " << *depth_ctx->get_texture() << endl; return false; } if (depth_tex->get_texture_type() == Texture::TT_2d_texture) { depth_d3d_tex = depth_ctx->_d3d_2d_texture; nassertr(depth_d3d_tex != 0, false); - hr = color_d3d_tex -> GetSurfaceLevel(0, &depth_surf); + hr = depth_d3d_tex -> GetSurfaceLevel(0, &depth_surf); if (!SUCCEEDED(hr)) { dxgsg9_cat.error ( ) << "GetSurfaceLevel " << D3DERRORSTRING(hr) FL; } diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.h b/panda/src/dxgsg9/wdxGraphicsBuffer9.h index d43ec66ce2..05e88a027f 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.h +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.h @@ -41,10 +41,13 @@ public: GraphicsOutput *host); virtual ~wdxGraphicsBuffer9(); + virtual INLINE bool get_supports_render_texture() const; + virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); virtual void select_cube_map(int cube_map_index); + virtual void process_events(); virtual bool share_depth_buffer(GraphicsOutput *graphics_output); @@ -101,4 +104,6 @@ private: friend class DXTextureContext9; }; +#include "wdxGraphicsBuffer9.I" + #endif diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index 3c1236658e..8ad1f40266 100755 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -150,10 +150,8 @@ make_output(const string &name, // Early success - if we are sure that this buffer WILL // meet specs, we can precertify it. // This looks rather overly optimistic -- ie, buggy. - if ((gsg != 0)&& - (gsg->is_valid())&& - (!gsg->needs_reset())&& - (DCAST(DXGraphicsStateGuardian9, gsg)->get_supports_render_texture())) { + if ((wdxgsg != NULL) && wdxgsg->is_valid() && !wdxgsg->needs_reset() && + wdxgsg->get_supports_render_texture()) { precertify = true; } return new wdxGraphicsBuffer9(engine, this, name, fb_prop, win_prop,