Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
ShaderBuffer Class Reference

This is a generic buffer object that lives in graphics memory. More...

#include "shaderBuffer.h"

Inheritance diagram for ShaderBuffer:
TypedWritableReferenceCount Namable GeomEnums TypedWritable ReferenceCount MemoryBase TypedObject MemoryBase MemoryBase

Public Member Functions

 ShaderBuffer (const std::string &name, uint64_t size, UsageHint usage_hint)
 Creates an uninitialized buffer object with the given size. More...
 
 ShaderBuffer (const std::string &name, vector_uchar initial_data, UsageHint usage_hint)
 Creates a buffer object initialized with the given data. More...
 
 ~ShaderBuffer ()
 Destructor. More...
 
virtual TypeHandle force_init_type ()
 
uint64_t get_data_size_bytes () const
 
const unsigned char * get_initial_data () const
 Returns a pointer to the initial buffer data, or NULL if not specified. More...
 
virtual TypeHandle get_type () const
 
UsageHint get_usage_hint () const
 
bool is_prepared (PreparedGraphicsObjects *prepared_objects) const
 Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise. More...
 
virtual void output (std::ostream &out) const
 
void prepare (PreparedGraphicsObjects *prepared_objects)
 Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame. More...
 
BufferContextprepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
 Creates a context for the data on the particular GSG, if it does not already exist. More...
 
bool release (PreparedGraphicsObjects *prepared_objects)
 Frees the data context only on the indicated object, if it exists there. More...
 
int release_all ()
 Frees the context allocated on all objects for which the data has been declared. More...
 
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file. More...
 
- Public Member Functions inherited from TypedWritableReferenceCount
 TypedWritableReferenceCount (const TypedWritableReferenceCount &copy)
 
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More...
 
void operator= (const TypedWritableReferenceCount &copy)
 
- Public Member Functions inherited from TypedWritable
 TypedWritable (const TypedWritable &copy)
 
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(). More...
 
vector_uchar encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More...
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter. More...
 
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
void operator= (const TypedWritable &copy)
 
virtual bool require_fully_complete () const
 Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More...
 
virtual void update_bam_nested (BamWriter *manager)
 Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 
- Public Member Functions inherited from Namable
 Namable (const std::string &initial_name="")
 
void clear_name ()
 Resets the Namable's name to empty. More...
 
const std::string & get_name () const
 
bool has_name () const
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
void output (std::ostream &out) const
 Outputs the Namable. More...
 
void set_name (const std::string &name)
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type ParamValue. More...
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
static PT (TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data
 
- Static Public Member Functions inherited from TypedWritable
static bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. More...
 
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

 get_data_size_bytes
 Returns the buffer size in bytes. More...
 
 get_usage_hint
 Returns the buffer usage hint. More...
 
- Public Attributes inherited from TypedWritableReferenceCount
static BamReaderreader = nullptr)
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 
- Public Attributes inherited from Namable
 get_name
 
 set_name
 

Friends

class PreparedGraphicsObjects
 

Additional Inherited Members

- Public Types inherited from GeomEnums
enum  AnimationType { AT_none, AT_panda, AT_hardware }
 
enum  Contents {
  C_other, C_point, C_clip_point, C_vector,
  C_texcoord, C_color, C_index, C_morph_delta,
  C_matrix, C_normal
}
 
enum  GeomRendering {
  GR_indexed_point = 0x00001, GR_indexed_other = 0x10000, GR_indexed_bits = 0x10001, GR_point = 0x00002,
  GR_point_uniform_size = 0x00004, GR_per_point_size = 0x00008, GR_point_perspective = 0x00010, GR_point_aspect_ratio = 0x00020,
  GR_point_scale = 0x00040, GR_point_rotate = 0x00080, GR_point_sprite = 0x00100, GR_point_sprite_tex_matrix = 0x00200,
  GR_point_bits = 0x003fe, GR_triangle_strip = 0x00400, GR_triangle_fan = 0x00800, GR_line_strip = 0x01000,
  GR_composite_bits = 0x01c00, GR_strip_cut_index = 0x20000, GR_flat_first_vertex = 0x02000, GR_flat_last_vertex = 0x04000,
  GR_shade_model_bits = 0x06000, GR_render_mode_wireframe = 0x40000, GR_render_mode_point = 0x80000, GR_adjacency = 0x100000
}
 
enum  NumericType {
  NT_uint8, NT_uint16, NT_uint32, NT_packed_dcba,
  NT_packed_dabc, NT_float32, NT_float64, NT_stdfloat,
  NT_int8, NT_int16, NT_int32, NT_packed_ufloat
}
 
enum  PrimitiveType {
  PT_none, PT_polygons, PT_lines, PT_points,
  PT_patches
}
 
