Panda3D
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
Shader Class Reference
Inheritance diagram for Shader:
TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

Classes

struct  ShaderArgId
 
struct  ShaderArgInfo
 
class  ShaderCaps
 
class  ShaderFile
 
struct  ShaderMatSpec
 
struct  ShaderPtrData
 
struct  ShaderPtrSpec
 
struct  ShaderTexSpec
 
struct  ShaderVarSpec
 

Public Types

enum  AutoShaderBit {
  bit_AutoShaderNormal = 0 , bit_AutoShaderGlow = 1 , bit_AutoShaderGloss = 2 , bit_AutoShaderRamp = 3 ,
  bit_AutoShaderShadow = 4
}
 
enum  AutoShaderSwitch {
  AS_normal = 0x01 , AS_glow = 0x02 , AS_gloss = 0x04 , AS_ramp = 0x08 ,
  AS_shadow = 0x10
}
 
enum  ShaderArgClass {
  SAC_scalar , SAC_vector , SAC_matrix , SAC_sampler ,
  SAC_array , SAC_unknown
}
 
enum  ShaderArgDir { SAD_in , SAD_out , SAD_inout , SAD_unknown }
 
enum  ShaderArgType {
  SAT_scalar , SAT_vec1 , SAT_vec2 , SAT_vec3 ,
  SAT_vec4 , SAT_mat1x1 , SAT_mat1x2 , SAT_mat1x3 ,
  SAT_mat1x4 , SAT_mat2x1 , SAT_mat2x2 , SAT_mat2x3 ,
  SAT_mat2x4 , SAT_mat3x1 , SAT_mat3x2 , SAT_mat3x3 ,
  SAT_mat3x4 , SAT_mat4x1 , SAT_mat4x2 , SAT_mat4x3 ,
  SAT_mat4x4 , SAT_sampler1d , SAT_sampler2d , SAT_sampler3d ,
  SAT_sampler2d_array , SAT_sampler_cube , SAT_sampler_buffer , SAT_sampler_cube_array ,
  SAT_sampler1d_array , SAT_unknown
}
 
enum  ShaderBug { SBUG_ati_draw_buffers }
 
enum  ShaderLanguage {
  SL_none , SL_Cg , SL_GLSL , SL_HLSL ,
  SL_SPIR_V
}
 
enum  ShaderMatFunc {
  SMF_compose , SMF_transform_dlight , SMF_transform_plight , SMF_transform_slight ,
  SMF_first
}
 
enum  ShaderMatInput {
  SMO_identity , SMO_window_size , SMO_pixel_size , SMO_texpad_x ,
  SMO_texpix_x , SMO_attr_material , SMO_attr_color , SMO_attr_colorscale ,
  SMO_alight_x , SMO_dlight_x , SMO_plight_x , SMO_slight_x ,
  SMO_satten_x , SMO_texmat_i , SMO_plane_x , SMO_clipplane_x ,
  SMO_mat_constant_x , SMO_vec_constant_x , SMO_world_to_view , SMO_view_to_world ,
  SMO_model_to_view , SMO_view_to_model , SMO_apiview_to_view , SMO_view_to_apiview ,
  SMO_clip_to_view , SMO_view_to_clip , SMO_apiclip_to_view , SMO_view_to_apiclip ,
  SMO_view_x_to_view , SMO_view_to_view_x , SMO_apiview_x_to_view , SMO_view_to_apiview_x ,
  SMO_clip_x_to_view , SMO_view_to_clip_x , SMO_apiclip_x_to_view , SMO_view_to_apiclip_x ,
  SMO_attr_fog , SMO_attr_fogcolor , SMO_frame_number , SMO_frame_time ,
  SMO_frame_delta , SMO_mat_constant_x_attrib , SMO_vec_constant_x_attrib , SMO_light_ambient ,
  SMO_light_source_i_attrib , SMO_light_product_i_ambient , SMO_light_product_i_diffuse , SMO_light_product_i_specular ,
  SMO_apiview_clipplane_i , SMO_model_to_apiview , SMO_apiview_to_model , SMO_apiview_to_apiclip ,
  SMO_apiclip_to_apiview , SMO_inv_texmat_i , SMO_attr_material2 , SMO_tex_is_alpha_i ,
  SMO_transform_i , SMO_slider_i , SMO_light_source_i_packed , SMO_texscale_i ,
  SMO_texcolor_i , SMO_texconst_i , SMO_attr_pointparams , SMO_INVALID
}
 
