MCPcopy Create free account
hub / github.com/PixarAnimationStudios/OpenUSD / _EmitDeclaration

Function _EmitDeclaration

pxr/imaging/hdSt/codeGen.cpp:3409–3523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3407}
3408
3409static void _EmitDeclaration(
3410 HioGlslfxResourceLayout::ElementVector *elements,
3411 TfToken const &name,
3412 TfToken const &type,
3413 HdStBinding const &binding,
3414 bool isWritable,
3415 int arraySize)
3416{
3417 /*
3418 [vertex attribute]
3419 layout (location = <location>) in <type> <name>;
3420 [uniform]
3421 layout (location = <location>) uniform <type> <name>;
3422 [SSBO]
3423 layout (std430, binding = <location>) buffer buffer_<location> {
3424 <type> <name>[];
3425 };
3426 [Bindless Uniform]
3427 layout (location = <location>) uniform <type> *<name>;
3428
3429 */
3430 HdStBinding::Type bindingType = binding.GetType();
3431
3432 if (!TF_VERIFY(!name.IsEmpty())) return;
3433 if (!TF_VERIFY(!type.IsEmpty(),
3434 "Unknown dataType for %s",
3435 name.GetText())) return;
3436
3437 if (arraySize > 0) {
3438 if (!TF_VERIFY(bindingType == HdStBinding::UNIFORM_ARRAY ||
3439 bindingType == HdStBinding::DRAW_INDEX_INSTANCE_ARRAY ||
3440 bindingType == HdStBinding::UBO ||
3441 bindingType == HdStBinding::SSBO ||
3442 bindingType == HdStBinding::BINDLESS_SSBO_RANGE ||
3443 bindingType == HdStBinding::BINDLESS_UNIFORM)) {
3444 // XXX: SSBO and BINDLESS_UNIFORM don't need arraySize, but for the
3445 // workaround of UBO allocation we're passing arraySize = 2
3446 // for all bindingType.
3447 return;
3448 }
3449 }
3450
3451 // layout qualifier (if exists)
3452 uint32_t location = binding.GetLocation();
3453 switch (bindingType) {
3454 case HdStBinding::VERTEX_ATTR:
3455 case HdStBinding::DRAW_INDEX:
3456 case HdStBinding::DRAW_INDEX_INSTANCE:
3457 _AddVertexAttribElement(elements,
3458 /*name=*/name,
3459 /*dataType=*/_GetPackedType(type, false),
3460 location);
3461
3462 break;
3463 case HdStBinding::DRAW_INDEX_INSTANCE_ARRAY:
3464 {
3465 for(int i = 0; i < arraySize;i++) {
3466 _AddVertexAttribElement(elements,

Calls 12

_AddVertexAttribElementFunction · 0.85
_AddUniformValueElementFunction · 0.85
_AddUniformBufferElementFunction · 0.85
_AddBufferElementFunction · 0.85
TfTokenClass · 0.50
to_stringFunction · 0.50
GetTypeMethod · 0.45
IsEmptyMethod · 0.45
GetTextMethod · 0.45
GetLocationMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected