mirror of https://github.com/snes9xgit/snes9x.git
Vulkan: Use helper for image transitions.
This commit is contained in:
parent
39c0f8418b
commit
79f6e911f3
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "vulkan_pipeline_image.hpp"
|
#include "vulkan_pipeline_image.hpp"
|
||||||
#include "slang_helpers.hpp"
|
#include "slang_helpers.hpp"
|
||||||
|
#include "vulkan_common.hpp"
|
||||||
|
|
||||||
namespace Vulkan
|
namespace Vulkan
|
||||||
{
|
{
|
||||||
|
@ -63,25 +64,14 @@ void PipelineImage::generate_mipmaps(vk::CommandBuffer cmd)
|
||||||
if (!mipmap)
|
if (!mipmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto srr = [](unsigned int i) { return vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, i, 1, 0, 1); };
|
auto range = [](unsigned int i) { return vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, i, 1, 0, 1); };
|
||||||
auto srl = [](unsigned int i) { return vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, i, 0, 1); };
|
auto level = [](unsigned int i) { return vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, i, 0, 1); };
|
||||||
auto image_memory_barrier = vk::ImageMemoryBarrier{}.setImage(image);
|
auto image_memory_barrier = vk::ImageMemoryBarrier{}.setImage(image);
|
||||||
|
|
||||||
auto mipmap_levels = mipmap ? mipmap_levels_for_size(image_width, image_height) : 1;
|
auto mipmap_levels = mipmap ? mipmap_levels_for_size(image_width, image_height) : 1;
|
||||||
|
|
||||||
|
image_layout_transition(cmd, image, vk::ImageLayout::eShaderReadOnlyOptimal, vk::ImageLayout::eTransferSrcOptimal);
|
||||||
// Transition base layer to readable format.
|
// Transition base layer to readable format.
|
||||||
image_memory_barrier
|
|
||||||
.setImage(image)
|
|
||||||
.setOldLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
|
||||||
.setNewLayout(vk::ImageLayout::eTransferSrcOptimal)
|
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eInputAttachmentRead)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferRead)
|
|
||||||
.setSubresourceRange(srr(0));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eVertexShader | vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, image_memory_barrier);
|
|
||||||
|
|
||||||
int base_width = image_width;
|
int base_width = image_width;
|
||||||
int base_height = image_height;
|
int base_height = image_height;
|
||||||
int base_level = 0;
|
int base_level = 0;
|
||||||
|
@ -90,75 +80,52 @@ void PipelineImage::generate_mipmaps(vk::CommandBuffer cmd)
|
||||||
// Transition base layer to readable format.
|
// Transition base layer to readable format.
|
||||||
if (base_level > 0)
|
if (base_level > 0)
|
||||||
{
|
{
|
||||||
image_memory_barrier
|
image_layout_transition(cmd,
|
||||||
.setImage(image)
|
image,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eTransferSrcOptimal)
|
vk::ImageLayout::eTransferSrcOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
range(base_level));
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferRead)
|
|
||||||
.setSubresourceRange(srr(base_level));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, image_memory_barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transition mipmap layer to writable
|
// Transition mipmap layer to writable
|
||||||
image_memory_barrier
|
image_layout_transition(cmd,
|
||||||
.setImage(image)
|
image,
|
||||||
.setOldLayout(vk::ImageLayout::eUndefined)
|
vk::ImageLayout::eUndefined,
|
||||||
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eNone)
|
range(base_level + 1));
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite)
|
|
||||||
.setSubresourceRange(srr(base_level + 1));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, image_memory_barrier);
|
|
||||||
|
|
||||||
// Blit base layer to mipmap layer
|
// Blit base layer to mipmap layer
|
||||||
int mipmap_width = base_width >> 1;
|
int mipmap_width = std::max(base_width >> 1, 1);
|
||||||
int mipmap_height = base_height >> 1;
|
int mipmap_height = std::max(base_height >> 1, 1);
|
||||||
if (mipmap_width < 1)
|
|
||||||
mipmap_width = 1;
|
|
||||||
if (mipmap_height < 1)
|
|
||||||
mipmap_height = 1;
|
|
||||||
|
|
||||||
auto blit = vk::ImageBlit{}
|
auto blit = vk::ImageBlit{}
|
||||||
.setSrcOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(base_width, base_height, 1) })
|
.setSrcOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(base_width, base_height, 1) })
|
||||||
.setDstOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(mipmap_width, mipmap_height, 1) })
|
.setDstOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(mipmap_width, mipmap_height, 1) })
|
||||||
.setSrcSubresource(srl(base_level))
|
.setSrcSubresource(level(base_level))
|
||||||
.setDstSubresource(srl(base_level + 1));
|
.setDstSubresource(level(base_level + 1));
|
||||||
|
|
||||||
base_width = mipmap_width;
|
base_width = mipmap_width;
|
||||||
base_height = mipmap_height;
|
base_height = mipmap_height;
|
||||||
|
|
||||||
cmd.blitImage(image, vk::ImageLayout::eTransferSrcOptimal, image, vk::ImageLayout::eTransferDstOptimal, blit, vk::Filter::eLinear);
|
cmd.blitImage(image,
|
||||||
|
vk::ImageLayout::eTransferSrcOptimal,
|
||||||
|
image,
|
||||||
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
|
blit,
|
||||||
|
vk::Filter::eLinear);
|
||||||
|
|
||||||
// Transition base layer to shader readable
|
image_layout_transition(cmd,
|
||||||
image_memory_barrier
|
image,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferSrcOptimal)
|
vk::ImageLayout::eTransferSrcOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferRead)
|
range(base_level));
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eShaderRead)
|
|
||||||
.setSubresourceRange(srr(base_level));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
{}, {}, {}, image_memory_barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transition final layer to shader readable
|
image_layout_transition(cmd,
|
||||||
image_memory_barrier
|
image,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
range(base_level));
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eShaderRead)
|
|
||||||
.setSubresourceRange(srr(base_level));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
{}, {}, {}, image_memory_barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PipelineImage::barrier(vk::CommandBuffer cmd)
|
void PipelineImage::barrier(vk::CommandBuffer cmd)
|
||||||
|
@ -172,18 +139,11 @@ void PipelineImage::clear(vk::CommandBuffer cmd)
|
||||||
{
|
{
|
||||||
vk::ImageSubresourceRange subresource_range(vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, 1);
|
vk::ImageSubresourceRange subresource_range(vk::ImageAspectFlagBits::eColor, 0, VK_REMAINING_MIP_LEVELS, 0, 1);
|
||||||
|
|
||||||
auto image_memory_barrier = vk::ImageMemoryBarrier{}
|
image_layout_transition(cmd,
|
||||||
.setImage(image)
|
image,
|
||||||
.setSubresourceRange(subresource_range)
|
vk::ImageLayout::eUndefined,
|
||||||
.setOldLayout(vk::ImageLayout::eUndefined)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
|
subresource_range);
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eShaderRead)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite);
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {},
|
|
||||||
image_memory_barrier);
|
|
||||||
|
|
||||||
vk::ClearColorValue color{};
|
vk::ClearColorValue color{};
|
||||||
|
|
||||||
|
@ -194,16 +154,11 @@ void PipelineImage::clear(vk::CommandBuffer cmd)
|
||||||
color,
|
color,
|
||||||
subresource_range);
|
subresource_range);
|
||||||
|
|
||||||
image_memory_barrier
|
image_layout_transition(cmd,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferDstOptimal)
|
image,
|
||||||
.setNewLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eShaderRead);
|
subresource_range);
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
{}, {}, {},
|
|
||||||
image_memory_barrier);
|
|
||||||
|
|
||||||
current_layout = vk::ImageLayout::eShaderReadOnlyOptimal;
|
current_layout = vk::ImageLayout::eShaderReadOnlyOptimal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "slang_helpers.hpp"
|
#include "slang_helpers.hpp"
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include "vulkan/vulkan_enums.hpp"
|
#include "vulkan/vulkan_enums.hpp"
|
||||||
|
#include "vulkan_common.hpp"
|
||||||
|
|
||||||
namespace Vulkan
|
namespace Vulkan
|
||||||
{
|
{
|
||||||
|
@ -464,25 +465,12 @@ bool ShaderChain::do_frame_without_swap(uint8_t *data, int width, int height, in
|
||||||
|
|
||||||
if (preset->last_pass_uses_feedback && is_last_pass)
|
if (preset->last_pass_uses_feedback && is_last_pass)
|
||||||
{
|
{
|
||||||
std::array<vk::ImageMemoryBarrier, 2> image_memory_barrier{};
|
image_layout_transition(cmd, frame.image.image,
|
||||||
image_memory_barrier[0]
|
vk::ImageLayout::eUndefined,
|
||||||
.setImage(frame.image.image)
|
vk::ImageLayout::eTransferDstOptimal);
|
||||||
.setOldLayout(vk::ImageLayout::eUndefined)
|
image_layout_transition(cmd, context->swapchain->get_image(),
|
||||||
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::ePresentSrcKHR,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eColorAttachmentWrite)
|
vk::ImageLayout::eTransferSrcOptimal);
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite)
|
|
||||||
.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
|
|
||||||
image_memory_barrier[1]
|
|
||||||
.setImage(context->swapchain->get_image())
|
|
||||||
.setOldLayout(vk::ImageLayout::ePresentSrcKHR)
|
|
||||||
.setNewLayout(vk::ImageLayout::eTransferSrcOptimal)
|
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eNone)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferRead)
|
|
||||||
.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, image_memory_barrier);
|
|
||||||
|
|
||||||
auto image_blit = vk::ImageBlit{}
|
auto image_blit = vk::ImageBlit{}
|
||||||
.setSrcOffsets({ vk::Offset3D(viewport_x, viewport_y, 0), vk::Offset3D(viewport_x + viewport_width, viewport_y + viewport_height, 1) })
|
.setSrcOffsets({ vk::Offset3D(viewport_x, viewport_y, 0), vk::Offset3D(viewport_x + viewport_width, viewport_y + viewport_height, 1) })
|
||||||
|
@ -492,25 +480,12 @@ bool ShaderChain::do_frame_without_swap(uint8_t *data, int width, int height, in
|
||||||
|
|
||||||
cmd.blitImage(context->swapchain->get_image(), vk::ImageLayout::eTransferSrcOptimal, frame.image.image, vk::ImageLayout::eTransferDstOptimal, image_blit, vk::Filter::eNearest);
|
cmd.blitImage(context->swapchain->get_image(), vk::ImageLayout::eTransferSrcOptimal, frame.image.image, vk::ImageLayout::eTransferDstOptimal, image_blit, vk::Filter::eNearest);
|
||||||
|
|
||||||
image_memory_barrier[0]
|
image_layout_transition(cmd, frame.image.image,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
vk::ImageLayout::eShaderReadOnlyOptimal);
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
image_layout_transition(cmd, context->swapchain->get_image(),
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eShaderRead)
|
vk::ImageLayout::eTransferSrcOptimal,
|
||||||
.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
|
vk::ImageLayout::ePresentSrcKHR);
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eVertexShader | vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
{}, {}, {}, image_memory_barrier[0]);
|
|
||||||
|
|
||||||
image_memory_barrier[1]
|
|
||||||
.setOldLayout(vk::ImageLayout::eTransferSrcOptimal)
|
|
||||||
.setNewLayout(vk::ImageLayout::ePresentSrcKHR)
|
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferRead)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eNone)
|
|
||||||
.setSubresourceRange(vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1));
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eBottomOfPipe,
|
|
||||||
{}, {}, {}, image_memory_barrier[1]);
|
|
||||||
|
|
||||||
frame.image.current_layout = vk::ImageLayout::eTransferDstOptimal;
|
frame.image.current_layout = vk::ImageLayout::eTransferDstOptimal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "vulkan_texture.hpp"
|
#include "vulkan_texture.hpp"
|
||||||
#include "vulkan/vulkan_enums.hpp"
|
|
||||||
#include "slang_helpers.hpp"
|
#include "slang_helpers.hpp"
|
||||||
|
#include "vulkan_common.hpp"
|
||||||
|
|
||||||
namespace Vulkan
|
namespace Vulkan
|
||||||
{
|
{
|
||||||
|
@ -103,20 +103,13 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
||||||
allocator.unmapMemory(buffer_allocation);
|
allocator.unmapMemory(buffer_allocation);
|
||||||
allocator.flushAllocation(buffer_allocation, 0, width * height * pixel_size);
|
allocator.flushAllocation(buffer_allocation, 0, width * height * pixel_size);
|
||||||
|
|
||||||
auto srr = [](unsigned int i) { return vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, i, 1, 0, 1); };
|
auto range = [](unsigned int i) { return vk::ImageSubresourceRange(vk::ImageAspectFlagBits::eColor, i, 1, 0, 1); };
|
||||||
auto srl = [](unsigned int i) { return vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, i, 0, 1); };
|
auto level = [](unsigned int i) { return vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, i, 0, 1); };
|
||||||
|
|
||||||
auto barrier = vk::ImageMemoryBarrier{}
|
image_layout_transition(cmd, image,
|
||||||
.setImage(image)
|
vk::ImageLayout::eUndefined,
|
||||||
.setOldLayout(vk::ImageLayout::eUndefined)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
|
range(0));
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eShaderRead)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite)
|
|
||||||
.setSubresourceRange(srr(0));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, barrier);
|
|
||||||
|
|
||||||
auto buffer_image_copy = vk::BufferImageCopy{}
|
auto buffer_image_copy = vk::BufferImageCopy{}
|
||||||
.setBufferOffset(0)
|
.setBufferOffset(0)
|
||||||
|
@ -124,7 +117,7 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
||||||
.setBufferImageHeight(height)
|
.setBufferImageHeight(height)
|
||||||
.setImageExtent(vk::Extent3D(width, height, 1))
|
.setImageExtent(vk::Extent3D(width, height, 1))
|
||||||
.setImageOffset(vk::Offset3D(0, 0, 0))
|
.setImageOffset(vk::Offset3D(0, 0, 0))
|
||||||
.setImageSubresource(srl(0));
|
.setImageSubresource(level(0));
|
||||||
cmd.copyBufferToImage(this->buffer, image, vk::ImageLayout::eTransferDstOptimal, buffer_image_copy);
|
cmd.copyBufferToImage(this->buffer, image, vk::ImageLayout::eTransferDstOptimal, buffer_image_copy);
|
||||||
|
|
||||||
auto mipmap_levels = mipmap ? mipmap_levels_for_size(image_width, image_height) : 1;
|
auto mipmap_levels = mipmap ? mipmap_levels_for_size(image_width, image_height) : 1;
|
||||||
|
@ -135,30 +128,16 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
||||||
for (; base_level + 1 < mipmap_levels; base_level++)
|
for (; base_level + 1 < mipmap_levels; base_level++)
|
||||||
{
|
{
|
||||||
// Transition base layer to readable format.
|
// Transition base layer to readable format.
|
||||||
barrier
|
image_layout_transition(cmd, image,
|
||||||
.setImage(image)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::eTransferSrcOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eTransferSrcOptimal)
|
range(base_level));
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferRead)
|
|
||||||
.setSubresourceRange(srr(base_level));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, barrier);
|
|
||||||
|
|
||||||
// Transition mipmap layer to writable
|
// Transition mipmap layer to writable
|
||||||
barrier
|
image_layout_transition(cmd, image,
|
||||||
.setImage(image)
|
vk::ImageLayout::eUndefined,
|
||||||
.setOldLayout(vk::ImageLayout::eUndefined)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eTransferDstOptimal)
|
range(base_level + 1));
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferRead)
|
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eTransferWrite)
|
|
||||||
.setSubresourceRange(srr(base_level + 1));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
{}, {}, {}, barrier);
|
|
||||||
|
|
||||||
// Blit base layer to mipmap layer
|
// Blit base layer to mipmap layer
|
||||||
int mipmap_width = base_width >> 1;
|
int mipmap_width = base_width >> 1;
|
||||||
|
@ -171,8 +150,8 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
||||||
auto blit = vk::ImageBlit{}
|
auto blit = vk::ImageBlit{}
|
||||||
.setSrcOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(base_width, base_height, 1) })
|
.setSrcOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(base_width, base_height, 1) })
|
||||||
.setDstOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(mipmap_width, mipmap_height, 1)})
|
.setDstOffsets({ vk::Offset3D(0, 0, 0), vk::Offset3D(mipmap_width, mipmap_height, 1)})
|
||||||
.setSrcSubresource(srl(base_level))
|
.setSrcSubresource(level(base_level))
|
||||||
.setDstSubresource(srl(base_level + 1));
|
.setDstSubresource(level(base_level + 1));
|
||||||
|
|
||||||
base_width = mipmap_width;
|
base_width = mipmap_width;
|
||||||
base_height = mipmap_height;
|
base_height = mipmap_height;
|
||||||
|
@ -180,29 +159,17 @@ void Texture::from_buffer(vk::CommandBuffer cmd,
|
||||||
cmd.blitImage(image, vk::ImageLayout::eTransferSrcOptimal, image, vk::ImageLayout::eTransferDstOptimal, blit, vk::Filter::eLinear);
|
cmd.blitImage(image, vk::ImageLayout::eTransferSrcOptimal, image, vk::ImageLayout::eTransferDstOptimal, blit, vk::Filter::eLinear);
|
||||||
|
|
||||||
// Transition base layer to shader readable
|
// Transition base layer to shader readable
|
||||||
barrier
|
image_layout_transition(cmd, image,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferSrcOptimal)
|
vk::ImageLayout::eTransferSrcOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
range(base_level));
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eShaderRead)
|
|
||||||
.setSubresourceRange(srr(base_level));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
{}, {}, {}, barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transition final layer to shader readable
|
// Transition final layer to shader readable
|
||||||
barrier
|
image_layout_transition(cmd, image,
|
||||||
.setOldLayout(vk::ImageLayout::eTransferDstOptimal)
|
vk::ImageLayout::eTransferDstOptimal,
|
||||||
.setNewLayout(vk::ImageLayout::eShaderReadOnlyOptimal)
|
vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||||
.setSrcAccessMask(vk::AccessFlagBits::eTransferWrite)
|
range(base_level));
|
||||||
.setDstAccessMask(vk::AccessFlagBits::eShaderRead)
|
|
||||||
.setSubresourceRange(srr(base_level));
|
|
||||||
|
|
||||||
cmd.pipelineBarrier(vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::PipelineStageFlagBits::eFragmentShader,
|
|
||||||
{}, {}, {}, barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::from_buffer(uint8_t *buffer, int width, int height, int byte_stride)
|
void Texture::from_buffer(uint8_t *buffer, int width, int height, int byte_stride)
|
||||||
|
|
|
@ -124,6 +124,8 @@ if(USE_SLANG)
|
||||||
../common/video/vulkan/vk_mem_alloc_implementation.cpp
|
../common/video/vulkan/vk_mem_alloc_implementation.cpp
|
||||||
../common/video/vulkan/vulkan_context.cpp
|
../common/video/vulkan/vulkan_context.cpp
|
||||||
../common/video/vulkan/vulkan_context.hpp
|
../common/video/vulkan/vulkan_context.hpp
|
||||||
|
../common/video/vulkan/vulkan_common.cpp
|
||||||
|
../common/video/vulkan/vulkan_common.hpp
|
||||||
../common/video/vulkan/vulkan_texture.cpp
|
../common/video/vulkan/vulkan_texture.cpp
|
||||||
../common/video/vulkan/vulkan_texture.hpp
|
../common/video/vulkan/vulkan_texture.hpp
|
||||||
../common/video/vulkan/vulkan_swapchain.cpp
|
../common/video/vulkan/vulkan_swapchain.cpp
|
||||||
|
|
|
@ -263,6 +263,8 @@ list(APPEND SOURCES
|
||||||
../common/video/vulkan/vk_mem_alloc_implementation.cpp
|
../common/video/vulkan/vk_mem_alloc_implementation.cpp
|
||||||
../common/video/vulkan/vulkan_context.cpp
|
../common/video/vulkan/vulkan_context.cpp
|
||||||
../common/video/vulkan/vulkan_context.hpp
|
../common/video/vulkan/vulkan_context.hpp
|
||||||
|
../common/video/vulkan/vulkan_common.cpp
|
||||||
|
../common/video/vulkan/vulkan_common.hpp
|
||||||
../common/video/vulkan/vulkan_texture.cpp
|
../common/video/vulkan/vulkan_texture.cpp
|
||||||
../common/video/vulkan/vulkan_texture.hpp
|
../common/video/vulkan/vulkan_texture.hpp
|
||||||
../common/video/vulkan/vulkan_swapchain.cpp
|
../common/video/vulkan/vulkan_swapchain.cpp
|
||||||
|
|
|
@ -454,6 +454,7 @@
|
||||||
<ClInclude Include="..\common\video\vulkan\slang_preset_ini.hpp" />
|
<ClInclude Include="..\common\video\vulkan\slang_preset_ini.hpp" />
|
||||||
<ClInclude Include="..\common\video\vulkan\slang_shader.hpp" />
|
<ClInclude Include="..\common\video\vulkan\slang_shader.hpp" />
|
||||||
<ClInclude Include="..\common\video\vulkan\vulkan_context.hpp" />
|
<ClInclude Include="..\common\video\vulkan\vulkan_context.hpp" />
|
||||||
|
<ClInclude Include="..\common\video\vulkan\vulkan_common.hpp" />
|
||||||
<ClInclude Include="..\common\video\vulkan\vulkan_pipeline_image.hpp" />
|
<ClInclude Include="..\common\video\vulkan\vulkan_pipeline_image.hpp" />
|
||||||
<ClInclude Include="..\common\video\vulkan\vulkan_shader_chain.hpp" />
|
<ClInclude Include="..\common\video\vulkan\vulkan_shader_chain.hpp" />
|
||||||
<ClInclude Include="..\common\video\vulkan\vulkan_simple_output.hpp" />
|
<ClInclude Include="..\common\video\vulkan\vulkan_simple_output.hpp" />
|
||||||
|
@ -625,6 +626,7 @@
|
||||||
<ClCompile Include="..\common\video\vulkan\slang_shader.cpp" />
|
<ClCompile Include="..\common\video\vulkan\slang_shader.cpp" />
|
||||||
<ClCompile Include="..\common\video\vulkan\vk_mem_alloc_implementation.cpp" />
|
<ClCompile Include="..\common\video\vulkan\vk_mem_alloc_implementation.cpp" />
|
||||||
<ClCompile Include="..\common\video\vulkan\vulkan_context.cpp" />
|
<ClCompile Include="..\common\video\vulkan\vulkan_context.cpp" />
|
||||||
|
<ClCompile Include="..\common\video\vulkan\vulkan_common.cpp" />
|
||||||
<ClCompile Include="..\common\video\vulkan\vulkan_hpp_storage.cpp" />
|
<ClCompile Include="..\common\video\vulkan\vulkan_hpp_storage.cpp" />
|
||||||
<ClCompile Include="..\common\video\vulkan\vulkan_pipeline_image.cpp" />
|
<ClCompile Include="..\common\video\vulkan\vulkan_pipeline_image.cpp" />
|
||||||
<ClCompile Include="..\common\video\vulkan\vulkan_shader_chain.cpp" />
|
<ClCompile Include="..\common\video\vulkan\vulkan_shader_chain.cpp" />
|
||||||
|
|
|
@ -315,6 +315,9 @@
|
||||||
<ClInclude Include="..\common\video\vulkan\vulkan_context.hpp">
|
<ClInclude Include="..\common\video\vulkan\vulkan_context.hpp">
|
||||||
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\common\video\vulkan\vulkan_common.hpp">
|
||||||
|
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\common\video\vulkan\vulkan_pipeline_image.hpp">
|
<ClInclude Include="..\common\video\vulkan\vulkan_pipeline_image.hpp">
|
||||||
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -737,6 +740,9 @@
|
||||||
<ClCompile Include="..\common\video\vulkan\vulkan_context.cpp">
|
<ClCompile Include="..\common\video\vulkan\vulkan_context.cpp">
|
||||||
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\common\video\vulkan\vulkan_common.cpp">
|
||||||
|
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\video\vulkan\vulkan_hpp_storage.cpp">
|
<ClCompile Include="..\common\video\vulkan\vulkan_hpp_storage.cpp">
|
||||||
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
<Filter>GUI\VideoDriver\Vulkan</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -997,4 +1003,4 @@
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
<CustomBuild Include="snes9x.cfg" />
|
<CustomBuild Include="snes9x.cfg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in New Issue