enum  ShaderMatPiece {
  SMP_whole , SMP_transpose , SMP_row0 , SMP_row1 ,
  SMP_row2 , SMP_row3 , SMP_col0 , SMP_col1 ,
  SMP_col2 , SMP_col3 , SMP_row3x1 , SMP_row3x2 ,
  SMP_row3x3 , SMP_upper3x3 , SMP_transpose3x3 , SMP_cell15 ,
  SMP_cell14 , SMP_cell13
}
 
enum  ShaderPtrType {
  SPT_float , SPT_double , SPT_int , SPT_uint ,
  SPT_unknown
}
 
enum  ShaderStateDep {
  SSD_NONE = 0x000 , SSD_general = 0x001 , SSD_transform = 0x2002 , SSD_color = 0x004 ,
  SSD_colorscale = 0x008 , SSD_material = 0x010 , SSD_shaderinputs = 0x020 , SSD_fog = 0x040 ,
  SSD_light = 0x080 , SSD_clip_planes = 0x100 , SSD_tex_matrix = 0x200 , SSD_frame = 0x400 ,
  SSD_projection = 0x800 , SSD_texture = 0x1000 , SSD_view_transform = 0x2000 , SSD_tex_gen = 0x4000 ,
  SSD_render_mode = 0x8000
}
 
enum  ShaderTexInput {
  STO_INVALID , STO_named_input , STO_named_stage , STO_stage_i ,
  STO_light_i_shadow_map , STO_ff_stage_i , STO_stage_modulate_i , STO_stage_add_i ,
  STO_stage_normal_i , STO_stage_height_i , STO_stage_selector_i , STO_stage_gloss_i ,
  STO_stage_emission_i
}
 
enum  ShaderType {
  ST_none = 0 , ST_vertex , ST_fragment , ST_geometry ,
  ST_tess_control , ST_tess_evaluation , ST_compute , ST_COUNT
}
 

Public Member Functions

 ~Shader ()
 Delete the compiled code, if it exists.
 
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.
 
int cp_dependency (ShaderMatInput inp)
 Given ShaderMatInput, returns an indication of what part or parts of the state_and_transform the ShaderMatInput depends upon.
 
bool cp_errchk_parameter_float (ShaderArgInfo &arg, int lo, int hi)
 Make sure the provided parameter has a floating point type.
 
bool cp_errchk_parameter_in (ShaderArgInfo &arg)
 Make sure the provided parameter has the 'in' direction.
 
bool cp_errchk_parameter_ptr (ShaderArgInfo &p)
 
bool cp_errchk_parameter_sampler (ShaderArgInfo &arg)
 Make sure the provided parameter has a texture type.
 
bool cp_errchk_parameter_uniform (ShaderArgInfo &arg)
 Make sure the provided parameter has the correct variance.
 
bool cp_errchk_parameter_varying (ShaderArgInfo &arg)
 Make sure the provided parameter has the correct variance.
 
bool cp_errchk_parameter_words (ShaderArgInfo &arg, int len)
 Make sure the provided parameter contains the specified number of words.
 
void cp_optimize_mat_spec (ShaderMatSpec &spec)
 Analyzes a ShaderMatSpec and decides what it should use its cache for.
 
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.
 
bool cp_parse_delimiter (ShaderArgInfo &arg, vector_string &pieces, int &next)
 Pop a delimiter ('to' or 'rel') from the word list.
 
bool cp_parse_eol (ShaderArgInfo &arg, vector_string &pieces, int &next)
 Make sure the next thing on the word list is EOL.
 
std::string cp_parse_non_delimiter (vector_string &pieces, int &next)
 Pop a non-delimiter word from the word list.
 
void cp_report_error (ShaderArgInfo &arg, const std::string &msg)
 Generate an error message including a description of the specified parameter.
 
virtual TypeHandle force_init_type ()
 
bool get_cache_compiled_shader () const
 Returns the setting of the cache_compiled_shader flag.
 
bool get_compiled (unsigned int &format, std::string &binary) const
 Called by the back-end to retrieve compiled data.
 
bool get_error_flag () const
 Returns true if the shader contains a compile-time error.
 
Filename get_filename (ShaderType type=ST_none) const
 Return the Shader's filename for the given shader type.
 
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).
 
const Filenameget_fullpath () const
 Returns the fullpath that has been set.
 
ShaderLanguage get_language () const
 Returns the shader language in which this shader was written.
 
const std::string & get_text (ShaderType type=ST_none) const
 Return the Shader's text for the given shader type.
 
virtual TypeHandle get_type () const
 
