mirror of
https://github.com/panda3d/panda3d.git
synced 2026-04-20 21:50:26 -05:00
remove vertex-data-allow-reread
This commit is contained in:
@@ -299,17 +299,6 @@ ConfigVariableInt vertex_data_small_size
|
||||
"is deemed too small to pay the overhead of paging it in and out, "
|
||||
"and it is permanently retained resident."));
|
||||
|
||||
ConfigVariableBool vertex_data_allow_reread
|
||||
("vertex-data-allow-reread", false,
|
||||
PRC_DESC("Set this true to allow a GeomVertexArrayData to re-read itself "
|
||||
"from the original bam file it was read from, if it is evicted "
|
||||
"and needs to be reloaded. This avoids the need to write the "
|
||||
"data to the page file, but it requires that bam files are not "
|
||||
"modified during program execution. Set it false to prevent "
|
||||
"this, so that the vertex data will need to be written to a "
|
||||
"page file when it is evicted. Note that this is not fully "
|
||||
"compatible with vertex-data-threaded-paging."));
|
||||
|
||||
ConfigVariableBool vertex_data_threaded_paging
|
||||
("vertex-data-threaded-paging", true,
|
||||
PRC_DESC("When this is true (and Panda has been compiled with thread "
|
||||
|
||||
@@ -74,7 +74,6 @@ extern EXPCL_PANDA ConfigVariableDouble default_keystone;
|
||||
extern EXPCL_PANDA ConfigVariableFilename vertex_save_file_directory;
|
||||
extern EXPCL_PANDA ConfigVariableString vertex_save_file_prefix;
|
||||
extern EXPCL_PANDA ConfigVariableInt vertex_data_small_size;
|
||||
extern EXPCL_PANDA ConfigVariableBool vertex_data_allow_reread;
|
||||
extern EXPCL_PANDA ConfigVariableBool vertex_data_threaded_paging;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -604,10 +604,6 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) {
|
||||
size_t size = scan.get_uint32();
|
||||
|
||||
_buffer.unclean_realloc(size);
|
||||
if (vertex_data_allow_reread) {
|
||||
streampos source_pos = manager->get_file_pos() + (streampos)scan.get_current_index() - (streampos)scan.get_datagram().get_length();
|
||||
_buffer.set_file(manager->get_file(), source_pos);
|
||||
}
|
||||
|
||||
const unsigned char *source_data =
|
||||
(const unsigned char *)scan.get_datagram().get_data();
|
||||
@@ -617,7 +613,6 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) {
|
||||
|
||||
if (manager->get_file_endian() != BE_native) {
|
||||
// For non-native endian files, we have to convert the data.
|
||||
_buffer.set_file(NULL, 0);
|
||||
|
||||
if (array_data->_array_format == (GeomVertexArrayFormat *)NULL) {
|
||||
// But we can't do that until we've completed the _array_format
|
||||
|
||||
@@ -66,8 +66,6 @@ operator = (const VertexDataBuffer ©) {
|
||||
|
||||
do_unclean_realloc(copy.get_size());
|
||||
memcpy(_resident_data, copy.get_read_pointer(true), _size);
|
||||
_source_file = copy._source_file;
|
||||
_source_pos = copy._source_pos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@@ -101,10 +99,6 @@ get_read_pointer(bool force) const {
|
||||
// pointer, which will force its page to resident status.
|
||||
return _block->get_pointer(force);
|
||||
}
|
||||
if (_resident_data == (unsigned char *)NULL && !_source_file.is_null()) {
|
||||
// If we need to re-read the original source, do so.
|
||||
((VertexDataBuffer *)this)->do_page_in();
|
||||
}
|
||||
|
||||
return _resident_data;
|
||||
}
|
||||
@@ -122,7 +116,6 @@ get_write_pointer() {
|
||||
_resident_data == (unsigned char *)NULL) {
|
||||
do_page_in();
|
||||
}
|
||||
_source_file.clear();
|
||||
return _resident_data;
|
||||
}
|
||||
|
||||
@@ -213,27 +206,6 @@ swap(VertexDataBuffer &other) {
|
||||
other._block = block;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: VertexDataBuffer::set_file
|
||||
// Access: Public
|
||||
// Description: Stores a reference to a byte location on an on-disk
|
||||
// file from which a copy of the data can be retrieved
|
||||
// if necessary.
|
||||
//
|
||||
// If this is non-NULL, the data will not be written to
|
||||
// the page file; instead, the specified file will be
|
||||
// re-opened and re-read if necessary.
|
||||
//
|
||||
// If this is set to NULL, the data will be paged out
|
||||
// and in normally.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void VertexDataBuffer::
|
||||
set_file(VirtualFile *source_file, streampos source_pos) {
|
||||
MutexHolder holder(_lock);
|
||||
_source_file = source_file;
|
||||
_source_pos = source_pos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: VertexDataBuffer::do_unclean_realloc
|
||||
// Access: Private
|
||||
|
||||
@@ -35,8 +35,6 @@ TypeHandle VertexDataBuffer::_type_handle;
|
||||
void VertexDataBuffer::
|
||||
do_clean_realloc(size_t size) {
|
||||
if (size != _size) {
|
||||
_source_file.clear();
|
||||
|
||||
if (size == 0) {
|
||||
// If we're going to size 0, we don't necessarily need to page
|
||||
// in first. But if we're paged out, discard the page.
|
||||
@@ -90,15 +88,11 @@ do_page_out(VertexDataBook &book) {
|
||||
}
|
||||
nassertv(_resident_data != (unsigned char *)NULL);
|
||||
|
||||
if (_source_file == (VirtualFile *)NULL) {
|
||||
// We only need to allocate a block if we don't have a source
|
||||
// file.
|
||||
_block = book.alloc(_size);
|
||||
nassertv(_block != (VertexDataBlock *)NULL);
|
||||
unsigned char *pointer = _block->get_pointer(true);
|
||||
nassertv(pointer != (unsigned char *)NULL);
|
||||
memcpy(pointer, _resident_data, _size);
|
||||
}
|
||||
_block = book.alloc(_size);
|
||||
nassertv(_block != (VertexDataBlock *)NULL);
|
||||
unsigned char *pointer = _block->get_pointer(true);
|
||||
nassertv(pointer != (unsigned char *)NULL);
|
||||
memcpy(pointer, _resident_data, _size);
|
||||
|
||||
free(_resident_data);
|
||||
_resident_data = NULL;
|
||||
@@ -116,43 +110,6 @@ do_page_out(VertexDataBook &book) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void VertexDataBuffer::
|
||||
do_page_in() {
|
||||
if (_source_file != (VirtualFile *)NULL && _resident_data == (unsigned char *)NULL) {
|
||||
// Re-read the data from its original source.
|
||||
PStatTimer timer(_vdata_reread_pcollector);
|
||||
|
||||
_resident_data = (unsigned char *)malloc(_size);
|
||||
nassertv(_resident_data != (unsigned char *)NULL);
|
||||
get_class_type().inc_memory_usage(TypeHandle::MC_array, _size);
|
||||
|
||||
istream *in = _source_file->open_read_file(true);
|
||||
if (in == (istream *)NULL) {
|
||||
gobj_cat.error()
|
||||
<< "Error reopening " << _source_file->get_filename()
|
||||
<< " to reread vertex data.\n";
|
||||
} else {
|
||||
if (gobj_cat.is_debug()) {
|
||||
gobj_cat.debug()
|
||||
<< "rereading " << _size << " bytes from "
|
||||
<< _source_file->get_filename() << ", position "
|
||||
<< _source_pos << "\n";
|
||||
}
|
||||
|
||||
in->seekg(_source_pos);
|
||||
|
||||
in->read((char *)_resident_data, _size);
|
||||
if (in->fail() || in->eof()) {
|
||||
gobj_cat.error()
|
||||
<< "Error rereading " << _size << " bytes from "
|
||||
<< _source_file->get_filename() << ", position "
|
||||
<< _source_pos << "\n";
|
||||
}
|
||||
|
||||
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
|
||||
vfs->close_read_file(in);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (_block == (VertexDataBlock *)NULL) {
|
||||
// We're already paged in.
|
||||
return;
|
||||
|
||||
@@ -80,8 +80,6 @@ public:
|
||||
|
||||
INLINE void swap(VertexDataBuffer &other);
|
||||
|
||||
INLINE void set_file(VirtualFile *source_file, streampos source_pos);
|
||||
|
||||
private:
|
||||
void do_clean_realloc(size_t size);
|
||||
INLINE void do_unclean_realloc(size_t size);
|
||||
@@ -92,8 +90,6 @@ private:
|
||||
unsigned char *_resident_data;
|
||||
size_t _size;
|
||||
PT(VertexDataBlock) _block;
|
||||
PT(VirtualFile) _source_file;
|
||||
streampos _source_pos;
|
||||
Mutex _lock;
|
||||
|
||||
static PStatCollector _vdata_reread_pcollector;
|
||||
|
||||
Reference in New Issue
Block a user