Skip to content

Commit

Permalink
igl | vulkan | Extract storage images from SPIR-V
Browse files Browse the repository at this point in the history
Reviewed By: rudybear

Differential Revision: D68870985

fbshipit-source-id: 5c70e5be103ea6f2f027294e0012922b3a0819c5
  • Loading branch information
corporateshark authored and facebook-github-bot committed Feb 3, 2025
1 parent ae91e3a commit d315733
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/igl/vulkan/util/SpvReflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,13 @@ SpvModuleInfo getReflectionData(const uint32_t* spirv, size_t numBytes) {
case SpvOpTypeImage: {
const TextureType tt = ids[ids[id.typeId].typeId].type; // dimension
IGL_DEBUG_ASSERT(tt != TextureType::Invalid);
const bool isStor = ids[ids[id.typeId].typeId].isStorageImage;
uint32_t imgFmt = ids[ids[id.typeId].typeId].imageFormat;
info.textures.push_back({id.binding, id.dset, tt, isStor, imgFmt});
const bool isStorageImage = ids[ids[id.typeId].typeId].isStorageImage;
if (isStorageImage) {
uint32_t imgFmt = ids[ids[id.typeId].typeId].imageFormat;
info.images.push_back({id.binding, id.dset, tt, imgFmt});
} else {
info.textures.push_back({id.binding, id.dset, tt});
}
break;
}
case SpvOpTypeSampler:
Expand All @@ -243,7 +247,7 @@ SpvModuleInfo getReflectionData(const uint32_t* spirv, size_t numBytes) {
IGL_DEBUG_ASSERT(ids[ids[ids[id.typeId].typeId].typeId].opCode == SpvOpTypeImage);
const TextureType tt = ids[ids[ids[id.typeId].typeId].typeId].type;
IGL_DEBUG_ASSERT(tt != TextureType::Invalid);
info.textures.push_back({id.binding, id.dset, tt, false, SpvImageFormatUnknown});
info.textures.push_back({id.binding, id.dset, tt});
break;
}
default:
Expand Down
8 changes: 7 additions & 1 deletion src/igl/vulkan/util/SpvReflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ struct TextureDescription {
uint32_t bindingLocation = kNoBindingLocation;
uint32_t descriptorSet = kNoDescriptorSet;
TextureType type = TextureType::Invalid;
bool isStorageImage = false;
};

struct ImageDescription {
uint32_t bindingLocation = kNoBindingLocation;
uint32_t descriptorSet = kNoDescriptorSet;
TextureType type = TextureType::Invalid;
uint32_t imageFormat = 0;
};

Expand All @@ -34,6 +39,7 @@ struct BufferDescription {
struct SpvModuleInfo {
std::vector<BufferDescription> buffers;
std::vector<TextureDescription> textures;
std::vector<ImageDescription> images;
bool hasPushConstants = false;
uint32_t usageMaskBuffers = 0;
uint32_t usageMaskTextures = 0;
Expand Down

0 comments on commit d315733

Please sign in to comment.