Skip to content

Commit

Permalink
Merge pull request KhronosGroup#2190 from hiteshbosamiya/SC-2189
Browse files Browse the repository at this point in the history
[SC-2189] Compiler::get_shader_resources() does not return all uniforms
  • Loading branch information
HansKristian-Work authored Aug 28, 2023
2 parents acf51c1 + df7fa1b commit 7ba6f5c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
58 changes: 33 additions & 25 deletions spirv_cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,37 +1003,45 @@ ShaderResources Compiler::get_shader_resources(const unordered_set<VariableID> *
{
res.shader_record_buffers.push_back({ var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, ssbo_instance_name) });
}
// Images
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image &&
type.image.sampled == 2)
{
res.storage_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Separate images
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Image &&
type.image.sampled == 1)
{
res.separate_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Separate samplers
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::Sampler)
{
res.separate_samplers.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Textures
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::SampledImage)
{
res.sampled_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Atomic counters
else if (type.storage == StorageClassAtomicCounter)
{
res.atomic_counters.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Acceleration structures
else if (type.storage == StorageClassUniformConstant && type.basetype == SPIRType::AccelerationStructure)
else if (type.storage == StorageClassUniformConstant)
{
res.acceleration_structures.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
if (type.basetype == SPIRType::Image)
{
// Images
if (type.image.sampled == 2)
{
res.storage_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Separate images
else if (type.image.sampled == 1)
{
res.separate_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
}
// Separate samplers
else if (type.basetype == SPIRType::Sampler)
{
res.separate_samplers.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Textures
else if (type.basetype == SPIRType::SampledImage)
{
res.sampled_images.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
// Acceleration structures
else if (type.basetype == SPIRType::AccelerationStructure)
{
res.acceleration_structures.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
else
{
res.gl_plain_uniforms.push_back({ var.self, var.basetype, type.self, get_name(var.self) });
}
}
});

Expand Down
1 change: 1 addition & 0 deletions spirv_cross.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct ShaderResources
SmallVector<Resource> sampled_images;
SmallVector<Resource> atomic_counters;
SmallVector<Resource> acceleration_structures;
SmallVector<Resource> gl_plain_uniforms;

// There can only be one push constant block,
// but keep the vector in case this restriction is lifted in the future.
Expand Down

0 comments on commit 7ba6f5c

Please sign in to comment.