Fix a couple validation issues.

This commit is contained in:
BearOso 2023-02-02 14:14:49 -06:00
parent 2c7d5f7a4d
commit fd3a9dba14
4 changed files with 17 additions and 4 deletions

View File

@ -230,6 +230,15 @@ vk::CommandBuffer Context::begin_cmd_buffer()
return one_time_use_cmd;
}
void Context::hard_barrier(vk::CommandBuffer cmd)
{
vk::MemoryBarrier barrier(vk::AccessFlagBits::eMemoryRead | vk::AccessFlagBits::eMemoryWrite,
vk::AccessFlagBits::eMemoryRead | vk::AccessFlagBits::eMemoryWrite);
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eAllCommands,
vk::PipelineStageFlagBits::eAllCommands,
{}, barrier, {}, {});
}
void Context::end_cmd_buffer()
{
one_time_use_cmd.end();

View File

@ -32,6 +32,7 @@ class Context
void wait_idle();
vk::CommandBuffer begin_cmd_buffer();
void end_cmd_buffer();
void hard_barrier(vk::CommandBuffer cmd);
vma::Allocator allocator;
vk::Device device;

View File

@ -279,6 +279,8 @@ bool ShaderChain::load_shader_preset(std::string filename)
current_frame_index = 0;
last_frame_index = 2;
context->wait_idle();
return true;
}
@ -393,6 +395,8 @@ void ShaderChain::do_frame(uint8_t *data, int width, int height, int stride, vk:
if (!context->swapchain->begin_frame())
return;
current_frame_index = context->swapchain->get_current_frame();
auto cmd = context->swapchain->get_cmd();
update_and_propagate_sizes(width, height, viewport_width, viewport_height);
@ -509,7 +513,6 @@ void ShaderChain::do_frame(uint8_t *data, int width, int height, int stride, vk:
context->swapchain->end_frame();
last_frame_index = current_frame_index;
current_frame_index = (current_frame_index + 1) % queue_size;
frame_count++;
}
@ -523,7 +526,7 @@ void ShaderChain::upload_original(vk::CommandBuffer cmd, uint8_t *data, int widt
format,
wrap_mode_from_string(pipelines[0]->shader->wrap_mode),
pipelines[0]->shader->filter_linear,
true);
pipelines[0]->shader->mipmap_input);
};
if (original.size() > original_history_size)

View File

@ -108,11 +108,11 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
.setImage(image)
.setOldLayout(vk::ImageLayout::eUndefined)
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
.setSrcAccessMask(vk::AccessFlagBits::eNone)
.setSrcAccessMask(vk::AccessFlagBits::eShaderRead)
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite)
.setSubresourceRange(srr(0));
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe,
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader,
vk::PipelineStageFlagBits::eTransfer,
{}, {}, {}, barrier);