enum  ShadeModel { SM_uniform, SM_smooth, SM_flat_first_vertex, SM_flat_last_vertex }
 
enum  UsageHint {
  UH_client, UH_stream, UH_dynamic, UH_static,
  UH_unspecified
}
 
- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = nullptr
 

Detailed Description

This is a generic buffer object that lives in graphics memory.

Since
1.10.0

Definition at line 33 of file shaderBuffer.h.

Constructor & Destructor Documentation

◆ ~ShaderBuffer()

ShaderBuffer::~ShaderBuffer ( )

Destructor.

Definition at line 23 of file shaderBuffer.cxx.

References release_all().

◆ ShaderBuffer() [1/2]

ShaderBuffer::ShaderBuffer ( const std::string &  name,
uint64_t  size,
UsageHint  usage_hint 
)
inlineexplicit

Creates an uninitialized buffer object with the given size.

For now, these parameters cannot be modified, but this may change in the future.

Definition at line 19 of file shaderBuffer.I.

◆ ShaderBuffer() [2/2]

ShaderBuffer::ShaderBuffer ( const std::string &  name,
vector_uchar  initial_data,
UsageHint  usage_hint 
)
inlineexplicit

Creates a buffer object initialized with the given data.

For now, these parameters cannot be modified, but this may change in the future.

Definition at line 30 of file shaderBuffer.I.

Member Function Documentation

◆ get_initial_data()

const unsigned char * ShaderBuffer::get_initial_data ( ) const
inline

Returns a pointer to the initial buffer data, or NULL if not specified.

Definition at line 63 of file shaderBuffer.I.

◆ is_prepared()

bool ShaderBuffer::is_prepared ( PreparedGraphicsObjects prepared_objects) const

Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.

Definition at line 53 of file shaderBuffer.cxx.

References PreparedGraphicsObjects::is_shader_buffer_queued().

◆ prepare()

void ShaderBuffer::prepare ( PreparedGraphicsObjects prepared_objects)

Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.

This will ensure the data is already loaded into the GSG if it is expected to be rendered soon.

Use this function instead of prepare_now() to preload datas from a user interface standpoint.

Definition at line 44 of file shaderBuffer.cxx.

References PreparedGraphicsObjects::enqueue_shader_buffer().

◆ prepare_now()

BufferContext * ShaderBuffer::prepare_now ( PreparedGraphicsObjects prepared_objects,
GraphicsStateGuardianBase gsg 
)

Creates a context for the data on the particular GSG, if it does not already exist.

Returns the new (or old) BufferContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new datas. If this is not necessarily the case, you should use prepare() instead.

Normally, this is not called directly except by the GraphicsStateGuardian; a data does not need to be explicitly prepared by the user before it may be rendered.

Definition at line 77 of file shaderBuffer.cxx.

References PreparedGraphicsObjects::prepare_shader_buffer_now().

◆ register_with_read_factory()

void ShaderBuffer::register_with_read_factory ( )
static

Tells the BamReader how to create objects of type ParamValue.

Definition at line 175 of file shaderBuffer.cxx.

References BamReader::get_factory(), and Factory< Type >::register_factory().

◆ release()

bool ShaderBuffer::release ( PreparedGraphicsObjects prepared_objects)

Frees the data context only on the indicated object, if it exists there.

Returns true if it was released, false if it had not been prepared.

Definition at line 100 of file shaderBuffer.cxx.

References PreparedGraphicsObjects::dequeue_shader_buffer(), and PreparedGraphicsObjects::release_shader_buffer().

◆ release_all()

int ShaderBuffer::release_all ( )

Frees the context allocated on all objects for which the data has been declared.

Returns the number of contexts which have been freed.

Definition at line 120 of file shaderBuffer.cxx.

References PreparedGraphicsObjects::release_shader_buffer().

Referenced by ~ShaderBuffer().

◆ write_datagram()

void ShaderBuffer::write_datagram ( BamWriter manager,
Datagram dg 
)
virtual

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from TypedWritable.

Definition at line 184 of file shaderBuffer.cxx.

References Datagram::add_bool(), Datagram::add_string(), Datagram::add_uint64(), Datagram::add_uint8(), Datagram::append_data(), and PreparedGraphicsObjects::get_name().

Member Data Documentation

◆ get_data_size_bytes

uint64_t ShaderBuffer::get_data_size_bytes
inline

Returns the buffer size in bytes.

Definition at line 51 of file shaderBuffer.h.

◆ get_usage_hint

GeomEnums::UsageHint ShaderBuffer::get_usage_hint
inline

Returns the buffer usage hint.

Definition at line 52 of file shaderBuffer.h.


The documentation for this class was generated from the following files: