Blender V5.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
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 >= 2511
37bool HdCyclesPlugin::IsSupported(HdRendererCreateArgs const & /*rendererCreateArgs*/,
38 std::string * /*reasonWhyNot*/) const
39{
40 return true;
41}
42#endif
43#if PXR_VERSION < 2608
44bool HdCyclesPlugin::IsSupported(bool /*gpuEnabled*/) const
45{
46 return true;
47}
48#endif
49
51{
52 return CreateRenderDelegate({});
53}
54
55HdRenderDelegate *HdCyclesPlugin::CreateRenderDelegate(const HdRenderSettingsMap &settingsMap)
56{
57 return new HD_CYCLES_NS::HdCyclesDelegate(settingsMap);
58}
59
60void HdCyclesPlugin::DeleteRenderDelegate(HdRenderDelegate *renderDelegate)
61{
62 delete renderDelegate;
63}
64
65// USD's type system accounts for namespace, so we'd have to register our name as
66// HdCycles::HdCyclesPlugin in plugInfo.json, which isn't all that bad for JSON,
67// but those colons may cause issues for any USD specific tooling. So just put our
68// plugin class in the pxr namespace (which USD's type system will elide).
70{
71 HdRendererPluginRegistry::Define<PXR_NS::HdCyclesPlugin>();
72}
73
74PXR_NAMESPACE_CLOSE_SCOPE
bool IsSupported(bool gpuEnabled) const override
Definition plugin.cpp:44
PXR_NS::HdRenderDelegate * CreateRenderDelegate() override
Definition plugin.cpp:50
~HdCyclesPlugin() override
Definition plugin.cpp:34
void DeleteRenderDelegate(PXR_NS::HdRenderDelegate *) override
Definition plugin.cpp:60
TF_REGISTRY_FUNCTION(TfType)
Definition plugin.cpp:69