diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index c2331ba1df..8b4c6d64c2 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -299,45 +299,6 @@ is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_one_shot -// Access: Published -// Description: Changes the current setting of the one-shot flag. -// When this is true, the GraphicsOutput will render one -// frame and then automatically set itself inactive. -// This is particularly useful for buffers that are -// created for the purposes of render-to-texture, for -// static textures that don't need to be continually -// re-rendered once they have been rendered the first -// time. -// -// Setting the buffer inactive is not the same thing as -// destroying it. You are still responsible for passing -// this buffer to GraphicsEngine::remove_window() when -// you no longer need the texture, in order to clean up -// fully. (However, you should not call remove_window() -// on this buffer while the texture is still needed, -// because depending on the render-to-texture mechanism -// in use, this may invalidate the texture contents.) -//////////////////////////////////////////////////////////////////// -INLINE void GraphicsOutput:: -set_one_shot(bool one_shot) { - _one_shot = one_shot; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_one_shot -// Access: Published -// Description: Returns the current setting of the one-shot flag. -// When this is true, the GraphicsOutput will -// automatically set itself inactive after the next -// frame. -//////////////////////////////////////////////////////////////////// -INLINE bool GraphicsOutput:: -get_one_shot() const { - return _one_shot; -} - //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_inverted // Access: Published diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index b28568b942..b01e382d2e 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -104,7 +104,6 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, _child_sort = 0; _got_child_sort = false; _internal_sort_index = 0; - _one_shot = false; _inverted = window_inverted; _red_blue_stereo = false; _left_eye_color_mask = 0x0f; @@ -447,9 +446,61 @@ is_active() const { } CDReader cdata(_cycler); + if (cdata->_one_shot_frame != -1) { + // If one_shot is in effect, then we are active only for the one + // indicated frame. + if (cdata->_one_shot_frame != ClockObject::get_global_clock()->get_frame_count()) { + return false; + } + } return cdata->_active; } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::set_one_shot +// Access: Published +// Description: Changes the current setting of the one-shot flag. +// When this is true, the GraphicsOutput will render the +// current frame and then automatically set itself +// inactive. This is particularly useful for buffers +// that are created for the purposes of +// render-to-texture, for static textures that don't +// need to be continually re-rendered once they have +// been rendered the first time. +// +// Setting the buffer inactive is not the same thing as +// destroying it. You are still responsible for passing +// this buffer to GraphicsEngine::remove_window() when +// you no longer need the texture, in order to clean up +// fully. (However, you should not call remove_window() +// on this buffer while the texture is still needed, +// because depending on the render-to-texture mechanism +// in use, this may invalidate the texture contents.) +//////////////////////////////////////////////////////////////////// +void GraphicsOutput:: +set_one_shot(bool one_shot) { + CDWriter cdata(_cycler, true); + if (one_shot) { + cdata->_one_shot_frame = ClockObject::get_global_clock()->get_frame_count(); + } else { + cdata->_one_shot_frame = -1; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::get_one_shot +// Access: Published +// Description: Returns the current setting of the one-shot flag. +// When this is true, the GraphicsOutput will +// automatically set itself inactive after the next +// frame. +//////////////////////////////////////////////////////////////////// +bool GraphicsOutput:: +get_one_shot() const { + CDReader cdata(_cycler); + return (cdata->_one_shot_frame == ClockObject::get_global_clock()->get_frame_count()); +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::set_inverted // Access: Published @@ -1669,6 +1720,7 @@ CData() { // initially populated with inactive outputs. Pipeline stage 0 is // set to active in the constructor. _active = false; + _one_shot_frame = -1; _active_display_regions_stale = false; } @@ -1681,6 +1733,7 @@ GraphicsOutput::CData:: CData(const GraphicsOutput::CData ©) : _textures(copy._textures), _active(copy._active), + _one_shot_frame(copy._one_shot_frame), _active_display_regions(copy._active_display_regions), _active_display_regions_stale(copy._active_display_regions_stale) { diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 208ecd398b..917187f703 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -127,8 +127,8 @@ PUBLISHED: void set_active(bool active); virtual bool is_active() const; - INLINE void set_one_shot(bool one_shot); - INLINE bool get_one_shot() const; + void set_one_shot(bool one_shot); + bool get_one_shot() const; void set_inverted(bool inverted); INLINE bool get_inverted() const; @@ -303,7 +303,6 @@ private: unsigned int _internal_sort_index; protected: - bool _one_shot; bool _inverted; bool _red_blue_stereo; unsigned int _left_eye_color_mask; @@ -342,6 +341,7 @@ protected: RenderTextures _textures; bool _active; + int _one_shot_frame; ActiveDisplayRegions _active_display_regions; bool _active_display_regions_stale; }; diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index c55d19681f..dcfc210a69 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -188,9 +188,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { promote_to_copy_texture(); copy_to_textures(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx b/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx index ea31bbb6d8..49cab550df 100644 --- a/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsBuffer8.cxx @@ -150,9 +150,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); restore_bitplanes(); } diff --git a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx index 1e8fdf1b39..ad408fa0e3 100644 --- a/panda/src/dxgsg8/wdxGraphicsWindow8.cxx +++ b/panda/src/dxgsg8/wdxGraphicsWindow8.cxx @@ -123,9 +123,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx index b5de693b35..de4ca3243e 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx @@ -172,9 +172,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); restore_bitplanes(); } diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index 1c60d9a179..a2e4c3e086 100755 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -141,9 +141,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index ba50b0b630..b34ca33e07 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -125,9 +125,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/egldisplay/eglGraphicsPixmap.cxx b/panda/src/egldisplay/eglGraphicsPixmap.cxx index 88af6f2174..46abe8a34b 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.cxx +++ b/panda/src/egldisplay/eglGraphicsPixmap.cxx @@ -130,9 +130,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index addccc6020..0a48676e1a 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -207,9 +207,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index e875bd0aa7..8c78ecc78e 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -924,9 +924,6 @@ void CLP(GraphicsBuffer)::end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } report_my_gl_errors(); diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index 24984b01ca..c9aeaeb7f1 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -125,9 +125,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index 0d23604c88..29585ae324 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -128,9 +128,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index 831e96179c..032b273f5b 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -276,7 +276,11 @@ flatten(GraphicsOutput *window) { GraphicsOutput *buffer = window->make_texture_buffer (multitex_name_strm.str(), x_size, y_size, NULL, false); + + // TODO: this no longer automatically deletes the buffer. We need + // to take care of this explicitly now. buffer->set_one_shot(true); + Texture *tex = buffer->get_texture(); tex->set_anisotropic_degree(aniso_degree); tex->set_minfilter(minfilter); diff --git a/panda/src/mesadisplay/osMesaGraphicsBuffer.cxx b/panda/src/mesadisplay/osMesaGraphicsBuffer.cxx index 99220a8c23..2bf9107279 100644 --- a/panda/src/mesadisplay/osMesaGraphicsBuffer.cxx +++ b/panda/src/mesadisplay/osMesaGraphicsBuffer.cxx @@ -102,9 +102,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index 9cad3ae7a0..2f7752274c 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -125,9 +125,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index 3d5935962a..f1e7bbfc3c 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -95,9 +95,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index ea3ec3265e..8cac3555a9 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -673,10 +673,7 @@ void TinyOsxGraphicsWindow::end_frame(FrameMode mode, Thread *current_thread) { copy_to_textures(); trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } - clear_cube_map_selection(); + clear_cube_map_selection(); } } diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index 48849320fb..39404871be 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -107,9 +107,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } } } diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx index 6ee4ba0983..ddfaab42a6 100755 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -103,9 +103,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index ab84f2e05d..c168379465 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -135,9 +135,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index f9ecefc495..07e7443021 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -130,9 +130,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index 1dd046dc4c..3f6a88fe1c 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -106,9 +106,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } } diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index aa5f1f50ca..cd862cde05 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -226,9 +226,6 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); - if (_one_shot) { - prepare_for_deletion(); - } clear_cube_map_selection(); } }