mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-01-22 08:36:32 +01:00
vulkan: Fix crashes with bindless texture constant buffer handling
Previously, the code would unconditionally add a constant buffer descriptor at index 0 whenever storage buffers were present, which could cause conflicts and crashes. This change: - Adds validation to check if constant buffer 0 already exists - Only adds the descriptor if it's not already present - Prevents potential descriptor conflicts in shaders This should resolve crashes in Vulkan games related to invalid descriptor layouts and resource binding conflicts.
This commit is contained in:
parent
08be9b0617
commit
0cf545858d
1 changed files with 13 additions and 5 deletions
|
@ -768,13 +768,21 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
|
|||
|
||||
auto program{TranslateProgram(pools.inst, pools.block, env, cfg, host_info)};
|
||||
|
||||
// Add support for bindless texture constant buffer
|
||||
// Add support for bindless texture constant buffer only if needed
|
||||
if (program.info.storage_buffers_descriptors.size() > 0) {
|
||||
// Check if a constant buffer at index 0 already exists
|
||||
const bool has_cb0 = std::any_of(program.info.constant_buffer_descriptors.begin(),
|
||||
program.info.constant_buffer_descriptors.end(),
|
||||
[](const auto& cb) { return cb.index == 0; });
|
||||
|
||||
// Only add if not already present
|
||||
if (!has_cb0) {
|
||||
Shader::ConstantBufferDescriptor desc;
|
||||
desc.index = 0;
|
||||
desc.count = 1;
|
||||
program.info.constant_buffer_descriptors.push_back(desc);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<u32> code{EmitSPIRV(profile, program)};
|
||||
device.SaveShader(code);
|
||||
|
|
Loading…
Reference in a new issue