Blender  V3.3
plugin.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2022 NVIDIA Corporation
3  * Copyright 2022 Blender Foundation */
4 
5 #include "hydra/plugin.h"
7 #include "util/log.h"
8 #include "util/path.h"
9 
10 #include <pxr/base/arch/fileSystem.h>
11 #include <pxr/base/plug/plugin.h>
12 #include <pxr/base/plug/thisPlugin.h>
13 #include <pxr/base/tf/envSetting.h>
14 #include <pxr/imaging/hd/rendererPluginRegistry.h>
15 
16 PXR_NAMESPACE_OPEN_SCOPE
17 
18 #ifdef WITH_CYCLES_LOGGING
19 TF_DEFINE_ENV_SETTING(CYCLES_LOGGING, false, "Enable Cycles logging")
20 TF_DEFINE_ENV_SETTING(CYCLES_LOGGING_SEVERITY, 1, "Cycles logging verbosity")
21 #endif
22 
24 {
25  const PlugPluginPtr plugin = PLUG_THIS_PLUGIN;
26  // Initialize Cycles paths relative to the plugin resource path
27  std::string rootPath = PXR_NS::ArchAbsPath(plugin->GetResourcePath());
28  CCL_NS::path_init(std::move(rootPath));
29 
30 #ifdef WITH_CYCLES_LOGGING
31  if (TfGetEnvSetting(CYCLES_LOGGING)) {
33  CCL_NS::util_logging_verbosity_set(TfGetEnvSetting(CYCLES_LOGGING_SEVERITY));
34  }
35 #endif
36 }
37 
39 {
40 }
41 
43 {
44  return true;
45 }
46 
48 {
49  return CreateRenderDelegate({});
50 }
51 
52 HdRenderDelegate *HdCyclesPlugin::CreateRenderDelegate(const HdRenderSettingsMap &settingsMap)
53 {
54  return new HD_CYCLES_NS::HdCyclesDelegate(settingsMap);
55 }
56 
57 void HdCyclesPlugin::DeleteRenderDelegate(HdRenderDelegate *renderDelegate)
58 {
59  delete renderDelegate;
60 }
61 
62 // USD's type system accounts for namespace, so we'd have to register our name as
63 // HdCycles::HdCyclesPlugin in plugInfo.json, which isn't all that bad for JSON,
64 // but those colons may cause issues for any USD specific tooling. So just put our
65 // plugin class in the pxr namespace (which USD's type system will elide).
67 {
68  HdRendererPluginRegistry::Define<PXR_NS::HdCyclesPlugin>();
69 }
70 
71 PXR_NAMESPACE_CLOSE_SCOPE
bool IsSupported() const override
Definition: plugin.cpp:42
PXR_NS::HdRenderDelegate * CreateRenderDelegate() override
Definition: plugin.cpp:47
~HdCyclesPlugin() override
Definition: plugin.cpp:38
void DeleteRenderDelegate(PXR_NS::HdRenderDelegate *) override
Definition: plugin.cpp:57
void util_logging_verbosity_set(int verbosity)
Definition: log.cpp:59
void util_logging_start()
Definition: log.cpp:46
void path_init(const string &path, const string &user_path)
Definition: path.cpp:325
TF_REGISTRY_FUNCTION(TfType)
Definition: plugin.cpp:66