MCPcopy Create free account
hub / github.com/NVIDIA-RTX/NVRHI / createBindingLayout

Method createBindingLayout

src/validation/validation-device.cpp:1329–1435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1327 }
1328
1329 BindingLayoutHandle DeviceWrapper::createBindingLayout(const BindingLayoutDesc& desc)
1330 {
1331 std::stringstream errorStream;
1332 bool anyErrors = false;
1333 bool const ignoreRegisterSpaces = (m_Device->getGraphicsAPI() == GraphicsAPI::D3D11);
1334
1335 BindingSummary bindings;
1336 BindingLocationSet duplicates;
1337
1338 FillBindingLayoutSummary(m_MessageCallback, desc, ignoreRegisterSpaces, bindings, duplicates);
1339
1340 if (desc.visibility == ShaderType::None)
1341 {
1342 errorStream << "Cannot create a binding layout with visibility = None" << std::endl;
1343 anyErrors = true;
1344 }
1345
1346 if (!duplicates.empty())
1347 {
1348 errorStream << "Binding layout contains duplicate bindings: " << duplicates << std::endl;
1349 anyErrors = true;
1350 }
1351
1352 if (bindings.numVolatileCBs > c_MaxVolatileConstantBuffersPerLayout)
1353 {
1354 errorStream << "Binding layout contains too many volatile CBs (" << bindings.numVolatileCBs << ")" << std::endl;
1355 anyErrors = true;
1356 }
1357
1358 uint32_t noneItemCount = 0;
1359 uint32_t pushConstantCount = 0;
1360 uint32_t zeroSizeCount = 0;
1361 for (const BindingLayoutItem& item : desc.bindings)
1362 {
1363 if (item.type == ResourceType::None)
1364 noneItemCount++;
1365
1366 if (item.type == ResourceType::PushConstants)
1367 {
1368 if (item.size == 0)
1369 {
1370 errorStream << "Push constant block size cannot be 0" << std::endl;
1371 anyErrors = true;
1372 }
1373
1374 if (item.size > c_MaxPushConstantSize)
1375 {
1376 errorStream << "Push constant block size (" << item.size << ") cannot exceed " << c_MaxPushConstantSize << " bytes" << std::endl;
1377 anyErrors = true;
1378 }
1379
1380 if ((item.size % 4) != 0)
1381 {
1382 errorStream << "Push constant block size (" << item.size << ") must be a multiple of 4" << std::endl;
1383 anyErrors = true;
1384 }
1385
1386 pushConstantCount++;

Callers 1

Calls 3

FillBindingLayoutSummaryFunction · 0.85
getGraphicsAPIMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected