Panda3D

Loading...
Searching...
No Matches
shader.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file shader.h
10 * @author jyelon
11 * @date 2005-09-01
12 * @author fperazzi, PandaSE
13 * @date 2010-04-29
14 */
15
16#ifndef SHADER_H
17#define SHADER_H
18
19#include "pandabase.h"
20#include "config_gobj.h"
21#include "typedWritableReferenceCount.h"
22#include "namable.h"
23#include "graphicsStateGuardianBase.h"
24#include "internalName.h"
25#include "pta_int.h"
26#include "pta_float.h"
27#include "pta_double.h"
28#include "pta_stdfloat.h"
29#include "pta_LMatrix4.h"
30#include "pta_LMatrix3.h"
31#include "pta_LVecBase4.h"
32#include "pta_LVecBase3.h"
33#include "pta_LVecBase2.h"
34#include "epvector.h"
35#include "asyncFuture.h"
36#include "bamCacheRecord.h"
37
38#ifdef HAVE_CG
39// I don't want to include the Cg header file into panda as a whole. Instead,
40// I'll just excerpt some opaque declarations.
41 typedef struct _CGcontext *CGcontext;
42 typedef struct _CGprogram *CGprogram;
43 typedef struct _CGparameter *CGparameter;
44#endif
45
46/**
47
48 */
49 class EXPCL_PANDA_GOBJ Shader : public TypedWritableReferenceCount {
50PUBLISHED:
51 enum ShaderLanguage {
52 SL_none,
53 SL_Cg,
54 SL_GLSL,
55 SL_HLSL,
56 SL_SPIR_V,
57 };
58
59 enum ShaderType {
60 ST_none = 0,
61 ST_vertex,
62 ST_fragment,
63 ST_geometry,
64 ST_tess_control,
65 ST_tess_evaluation,
66 ST_compute,
67 ST_COUNT
68 };
69
70 enum AutoShaderSwitch {
71 AS_normal = 0x01,
72 AS_glow = 0x02,
73 AS_gloss = 0x04,
74 AS_ramp = 0x08,
75 AS_shadow = 0x10,
76 };
77
78 enum AutoShaderBit {
79 bit_AutoShaderNormal = 0, // bit for AS_normal
80 bit_AutoShaderGlow = 1, // bit for AS_glow
81 bit_AutoShaderGloss = 2, // bit for AS_gloss
82 bit_AutoShaderRamp = 3, // bit for AS_ramp
83 bit_AutoShaderShadow = 4, // bit for AS_shadow
84 };
85
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,
89 const Filename &vertex, const Filename &fragment,
90 const Filename &geometry = "",
91 const Filename &tess_control = "",
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);
100
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;
106
107 INLINE bool has_fullpath() const;
108 INLINE const Filename &get_fullpath() const;
109
110 INLINE bool get_cache_compiled_shader() const;
111 INLINE void set_cache_compiled_shader(bool flag);
112
113 PT(AsyncFuture) prepare(PreparedGraphicsObjects *prepared_objects);
114 bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
115 bool release(PreparedGraphicsObjects *prepared_objects);
116 int release_all();
117
118 ShaderContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
119 GraphicsStateGuardianBase *gsg);
120
121 public:
122 enum ShaderMatInput {
123 SMO_identity,
124
125 SMO_window_size,
126 SMO_pixel_size,
127 SMO_texpad_x,
128 SMO_texpix_x,
129
130 SMO_attr_material,
131 SMO_attr_color,
132 SMO_attr_colorscale,
133
134 SMO_alight_x,
135 SMO_dlight_x,
136 SMO_plight_x,
137 SMO_slight_x,
138 SMO_satten_x,
139 SMO_texmat_i,
140 SMO_plane_x,
141 SMO_clipplane_x,
142
143 SMO_mat_constant_x,
144 SMO_vec_constant_x,
145
146 SMO_world_to_view,
147 SMO_view_to_world,
148
149 SMO_model_to_view,
150 SMO_view_to_model,
151
152 SMO_apiview_to_view,
153 SMO_view_to_apiview,
154
155 SMO_clip_to_view,
156 SMO_view_to_clip,
157
158 SMO_apiclip_to_view,
159 SMO_view_to_apiclip,
160
161 SMO_view_x_to_view,
162 SMO_view_to_view_x,
163
164 SMO_apiview_x_to_view,
165 SMO_view_to_apiview_x,
166
167 SMO_clip_x_to_view,
168 SMO_view_to_clip_x,
169
170 SMO_apiclip_x_to_view,
171 SMO_view_to_apiclip_x,
172
173 SMO_attr_fog,
174 SMO_attr_fogcolor,
175
176 SMO_frame_number,
177 SMO_frame_time,
178 SMO_frame_delta,
179
180 SMO_mat_constant_x_attrib,
181 SMO_vec_constant_x_attrib,
182
183 SMO_light_ambient,
184 SMO_light_source_i_attrib,
185
186 SMO_light_product_i_ambient,
187 SMO_light_product_i_diffuse,
188 SMO_light_product_i_specular,
189
190 // SMO_clipplane_x is world coords, GLSL needs eye coords
191 SMO_apiview_clipplane_i,
192
193 SMO_model_to_apiview,
194 SMO_apiview_to_model,
195 SMO_apiview_to_apiclip,
196 SMO_apiclip_to_apiview,
197
198 SMO_inv_texmat_i,
199
200 // Additional properties for PBR materials
201 SMO_attr_material2,
202
203 // Hack for text rendering. Don't use in user shaders.
204 SMO_tex_is_alpha_i,
205
206 SMO_transform_i,
207 SMO_slider_i,
208
209 SMO_light_source_i_packed,
210
211 // Texture scale component of texture matrix.
212 SMO_texscale_i,
213
214 // Color of an M_blend texture stage.
215 SMO_texcolor_i,
216
217 // Constant value of the TexGenAttrib of stage i.
218 SMO_texconst_i,
219
220 // Point parameters
221 SMO_attr_pointparams,
222
223 SMO_INVALID
224 };
225
226 enum ShaderTexInput {
227 STO_INVALID,
228
229 STO_named_input,
230 STO_named_stage,
231
232 STO_stage_i,
233 STO_light_i_shadow_map,
234
235 STO_ff_stage_i,
236 STO_stage_modulate_i,
237 STO_stage_add_i,
238 STO_stage_normal_i,
239 STO_stage_height_i,
240 STO_stage_selector_i,
241 STO_stage_gloss_i,
242 STO_stage_emission_i,
243 };
244
245 enum ShaderArgClass {
246 SAC_scalar,
247 SAC_vector,
248 SAC_matrix,
249 SAC_sampler,
250 SAC_array,
251 SAC_unknown,
252 };
253
254 enum ShaderArgType {
255 SAT_scalar,
256 SAT_vec1,
257 SAT_vec2,
258 SAT_vec3,
259 SAT_vec4,
260 SAT_mat1x1,
261 SAT_mat1x2,
262 SAT_mat1x3,
263 SAT_mat1x4,
264 SAT_mat2x1,
265 SAT_mat2x2,
266 SAT_mat2x3,
267 SAT_mat2x4,
268 SAT_mat3x1,
269 SAT_mat3x2,
270 SAT_mat3x3,
271 SAT_mat3x4,
272 SAT_mat4x1,
273 SAT_mat4x2,
274 SAT_mat4x3,
275 SAT_mat4x4,
276 SAT_sampler1d,
277 SAT_sampler2d,
278 SAT_sampler3d,
279 SAT_sampler2d_array,
280 SAT_sampler_cube,
281 SAT_sampler_buffer,
282 SAT_sampler_cube_array,
283 SAT_sampler1d_array,
284 SAT_unknown
285};
286
287 enum ShaderArgDir {
288 SAD_in,
289 SAD_out,
290 SAD_inout,
291 SAD_unknown,
292 };
293
294 enum ShaderMatPiece {
295 SMP_whole,
296 SMP_transpose,
297 SMP_row0,
298 SMP_row1,
299 SMP_row2,
300 SMP_row3,
301 SMP_col0,
302 SMP_col1,
303 SMP_col2,
304 SMP_col3,
305 SMP_row3x1,
306 SMP_row3x2,
307 SMP_row3x3,
308 SMP_upper3x3,
309 SMP_transpose3x3,
310 SMP_cell15,
311 SMP_cell14,
312 SMP_cell13,
313 };
314
315 enum ShaderStateDep {
316 SSD_NONE = 0x000,
317 SSD_general = 0x001,
318 SSD_transform = 0x2002,
319 SSD_color = 0x004,
320 SSD_colorscale = 0x008,
321 SSD_material = 0x010,
322 SSD_shaderinputs = 0x020,
323 SSD_fog = 0x040,
324 SSD_light = 0x080,
325 SSD_clip_planes = 0x100,
326 SSD_tex_matrix = 0x200,
327 SSD_frame = 0x400,
328 SSD_projection = 0x800,
329 SSD_texture = 0x1000,
330 SSD_view_transform= 0x2000,
331 SSD_tex_gen = 0x4000,
332 SSD_render_mode = 0x8000,
333 };
334
335 enum ShaderBug {
336 SBUG_ati_draw_buffers,
337 };
338
339 enum ShaderMatFunc {
340 SMF_compose,
341 SMF_transform_dlight,
342 SMF_transform_plight,
343 SMF_transform_slight,
344 SMF_first,
345 };
346
347 struct ShaderArgId {
348 std::string _name;
349 ShaderType _type;
350 int _seqno;
351 };
352
353 enum ShaderPtrType {
354 SPT_float,
355 SPT_double,
356 SPT_int,
357 SPT_uint,
358 SPT_unknown
359 };
360
361 struct ShaderArgInfo {
362 ShaderArgId _id;
363 ShaderArgClass _class;
364 ShaderArgClass _subclass;
365 ShaderArgType _type;
366 ShaderArgDir _direction;
367 bool _varying;
368 ShaderPtrType _numeric_type;
369 NotifyCategory *_cat;
370 };
371
372 // Container structure for data of parameters ShaderPtrSpec.
373 struct ShaderPtrData {
374 private:
375 PT(ReferenceCount) _pta;
376
377 public:
378 void *_ptr;
379 ShaderPtrType _type;
380 bool _updated;
381 size_t _size; //number of elements vec3[4]=12
382
383 public:
384 INLINE ShaderPtrData();
385 INLINE ShaderPtrData(const PTA_float &ptr);
386 INLINE ShaderPtrData(const PTA_LVecBase4f &ptr);
387 INLINE ShaderPtrData(const PTA_LVecBase3f &ptr);
388 INLINE ShaderPtrData(const PTA_LVecBase2f &ptr);
389 INLINE ShaderPtrData(const PTA_LMatrix4f &mat);
390 INLINE ShaderPtrData(const PTA_LMatrix3f &mat);
391 INLINE ShaderPtrData(const LVecBase4f &vec);
392 INLINE ShaderPtrData(const LVecBase3f &vec);
393 INLINE ShaderPtrData(const LVecBase2f &vec);
394 INLINE ShaderPtrData(const LMatrix4f &mat);
395 INLINE ShaderPtrData(const LMatrix3f &mat);
396
397 INLINE ShaderPtrData(const PTA_double &ptr);
398 INLINE ShaderPtrData(const PTA_LVecBase4d &ptr);
399 INLINE ShaderPtrData(const PTA_LVecBase3d &ptr);
400 INLINE ShaderPtrData(const PTA_LVecBase2d &ptr);
401 INLINE ShaderPtrData(const PTA_LMatrix4d &mat);
402 INLINE ShaderPtrData(const PTA_LMatrix3d &mat);
403 INLINE ShaderPtrData(const LVecBase4d &vec);
404 INLINE ShaderPtrData(const LVecBase3d &vec);
405 INLINE ShaderPtrData(const LVecBase2d &vec);
406 INLINE ShaderPtrData(const LMatrix4d &mat);
407 INLINE ShaderPtrData(const LMatrix3d &mat);
408
409 INLINE ShaderPtrData(const PTA_int &ptr);
410 INLINE ShaderPtrData(const PTA_LVecBase4i &ptr);
411 INLINE ShaderPtrData(const PTA_LVecBase3i &ptr);
412 INLINE ShaderPtrData(const PTA_LVecBase2i &ptr);
413 INLINE ShaderPtrData(const LVecBase4i &vec);
414 INLINE ShaderPtrData(const LVecBase3i &vec);
415 INLINE ShaderPtrData(const LVecBase2i &vec);
416
417 INLINE void write_datagram(Datagram &dg) const;
418 INLINE void read_datagram(DatagramIterator &source);
419 };
420
421 struct ShaderMatSpec {
422 LMatrix4 _cache[2];
423 LMatrix4 _value;
424 ShaderArgId _id;
425 ShaderMatFunc _func;
426 ShaderMatInput _part[2];
427 PT(InternalName) _arg[2];
428 int _dep[2];
429 int _index;
430 ShaderMatPiece _piece;
431 };
432
433 struct ShaderTexSpec {
434 ShaderArgId _id;
435 PT(InternalName) _name;
436 ShaderTexInput _part;
437 int _stage;
438 int _desired_type;
439 PT(InternalName) _suffix;
440 };
441
442 struct ShaderVarSpec {
443 ShaderArgId _id;
444 PT(InternalName) _name;
445 int _append_uv;
446 int _elements;
447 ShaderPtrType _numeric_type;
448 };
449
450 struct ShaderPtrSpec {
451 ShaderArgId _id;
452 int _dim[3]; //n_elements,rows,cols
453 int _dep[2];
454 PT(InternalName) _arg;
455 ShaderArgInfo _info;
456 ShaderPtrType _type;
457 };
458
459 class EXPCL_PANDA_GOBJ ShaderCaps {
460 public:
461 void clear();
462 INLINE bool operator == (const ShaderCaps &other) const;
463 INLINE ShaderCaps();
464
465 public:
466 bool _supports_glsl;
467
468#ifdef HAVE_CG
469 int _active_vprofile;
470 int _active_fprofile;
471 int _active_gprofile;
472 int _active_tprofile;
473
474 int _ultimate_vprofile;
475 int _ultimate_fprofile;
476 int _ultimate_gprofile;
477 int _ultimate_tprofile;
478
479 pset <ShaderBug> _bug_list;
480#endif
481 };
482
483 class ShaderFile : public ReferenceCount {
484 public:
485 INLINE ShaderFile() {};
486 INLINE ShaderFile(std::string shared);
487 INLINE ShaderFile(std::string vertex, std::string fragment, std::string geometry,
488 std::string tess_control, std::string tess_evaluation);
489
490 INLINE void write_datagram(Datagram &dg) const;
491 INLINE void read_datagram(DatagramIterator &source);
492
493 INLINE bool operator < (const ShaderFile &other) const;
494
495 public:
496 bool _separate;
497 std::string _shared;
498 std::string _vertex;
499 std::string _fragment;
500 std::string _geometry;
501 std::string _tess_control;
502 std::string _tess_evaluation;
503 std::string _compute;
504 };
505
506 public:
507 // These routines help split the shader into sections, for those shader
508 // implementations that need to do so. Don't use them when you use separate
509 // shader programs.
510 void parse_init();
511 void parse_line(std::string &result, bool rt, bool lt);
512 void parse_upto(std::string &result, std::string pattern, bool include);
513 void parse_rest(std::string &result);
514 bool parse_eof();
515
516 void cp_report_error(ShaderArgInfo &arg, const std::string &msg);
517 bool cp_errchk_parameter_words(ShaderArgInfo &arg, int len);
518 bool cp_errchk_parameter_in(ShaderArgInfo &arg);
519 bool cp_errchk_parameter_ptr(ShaderArgInfo &p);
520 bool cp_errchk_parameter_varying(ShaderArgInfo &arg);
521 bool cp_errchk_parameter_uniform(ShaderArgInfo &arg);
522 bool cp_errchk_parameter_float(ShaderArgInfo &arg, int lo, int hi);
523 bool cp_errchk_parameter_sampler(ShaderArgInfo &arg);
524 bool cp_parse_eol(ShaderArgInfo &arg,
525 vector_string &pieces, int &next);
526 bool cp_parse_delimiter(ShaderArgInfo &arg,
527 vector_string &pieces, int &next);
528 std::string cp_parse_non_delimiter(vector_string &pieces, int &next);
529 bool cp_parse_coord_sys(ShaderArgInfo &arg,
530 vector_string &pieces, int &next,
531 ShaderMatSpec &spec, bool fromflag);
532 int cp_dependency(ShaderMatInput inp);
533 void cp_optimize_mat_spec(ShaderMatSpec &spec);
534
535#ifdef HAVE_CG
536 void cg_recurse_parameters(CGparameter parameter,
537 const ShaderType &type,
538 bool &success);
539#endif
540
541 bool compile_parameter(ShaderArgInfo &p, int *arg_dim);
542
543 void clear_parameters();
544
545 void set_compiled(unsigned int format, const char *data, size_t length);
546 bool get_compiled(unsigned int &format, std::string &binary) const;
547
548 static void set_default_caps(const ShaderCaps &caps);
549
550 private:
551#ifdef HAVE_CG
552 ShaderArgClass cg_parameter_class(CGparameter p);
553 ShaderArgType cg_parameter_type(CGparameter p);
554 ShaderArgDir cg_parameter_dir(CGparameter p);
555
556 CGprogram cg_compile_entry_point(const char *entry, const ShaderCaps &caps,
557 CGcontext context, ShaderType type);
558
559 bool cg_analyze_entry_point(CGprogram prog, ShaderType type);
560
561 bool cg_analyze_shader(const ShaderCaps &caps);
562 bool cg_compile_shader(const ShaderCaps &caps, CGcontext context);
563 void cg_release_resources();
564 void cg_report_errors();
565
566 // Determines the appropriate cg profile settings and stores them in the
567 // active shader caps based on any profile settings stored in the shader's
568 // header
569 void cg_get_profile_from_header(ShaderCaps &caps);
570
571 ShaderCaps _cg_last_caps;
572 static CGcontext _cg_context;
573 CGprogram _cg_vprogram;
574 CGprogram _cg_fprogram;
575 CGprogram _cg_gprogram;
576
577 int _cg_vprofile;
578 int _cg_fprofile;
579 int _cg_gprofile;
580
581 CGprogram cg_program_from_shadertype(ShaderType type);
582
583 public:
584 bool cg_compile_for(const ShaderCaps &caps, CGcontext context,
585 CGprogram &combined_program, pvector<CGparameter> &map);
586
587#endif
588
589 public:
590 pvector<ShaderPtrSpec> _ptr_spec;
591 epvector<ShaderMatSpec> _mat_spec;
592 pvector<ShaderTexSpec> _tex_spec;
593 pvector<ShaderVarSpec> _var_spec;
594 int _mat_deps;
595
596 bool _error_flag;
597 ShaderFile _text;
598
599 protected:
600 ShaderFile _filename;
601 Filename _fullpath;
602 int _parse;
603 bool _loaded;
604 ShaderLanguage _language;
605
606 typedef pvector<Filename> Filenames;
607 Filenames _included_files;
608
609 // Stores full paths, and includes the fullpaths of the shaders themselves
610 // as well as the includes.
611 Filenames _source_files;
612 time_t _last_modified;
613
614 PT(BamCacheRecord) _record;
615 bool _cache_compiled_shader;
616 unsigned int _compiled_format;
617 std::string _compiled_binary;
618
619 static ShaderCaps _default_caps;
620 static int _shaders_generated;
621
622 typedef pmap<ShaderFile, PT(Shader)> ShaderTable;
623
624 static ShaderTable _load_table;
625 static ShaderTable _make_table;
626
627 friend class ShaderContext;
628 friend class PreparedGraphicsObjects;
629
630 typedef pmap <PreparedGraphicsObjects *, ShaderContext *> Contexts;
631 Contexts _contexts;
632
633 private:
634 void clear_prepared(PreparedGraphicsObjects *prepared_objects);
635
636 Shader(ShaderLanguage lang);
637
638 bool read(const ShaderFile &sfile, BamCacheRecord *record = nullptr);
639 bool load(const ShaderFile &sbody, BamCacheRecord *record = nullptr);
640 bool do_read_source(std::string &into, const Filename &fn, BamCacheRecord *record);
641 bool do_load_source(std::string &into, const std::string &source, BamCacheRecord *record);
642 bool r_preprocess_include(std::ostream &out, const Filename &fn,
643 const Filename &source_dir,
644 std::set<Filename> &open_files,
645 BamCacheRecord *record, int depth);
646 bool r_preprocess_source(std::ostream &out, std::istream &in,
647 const Filename &fn, const Filename &full_fn,
648 std::set<Filename> &open_files,
649 BamCacheRecord *record,
650 int fileno = 0, int depth = 0);
651
652 bool check_modified() const;
653
654 public:
655 ~Shader();
656
657 Filename get_filename_from_index(int index, ShaderType type) const;
658
659 public:
660 static void register_with_read_factory();
661 virtual void write_datagram(BamWriter *manager, Datagram &dg);
662
663 protected:
664 static TypedWritable *make_from_bam(const FactoryParams &params);
665 void fillin(DatagramIterator &scan, BamReader *manager);
666
667 public:
668 static TypeHandle get_class_type() {
669 return _type_handle;
670 }
671 static void init_type() {
672 TypedWritableReferenceCount::init_type();
673 register_type(_type_handle, "Shader",
674 TypedWritableReferenceCount::get_class_type());
675 }
676 virtual TypeHandle get_type() const {
677 return get_class_type();
678 }
679 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
680
681 private:
682 static TypeHandle _type_handle;
683};
684
685#include "shader.I"
686
687#endif
asyncFuture.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bamCacheRecord.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AsyncFuture
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
Definition asyncFuture.h:61
BamCacheRecord
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
Definition bamCacheRecord.h:36
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
Filename
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
GraphicsStateGuardianBase
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Definition graphicsStateGuardianBase.h:110
InternalName
Encodes a string name in a hash table, mapping it to a pointer.
Definition internalName.h:38
NotifyCategory
A particular category of error messages.
Definition notifyCategory.h:32
Shader::ShaderCaps
Definition shader.h:459
Shader::ShaderFile
Definition shader.h:483
Shader::ShaderFile::read_datagram
void read_datagram(DatagramIterator &source)
Reads the object from a Datagram.
Definition shader.I:742
Shader::ShaderFile::write_datagram
void write_datagram(Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition shader.I:723
Shader::cp_errchk_parameter_varying
bool cp_errchk_parameter_varying(ShaderArgInfo &arg)
Make sure the provided parameter has the correct variance.
Definition shader.cxx:152
Shader::cp_parse_eol
bool cp_parse_eol(ShaderArgInfo &arg, vector_string &pieces, int &next)
Make sure the next thing on the word list is EOL.
Definition shader.cxx:250
Shader::get_error_flag
bool get_error_flag() const
Returns true if the shader contains a compile-time error.
Definition shader.I:124
Shader::cp_optimize_mat_spec
void cp_optimize_mat_spec(ShaderMatSpec &spec)
Analyzes a ShaderMatSpec and decides what it should use its cache for.
Definition shader.cxx:514
Shader::get_compiled
bool get_compiled(unsigned int &format, std::string &binary) const
Called by the back-end to retrieve compiled data.
Definition shader.cxx:1636
Shader::cp_parse_delimiter
bool cp_parse_delimiter(ShaderArgInfo &arg, vector_string &pieces, int &next)
Pop a delimiter ('to' or 'rel') from the word list.
Definition shader.cxx:262
Shader::has_fullpath
bool has_fullpath() const
Returns true if the fullpath has been set and is available.
Definition shader.I:141
Shader::get_text
const std::string & get_text(ShaderType type=ST_none) const
Return the Shader's text for the given shader type.
Definition shader.I:89
Shader::cp_report_error
void cp_report_error(ShaderArgInfo &arg, const std::string &msg)
Generate an error message including a description of the specified parameter.
Definition shader.cxx:50
Shader::parse_init
void parse_init()
Set a 'parse pointer' to the beginning of the shader.
Definition shader.cxx:3629
Shader::set_compiled
void set_compiled(unsigned int format, const char *data, size_t length)
Called by the back-end when the shader has compiled data available.
Definition shader.cxx:1619
Shader::prepare_now
ShaderContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the shader on the particular GSG, if it does not already exist.
Definition shader.cxx:3762
Shader::compile_parameter
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.
Definition shader.cxx:674
Shader::release_all
int release_all()
Frees the context allocated on all objects for which the texture has been declared.
Definition shader.cxx:3800
Shader::set_filename
void set_filename(ShaderType type, const Filename &filename)
Sets the Shader's filename for the given shader type.
Definition shader.I:58
Shader::cp_errchk_parameter_in
bool cp_errchk_parameter_in(ShaderArgInfo &arg)
Make sure the provided parameter has the 'in' direction.
Definition shader.cxx:138
Shader::cp_errchk_parameter_uniform
bool cp_errchk_parameter_uniform(ShaderArgInfo &arg)
Make sure the provided parameter has the correct variance.
Definition shader.cxx:166
Shader::cp_parse_coord_sys
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.
Definition shader.cxx:290
Shader::set_default_caps
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 ou...
Definition shader.cxx:1647
Shader::get_filename_from_index
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 #lin...
Definition shader.cxx:3302
Shader::cp_parse_non_delimiter
std::string cp_parse_non_delimiter(vector_string &pieces, int &next)
Pop a non-delimiter word from the word list.
Definition shader.cxx:276
Shader::parse_line
void parse_line(std::string &result, bool rt, bool lt)
Parse a line of text.
Definition shader.cxx:3639
Shader::set_cache_compiled_shader
void set_cache_compiled_shader(bool flag)
Sets the cache_compiled_shader flag.
Definition shader.I:173
Shader::parse_rest
void parse_rest(std::string &result)
Returns the rest of the text from the current parse location.
Definition shader.cxx:3687
Shader::is_prepared
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the shader has already been prepared or enqueued for preparation on the indicated GSG...
Definition shader.cxx:3719
Shader::cp_errchk_parameter_float
bool cp_errchk_parameter_float(ShaderArgInfo &arg, int lo, int hi)
Make sure the provided parameter has a floating point type.
Definition shader.cxx:180
Shader::parse_upto
void parse_upto(std::string &result, std::string pattern, bool include)
Parse lines until you read a line that matches the specified pattern.
Definition shader.cxx:3665
Shader::get_cache_compiled_shader
bool get_cache_compiled_shader() const
Returns the setting of the cache_compiled_shader flag.
Definition shader.I:159
Shader::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type Shader.
Definition shader.cxx:3845
Shader::cp_errchk_parameter_words
bool cp_errchk_parameter_words(ShaderArgInfo &arg, int len)
Make sure the provided parameter contains the specified number of words.
Definition shader.cxx:122
Shader::cp_errchk_parameter_sampler
bool cp_errchk_parameter_sampler(ShaderArgInfo &arg)
Make sure the provided parameter has a texture type.
Definition shader.cxx:231
Shader::get_language
ShaderLanguage get_language() const
Returns the shader language in which this shader was written.
Definition shader.I:132
Shader::parse_eof
bool parse_eof()
Returns true if the parse pointer is at the end of the shader.
Definition shader.cxx:3696
Shader::get_filename
Filename get_filename(ShaderType type=ST_none) const
Return the Shader's filename for the given shader type.
Definition shader.I:20
Shader::get_fullpath
const Filename & get_fullpath() const
Returns the fullpath that has been set.
Definition shader.I:150
Shader::cp_dependency
int cp_dependency(ShaderMatInput inp)
Given ShaderMatInput, returns an indication of what part or parts of the state_and_transform the Shad...
Definition shader.cxx:377
Shader::release
bool release(PreparedGraphicsObjects *prepared_objects)
Frees the texture context only on the indicated object, if it exists there.
Definition shader.cxx:3733
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
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...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
map
STL class.
config_gobj.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
epvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
graphicsStateGuardianBase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
internalName.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
namable.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_LMatrix3.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_LMatrix4.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_LVecBase2.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_LVecBase3.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_LVecBase4.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_double.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_float.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_int.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pta_stdfloat.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
shader.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Shader::ShaderArgId
Definition shader.h:347
Shader::ShaderArgInfo
Definition shader.h:361
Shader::ShaderMatSpec
Definition shader.h:421
Shader::ShaderPtrData::write_datagram
void write_datagram(Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition shader.I:636
Shader::ShaderPtrData::read_datagram
void read_datagram(DatagramIterator &source)
Reads the object from a Datagram.
Definition shader.I:663
Shader::ShaderPtrSpec
Definition shader.h:450
Shader::ShaderTexSpec
Definition shader.h:433
Shader::ShaderVarSpec
Definition shader.h:442
typedWritableReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.