41 typedef struct _CGcontext *CGcontext;
42 typedef struct _CGprogram *CGprogram;
43 typedef struct _CGparameter *CGparameter;
70 enum AutoShaderSwitch {
79 bit_AutoShaderNormal = 0,
80 bit_AutoShaderGlow = 1,
81 bit_AutoShaderGloss = 2,
82 bit_AutoShaderRamp = 3,
83 bit_AutoShaderShadow = 4,
86 static PT(
Shader) load(
const Filename &file, ShaderLanguage lang = SL_none);
87 static PT(
Shader) make(std::string body, ShaderLanguage lang = SL_none);
88 static PT(
Shader) load(ShaderLanguage lang,
92 const Filename &tess_evaluation =
"");
93 static PT(
Shader) load_compute(ShaderLanguage lang,
const Filename &fn);
94 static PT(
Shader) make(ShaderLanguage lang,
95 std::string vertex, std::string fragment,
96 std::string geometry =
"",
97 std::string tess_control =
"",
98 std::string tess_evaluation =
"");
99 static PT(
Shader) make_compute(ShaderLanguage lang, std::string body);
101 INLINE
Filename get_filename(ShaderType type = ST_none)
const;
102 INLINE
void set_filename(ShaderType type,
const Filename &filename);
103 INLINE
const std::string &get_text(ShaderType type = ST_none)
const;
104 INLINE
bool get_error_flag()
const;
105 INLINE ShaderLanguage get_language()
const;
107 INLINE
bool has_fullpath()
const;
108 INLINE
const Filename &get_fullpath()
const;
110 INLINE
bool get_cache_compiled_shader()
const;
111 INLINE
void set_cache_compiled_shader(
bool flag);
122 enum ShaderMatInput {
164 SMO_apiview_x_to_view,
165 SMO_view_to_apiview_x,
170 SMO_apiclip_x_to_view,
171 SMO_view_to_apiclip_x,
180 SMO_mat_constant_x_attrib,
181 SMO_vec_constant_x_attrib,
184 SMO_light_source_i_attrib,
186 SMO_light_product_i_ambient,
187 SMO_light_product_i_diffuse,
188 SMO_light_product_i_specular,
191 SMO_apiview_clipplane_i,
193 SMO_model_to_apiview,
194 SMO_apiview_to_model,
195 SMO_apiview_to_apiclip,
196 SMO_apiclip_to_apiview,
209 SMO_light_source_i_packed,
220 enum ShaderTexInput {
227 STO_light_i_shadow_map,
230 STO_stage_modulate_i,
234 STO_stage_selector_i,
236 STO_stage_emission_i,
239 enum ShaderArgClass {
276 SAT_sampler_cube_array,
287 enum ShaderMatPiece {
308 enum ShaderStateDep {
311 SSD_transform = 0x2002,
313 SSD_colorscale = 0x008,
314 SSD_material = 0x010,
315 SSD_shaderinputs = 0x020,
318 SSD_clip_planes = 0x100,
319 SSD_tex_matrix = 0x200,
321 SSD_projection = 0x800,
322 SSD_texture = 0x1000,
323 SSD_view_transform= 0x2000,
327 SBUG_ati_draw_buffers,
332 SMF_transform_dlight,
333 SMF_transform_plight,
334 SMF_transform_slight,
354 ShaderArgClass _class;
355 ShaderArgClass _subclass;
357 ShaderArgDir _direction;
359 ShaderPtrType _numeric_type;
408 INLINE
void write_datagram(
Datagram &dg)
const;
417 ShaderMatInput _part[2];
421 ShaderMatPiece _piece;
427 ShaderTexInput _part;
438 ShaderPtrType _numeric_type;
453 INLINE
bool operator == (
const ShaderCaps &other)
const;
460 int _active_vprofile;
461 int _active_fprofile;
462 int _active_gprofile;
463 int _active_tprofile;
465 int _ultimate_vprofile;
466 int _ultimate_fprofile;
467 int _ultimate_gprofile;
468 int _ultimate_tprofile;
478 INLINE
ShaderFile(std::string vertex, std::string fragment, std::string geometry,
479 std::string tess_control, std::string tess_evaluation);
481 INLINE
void write_datagram(
Datagram &dg)
const;
484 INLINE
bool operator < (
const ShaderFile &other)
const;
490 std::string _fragment;
491 std::string _geometry;
492 std::string _tess_control;
493 std::string _tess_evaluation;
494 std::string _compute;
502 void parse_line(std::string &result,
bool rt,
bool lt);
503 void parse_upto(std::string &result, std::string pattern,
bool include);
504 void parse_rest(std::string &result);
507 void cp_report_error(
ShaderArgInfo &arg,
const std::string &msg);
513 bool cp_errchk_parameter_float(
ShaderArgInfo &arg,
int lo,
int hi);
516 vector_string &pieces,
int &next);
518 vector_string &pieces,
int &next);
519 std::string cp_parse_non_delimiter(vector_string &pieces,
int &next);
521 vector_string &pieces,
int &next,
523 int cp_dependency(ShaderMatInput inp);
527 void cg_recurse_parameters(CGparameter parameter,
528 const ShaderType &type,
534 void clear_parameters();
536 void set_compiled(
unsigned int format,
const char *data,
size_t length);
537 bool get_compiled(
unsigned int &format, std::string &binary)
const;
539 static void set_default_caps(
const ShaderCaps &caps);
543 ShaderArgClass cg_parameter_class(CGparameter p);
544 ShaderArgType cg_parameter_type(CGparameter p);
545 ShaderArgDir cg_parameter_dir(CGparameter p);
547 CGprogram cg_compile_entry_point(
const char *entry,
const ShaderCaps &caps,
548 CGcontext context, ShaderType type);
550 bool cg_analyze_entry_point(CGprogram prog, ShaderType type);
552 bool cg_analyze_shader(
const ShaderCaps &caps);
553 bool cg_compile_shader(
const ShaderCaps &caps, CGcontext context);
554 void cg_release_resources();
555 void cg_report_errors();
560 void cg_get_profile_from_header(
ShaderCaps &caps);
563 static CGcontext _cg_context;
564 CGprogram _cg_vprogram;
565 CGprogram _cg_fprogram;
566 CGprogram _cg_gprogram;
572 CGprogram cg_program_from_shadertype(ShaderType type);
575 bool cg_compile_for(
const ShaderCaps &caps, CGcontext context,
582 epvector<ShaderMatSpec> _mat_spec;
595 ShaderLanguage _language;
603 time_t _last_modified;
606 bool _cache_compiled_shader;
607 unsigned int _compiled_format;
608 std::string _compiled_binary;
611 static int _shaders_generated;
627 Shader(ShaderLanguage lang);
632 bool do_load_source(std::string &into,
const std::string &source,
BamCacheRecord *record);
633 bool r_preprocess_include(std::ostream &out,
const Filename &fn,
635 std::set<Filename> &open_files,
637 bool r_preprocess_source(std::ostream &out, std::istream &in,
639 std::set<Filename> &open_files,
641 int fileno = 0,
int depth = 0);
643 bool check_modified()
const;
648 Filename get_filename_from_index(
int index, ShaderType type)
const;
651 static void register_with_read_factory();
662 static void init_type() {
663 TypedWritableReferenceCount::init_type();
665 TypedWritableReferenceCount::get_class_type());
668 return get_class_type();
670 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
The name of a file, such as a texture file or an Egg file.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Encodes a string name in a hash table, mapping it to a pointer.
A particular category of error messages.
A table of objects that are saved within the graphics context for reference by handle later.
A base class for all things that want to be reference-counted.
The ShaderContext is meant to contain the compiled version of a shader string.
TypeHandle is the identifier used to differentiate C++ class types.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This is our own Panda specialization on the default STL map.
This is our own Panda specialization on the default STL set.
This is our own Panda specialization on the default STL vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.