blender/intern/cycles/hydra/material.h
Brecht Van Lommel 51977de03a Cycles: Hydra: Change render delegate to use Hydra 2.0 API
The 1.0 API is deprecated (though not yet removed) in OpenUSD 26.xx
releases. So it's time to migrate.

Use of the HdSceneDelegate is mostly removed, except for retrieving the
prims. Specific properties of prims are retrieved through schemas rather
than querying the scene delegate.

The full replacement of HdSceneDelegate is still ongoing in USD itself.
In the very latest 26.05 only HdPrman has an experimental option for
using the scene index directly, but for example HdStorm does not use it
yet. So removing it's use with the current 25.08 in Blender is not
expected to be stable enough.

Additionally HdRenderer is supposed to replace HdRenderDelegate and its
handling of tasks. However even in 26.05 that is only a stub
implementation so there is no actual alternative to migrate to.

Note that OpenUSD provides a compatibility layer so 1.0 and 2.0 hosts and
render delegates can work together. Which means ideally everything keeps
working the same, but there are likely some differences anyway. Support for
OpenUSD version 23.xx and older was dropped.

Pull Request: https://projects.blender.org/blender/blender/pulls/158456
2026-05-27 15:56:20 +02:00

60 lines
1.7 KiB
C++

/* SPDX-FileCopyrightText: 2022 NVIDIA Corporation
* SPDX-FileCopyrightText: 2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#pragma once
#include "hydra/config.h"
#include <pxr/imaging/hd/material.h>
#include <pxr/imaging/hd/materialNetworkSchema.h>
#include <pxr/imaging/hd/materialNodeParameterSchema.h>
#include <pxr/imaging/hd/materialNodeSchema.h>
HDCYCLES_NAMESPACE_OPEN_SCOPE
class HdCyclesMaterial final : public PXR_NS::HdMaterial {
public:
HdCyclesMaterial(const PXR_NS::SdfPath &sprimId);
~HdCyclesMaterial() override;
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
PXR_NS::HdRenderParam *renderParam,
PXR_NS::HdDirtyBits *dirtyBits) override;
void Finalize(PXR_NS::HdRenderParam *renderParam) override;
CCL_NS::Shader *GetCyclesShader() const
{
return _shader;
}
private:
struct NodeDesc {
CCL_NS::ShaderNode *node;
const class UsdToCyclesMapping *mapping;
};
void Initialize(PXR_NS::HdRenderParam *renderParam);
void UpdateParameters(NodeDesc &nodeDesc,
PXR_NS::HdMaterialNodeParameterContainerSchema params,
const PXR_NS::SdfPath &nodePath);
void UpdateParameters(PXR_NS::HdMaterialNetworkSchema network);
void UpdateConnections(NodeDesc &nodeDesc,
PXR_NS::HdMaterialNodeSchema nodeSchema,
const PXR_NS::SdfPath &nodePath,
CCL_NS::ShaderGraph *shaderGraph);
void PopulateShaderGraph(PXR_NS::HdMaterialNetworkSchema network);
CCL_NS::Shader *_shader = nullptr;
std::unordered_map<PXR_NS::SdfPath, NodeDesc, PXR_NS::SdfPath::Hash> _nodes;
};
HDCYCLES_NAMESPACE_CLOSE_SCOPE