From 502ae6d15e36d21b87ee572f533eb9abcb63672d Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 1 Mar 2005 22:34:08 +0000 Subject: [PATCH] add prefer-texture-buffer --- panda/src/display/config_display.cxx | 24 +++++++++++++++++++----- panda/src/display/config_display.h | 1 + panda/src/display/graphicsOutput.cxx | 6 +++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 704c997b8a..86c6f8bd13 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -87,13 +87,27 @@ ConfigVariableBool show_buffers "GraphicsWindows, if possible, so that their contents may be viewed " "interactively. Handy during development of multipass algorithms.")); +ConfigVariableBool prefer_texture_buffer +("prefer-texture-buffer", true, + PRC_DESC("Set this true to make GraphicsOutput::make_texture_buffer() always " + "try to create an offscreen buffer supporting render-to-texture, " + "if the graphics card claims to be able to support this feature. " + "If the graphics card cannot support this feature, this option is " + "ignored. This is usually the fastest way to render " + "to a texture, and it presumably does not consume any additional " + "framebuffer memory over a copy-to-texture operation (since " + "the texture and the buffer share the " + "same memory).")); + ConfigVariableBool prefer_parasite_buffer ("prefer-parasite-buffer", true, PRC_DESC("Set this true to make GraphicsOutput::make_texture_buffer() try to " - "create a parasite buffer before it tries to create an offscreen " - "buffer. This may be desired if you know your graphics API does not " - "support render-to-texture and you want to minimize " - "framebuffer memory.")); + "create a ParasiteBuffer before it tries to create an offscreen " + "buffer (assuming it could not create a direct render buffer for " + "some reason). This may reduce your graphics card memory " + "requirements by sharing memory with the framebuffer, but it can " + "cause problems if the user subsequently resizes the window " + "smaller than the buffer.")); ConfigVariableBool prefer_single_buffer ("prefer-single-buffer", true, @@ -101,7 +115,7 @@ ConfigVariableBool prefer_single_buffer "try to create a single-buffered offscreen buffer, before falling " "back to a double-buffered one (or whatever kind the source window " "has). This is true by default to reduce waste of framebuffer " - "memory, but you may get a performance benefit by setting it to " + "memory, but you might get a performance benefit by setting it to " "false (since in that case the buffer can share a graphics context " "with the window).")); diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index f731bbd2c6..5f7a4ddd0b 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -48,6 +48,7 @@ extern EXPCL_PANDA ConfigVariableString screenshot_extension; extern EXPCL_PANDA ConfigVariableBool show_buffers; +extern EXPCL_PANDA ConfigVariableBool prefer_texture_buffer; extern EXPCL_PANDA ConfigVariableBool prefer_parasite_buffer; extern EXPCL_PANDA ConfigVariableBool prefer_single_buffer; diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 60378600d4..e02a7c14bc 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -448,8 +448,12 @@ make_texture_buffer(const string &name, int x_size, int y_size) { // If the user so indicated in the Config.prc file, try to create a // parasite buffer first. We can only do this if the requested size - // fits within the available framebuffer size. + // fits within the available framebuffer size. Also, don't do this + // if the GSG supports render-to-a-texture and prefer_texture_buffer + // is true, since using a ParasiteButter precludes + // render-to-a-texture. if (prefer_parasite_buffer && + !(prefer_texture_buffer && gsg->get_supports_render_texture()) && (x_size <= host->get_x_size() && y_size <= host->get_y_size())) { buffer = engine->make_parasite(host, name, sort, x_size, y_size); if (buffer != (GraphicsOutput *)NULL) {