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 enum ShaderArgClass {
267 SAT_sampler_cube_array,
278 enum ShaderMatPiece {
299 enum ShaderStateDep {
302 SSD_transform = 0x2002,
304 SSD_colorscale = 0x008,
305 SSD_material = 0x010,
306 SSD_shaderinputs = 0x020,
309 SSD_clip_planes = 0x100,
310 SSD_tex_matrix = 0x200,
312 SSD_projection = 0x800,
313 SSD_texture = 0x1000,
314 SSD_view_transform= 0x2000,
318 SBUG_ati_draw_buffers,
323 SMF_transform_dlight,
324 SMF_transform_plight,
325 SMF_transform_slight,
345 ShaderArgClass _class;
346 ShaderArgClass _subclass;
348 ShaderArgDir _direction;
350 ShaderPtrType _numeric_type;
399 INLINE
void write_datagram(
Datagram &dg)
const;
408 ShaderMatInput _part[2];
412 ShaderMatPiece _piece;
418 ShaderTexInput _part;
429 ShaderPtrType _numeric_type;
444 INLINE
bool operator == (
const ShaderCaps &other)
const;
451 int _active_vprofile;
452 int _active_fprofile;
453 int _active_gprofile;
454 int _active_tprofile;
456 int _ultimate_vprofile;
457 int _ultimate_fprofile;
458 int _ultimate_gprofile;
459 int _ultimate_tprofile;
469 INLINE
ShaderFile(std::string vertex, std::string fragment, std::string geometry,
470 std::string tess_control, std::string tess_evaluation);
472 INLINE
void write_datagram(
Datagram &dg)
const;
475 INLINE
bool operator < (
const ShaderFile &other)
const;
481 std::string _fragment;
482 std::string _geometry;
483 std::string _tess_control;
484 std::string _tess_evaluation;
485 std::string _compute;
493 void parse_line(std::string &result,
bool rt,
bool lt);
494 void parse_upto(std::string &result, std::string pattern,
bool include);
495 void parse_rest(std::string &result);
498 void cp_report_error(
ShaderArgInfo &arg,
const std::string &msg);
504 bool cp_errchk_parameter_float(
ShaderArgInfo &arg,
int lo,
int hi);
507 vector_string &pieces,
int &next);
509 vector_string &pieces,
int &next);
510 std::string cp_parse_non_delimiter(vector_string &pieces,
int &next);
512 vector_string &pieces,
int &next,
514 int cp_dependency(ShaderMatInput inp);
518 void cg_recurse_parameters(CGparameter parameter,
519 const ShaderType &type,
525 void clear_parameters();
527 void set_compiled(
unsigned int format,
const char *data,
size_t length);
528 bool get_compiled(
unsigned int &format, std::string &binary)
const;
530 static void set_default_caps(
const ShaderCaps &caps);
534 ShaderArgClass cg_parameter_class(CGparameter p);
535 ShaderArgType cg_parameter_type(CGparameter p);
536 ShaderArgDir cg_parameter_dir(CGparameter p);
538 CGprogram cg_compile_entry_point(
const char *entry,
const ShaderCaps &caps,
539 CGcontext context, ShaderType type);
541 bool cg_analyze_entry_point(CGprogram prog, ShaderType type);
543 bool cg_analyze_shader(
const ShaderCaps &caps);
544 bool cg_compile_shader(
const ShaderCaps &caps, CGcontext context);
545 void cg_release_resources();
546 void cg_report_errors();
551 void cg_get_profile_from_header(
ShaderCaps &caps);
554 static CGcontext _cg_context;
555 CGprogram _cg_vprogram;
556 CGprogram _cg_fprogram;
557 CGprogram _cg_gprogram;
563 CGprogram cg_program_from_shadertype(ShaderType type);
566 bool cg_compile_for(
const ShaderCaps &caps, CGcontext context,
573 epvector<ShaderMatSpec> _mat_spec;
586 ShaderLanguage _language;
594 time_t _last_modified;
597 bool _cache_compiled_shader;
598 unsigned int _compiled_format;
599 std::string _compiled_binary;
602 static int _shaders_generated;
618 Shader(ShaderLanguage lang);
623 bool do_load_source(std::string &into,
const std::string &source,
BamCacheRecord *record);
624 bool r_preprocess_include(std::ostream &out,
const Filename &fn,
626 std::set<Filename> &open_files,
628 bool r_preprocess_source(std::ostream &out, std::istream &in,
630 std::set<Filename> &open_files,
632 int fileno = 0,
int depth = 0);
634 bool check_modified()
const;
639 Filename get_filename_from_index(
int index, ShaderType type)
const;
642 static void register_with_read_factory();
653 static void init_type() {
654 TypedWritableReferenceCount::init_type();
656 TypedWritableReferenceCount::get_class_type());
659 return get_class_type();
661 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
This is our own Panda specialization on the default STL map.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
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.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A table of objects that are saved within the graphics context for reference by handle later.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The ShaderContext is meant to contain the compiled version of a shader string.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A particular category of error messages.
This is our own Panda specialization on the default STL vector.
The name of a file, such as a texture file or an Egg file.
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encodes a string name in a hash table, mapping it to a pointer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for all things that want to be reference-counted.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL set.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.