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