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 (ShaderArgInfo &p, int *arg_dim) |
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... | |
std::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 std::string &msg) |
Generate an error message including a description of the specified parameter. More... | |
virtual TypeHandle | force_init_type () |
bool | get_cache_compiled_shader () const |
Returns the setting of the cache_compiled_shader flag. More... | |
bool | get_compiled (unsigned int &format, std::string &binary) const |
Called by the back-end to retrieve compiled data. More... | |
bool | get_error_flag () const |
Returns true if the shader contains a compile-time error. More... | |
Filename | get_filename (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... | |
const Filename & | get_fullpath () const |
Returns the fullpath that has been set. More... | |
ShaderLanguage | get_language () const |
Returns the shader language in which this shader was written. More... | |
const std::string & | get_text (ShaderType type=ST_none) const |
Return the Shader's text for the given shader type. More... | |
virtual TypeHandle | get_type () const |
bool | has_fullpath () const |
Returns true if the fullpath has been set and is available. More... | |
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 (std::string &result, bool rt, bool lt) |
Parse a line of text. More... | |
void | parse_rest (std::string &result) |
Returns the rest of the text from the current parse location. More... | |
void | parse_upto (std::string &result, std::string pattern, bool include) |
Parse lines until you read a line that matches the specified pattern. 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... | |
PT (AsyncFuture) prepare(PreparedGraphicsObjects *prepared_objects) | |
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... | |
void | set_cache_compiled_shader (bool flag) |
Sets the cache_compiled_shader flag. More... | |
void | set_compiled (unsigned int format, const char *data, size_t length) |
Called by the back-end when the shader has compiled data available. More... | |
void | set_filename (ShaderType type, const Filename &filename) |
Sets the Shader's filename for the given shader type. 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 ©) | |
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 ©) |
Public Member Functions inherited from TypedWritable | |
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... | |
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 ©) |
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 ©)=default | |
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... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
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 | 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... | |
WeakReferenceList * | weak_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... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static | PT (Shader) load(const Filename &file |
static static PT(Shader) make(std | 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_default_caps (const ShaderCaps &caps) |
Called by the graphics back-end to specify the caps with which we will likely want to be compiling our shaders. 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 () |
Public Attributes | |
bool | _error_flag |
int | _mat_deps |
epvector< ShaderMatSpec > | _mat_spec |
pvector< ShaderPtrSpec > | _ptr_spec |
pvector< ShaderTexSpec > | _tex_spec |
ShaderFile | _text |
pvector< ShaderVarSpec > | _var_spec |
static std::string | body |
static const Filename & | fn |
static static PT(Shader) make(std const Filename const Filename & | fragment |
static std::string std::string | fragment |
static static PT(Shader) make(std const Filename const Filename const Filename & | geometry = "" |
static std::string std::string std::string | geometry = "" |
static ShaderLanguage | lang = SL_none) |
static static PT(Shader) make(std const Filename const Filename const Filename const Filename & | tess_control = "" |
static std::string std::string std::string std::string | tess_control = "" |
static static PT(Shader) make(std const Filename const Filename const Filename const Filename const Filename & | tess_evaluation = "") |
static std::string std::string std::string std::string std::string | tess_evaluation = "") |
static static PT(Shader) make(std const Filename & | vertex |
static std::string | vertex |
Public Attributes inherited from TypedWritableReferenceCount | |
static BamReader * | reader = nullptr) |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Friends | |
class | PreparedGraphicsObjects |
class | ShaderContext |
Additional Inherited Members | |
Static Public Attributes inherited from TypedWritable | |
static TypedWritable *const | Null = nullptr |
Shader::~Shader | ( | ) |
Delete the compiled code, if it exists.
Definition at line 3231 of file shader.cxx.
References release_all().
bool Shader::compile_parameter | ( | ShaderArgInfo & | p, |
int * | arg_dim | ||
) |
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 668 of file shader.cxx.
References cp_errchk_parameter_float(), cp_errchk_parameter_in(), cp_errchk_parameter_varying(), and tokenize().
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 377 of file shader.cxx.
Referenced by cp_optimize_mat_spec().
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 180 of file shader.cxx.
References cp_report_error().
Referenced by compile_parameter().
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 138 of file shader.cxx.
References cp_report_error().
Referenced by compile_parameter().
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 231 of file shader.cxx.
References cp_report_error().
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 166 of file shader.cxx.
References cp_report_error().
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_report_error().
Referenced by compile_parameter().
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 122 of file shader.cxx.
References cp_report_error(), and tokenize().
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 508 of file shader.cxx.
References 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 290 of file shader.cxx.
References cp_parse_non_delimiter(), and cp_report_error().
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 262 of file shader.cxx.
References cp_report_error().
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 250 of file shader.cxx.
References cp_report_error().
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 276 of file shader.cxx.
Referenced by cp_parse_coord_sys().
void Shader::cp_report_error | ( | ShaderArgInfo & | arg, |
const std::string & | msg | ||
) |
Generate an error message including a description of the specified parameter.
Definition at line 51 of file shader.cxx.
References NotifyCategory::error(), and get_filename().
Referenced by 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 the setting of the cache_compiled_shader flag.
bool Shader::get_compiled | ( | unsigned int & | format, |
std::string & | binary | ||
) | const |
Called by the back-end to retrieve compiled data.
Definition at line 1586 of file shader.cxx.
|
inline |
|
inline |
Return the Shader's filename for the given shader type.
Definition at line 20 of file shader.I.
Referenced by cp_report_error(), DXShaderContext9::DXShaderContext9(), and get_filename_from_index().
Filename Shader::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).
We use this to associate error messages with included files.
Definition at line 3249 of file shader.cxx.
References get_filename().
|
inline |
|
inline |
Returns the shader language in which this shader was written.
Definition at line 132 of file shader.I.
Referenced by DXGraphicsStateGuardian9::prepare_shader().
|
inline |
|
inline |
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 3660 of file shader.cxx.
References PreparedGraphicsObjects::is_shader_queued().
Referenced by PreparedGraphicsObjects::is_shader_prepared().
bool Shader::parse_eof | ( | ) |
Returns true if the parse pointer is at the end of the shader.
Definition at line 3637 of file shader.cxx.
void Shader::parse_init | ( | ) |
Set a 'parse pointer' to the beginning of the shader.
Definition at line 3570 of file shader.cxx.
void Shader::parse_line | ( | std::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 3580 of file shader.cxx.
void Shader::parse_rest | ( | std::string & | result | ) |
Returns the rest of the text from the current parse location.
Definition at line 3628 of file shader.cxx.
void Shader::parse_upto | ( | std::string & | result, |
std::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 3606 of file shader.cxx.
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 3703 of file shader.cxx.
References PreparedGraphicsObjects::prepare_shader_now().
Referenced by PreparedGraphicsObjects::begin_frame().
|
static |
Tells the BamReader how to create objects of type Shader.
Definition at line 3786 of file shader.cxx.
References BamReader::get_factory(), and Factory< Type >::register_factory().
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 3674 of file shader.cxx.
References PreparedGraphicsObjects::dequeue_shader(), and PreparedGraphicsObjects::release_shader().
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 3741 of file shader.cxx.
References PreparedGraphicsObjects::release_shader().
Referenced by ~Shader().
|
inline |
Sets the cache_compiled_shader flag.
When this is set, the next time the Shader is loaded on a GSG, it will automatically extract the compiled shader from the GSG and save it to the global BamCache.
This is used to store compiled shaders in the BamCache. This flag should not be set explicitly; it is set automatically by the ShaderPool when model-cache-compiled-shaders is set true.
void Shader::set_compiled | ( | unsigned int | format, |
const char * | data, | ||
size_t | length | ||
) |
Called by the back-end when the shader has compiled data available.
Definition at line 1569 of file shader.cxx.
|
static |
Called by the graphics back-end to specify the caps with which we will likely want to be compiling our shaders.
Definition at line 1597 of file shader.cxx.
|
inline |
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 3795 of file shader.cxx.
References Datagram::add_bool(), Datagram::add_string(), Datagram::add_uint32(), Datagram::add_uint8(), and Shader::ShaderFile::write_datagram().