Skip to content
Snippets Groups Projects
Commit d38defae authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Correct SPD fallback mechanic for safe downsampling

parent 40fde444
No related branches found
No related tags found
No related merge requests found
...@@ -146,7 +146,7 @@ namespace vkcv::algorithm { ...@@ -146,7 +146,7 @@ namespace vkcv::algorithm {
vkcv::Downsampler(core), vkcv::Downsampler(core),
m_pipeline(), m_pipeline(),
m_descriptorSetLayout(m_core.createDescriptorSetLayout(getDescriptorBindings(sampler))), m_descriptorSetLayout(),
m_descriptorSets(), m_descriptorSets(),
m_globalCounter(m_core.createBuffer<uint32_t>( m_globalCounter(m_core.createBuffer<uint32_t>(
...@@ -155,6 +155,21 @@ namespace vkcv::algorithm { ...@@ -155,6 +155,21 @@ namespace vkcv::algorithm {
)), )),
m_sampler(sampler) { m_sampler(sampler) {
const auto& featureManager = m_core.getContext().getFeatureManager();
const bool partialBound = featureManager.checkFeatures<vk::PhysicalDeviceDescriptorIndexingFeatures>(
vk::StructureType::ePhysicalDeviceDescriptorIndexingFeatures,
[](const vk::PhysicalDeviceDescriptorIndexingFeatures& features) {
return features.descriptorBindingPartiallyBound;
}
);
if (!partialBound) {
return;
}
m_descriptorSetLayout = m_core.createDescriptorSetLayout(getDescriptorBindings(sampler));
vkcv::shader::GLSLCompiler compiler (vkcv::shader::GLSLCompileTarget::SUBGROUP_OP); vkcv::shader::GLSLCompiler compiler (vkcv::shader::GLSLCompileTarget::SUBGROUP_OP);
vk::PhysicalDeviceSubgroupProperties subgroupProperties; vk::PhysicalDeviceSubgroupProperties subgroupProperties;
...@@ -169,8 +184,6 @@ namespace vkcv::algorithm { ...@@ -169,8 +184,6 @@ namespace vkcv::algorithm {
compiler.setDefine("SPD_NO_WAVE_OPERATIONS", "1"); compiler.setDefine("SPD_NO_WAVE_OPERATIONS", "1");
} }
const auto& featureManager = m_core.getContext().getFeatureManager();
const bool float16Support = ( const bool float16Support = (
featureManager.checkFeatures<vk::PhysicalDeviceFloat16Int8FeaturesKHR>( featureManager.checkFeatures<vk::PhysicalDeviceFloat16Int8FeaturesKHR>(
vk::StructureType::ePhysicalDeviceShaderFloat16Int8FeaturesKHR, vk::StructureType::ePhysicalDeviceShaderFloat16Int8FeaturesKHR,
...@@ -229,13 +242,20 @@ namespace vkcv::algorithm { ...@@ -229,13 +242,20 @@ namespace vkcv::algorithm {
void SinglePassDownsampler::recordDownsampling(const CommandStreamHandle &cmdStream, void SinglePassDownsampler::recordDownsampling(const CommandStreamHandle &cmdStream,
const ImageHandle &image) { const ImageHandle &image) {
Downsampler& fallback = m_core.getDownsampler();
if (m_pipeline) {
fallback.recordDownsampling(cmdStream, image);
return;
}
const uint32_t mipLevels = m_core.getImageMipLevels(image); const uint32_t mipLevels = m_core.getImageMipLevels(image);
const uint32_t depth = m_core.getImageDepth(image); const uint32_t depth = m_core.getImageDepth(image);
m_core.prepareImageForSampling(cmdStream, image); m_core.prepareImageForSampling(cmdStream, image);
if ((mipLevels < 4) || (depth > 1) || (!m_core.isImageSupportingStorage(image))) { if ((mipLevels < 4) || (depth > 1) || (!m_core.isImageSupportingStorage(image))) {
m_core.getDownsampler().recordDownsampling(cmdStream, image); fallback.recordDownsampling(cmdStream, image);
return; return;
} }
......
...@@ -284,26 +284,12 @@ namespace vkcv::scene { ...@@ -284,26 +284,12 @@ namespace vkcv::scene {
); );
const vkcv::FeatureManager& featureManager = core.getContext().getFeatureManager(); const vkcv::FeatureManager& featureManager = core.getContext().getFeatureManager();
const bool partialBound = featureManager.checkFeatures<vk::PhysicalDeviceDescriptorIndexingFeatures>(
vk::StructureType::ePhysicalDeviceDescriptorIndexingFeatures,
[](const vk::PhysicalDeviceDescriptorIndexingFeatures& features) {
return features.descriptorBindingPartiallyBound;
}
);
vkcv::Downsampler& downsampler = core.getDownsampler();
vkcv::algorithm::SinglePassDownsampler spdDownsampler (core, sampler); vkcv::algorithm::SinglePassDownsampler spdDownsampler (core, sampler);
auto mipStream = core.createCommandStream(vkcv::QueueType::Graphics); auto mipStream = core.createCommandStream(vkcv::QueueType::Graphics);
if (partialBound) { for (auto& material : scene.m_materials) {
for (auto& material : scene.m_materials) { material.m_data.recordMipChainGeneration(mipStream, spdDownsampler);
material.m_data.recordMipChainGeneration(mipStream, spdDownsampler);
}
} else {
for (auto& material : scene.m_materials) {
material.m_data.recordMipChainGeneration(mipStream, downsampler);
}
} }
core.submitCommandStream(mipStream, false); core.submitCommandStream(mipStream, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment