14#ifndef GEOMVERTEXARRAYDATA_H
15#define GEOMVERTEXARRAYDATA_H
58class EXPCL_PANDA_GOBJ GeomVertexArrayData :
public CopyOnWriteObject,
public SimpleLruPage,
public GeomEnums {
60 GeomVertexArrayData();
63 virtual PT(CopyOnWriteObject) make_cow_copy();
67 UsageHint usage_hint);
68 GeomVertexArrayData(
const GeomVertexArrayData ©);
69 void operator = (
const GeomVertexArrayData ©);
70 virtual ~GeomVertexArrayData();
71 ALLOC_DELETED_CHAIN(GeomVertexArrayData);
73 int compare_to(
const GeomVertexArrayData &other)
const;
95 void output(std::ostream &out)
const;
96 void write(std::ostream &out,
int indent_level = 0)
const;
103 void prepare(PreparedGraphicsObjects *prepared_objects);
104 bool is_prepared(PreparedGraphicsObjects *prepared_objects)
const;
108 bool release(PreparedGraphicsObjects *prepared_objects);
117 EXTENSION(
int __getbuffer__(PyObject *self, Py_buffer *view,
int flags));
118 EXTENSION(
int __getbuffer__(PyObject *self, Py_buffer *view,
int flags)
const);
119 EXTENSION(
void __releasebuffer__(PyObject *self, Py_buffer *view)
const);
127 INLINE
void mark_used();
129 void clear_prepared(PreparedGraphicsObjects *prepared_objects);
130 void reverse_data_endianness(
unsigned char *dest,
131 const unsigned char *source,
size_t size);
140 typedef pmap<PreparedGraphicsObjects *, VertexBufferContext *> Contexts;
147 bool _endian_reversed;
151 class EXPCL_PANDA_GOBJ CData :
public CycleData {
153 INLINE CData(UsageHint usage_hint = UH_unspecified);
154 INLINE CData(CData &&from)
noexcept;
155 INLINE CData(
const CData ©);
156 INLINE
void operator = (
const CData ©);
159 ALLOC_DELETED_CHAIN(CData);
162 void *extra_data)
const;
166 return GeomVertexArrayData::get_class_type();
169 UsageHint _usage_hint;
170 VertexDataBuffer _buffer;
178 static TypeHandle get_class_type() {
181 static void init_type() {
186 static TypeHandle _type_handle;
188 friend class GeomVertexArrayData;
191 PipelineCycler<CData> _cycler;
192 typedef CycleDataReader<CData> CDReader;
193 typedef CycleDataWriter<CData> CDWriter;
194 typedef CycleDataStageReader<CData> CDStageReader;
195 typedef CycleDataStageWriter<CData> CDStageWriter;
197 static SimpleLru _independent_lru;
198 static SimpleLru _small_lru;
199 static VertexDataBook _book;
202 static void register_with_read_factory();
204 PTA_uchar read_raw_data(BamReader *manager, DatagramIterator &source);
207 virtual void finalize(BamReader *manager);
210 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
211 void fillin(DatagramIterator &scan, BamReader *manager);
214 static TypeHandle get_class_type() {
217 static void init_type() {
218 CopyOnWriteObject::init_type();
220 CopyOnWriteObject::get_class_type());
223 virtual TypeHandle get_type()
const {
224 return get_class_type();
226 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
229 static TypeHandle _type_handle;
231 friend class GeomCacheManager;
232 friend class GeomVertexData;
233 friend class PreparedGraphicsObjects;
234 friend class GeomVertexArrayDataHandle;
235 friend class GeomPrimitivePipelineReader;
250class EXPCL_PANDA_GOBJ GeomVertexArrayDataHandle :
public ReferenceCount,
public GeomEnums {
252 INLINE GeomVertexArrayDataHandle(CPT(GeomVertexArrayData)
object,
254 INLINE GeomVertexArrayDataHandle(
const GeomVertexArrayData *
object,
256 INLINE GeomVertexArrayDataHandle(PT(GeomVertexArrayData)
object,
258 INLINE GeomVertexArrayDataHandle(GeomVertexArrayData *
object,
262 INLINE ~GeomVertexArrayDataHandle();
265 GeomVertexArrayDataHandle(
const GeomVertexArrayDataHandle &) =
delete;
267 ALLOC_DELETED_CHAIN_DECL(GeomVertexArrayDataHandle);
269 GeomVertexArrayDataHandle &operator = (
const GeomVertexArrayDataHandle &) =
delete;
271 INLINE
Thread *get_current_thread()
const;
273 INLINE
const unsigned char *
get_read_pointer(
bool force)
const RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT);
277 INLINE
const GeomVertexArrayData *get_object()
const;
278 INLINE GeomVertexArrayData *get_object();
279 MAKE_PROPERTY(
object, get_object);
282 INLINE UsageHint get_usage_hint()
const;
283 MAKE_PROPERTY(array_format, get_array_format);
284 MAKE_PROPERTY(usage_hint, get_usage_hint);
286 INLINE
int get_num_rows()
const;
287 bool set_num_rows(
int n);
288 bool unclean_set_num_rows(
int n);
289 bool reserve_num_rows(
int n);
290 INLINE
void clear_rows();
292 INLINE
size_t get_data_size_bytes()
const;
294 MAKE_PROPERTY(data_size_bytes, get_data_size_bytes);
295 MAKE_PROPERTY(modified, get_modified);
304 const GeomVertexArrayDataHandle *other,
305 size_t from_start,
size_t from_size);
309 const unsigned char *source,
310 size_t from_start,
size_t from_size);
317 size_t from_start,
size_t from_size));
319 INLINE vector_uchar
get_data()
const;
320 void set_data(
const vector_uchar &data);
321 INLINE vector_uchar
get_subdata(
size_t start,
size_t size)
const;
322 void set_subdata(
size_t start,
size_t size,
const vector_uchar &data);
327 PT(GeomVertexArrayData) _object;
328 Thread *
const _current_thread;
329 GeomVertexArrayData::CData *_cdata;
336 static void init_type() {
337 ReferenceCount::init_type();
339 ReferenceCount::get_class_type());
346 friend class GeomPrimitive;
347 friend class GeomVertexData;
348 friend class GeomVertexDataPipelineReader;
349 friend class GeomVertexDataPipelineWriter;
350 friend class GeomVertexArrayData;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A single page of data maintained by a PipelineCycler.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
void copy_data_from(const GeomVertexArrayDataHandle *other)
Copies the entire data array from the other object.
void set_subdata(size_t start, size_t size, const vector_uchar &data)
Replaces a portion of the data array from the indicated string.
vector_uchar get_subdata(size_t start, size_t size) const
Returns a subset of the raw data of the GeomVertexArrayData object, formatted as a string.
VertexBufferContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const
Creates a context for the data on the particular GSG, if it does not already exist.
const unsigned char * get_read_pointer(bool force) const
Returns a readable pointer to the beginning of the actual data stream, or NULL if the data is not cur...
vector_uchar get_data() const
Returns the entire raw data of the GeomVertexArrayData object, formatted as a string.
void copy_subdata_from(size_t to_start, size_t to_size, const GeomVertexArrayDataHandle *other, size_t from_start, size_t from_size)
Copies a portion of the data array from the other object into a portion of the data array of this obj...
bool request_resident() const
Returns true if the vertex data is currently resident in memory.
unsigned char * get_write_pointer()
Returns a writable pointer to the beginning of the actual data stream.
void mark_used() const
Marks the array data recently-used.
void set_data(const vector_uchar &data)
Replaces the entire raw data array with the contents of the indicated string.
This is the data for one array of a GeomVertexData structure.
get_usage_hint
Returns the usage hint that describes to the rendering backend how often the vertex data will be modi...
get_data_size_bytes
Returns the number of bytes stored in the array.
get_modified
Returns a sequence number which is guaranteed to change at least every time the array vertex data is ...
static VertexDataBook & get_book()
Returns the global VertexDataBook that will be used to allocate vertex data buffers.
bool request_resident(Thread *current_thread=Thread::get_current_thread()) const
Returns true if the vertex data is currently resident in memory.
static SimpleLru * get_small_lru()
Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that are deemed too...
bool release(PreparedGraphicsObjects *prepared_objects)
Frees the data context only on the indicated object, if it exists there.
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG,...
bool set_num_rows(int n)
Sets the length of the array to n rows.
int compare_to(const GeomVertexArrayData &other) const
Returns 0 if the two arrays are equivalent, even if they are not the same pointer.
void clear_rows()
Removes all of the rows in the array.
get_array_format
Returns the format object that describes this array.
int get_num_rows() const
Returns the number of rows stored in the array, based on the number of bytes and the stride.
static SimpleLru * get_independent_lru()
Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that have not (yet)...
int release_all()
Frees the context allocated on all objects for which the data has been declared.
bool reserve_num_rows(int n)
This ensures that enough memory space for n rows is allocated, so that you may increase the number of...
void prepare(PreparedGraphicsObjects *prepared_objects)
Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the be...
VertexBufferContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the data on the particular GSG, if it does not already exist.
bool has_column(const InternalName *name) const
Returns true if the array has the named column, false otherwise.
bool unclean_set_num_rows(int n)
This method behaves like set_num_rows(), except the new data is not initialized.
static void lru_epoch()
Marks that an epoch has passed in each LRU.
set_usage_hint
Changes the UsageHint hint for this array.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Encodes a string name in a hash table, mapping it to a pointer.
A table of objects that are saved within the graphics context for reference by handle later.
A single block as returned from SimpleAllocator::alloc().
void set_lru_size(size_t lru_size)
Specifies the size of this page, presumably in bytes, although any unit is possible.
virtual void evict_lru()
Evicts the page from the LRU.
A thread; that is, a lightweight process.
get_current_thread
Returns a pointer to the currently-executing Thread object.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is a sequence number that increments monotonically.
This is a special class object that holds all the information returned by a particular GSG to indicat...
A collection of VertexDataPages, which can be used to allocate new VertexDataBlock objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.