Panda3D
|
Classes | |
struct | ShaderArgId |
struct | ShaderArgInfo |
class | ShaderCaps |
class | ShaderFile |
struct | ShaderMatSpec |
struct | ShaderPtrData |
struct | ShaderPtrSpec |
struct | ShaderTexSpec |
struct | ShaderVarSpec |
Public Member Functions | |
~Shader () | |
Delete the compiled code, if it exists. More... | |
void | clear_parameters () |
bool | compile_parameter (const ShaderArgId &arg_id, const ShaderArgClass &arg_class, const ShaderArgClass &arg_subclass, const ShaderArgType &arg_type, const ShaderArgDir &arg_direction, bool arg_varying, int *arg_dim, NotifyCategory *arg_cat) |
Analyzes a parameter and decides how to bind the parameter to some part of panda's internal state. More... | |
int | cp_dependency (ShaderMatInput inp) |
Given ShaderMatInput, returns an indication of what part or parts of the state_and_transform the ShaderMatInput depends upon. More... | |
bool | cp_errchk_parameter_float (ShaderArgInfo &arg, int lo, int hi) |
Make sure the provided parameter has a floating point type. More... | |
bool | cp_errchk_parameter_in (ShaderArgInfo &arg) |
Make sure the provided parameter has the 'in' direction. More... | |
bool | cp_errchk_parameter_ptr (ShaderArgInfo &p) |
bool | cp_errchk_parameter_sampler (ShaderArgInfo &arg) |
Make sure the provided parameter has a texture type. More... | |
bool | cp_errchk_parameter_uniform (ShaderArgInfo &arg) |
Make sure the provided parameter has the correct variance. More... | |
bool | cp_errchk_parameter_varying (ShaderArgInfo &arg) |
Make sure the provided parameter has the correct variance. More... | |
bool | cp_errchk_parameter_words (ShaderArgInfo &arg, int len) |
Make sure the provided parameter contains the specified number of words. More... | |
void | cp_optimize_mat_spec (ShaderMatSpec &spec) |
Analyzes a ShaderMatSpec and decides what it should use its cache for. More... | |
bool | cp_parse_coord_sys (ShaderArgInfo &arg, vector_string &pieces, int &next, ShaderMatSpec &spec, bool fromflag) |
Convert a single-word coordinate system name into a PART/ARG of a ShaderMatSpec. More... | |
bool | cp_parse_delimiter (ShaderArgInfo &arg, vector_string &pieces, int &next) |
Pop a delimiter ('to' or 'rel') from the word list. More... | |
bool | cp_parse_eol (ShaderArgInfo &arg, vector_string &pieces, int &next) |
Make sure the next thing on the word list is EOL. More... | |
string | cp_parse_non_delimiter (vector_string &pieces, int &next) |
Pop a non-delimiter word from the word list. More... | |
void | cp_report_error (ShaderArgInfo &arg, const string &msg) |
Generate an error message including a description of the specified parameter. More... | |
virtual TypeHandle | force_init_type () |
bool | get_error_flag () const |
Returns true if the shader contains a compile-time error. More... | |
Filename | get_filename (const ShaderType &type=ST_none) const |
Return the Shader's filename for the given shader type. More... | |
Filename | get_filename_from_index (int index, ShaderType type) const |
Returns the filename of the included shader with the given source file index (as recorded in the #line statement in r_preprocess_source). More... | |
ShaderLanguage | get_language () const |
Returns the shader language in which this shader was written. More... | |
const string & | get_text (const ShaderType &type=ST_none) const |
Return the Shader's text for the given shader type. More... | |
virtual TypeHandle | get_type () const |
bool | is_prepared (PreparedGraphicsObjects *prepared_objects) const |
Returns true if the shader has already been prepared or enqueued for preparation on the indicated GSG, false otherwise. More... | |
bool | parse_eof () |
Returns true if the parse pointer is at the end of the shader. More... | |
void | parse_init () |
Set a 'parse pointer' to the beginning of the shader. More... | |
void | parse_line (string &result, bool rt, bool lt) |
Parse a line of text. More... | |
void | parse_rest (string &result) |
Returns the rest of the text from the current parse location. More... | |
void | parse_upto (string &result, string pattern, bool include) |
Parse lines until you read a line that matches the specified pattern. More... | |
void | prepare (PreparedGraphicsObjects *prepared_objects) |
Indicates that the shader should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame. More... | |
ShaderContext * | prepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) |
Creates a context for the shader on the particular GSG, if it does not already exist. More... | |
bool | release (PreparedGraphicsObjects *prepared_objects) |
Frees the texture context only on the indicated object, if it exists there. More... | |
int | release_all () |
Frees the context allocated on all objects for which the texture 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... | |
![]() | |
TypedWritableReferenceCount (const TypedWritableReferenceCount ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More... | |
void | operator= (const TypedWritableReferenceCount ©) |
![]() | |
TypedWritable (const TypedWritable ©) | |
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... | |
string | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. More... | |
bool | encode_to_bam_stream (string &data, BamWriter *writer=NULL) 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 ©) |
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... | |
![]() | |
TypedObject (const TypedObject ©) | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_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... | |
void | operator= (const TypedObject ©) |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
WeakReferenceList * | get_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 | 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... | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static ShaderUtilization | get_shader_utilization () |
This flag returns SUT_none, SUT_basic, or SUT_advanced and controls the automatic generation of shaders. More... | |
static bool | have_shader_utilization () |
If true, then get_shader_utilization has been set using set_shader_utilization. More... | |
static void | init_type () |
static | PT (Shader) load(const Filename &file |
static | PT (Shader) make(const string &body |
static | PT (Shader) load(ShaderLanguage lang |
static | PT (Shader) load_compute(ShaderLanguage lang |
static | PT (Shader) make(ShaderLanguage lang |
static | PT (Shader) make_compute(ShaderLanguage lang |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type Shader. More... | |
static void | set_shader_utilization (ShaderUtilization utl) |
Set this flag to SUT_none, SUT_basic, or SUT_advanced to limit panda's automatic shader generation facilities. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
static | PT (TypedWritableReferenceCount) decode_from_bam_stream(const string &data |
![]() | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL) |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
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 TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
bool | _error_flag |
epvector< ShaderMatSpec > | _mat_spec |
pvector< ShaderPtrSpec > | _ptr_spec |
pvector< ShaderTexSpec > | _tex_spec |
ShaderFile | _text |
pvector< ShaderVarSpec > | _var_spec |
static const string & | body |
static const Filename & | fn |
static const Filename const Filename & | fragment |
static const string const string & | fragment |
static const Filename const Filename const Filename & | geometry = "" |
static const string const string const string & | geometry = "" |
static ShaderLanguage | lang = SL_none) |
static const Filename const Filename const Filename const Filename & | tess_control = "" |
static const string const string const string const string & | tess_control = "" |
static const Filename const Filename const Filename const Filename const Filename & | tess_evaluation = "") |
static const string const string const string const string const string & | tess_evaluation = "") |
static const Filename & | vertex |
static const string & | vertex |
![]() | |
static BamReader * | reader = NULL) |
Friends | |
class | PreparedGraphicsObjects |
class | ShaderContext |
Additional Inherited Members | |
![]() | |
static TypedWritable *const | Null = (TypedWritable*)0L |
Shader::~Shader | ( | ) |
Delete the compiled code, if it exists.
Definition at line 2591 of file shader.cxx.
References parse_init(), and release_all().
Referenced by compile_parameter().
bool Shader::compile_parameter | ( | const ShaderArgId & | arg_id, |
const ShaderArgClass & | arg_class, | ||
const ShaderArgClass & | arg_subclass, | ||
const ShaderArgType & | arg_type, | ||
const ShaderArgDir & | arg_direction, | ||
bool | arg_varying, | ||
int * | arg_dim, | ||
NotifyCategory * | arg_cat | ||
) |
Analyzes a parameter and decides how to bind the parameter to some part of panda's internal state.
Updates one of the bind arrays to cause the binding to occur.
If there is an error, this routine will append an error message onto the error messages.
Definition at line 604 of file shader.cxx.
References cp_errchk_parameter_float(), cp_errchk_parameter_in(), cp_errchk_parameter_sampler(), cp_errchk_parameter_uniform(), cp_errchk_parameter_varying(), cp_errchk_parameter_words(), cp_optimize_mat_spec(), cp_parse_coord_sys(), cp_parse_delimiter(), cp_parse_eol(), cp_report_error(), VirtualFileSystem::find_file(), Filename::get_dirname(), VirtualFileSystem::get_file(), get_filename(), VirtualFileSystem::get_global_ptr(), get_text(), parse_init(), parse_line(), DSearchPath::prepend_directory(), and ~Shader().
Referenced by cp_optimize_mat_spec().
int Shader::cp_dependency | ( | ShaderMatInput | inp | ) |
Given ShaderMatInput, returns an indication of what part or parts of the state_and_transform the ShaderMatInput depends upon.
Definition at line 397 of file shader.cxx.
References cp_optimize_mat_spec().
Referenced by cp_optimize_mat_spec(), and cp_parse_coord_sys().
bool Shader::cp_errchk_parameter_float | ( | ShaderArgInfo & | p, |
int | lo, | ||
int | hi | ||
) |
Make sure the provided parameter has a floating point type.
If not, print error message and return false.
Definition at line 186 of file shader.cxx.
References cp_errchk_parameter_sampler(), and cp_report_error().
Referenced by compile_parameter(), and cp_errchk_parameter_uniform().
bool Shader::cp_errchk_parameter_in | ( | ShaderArgInfo & | p | ) |
Make sure the provided parameter has the 'in' direction.
If not, print error message and return false.
Definition at line 135 of file shader.cxx.
References cp_errchk_parameter_varying(), and cp_report_error().
Referenced by compile_parameter(), and cp_errchk_parameter_words().
bool Shader::cp_errchk_parameter_sampler | ( | ShaderArgInfo & | p | ) |
Make sure the provided parameter has a texture type.
If not, print error message and return false.
Definition at line 242 of file shader.cxx.
References cp_parse_eol(), and cp_report_error().
Referenced by compile_parameter(), and cp_errchk_parameter_float().
bool Shader::cp_errchk_parameter_uniform | ( | ShaderArgInfo & | p | ) |
Make sure the provided parameter has the correct variance.
If not, print error message and return false.
Definition at line 169 of file shader.cxx.
References cp_errchk_parameter_float(), and cp_report_error().
Referenced by compile_parameter(), and cp_errchk_parameter_varying().
bool Shader::cp_errchk_parameter_varying | ( | ShaderArgInfo & | p | ) |
Make sure the provided parameter has the correct variance.
If not, print error message and return false.
Definition at line 152 of file shader.cxx.
References cp_errchk_parameter_uniform(), and cp_report_error().
Referenced by compile_parameter(), and cp_errchk_parameter_in().
bool Shader::cp_errchk_parameter_words | ( | ShaderArgInfo & | p, |
int | len | ||
) |
Make sure the provided parameter contains the specified number of words.
If not, print error message and return false.
Definition at line 116 of file shader.cxx.
References cp_errchk_parameter_in(), and cp_report_error().
Referenced by compile_parameter(), and cp_report_error().
void Shader::cp_optimize_mat_spec | ( | ShaderMatSpec & | spec | ) |
Analyzes a ShaderMatSpec and decides what it should use its cache for.
It can cache the results of any one opcode, or, it can cache the entire result. This routine needs to be smart enough to know which data items can be correctly cached, and which cannot.
Definition at line 469 of file shader.cxx.
References compile_parameter(), cp_dependency(), and get_filename().
Referenced by compile_parameter(), and cp_dependency().
bool Shader::cp_parse_coord_sys | ( | ShaderArgInfo & | arg, |
vector_string & | pieces, | ||
int & | next, | ||
ShaderMatSpec & | spec, | ||
bool | fromflag | ||
) |
Convert a single-word coordinate system name into a PART/ARG of a ShaderMatSpec.
Definition at line 307 of file shader.cxx.
References cp_dependency(), cp_parse_non_delimiter(), and cp_report_error().
Referenced by compile_parameter(), and cp_parse_non_delimiter().
bool Shader::cp_parse_delimiter | ( | ShaderArgInfo & | arg, |
vector_string & | pieces, | ||
int & | next | ||
) |
Pop a delimiter ('to' or 'rel') from the word list.
Definition at line 275 of file shader.cxx.
References cp_parse_non_delimiter(), and cp_report_error().
Referenced by compile_parameter(), and cp_parse_eol().
bool Shader::cp_parse_eol | ( | ShaderArgInfo & | arg, |
vector_string & | pieces, | ||
int & | next | ||
) |
Make sure the next thing on the word list is EOL.
Definition at line 261 of file shader.cxx.
References cp_parse_delimiter(), and cp_report_error().
Referenced by compile_parameter(), and cp_errchk_parameter_sampler().
string Shader::cp_parse_non_delimiter | ( | vector_string & | words, |
int & | next | ||
) |
Pop a non-delimiter word from the word list.
Delimiters are 'to' and 'rel.'
Definition at line 291 of file shader.cxx.
References cp_parse_coord_sys().
Referenced by cp_parse_coord_sys(), and cp_parse_delimiter().
void Shader::cp_report_error | ( | ShaderArgInfo & | arg, |
const string & | msg | ||
) |
Generate an error message including a description of the specified parameter.
Definition at line 44 of file shader.cxx.
References cp_errchk_parameter_words(), NotifyCategory::error(), and get_filename().
Referenced by compile_parameter(), cp_errchk_parameter_float(), cp_errchk_parameter_in(), cp_errchk_parameter_sampler(), cp_errchk_parameter_uniform(), cp_errchk_parameter_varying(), cp_errchk_parameter_words(), cp_parse_coord_sys(), cp_parse_delimiter(), and cp_parse_eol().
|
inline |
Returns true if the shader contains a compile-time error.
This doesn't tell you whether or not the shader is supported on the current video card.
Definition at line 100 of file shader.I.
References set_shader_utilization().
Referenced by get_text().
|
inline |
Return the Shader's filename for the given shader type.
Definition at line 23 of file shader.I.
References get_text().
Referenced by compile_parameter(), cp_optimize_mat_spec(), cp_report_error(), and get_filename_from_index().
|
inline |
Returns the filename of the included shader with the given source file index (as recorded in the #line statement in r_preprocess_source).
We use this to associate error messages with included files.
Definition at line 862 of file shader.I.
References get_filename().
Referenced by Shader::ShaderFile::operator<().
|
inline |
Returns the shader language in which this shader was written.
Definition at line 154 of file shader.I.
References LVecBase2f::get_data(), LVecBase3f::get_data(), LVecBase4f::get_data(), LMatrix3f::get_data(), LMatrix4f::get_data(), LVecBase2d::get_data(), LVecBase3d::get_data(), LVecBase4d::get_data(), LVecBase2i::get_data(), LVecBase3i::get_data(), LVecBase4i::get_data(), LMatrix3d::get_data(), LMatrix4d::get_data(), LVecBase2f::get_num_components(), LVecBase3f::get_num_components(), LVecBase4f::get_num_components(), LMatrix3f::get_num_components(), LMatrix4f::get_num_components(), LVecBase2d::get_num_components(), LVecBase3d::get_num_components(), LVecBase4d::get_num_components(), LVecBase2i::get_num_components(), LVecBase3i::get_num_components(), LVecBase4i::get_num_components(), LMatrix3d::get_num_components(), LMatrix4d::get_num_components(), and Shader::ShaderPtrData::write_datagram().
Referenced by have_shader_utilization(), and DXGraphicsStateGuardian9::prepare_shader().
|
inlinestatic |
This flag returns SUT_none, SUT_basic, or SUT_advanced and controls the automatic generation of shaders.
It is initialized from the config variable of the same name, but it can be subsequently adjusted.
Definition at line 126 of file shader.I.
References have_shader_utilization().
Referenced by GraphicsEngine::do_cull(), and set_shader_utilization().
|
inline |
Return the Shader's text for the given shader type.
Definition at line 62 of file shader.I.
References get_error_flag().
Referenced by compile_parameter(), and get_filename().
|
inlinestatic |
If true, then get_shader_utilization has been set using set_shader_utilization.
If false, then get_shader_utilization simply returns the config variable of the same name.
Definition at line 143 of file shader.I.
References get_language().
Referenced by GraphicsEngine::do_cull(), and get_shader_utilization().
bool Shader::is_prepared | ( | PreparedGraphicsObjects * | prepared_objects | ) | const |
Returns true if the shader has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.
Definition at line 2974 of file shader.cxx.
References PreparedGraphicsObjects::is_shader_queued(), and release().
Referenced by PreparedGraphicsObjects::is_shader_prepared(), and prepare().
bool Shader::parse_eof | ( | ) |
Returns true if the parse pointer is at the end of the shader.
Definition at line 2945 of file shader.cxx.
References prepare().
Referenced by parse_rest().
void Shader::parse_init | ( | ) |
Set a 'parse pointer' to the beginning of the shader.
Definition at line 2866 of file shader.cxx.
References parse_line().
Referenced by compile_parameter(), and ~Shader().
void Shader::parse_line | ( | string & | result, |
bool | lt, | ||
bool | rt | ||
) |
Parse a line of text.
If 'lt' is true, trim blanks from the left end of the line. If 'rt' is true, trim blanks from the right end (the newline is always trimmed).
Definition at line 2879 of file shader.cxx.
References parse_upto().
Referenced by compile_parameter(), parse_init(), and parse_upto().
void Shader::parse_rest | ( | string & | result | ) |
Returns the rest of the text from the current parse location.
Definition at line 2933 of file shader.cxx.
References parse_eof().
Referenced by parse_upto().
void Shader::parse_upto | ( | string & | result, |
string | pattern, | ||
bool | include | ||
) |
Parse lines until you read a line that matches the specified pattern.
Returns all the preceding lines, and if the include flag is set, returns the final line as well.
Definition at line 2908 of file shader.cxx.
References GlobPattern::matches(), parse_line(), and parse_rest().
Referenced by parse_line().
void Shader::prepare | ( | PreparedGraphicsObjects * | prepared_objects | ) |
Indicates that the shader should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.
This will ensure the texture is already loaded into texture memory if it is expected to be rendered soon.
Use this function instead of prepare_now() to preload textures from a user interface standpoint.
Definition at line 2962 of file shader.cxx.
References PreparedGraphicsObjects::enqueue_shader(), and is_prepared().
Referenced by parse_eof(), and GeomNode::r_prepare_scene().
ShaderContext * Shader::prepare_now | ( | PreparedGraphicsObjects * | prepared_objects, |
GraphicsStateGuardianBase * | gsg | ||
) |
Creates a context for the shader on the particular GSG, if it does not already exist.
Returns the new (or old) ShaderContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new textures. If this is not necessarily the case, you should use prepare() instead.
Normally, this is not called directly except by the GraphicsStateGuardian; a shader does not need to be explicitly prepared by the user before it may be rendered.
Definition at line 3025 of file shader.cxx.
References PreparedGraphicsObjects::prepare_shader_now(), and release_all().
Referenced by PreparedGraphicsObjects::begin_frame(), release(), and DXGraphicsStateGuardian9::reset().
|
static |
Tells the BamReader how to create objects of type Shader.
Definition at line 3121 of file shader.cxx.
References write_datagram().
Referenced by release_all().
bool Shader::release | ( | PreparedGraphicsObjects * | prepared_objects | ) |
Frees the texture 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 2991 of file shader.cxx.
References PreparedGraphicsObjects::dequeue_shader(), prepare_now(), and PreparedGraphicsObjects::release_shader().
Referenced by is_prepared().
int Shader::release_all | ( | ) |
Frees the context allocated on all objects for which the texture has been declared.
Returns the number of contexts which have been freed.
Definition at line 3069 of file shader.cxx.
References register_with_read_factory(), and PreparedGraphicsObjects::release_shader().
Referenced by prepare_now(), and ~Shader().
|
inlinestatic |
Set this flag to SUT_none, SUT_basic, or SUT_advanced to limit panda's automatic shader generation facilities.
Definition at line 112 of file shader.I.
References get_shader_utilization().
Referenced by GraphicsEngine::do_cull(), and get_error_flag().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 3132 of file shader.cxx.
References Datagram::add_bool(), Datagram::add_uint8(), DatagramIterator::get_bool(), DatagramIterator::get_uint8(), Shader::ShaderFile::read_datagram(), and Shader::ShaderFile::write_datagram().
Referenced by register_with_read_factory().