MCPcopy Create free account
hub / github.com/carbonengine/trinity / apply_to_shaders

Function apply_to_shaders

shadercompiler/python/shadercompiler/effectinfo.py:664–693  ·  view source on GitHub ↗

Applies a callback to all shader permutations :param path: effect path :type path: basestring :param callback: callback function that is called for each shader permutation :type callback: (ShaderInfo)->None :param shader_filter: optional filter for permutations, called with

(path, callback, shader_filter=None)

Source from the content-addressed store, hash-verified

662
663
664def apply_to_shaders(path, callback, shader_filter=None):
665 """
666 Applies a callback to all shader permutations
667
668 :param path: effect path
669 :type path: basestring
670 :param callback: callback function that is called for each shader permutation
671 :type callback: (ShaderInfo)->None
672 :param shader_filter: optional filter for permutations, called with platform, shader model
673 :type shader_filter: (int, int, list[(str, Permutation)])->bool
674 :return:
675 """
676 for platform in PLATFORM_NAMES.keys():
677 for sm in SHADER_MODEL_NAMES.keys():
678 try:
679 compiled = paths.get_compiled_path(path, sm, platform)
680 except ValueError:
681 continue
682 try:
683 effect = EffectInfo(compiled)
684 except IOError:
685 continue
686 count = 1
687 for each in effect.permutations:
688 count *= len(each.options)
689 for each in range(count):
690 if shader_filter:
691 if not shader_filter(platform, sm, effect.index_to_options(each)):
692 continue
693 callback(effect.get_shader(each))
694
695
696def get_merged_parameters(path, shader_filter=None):

Callers

nothing calls this directly

Calls 3

index_to_optionsMethod · 0.95
get_shaderMethod · 0.95
EffectInfoClass · 0.85

Tested by

no test coverage detected