bool has_fullpath () const
 Returns true if the fullpath has been set and is available.
 
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.
 
bool parse_eof ()
 Returns true if the parse pointer is at the end of the shader.
 
void parse_init ()
 Set a 'parse pointer' to the beginning of the shader.
 
void parse_line (std::string &result, bool rt, bool lt)
 Parse a line of text.
 
void parse_rest (std::string &result)
 Returns the rest of the text from the current parse location.
 
void parse_upto (std::string &result, std::string pattern, bool include)
 Parse lines until you read a line that matches the specified pattern.
 
ShaderContextprepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
 Creates a context for the shader on the particular GSG, if it does not already exist.
 
 PT (AsyncFuture) prepare(PreparedGraphicsObjects *prepared_objects)
 
bool release (PreparedGraphicsObjects *prepared_objects)
 Frees the texture context only on the indicated object, if it exists there.
 
int release_all ()
 Frees the context allocated on all objects for which the texture has been declared.
 
void set_cache_compiled_shader (bool flag)
 Sets the cache_compiled_shader flag.
 
void set_compiled (unsigned int format, const char *data, size_t length)
 Called by the back-end when the shader has compiled data available.
 
void set_filename (ShaderType type, const Filename &filename)
 Sets the Shader's filename for the given shader type.
 
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.
 
- 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.
 
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().
 
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.
 
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.
 
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.
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter.
 
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.
 
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.
 
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.
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer.
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer.
 
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.
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from MemoryBase
void operator delete (void *, void *)
 
void operator delete (void *ptr)
 
void operator delete[] (void *, void *)
 
void operator delete[] (void *ptr)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size)
 
void * operator new[] (size_t size, void *ptr)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object.
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
 
void ref () const
 Explicitly increments the reference count.
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero.
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
 
virtual bool unref () const
 Explicitly decrements the reference count.
 
bool unref_if_one () const
 Atomically decreases the reference count of this object if it is one.
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object.
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object.
 

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.
 
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.
 
- 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.
 
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.
 
- 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 Filenamefn
 
static static PT(Shader) make(std const Filename const Filenamefragment
 
static std::string std::string fragment
 
static static PT(Shader) make(std const Filename const Filename const Filenamegeometry = ""
 
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 Filenametess_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 Filenametess_evaluation = "")
 
static std::string std::string std::string std::string std::string tess_evaluation = "")
 
