| 5318 | |
| 5319 | |
| 5320 | spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol* node, spv::Id forcedType) |
| 5321 | { |
| 5322 | // First, steer off constants, which are not SPIR-V variables, but |
| 5323 | // can still have a mapping to a SPIR-V Id. |
| 5324 | // This includes specialization constants. |
| 5325 | if (node->getQualifier().isConstant()) { |
| 5326 | spv::Id result = createSpvConstant(*node); |
| 5327 | if (result != spv::NoResult) { |
| 5328 | auto name = node->getAsSymbolNode()->getAccessName().c_str(); |
| 5329 | auto typeId = convertGlslangToSpvType(node->getType()); |
| 5330 | builder.createConstVariable(typeId, name, result, currentFunction == nullptr); |
| 5331 | return result; |
| 5332 | } |
| 5333 | } |
| 5334 | |
| 5335 | // Now, handle actual variables |
| 5336 | spv::StorageClass storageClass = TranslateStorageClass(node->getType()); |
| 5337 | spv::Id spvType = forcedType == spv::NoType ? convertGlslangToSpvType(node->getType()) |
| 5338 | : forcedType; |
| 5339 | |
| 5340 | const bool contains16BitType = node->getType().contains16BitFloat() || |
| 5341 | node->getType().contains16BitInt(); |
| 5342 | if (contains16BitType) { |
| 5343 | switch (storageClass) { |
| 5344 | case spv::StorageClass::Input: |
| 5345 | case spv::StorageClass::Output: |
| 5346 | builder.addIncorporatedExtension(spv::E_SPV_KHR_16bit_storage, spv::Spv_1_3); |
| 5347 | builder.addCapability(spv::Capability::StorageInputOutput16); |
| 5348 | break; |
| 5349 | case spv::StorageClass::Uniform: |
| 5350 | builder.addIncorporatedExtension(spv::E_SPV_KHR_16bit_storage, spv::Spv_1_3); |
| 5351 | if (node->getType().getQualifier().storage == glslang::EvqBuffer) |
| 5352 | builder.addCapability(spv::Capability::StorageUniformBufferBlock16); |
| 5353 | else |
| 5354 | builder.addCapability(spv::Capability::StorageUniform16); |
| 5355 | break; |
| 5356 | case spv::StorageClass::PushConstant: |
| 5357 | builder.addIncorporatedExtension(spv::E_SPV_KHR_16bit_storage, spv::Spv_1_3); |
| 5358 | builder.addCapability(spv::Capability::StoragePushConstant16); |
| 5359 | break; |
| 5360 | case spv::StorageClass::StorageBuffer: |
| 5361 | case spv::StorageClass::PhysicalStorageBufferEXT: |
| 5362 | builder.addIncorporatedExtension(spv::E_SPV_KHR_16bit_storage, spv::Spv_1_3); |
| 5363 | builder.addCapability(spv::Capability::StorageUniformBufferBlock16); |
| 5364 | break; |
| 5365 | case spv::StorageClass::TileAttachmentQCOM: |
| 5366 | builder.addCapability(spv::Capability::TileShadingQCOM); |
| 5367 | break; |
| 5368 | default: |
| 5369 | if (storageClass == spv::StorageClass::Workgroup && |
| 5370 | node->getType().getBasicType() == glslang::EbtBlock) { |
| 5371 | builder.addCapability(spv::Capability::WorkgroupMemoryExplicitLayout16BitAccessKHR); |
| 5372 | break; |
| 5373 | } |
| 5374 | if (node->getType().contains16BitFloat()) |
| 5375 | builder.addCapability(spv::Capability::Float16); |
| 5376 | if (node->getType().contains16BitInt()) |
| 5377 | builder.addCapability(spv::Capability::Int16); |
nothing calls this directly
no test coverage detected