renderer_vulkan: Enable logic ops and fix swapchain resizing
This commit is contained in:
@ -414,8 +414,8 @@ vk::Pipeline PipelineCache::BuildPipeline(const PipelineInfo& info) {
|
|||||||
vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA};
|
vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA};
|
||||||
|
|
||||||
const vk::PipelineColorBlendStateCreateInfo color_blending = {
|
const vk::PipelineColorBlendStateCreateInfo color_blending = {
|
||||||
.logicOpEnable = info.blending.logic_op_enable.Value(),
|
.logicOpEnable = !info.blending.blend_enable.Value(),
|
||||||
.logicOp = PicaToVK::LogicOp(info.blending.logic_op),
|
.logicOp = PicaToVK::LogicOp(info.blending.logic_op.Value()),
|
||||||
.attachmentCount = 1,
|
.attachmentCount = 1,
|
||||||
.pAttachments = &colorblend_attachment,
|
.pAttachments = &colorblend_attachment,
|
||||||
.blendConstants = std::array{1.0f, 1.0f, 1.0f, 1.0f}};
|
.blendConstants = std::array{1.0f, 1.0f, 1.0f, 1.0f}};
|
||||||
|
@ -61,8 +61,7 @@ union BlendingState {
|
|||||||
BitField<16, 4, Pica::FramebufferRegs::BlendFactor> dst_alpha_blend_factor;
|
BitField<16, 4, Pica::FramebufferRegs::BlendFactor> dst_alpha_blend_factor;
|
||||||
BitField<20, 3, Pica::FramebufferRegs::BlendEquation> alpha_blend_eq;
|
BitField<20, 3, Pica::FramebufferRegs::BlendEquation> alpha_blend_eq;
|
||||||
BitField<23, 4, u32> color_write_mask;
|
BitField<23, 4, u32> color_write_mask;
|
||||||
BitField<27, 1, u32> logic_op_enable;
|
BitField<27, 4, Pica::FramebufferRegs::LogicOp> logic_op;
|
||||||
BitField<28, 4, Pica::FramebufferRegs::LogicOp> logic_op;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
union VertexBinding {
|
union VertexBinding {
|
||||||
|
@ -33,15 +33,6 @@ void Swapchain::Create(u32 width, u32 height) {
|
|||||||
is_outdated = false;
|
is_outdated = false;
|
||||||
is_suboptimal = false;
|
is_suboptimal = false;
|
||||||
|
|
||||||
// Destroy the previous image views
|
|
||||||
vk::Device device = instance.GetDevice();
|
|
||||||
for (auto& image : swapchain_images) {
|
|
||||||
if (image.image) {
|
|
||||||
device.destroyImageView(image.image_view);
|
|
||||||
device.destroyFramebuffer(image.framebuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch information about the provided surface
|
// Fetch information about the provided surface
|
||||||
Configure(width, height);
|
Configure(width, height);
|
||||||
|
|
||||||
@ -70,6 +61,7 @@ void Swapchain::Create(u32 width, u32 height) {
|
|||||||
.clipped = true,
|
.clipped = true,
|
||||||
.oldSwapchain = swapchain};
|
.oldSwapchain = swapchain};
|
||||||
|
|
||||||
|
vk::Device device = instance.GetDevice();
|
||||||
vk::SwapchainKHR new_swapchain = device.createSwapchainKHR(swapchain_info);
|
vk::SwapchainKHR new_swapchain = device.createSwapchainKHR(swapchain_info);
|
||||||
|
|
||||||
// If an old swapchain exists, destroy it and move the new one to its place.
|
// If an old swapchain exists, destroy it and move the new one to its place.
|
||||||
@ -79,6 +71,12 @@ void Swapchain::Create(u32 width, u32 height) {
|
|||||||
|
|
||||||
auto images = device.getSwapchainImagesKHR(swapchain);
|
auto images = device.getSwapchainImagesKHR(swapchain);
|
||||||
|
|
||||||
|
// Destroy the previous image views
|
||||||
|
for (auto& image : swapchain_images) {
|
||||||
|
device.destroyImageView(image.image_view);
|
||||||
|
device.destroyFramebuffer(image.framebuffer);
|
||||||
|
}
|
||||||
|
|
||||||
swapchain_images.clear();
|
swapchain_images.clear();
|
||||||
swapchain_images.resize(images.size());
|
swapchain_images.resize(images.size());
|
||||||
|
|
||||||
@ -149,21 +147,13 @@ void Swapchain::Present(vk::Semaphore wait_for_present) {
|
|||||||
.pImageIndices = ¤t_image};
|
.pImageIndices = ¤t_image};
|
||||||
|
|
||||||
vk::Queue present_queue = instance.GetPresentQueue();
|
vk::Queue present_queue = instance.GetPresentQueue();
|
||||||
vk::Result result = present_queue.presentKHR(present_info);
|
try {
|
||||||
|
[[maybe_unused]] vk::Result result = present_queue.presentKHR(present_info);
|
||||||
switch (result) {
|
} catch (vk::OutOfDateKHRError err) {
|
||||||
case vk::Result::eSuccess:
|
|
||||||
break;
|
|
||||||
case vk::Result::eSuboptimalKHR:
|
|
||||||
is_suboptimal = true;
|
|
||||||
LOG_DEBUG(Render_Vulkan, "Suboptimal swapchain");
|
|
||||||
break;
|
|
||||||
case vk::Result::eErrorOutOfDateKHR:
|
|
||||||
is_outdated = true;
|
is_outdated = true;
|
||||||
break;
|
} catch (vk::SystemError err) {
|
||||||
default:
|
|
||||||
LOG_CRITICAL(Render_Vulkan, "Swapchain presentation failed");
|
LOG_CRITICAL(Render_Vulkan, "Swapchain presentation failed");
|
||||||
break;
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +228,10 @@ void TextureRuntime::FormatConvert(const Surface& surface, bool upload, std::spa
|
|||||||
switch (surface.pixel_format) {
|
switch (surface.pixel_format) {
|
||||||
case VideoCore::PixelFormat::RGBA4:
|
case VideoCore::PixelFormat::RGBA4:
|
||||||
return Pica::Texture::ConvertRGBA8ToRGBA4(source, dest);
|
return Pica::Texture::ConvertRGBA8ToRGBA4(source, dest);
|
||||||
|
case VideoCore::PixelFormat::RGB8:
|
||||||
|
return Pica::Texture::ConvertRGBAToBGR(source, dest);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,6 +454,8 @@ void TextureRuntime::Transition(vk::CommandBuffer command_buffer, ImageAlloc& al
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderpass_cache.ExitRenderpass();
|
||||||
|
|
||||||
struct LayoutInfo {
|
struct LayoutInfo {
|
||||||
vk::AccessFlags access;
|
vk::AccessFlags access;
|
||||||
vk::PipelineStageFlags stage;
|
vk::PipelineStageFlags stage;
|
||||||
|
Reference in New Issue
Block a user