Fix parameter misordering. Fix a couple sync issues.

This commit is contained in:
BearOso 2023-01-29 19:26:48 -06:00
parent 11dd6b1e6d
commit 4305bb7be1
3 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,7 @@
#include "slang_helpers.hpp"
#include "slang_preset_ini.hpp"
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
@ -10,7 +11,6 @@
#include <iostream>
#include <fstream>
#include <filesystem>
#include <unordered_map>
#include "../external/SPIRV-Cross/spirv_cross.hpp"
#include "../external/SPIRV-Cross/spirv_glsl.hpp"
#include "slang_shader.hpp"
@ -247,19 +247,19 @@ bool SlangPreset::load_preset_file(string filename)
*/
void SlangPreset::gather_parameters()
{
std::unordered_map<std::string, SlangShader::Parameter> map;
parameters.clear();
for (auto &s : passes)
{
for (auto &p : s.parameters)
{
map.insert({ p.id, p });
auto it = std::find_if(parameters.begin(), parameters.end(), [&p](SlangShader::Parameter &needle) {
return (needle.id == p.id);
});
if (it == parameters.end())
parameters.push_back(p);
}
}
parameters.clear();
for (auto &p : map)
parameters.push_back(p.second);
}
/*

View File

@ -175,10 +175,10 @@ void PipelineImage::clear(vk::CommandBuffer cmd)
.setSubresourceRange(subresource_range)
.setOldLayout(vk::ImageLayout::eUndefined)
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite | vk::AccessFlagBits::eTransferRead)
.setSrcAccessMask(vk::AccessFlagBits::eShaderRead)
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite | vk::AccessFlagBits::eTransferRead);
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader,
vk::PipelineStageFlagBits::eTransfer,
{}, {}, {},
image_memory_barrier);

View File

@ -214,6 +214,7 @@ void Texture::from_buffer(uint8_t *buffer, int width, int height, int byte_strid
vk::SubmitInfo si{};
si.setCommandBuffers(cmd.get());
queue.submit(si);
queue.waitIdle();
}
void Texture::create(int width, int height, vk::Format fmt, vk::SamplerAddressMode wrap_mode, bool linear, bool mipmap)