Blender V5.0
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
19TF_DEFINE_ENV_SETTING(CYCLES_LOGGING, false, "Enable Cycles logging")
20TF_DEFINE_ENV_SETTING(CYCLES_LOGGING_LEVEL, "warning", "Cycles logging level")
21
23{
24 const PlugPluginPtr plugin = PLUG_THIS_PLUGIN;
25 // Initialize Cycles paths relative to the plugin resource path
26 const std::string rootPath = PXR_NS::ArchAbsPath(plugin->GetResourcePath());
27 CCL_NS::path_init(std::move(rootPath));
28
29 if (TfGetEnvSetting(CYCLES_LOGGING)) {
30 CCL_NS::log_level_set(TfGetEnvSetting(CYCLES_LOGGING_LEVEL));
31 }
32}
33
35
36#if PXR_VERSION < 2302
38{
39 return true;
40}
41#else
42bool HdCyclesPlugin::IsSupported(bool /*gpuEnabled*/) const
43{
44 return true;
45}
46#endif
47
49{
50 return CreateRenderDelegate({});
51}
52
53HdRenderDelegate *HdCyclesPlugin::CreateRenderDelegate(const HdRenderSettingsMap &settingsMap)
54{
55 return new HD_CYCLES_NS::HdCyclesDelegate(settingsMap);
56}
57
58void HdCyclesPlugin::DeleteRenderDelegate(HdRenderDelegate *renderDelegate)
59{
60 delete renderDelegate;
61}
62
63// USD's type system accounts for namespace, so we'd have to register our name as
64// HdCycles::HdCyclesPlugin in plugInfo.json, which isn't all that bad for JSON,
65// but those colons may cause issues for any USD specific tooling. So just put our
66// plugin class in the pxr namespace (which USD's type system will elide).
68{
69 HdRendererPluginRegistry::Define<PXR_NS::HdCyclesPlugin>();
70}
71
72PXR_NAMESPACE_CLOSE_SCOPE
bool IsSupported() const override
Definition plugin.cpp:37
PXR_NS::HdRenderDelegate * CreateRenderDelegate() override
Definition plugin.cpp:48
~HdCyclesPlugin() override
Definition plugin.cpp:34
void DeleteRenderDelegate(PXR_NS::HdRenderDelegate *) override
Definition plugin.cpp:58
TF_REGISTRY_FUNCTION(TfType)
Definition plugin.cpp:67