static static PT(Shader) make(std const Filenamevertex
 
static std::string vertex
 
- 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.
 

Friends

class PreparedGraphicsObjects
 
class ShaderContext
 

Additional Inherited Members

- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = nullptr
 

Detailed Description

Definition at line 49 of file shader.h.

Member Enumeration Documentation

◆ AutoShaderBit

enum Shader::AutoShaderBit

Definition at line 78 of file shader.h.

◆ AutoShaderSwitch

enum Shader::AutoShaderSwitch

Definition at line 70 of file shader.h.

◆ ShaderArgClass

enum Shader::ShaderArgClass

Definition at line 245 of file shader.h.

◆ ShaderArgDir

enum Shader::ShaderArgDir

Definition at line 287 of file shader.h.

◆ ShaderArgType

enum Shader::ShaderArgType

Definition at line 254 of file shader.h.

◆ ShaderBug

enum Shader::ShaderBug

Definition at line 335 of file shader.h.

◆ ShaderLanguage

enum Shader::ShaderLanguage

Definition at line 51 of file shader.h.

◆ ShaderMatFunc

enum Shader::ShaderMatFunc

Definition at line 339 of file shader.h.

◆ ShaderMatInput

enum Shader::ShaderMatInput

Definition at line 122 of file shader.h.

◆ ShaderMatPiece

enum Shader::ShaderMatPiece

Definition at line 294 of file shader.h.

◆ ShaderPtrType

enum Shader::ShaderPtrType

Definition at line 353 of file shader.h.

◆ ShaderStateDep

enum Shader::ShaderStateDep

Definition at line 315 of file shader.h.

◆ ShaderTexInput

enum Shader::ShaderTexInput

Definition at line 226 of file shader.h.

◆ ShaderType

enum Shader::ShaderType

Definition at line 59 of file shader.h.

Constructor & Destructor Documentation

◆ ~Shader()

Shader::~Shader ( )

Delete the compiled code, if it exists.

Definition at line 3283 of file shader.cxx.

References release_all().

Member Function Documentation

◆ clear_parameters()

void Shader::clear_parameters ( )

Definition at line 1608 of file shader.cxx.

◆ compile_parameter()

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 673 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(), and tokenize().

◆ cp_dependency()

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 376 of file shader.cxx.

Referenced by cp_optimize_mat_spec().

◆ cp_errchk_parameter_float()

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 179 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ cp_errchk_parameter_in()

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 137 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ cp_errchk_parameter_ptr()

bool Shader::cp_errchk_parameter_ptr ( ShaderArgInfo & p)

Definition at line 203 of file shader.cxx.

◆ cp_errchk_parameter_sampler()

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 230 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ cp_errchk_parameter_uniform()

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 165 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ 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 151 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ cp_errchk_parameter_words()

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 121 of file shader.cxx.

References cp_report_error(), and tokenize().

Referenced by compile_parameter().

◆ cp_optimize_mat_spec()

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 513 of file shader.cxx.

References cp_dependency().

Referenced by compile_parameter().

◆ cp_parse_coord_sys()

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 289 of file shader.cxx.

References cp_parse_non_delimiter(), and cp_report_error().

Referenced by compile_parameter().

◆ cp_parse_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 261 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ 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 249 of file shader.cxx.

References cp_report_error().

Referenced by compile_parameter().

◆ cp_parse_non_delimiter()

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 275 of file shader.cxx.

Referenced by cp_parse_coord_sys().

◆ cp_report_error()

void Shader::cp_report_error ( ShaderArgInfo & arg,
const std::string & msg )

◆ force_init_type()

virtual TypeHandle Shader::force_init_type ( )
inlinevirtual

Reimplemented from TypedWritableReferenceCount.

Definition at line 679 of file shader.h.

◆ get_cache_compiled_shader()

bool Shader::get_cache_compiled_shader ( ) const
inline

Returns the setting of the cache_compiled_shader flag.

See set_cache_compiled_shader().

Definition at line 158 of file shader.I.

◆ get_class_type()

static TypeHandle Shader::get_class_type ( )
inlinestatic

Definition at line 668 of file shader.h.

◆ get_compiled()

bool Shader::get_compiled ( unsigned int & format,
std::string & binary ) const

Called by the back-end to retrieve compiled data.

Definition at line 1635 of file shader.cxx.

◆ get_error_flag()

bool Shader::get_error_flag ( ) const
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 123 of file shader.I.

◆ get_filename()

Filename Shader::get_filename ( ShaderType type = ST_none) const
inline

Return the Shader's filename for the given shader type.

Definition at line 19 of file shader.I.

Referenced by DXShaderContext9::DXShaderContext9(), cp_report_error(), GraphicsEngine::dispatch_compute(), and get_filename_from_index().

◆ 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 3301 of file shader.cxx.

References get_filename().

◆ get_fullpath()

const Filename & Shader::get_fullpath ( ) const
inline

Returns the fullpath that has been set.

This is the full path to the file as it was found along the model-path.

Definition at line 149 of file shader.I.

◆ get_language()

Shader::ShaderLanguage Shader::get_language ( ) const
inline

Returns the shader language in which this shader was written.

Definition at line 131 of file shader.I.

Referenced by DXShaderContext9::DXShaderContext9(), and DXGraphicsStateGuardian9::prepare_shader().

◆ get_text()

const std::string & Shader::get_text ( ShaderType type = ST_none) const
inline

Return the Shader's text for the given shader type.

Definition at line 88 of file shader.I.

◆ get_type()

virtual TypeHandle Shader::get_type ( ) const
inlinevirtual

Reimplemented from TypedWritableReferenceCount.

Definition at line 676 of file shader.h.

◆ has_fullpath()

bool Shader::has_fullpath ( ) const
inline

Returns true if the fullpath has been set and is available.

See set_fullpath().

Definition at line 140 of file shader.I.

◆ init_type()

static void Shader::init_type ( )
inlinestatic

Definition at line 671 of file shader.h.

◆ is_prepared()

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 3718 of file shader.cxx.

References PreparedGraphicsObjects::is_shader_queued().

Referenced by PreparedGraphicsObjects::is_shader_prepared().

◆ parse_eof()

bool Shader::parse_eof ( )

Returns true if the parse pointer is at the end of the shader.

Definition at line 3695 of file shader.cxx.

◆ parse_init()

void Shader::parse_init ( )

Set a 'parse pointer' to the beginning of the shader.

Definition at line 3628 of file shader.cxx.

◆ parse_line()

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 3638 of file shader.cxx.

Referenced by parse_upto().

◆ parse_rest()

void Shader::parse_rest ( std::string & result)

Returns the rest of the text from the current parse location.

Definition at line 3686 of file shader.cxx.

◆ parse_upto()

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 3664 of file shader.cxx.

References GlobPattern::matches(), and parse_line().

◆ prepare_now()

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 3761 of file shader.cxx.

References PreparedGraphicsObjects::prepare_shader_now().

Referenced by PreparedGraphicsObjects::begin_frame().

◆ register_with_read_factory()

void Shader::register_with_read_factory ( )
static

Tells the BamReader how to create objects of type Shader.

Definition at line 3844 of file shader.cxx.

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

◆ release()

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 3732 of file shader.cxx.

References PreparedGraphicsObjects::dequeue_shader(), and PreparedGraphicsObjects::release_shader().

◆ release_all()

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 3799 of file shader.cxx.

References PreparedGraphicsObjects::release_shader().

Referenced by ~Shader().

◆ set_cache_compiled_shader()

void Shader::set_cache_compiled_shader ( bool flag)
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.

Definition at line 172 of file shader.I.

◆ set_compiled()

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 1618 of file shader.cxx.

References BamCache::get_global_ptr(), and BamCache::store().

◆ set_default_caps()

void Shader::set_default_caps ( const ShaderCaps & caps)
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 1646 of file shader.cxx.

◆ set_filename()

void Shader::set_filename ( ShaderType type,
const Filename & filename )
inline

Sets the Shader's filename for the given shader type.

Useful for associating a shader created with Shader.make with a name for diagnostics.

Definition at line 57 of file shader.I.

◆ write_datagram()

void Shader::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 3853 of file shader.cxx.

References Datagram::add_bool(), Datagram::add_string(), Datagram::add_uint32(), Datagram::add_uint8(), and Shader::ShaderFile::write_datagram().

Friends And Related Symbol Documentation

◆ PreparedGraphicsObjects

friend class PreparedGraphicsObjects
friend

Definition at line 628 of file shader.h.

◆ ShaderContext

friend class ShaderContext
friend

Definition at line 627 of file shader.h.

Member Data Documentation

◆ _error_flag

bool Shader::_error_flag

Definition at line 596 of file shader.h.

◆ _mat_deps

int Shader::_mat_deps

Definition at line 594 of file shader.h.

◆ _mat_spec

epvector<ShaderMatSpec> Shader::_mat_spec

Definition at line 591 of file shader.h.

◆ _ptr_spec

pvector<ShaderPtrSpec> Shader::_ptr_spec

Definition at line 590 of file shader.h.

◆ _tex_spec

pvector<ShaderTexSpec> Shader::_tex_spec

Definition at line 592 of file shader.h.

◆ _text

ShaderFile Shader::_text

Definition at line 597 of file shader.h.

◆ _var_spec

pvector<ShaderVarSpec> Shader::_var_spec

Definition at line 593 of file shader.h.

◆ body

std::string Shader::body

Definition at line 99 of file shader.h.

◆ fn

const Filename& Shader::fn

Definition at line 93 of file shader.h.

◆ fragment [1/2]

static PT(Shader) make(std const Filename const Filename& Shader::fragment

Definition at line 89 of file shader.h.

◆ fragment [2/2]

std::string std::string Shader::fragment

Definition at line 95 of file shader.h.

◆ geometry [1/2]

static PT(Shader) make(std const Filename const Filename const Filename& Shader::geometry = ""

Definition at line 90 of file shader.h.

◆ geometry [2/2]

std::string std::string std::string Shader::geometry = ""

Definition at line 96 of file shader.h.

◆ lang

ShaderLanguage Shader::lang = SL_none)

Definition at line 86 of file shader.h.

◆ tess_control [1/2]

static PT(Shader) make(std const Filename const Filename const Filename const Filename& Shader::tess_control = ""

Definition at line 91 of file shader.h.

◆ tess_control [2/2]

std::string std::string std::string std::string Shader::tess_control = ""

Definition at line 97 of file shader.h.

◆ tess_evaluation [1/2]

static PT(Shader) make(std const Filename const Filename const Filename const Filename const Filename& Shader::tess_evaluation = "")

Definition at line 92 of file shader.h.

◆ tess_evaluation [2/2]

std::string std::string std::string std::string std::string Shader::tess_evaluation = "")

Definition at line 98 of file shader.h.

◆ vertex [1/2]

static PT(Shader) make(std const Filename& Shader::vertex

Definition at line 89 of file shader.h.

◆ vertex [2/2]

std::string Shader::vertex

Definition at line 95 of file shader.h.


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