mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
auto-downscale parasite buffers
This commit is contained in:
parent
251416cd5c
commit
ba38195f19
@ -408,15 +408,6 @@ make_output(GraphicsPipe *pipe,
|
||||
// last hope.
|
||||
|
||||
if (can_use_parasite) {
|
||||
if (x_size > host->get_x_size()) {
|
||||
x_size = Texture::down_to_power_2(host->get_x_size());
|
||||
}
|
||||
if (y_size > host->get_y_size()) {
|
||||
y_size = Texture::down_to_power_2(host->get_y_size());
|
||||
}
|
||||
if (flags & GraphicsPipe::BF_size_square) {
|
||||
x_size = y_size = min(x_size, y_size);
|
||||
}
|
||||
ParasiteBuffer *buffer = new ParasiteBuffer(host, name, x_size, y_size, flags);
|
||||
buffer->_sort = sort;
|
||||
do_add_window(buffer, threading_model);
|
||||
|
@ -732,13 +732,20 @@ make_texture_buffer(const string &name, int x_size, int y_size,
|
||||
FrameBufferProperties props;
|
||||
props.set_rgb_color(1);
|
||||
props.set_depth_bits(1);
|
||||
|
||||
int flags = GraphicsPipe::BF_refuse_window;
|
||||
if (textures_power_2 != ATS_none) {
|
||||
flags |= GraphicsPipe::BF_size_power_2;
|
||||
}
|
||||
if (tex->get_texture_type() == Texture::TT_cube_map) {
|
||||
flags |= GraphicsPipe::BF_size_square;
|
||||
}
|
||||
|
||||
GraphicsOutput *buffer = get_gsg()->get_engine()->
|
||||
make_output(get_gsg()->get_pipe(),
|
||||
name, get_child_sort(),
|
||||
props, WindowProperties::size(x_size, y_size),
|
||||
GraphicsPipe::BF_refuse_window,
|
||||
get_gsg(), get_host());
|
||||
flags, get_gsg(), get_host());
|
||||
|
||||
if (buffer != (GraphicsOutput *)NULL) {
|
||||
buffer->add_render_texture(tex, to_ram ? RTM_copy_ram : RTM_bind_or_copy);
|
||||
|
@ -85,6 +85,7 @@ PUBLISHED:
|
||||
BF_rtt_cumulative = 0x0400, // Buffer supports cumulative render-to-texture.
|
||||
BF_fb_props_optional = 0x0800, // FrameBufferProperties can be ignored.
|
||||
BF_size_square = 0x1000, // x_size must equal y_size (e.g. for cube maps)
|
||||
BF_size_power_2 = 0x2000, // x_size and y_size must each be a power of two
|
||||
};
|
||||
|
||||
INLINE bool is_valid() const;
|
||||
|
@ -12,8 +12,8 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "parasiteBuffer.h"
|
||||
#include "texture.h"
|
||||
|
||||
TypeHandle ParasiteBuffer::_type_handle;
|
||||
|
||||
@ -87,6 +87,24 @@ set_size(int x, int y) {
|
||||
set_size_and_recalc(x, y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ParasiteBuffer::set_size_and_recalc
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ParasiteBuffer::
|
||||
set_size_and_recalc(int x, int y) {
|
||||
if (_creation_flags & GraphicsPipe::BF_size_power_2) {
|
||||
x = Texture::down_to_power_2(x);
|
||||
y = Texture::down_to_power_2(y);
|
||||
}
|
||||
if (_creation_flags & GraphicsPipe::BF_size_square) {
|
||||
x = y = min(x, y);
|
||||
}
|
||||
|
||||
GraphicsOutput::set_size_and_recalc(x, y);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ParasiteBuffer::is_active
|
||||
// Access: Published, Virtual
|
||||
@ -135,6 +153,12 @@ begin_frame(FrameMode mode, Thread *current_thread) {
|
||||
set_size_and_recalc(_host->get_x_size(),
|
||||
_host->get_y_size());
|
||||
}
|
||||
} else {
|
||||
if (_host->get_x_size() < _x_size ||
|
||||
_host->get_y_size() < _y_size) {
|
||||
set_size_and_recalc(min(_x_size, _host->get_x_size()),
|
||||
min(_y_size, _host->get_y_size()));
|
||||
}
|
||||
}
|
||||
|
||||
clear_cube_map_selection();
|
||||
|
@ -60,6 +60,7 @@ PUBLISHED:
|
||||
void set_size(int x, int y);
|
||||
|
||||
public:
|
||||
void set_size_and_recalc(int x, int y);
|
||||
virtual bool begin_frame(FrameMode mode, Thread *current_thread);
|
||||
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
||||
virtual GraphicsOutput *get_host();
|
||||
|
Loading…
x
Reference in New Issue
Block a user