diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-11-04 15:20:14 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-11-04 17:54:54 +0300 |
commit | d3947f782154616ceca9a19945059af79a68c8bb (patch) | |
tree | aaf563ea127df6c39affa1f6c59b7e37f868a793 /dxil_converter.cpp | |
parent | 17e235a9a07bd7f1551ea08013f4f1b713c0e014 (diff) |
Vectorize StructuredBuffer.
Diffstat (limited to 'dxil_converter.cpp')
-rw-r--r-- | dxil_converter.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/dxil_converter.cpp b/dxil_converter.cpp index 1446e4b..0013a1e 100644 --- a/dxil_converter.cpp +++ b/dxil_converter.cpp @@ -2343,17 +2343,18 @@ void Converter::Impl::get_shader_model(const llvm::Module &module, String *model } } -DXIL::ResourceKind Converter::Impl::get_resource_kind_from_meta(DXIL::ResourceType resource_type, unsigned meta_index) +Converter::Impl::RawBufferMeta +Converter::Impl::get_raw_buffer_meta(DXIL::ResourceType resource_type, unsigned meta_index) { auto &module = bitcode_parser.get_module(); auto *resource_meta = module.getNamedMetadata("dx.resources"); if (!resource_meta) - return DXIL::ResourceKind::Invalid; + return { DXIL::ResourceKind::Invalid, 0 }; auto *metas = resource_meta->getOperand(0); auto &resource_list = metas->getOperand(uint32_t(resource_type)); if (!resource_list) - return DXIL::ResourceKind::Invalid; + return { DXIL::ResourceKind::Invalid, 0 }; auto *entries = llvm::cast<llvm::MDNode>(resource_list); unsigned num_entries = entries->getNumOperands(); @@ -2361,10 +2362,22 @@ DXIL::ResourceKind Converter::Impl::get_resource_kind_from_meta(DXIL::ResourceTy { auto *entry = llvm::cast<llvm::MDNode>(entries->getOperand(i)); if (get_constant_metadata(entry, 0) == meta_index) - return DXIL::ResourceKind(get_constant_metadata(entry, 6)); + { + RawBufferMeta meta = {}; + meta.kind = DXIL::ResourceKind(get_constant_metadata(entry, 6)); + + unsigned tag_index = resource_type == DXIL::ResourceType::SRV ? 8 : 10; + + llvm::MDNode *tags = nullptr; + if (entry->getNumOperands() > tag_index && entry->getOperand(tag_index)) + tags = llvm::dyn_cast<llvm::MDNode>(entry->getOperand(tag_index)); + if (tags) + meta.stride = get_constant_metadata(tags, 1); + return meta; + } } - return DXIL::ResourceKind::Invalid; + return { DXIL::ResourceKind::Invalid, 0 }; } uint32_t Converter::Impl::find_binding_meta_index(uint32_t binding_range_lo, uint32_t binding_range_hi, |