MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / MaterialBindingCache

Method MaterialBindingCache

src/engine/MaterialBindingCache.cpp:28–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26using namespace donut::engine;
27
28MaterialBindingCache::MaterialBindingCache(
29 nvrhi::IDevice* device,
30 nvrhi::ShaderType shaderType,
31 uint32_t registerSpace,
32 bool registerSpaceIsDescriptorSet,
33 const std::vector<MaterialResourceBinding>& bindings,
34 nvrhi::ISampler* sampler,
35 nvrhi::ITexture* fallbackTexture,
36 bool trackLiveness)
37 : m_Device(device)
38 , m_BindingDesc(bindings)
39 , m_FallbackTexture(fallbackTexture)
40 , m_Sampler(sampler)
41 , m_TrackLiveness(trackLiveness)
42{
43 nvrhi::BindingLayoutDesc layoutDesc;
44 layoutDesc.visibility = shaderType;
45 layoutDesc.registerSpace = registerSpace;
46 layoutDesc.registerSpaceIsDescriptorSet = registerSpaceIsDescriptorSet;
47
48 for (const auto& item : bindings)
49 {
50 nvrhi::BindingLayoutItem layoutItem{};
51 layoutItem.slot = item.slot;
52 layoutItem.size = 1;
53
54 switch (item.resource)
55 {
56 case MaterialResource::ConstantBuffer:
57 layoutItem.type = nvrhi::ResourceType::ConstantBuffer;
58 break;
59 case MaterialResource::DiffuseTexture:
60 case MaterialResource::SpecularTexture:
61 case MaterialResource::NormalTexture:
62 case MaterialResource::EmissiveTexture:
63 case MaterialResource::OcclusionTexture:
64 case MaterialResource::TransmissionTexture:
65 case MaterialResource::OpacityTexture:
66 layoutItem.type = nvrhi::ResourceType::Texture_SRV;
67 break;
68 case MaterialResource::Sampler:
69 layoutItem.type = nvrhi::ResourceType::Sampler;
70 break;
71 default:
72 log::error("MaterialBindingCache: unknown MaterialResource value (%d)", item.resource);
73 return;
74 }
75
76 layoutDesc.bindings.push_back(layoutItem);
77 }
78
79 m_BindingLayout = m_Device->createBindingLayout(layoutDesc);
80}
81
82nvrhi::IBindingLayout* donut::engine::MaterialBindingCache::GetLayout() const
83{

Callers

nothing calls this directly

Calls 2

errorFunction · 0.85
push_backMethod · 0.80

Tested by

no test coverage detected