// // Copyright 2020 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #include "renderDelegate.h" #include "mesh.h" #include "renderPass.h" #include PXR_NAMESPACE_OPEN_SCOPE const TfTokenVector HdTinyRenderDelegate::SUPPORTED_RPRIM_TYPES = { HdPrimTypeTokens->mesh, }; const TfTokenVector HdTinyRenderDelegate::SUPPORTED_SPRIM_TYPES = { }; const TfTokenVector HdTinyRenderDelegate::SUPPORTED_BPRIM_TYPES = { }; HdTinyRenderDelegate::HdTinyRenderDelegate() : HdRenderDelegate() { _Initialize(); } HdTinyRenderDelegate::HdTinyRenderDelegate( HdRenderSettingsMap const& settingsMap) : HdRenderDelegate(settingsMap) { _Initialize(); } void HdTinyRenderDelegate::_Initialize() { std::cout << "Creating Tiny RenderDelegate" << std::endl; _resourceRegistry = std::make_shared(); } HdTinyRenderDelegate::~HdTinyRenderDelegate() { _resourceRegistry.reset(); std::cout << "Destroying Tiny RenderDelegate" << std::endl; } TfTokenVector const& HdTinyRenderDelegate::GetSupportedRprimTypes() const { return SUPPORTED_RPRIM_TYPES; } TfTokenVector const& HdTinyRenderDelegate::GetSupportedSprimTypes() const { return SUPPORTED_SPRIM_TYPES; } TfTokenVector const& HdTinyRenderDelegate::GetSupportedBprimTypes() const { return SUPPORTED_BPRIM_TYPES; } HdResourceRegistrySharedPtr HdTinyRenderDelegate::GetResourceRegistry() const { return _resourceRegistry; } void HdTinyRenderDelegate::CommitResources(HdChangeTracker *tracker) { std::cout << "=> CommitResources RenderDelegate" << std::endl; } HdRenderPassSharedPtr HdTinyRenderDelegate::CreateRenderPass( HdRenderIndex *index, HdRprimCollection const& collection) { std::cout << "Create RenderPass with Collection=" << collection.GetName() << std::endl; return HdRenderPassSharedPtr(new HdTinyRenderPass(index, collection)); } HdRprim * HdTinyRenderDelegate::CreateRprim(TfToken const& typeId, SdfPath const& rprimId, SdfPath const& instancerId) { std::cout << "Create Tiny Rprim type=" << typeId.GetText() << " id=" << rprimId << " instancerId=" << instancerId << std::endl; if (typeId == HdPrimTypeTokens->mesh) { return new HdTinyMesh(rprimId, instancerId); } else { TF_CODING_ERROR("Unknown Rprim type=%s id=%s", typeId.GetText(), rprimId.GetText()); } return nullptr; } void HdTinyRenderDelegate::DestroyRprim(HdRprim *rPrim) { std::cout << "Destroy Tiny Rprim id=" << rPrim->GetId() << std::endl; delete rPrim; } HdSprim * HdTinyRenderDelegate::CreateSprim(TfToken const& typeId, SdfPath const& sprimId) { TF_CODING_ERROR("Unknown Sprim type=%s id=%s", typeId.GetText(), sprimId.GetText()); return nullptr; } HdSprim * HdTinyRenderDelegate::CreateFallbackSprim(TfToken const& typeId) { TF_CODING_ERROR("Creating unknown fallback sprim type=%s", typeId.GetText()); return nullptr; } void HdTinyRenderDelegate::DestroySprim(HdSprim *sPrim) { TF_CODING_ERROR("Destroy Sprim not supported"); } HdBprim * HdTinyRenderDelegate::CreateBprim(TfToken const& typeId, SdfPath const& bprimId) { TF_CODING_ERROR("Unknown Bprim type=%s id=%s", typeId.GetText(), bprimId.GetText()); return nullptr; } HdBprim * HdTinyRenderDelegate::CreateFallbackBprim(TfToken const& typeId) { TF_CODING_ERROR("Creating unknown fallback bprim type=%s", typeId.GetText()); return nullptr; } void HdTinyRenderDelegate::DestroyBprim(HdBprim *bPrim) { TF_CODING_ERROR("Destroy Bprim not supported"); } HdInstancer * HdTinyRenderDelegate::CreateInstancer( HdSceneDelegate *delegate, SdfPath const& id, SdfPath const& instancerId) { TF_CODING_ERROR("Creating Instancer not supported id=%s instancerId=%s", id.GetText(), instancerId.GetText()); return nullptr; } void HdTinyRenderDelegate::DestroyInstancer(HdInstancer *instancer) { TF_CODING_ERROR("Destroy instancer not supported"); } HdRenderParam * HdTinyRenderDelegate::GetRenderParam() const { return nullptr; } PXR_NAMESPACE_CLOSE_SCOPE