def __init__(self, rpr_context: pyrpr.Context, inputs, sigmas, params, width, height, frame_buffer_gl=None): # field for custom external settings self.settings = None rif.Context.set_cache_path(utils.core_cache_dir() / f"{hex(rif.API_VERSION)}_rif") # creating context creation_flags = rpr_context.get_creation_flags() if creation_flags & pyrpr.CREATION_FLAGS_ENABLE_METAL: if isinstance(rpr_context, pyrpr2.Context): self.context = rif.Context(rpr_context) else: self.context = rif.ContextMetal(rpr_context) elif pyrpr.is_gpu_enabled(creation_flags) and \ not isinstance(rpr_context, (pyhybrid.Context, pyrpr2.Context)): self.context = rif.ContextOpenCL(rpr_context) else: self.context = rif.Context(rpr_context) self.width = width self.height = height self.filter = None self.params = params self.sigmas = sigmas self.inputs = {} if isinstance(inputs, set): for input_id in inputs: self.inputs[input_id] = self.context.create_image( self.width, self.height) else: for input_id, fb in inputs.items(): if fb: self.inputs[ input_id] = self.context.create_frame_buffer_image(fb) else: self.inputs[input_id] = self.context.create_image( self.width, self.height) self.command_queue = self.context.create_command_queue() if frame_buffer_gl: self.output_image = self.context.create_frame_buffer_image_gl( frame_buffer_gl) else: self.output_image = self.context.create_image( self.width, self.height) self._create_filter()
def register_plugins(): rprsdk_bin_path = utils.package_root_dir() if not utils.IS_DEBUG_MODE else \ utils.package_root_dir().parent.parent / '.sdk/rpr/bin' def register_plugin(ContextCls, lib_name, cache_path): lib_path = rprsdk_bin_path / lib_name ContextCls.register_plugin(lib_path, cache_path) log(f"Registered plugin: plugin_id={ContextCls.plugin_id}, " f"lib_path={lib_path}, cache_path={cache_path}") cache_dir = utils.core_cache_dir() register_plugin( pyrpr.Context, { 'Windows': 'Tahoe64.dll', 'Linux': 'libTahoe64.so', 'Darwin': 'libTahoe64.dylib' }[utils.OS], cache_dir / f"{hex(pyrpr.API_VERSION)}_rpr") # enabling hybrid only for Windows and Linux pyhybrid.enabled = config.enable_hybrid and (utils.IS_WIN or utils.IS_LINUX) if pyhybrid.enabled: try: register_plugin(pyhybrid.Context, { 'Windows': 'Hybrid.dll', 'Linux': 'Hybrid.so' }[utils.OS], cache_dir / f"{hex(pyrpr.API_VERSION)}_hybrid") except RuntimeError as err: log.warn(err) pyhybrid.enabled = False # enabling RPR 2 try: register_plugin( pyrpr2.Context, { 'Windows': 'Northstar64.dll', 'Linux': 'libNorthstar64.so', 'Darwin': 'libNorthstar64.dylib' }[utils.OS], cache_dir / f"{hex(pyrpr.API_VERSION)}_rpr2") except RuntimeError as err: log.warn(err)