GS/Vulkan: clang-format

This commit is contained in:
Stenzek 2023-08-09 00:27:58 +10:00 committed by Connor McLaughlin
parent cf523d4215
commit 2432cc6ed2
7 changed files with 200 additions and 178 deletions

View File

@ -15,14 +15,14 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GS/Renderers/Vulkan/GSDeviceVK.h"
#include "GS/Renderers/Vulkan/VKBuilders.h"
#include "GS/Renderers/Vulkan/VKShaderCache.h"
#include "GS/Renderers/Vulkan/VKSwapChain.h"
#include "GS/GS.h" #include "GS/GS.h"
#include "GS/GSGL.h" #include "GS/GSGL.h"
#include "GS/GSPerfMon.h" #include "GS/GSPerfMon.h"
#include "GS/GSUtil.h" #include "GS/GSUtil.h"
#include "GS/Renderers/Vulkan/GSDeviceVK.h"
#include "GS/Renderers/Vulkan/VKBuilders.h"
#include "GS/Renderers/Vulkan/VKShaderCache.h"
#include "GS/Renderers/Vulkan/VKSwapChain.h"
#include "Host.h" #include "Host.h"
@ -33,9 +33,9 @@
#include "imgui.h" #include "imgui.h"
#include <bit> #include <bit>
#include <limits>
#include <mutex> #include <mutex>
#include <sstream> #include <sstream>
#include <limits>
// Tweakables // Tweakables
enum : u32 enum : u32
@ -60,8 +60,14 @@ enum : u32
static u32 s_debug_scope_depth = 0; static u32 s_debug_scope_depth = 0;
#endif #endif
static bool IsDATMConvertShader(ShaderConvert i) { return (i == ShaderConvert::DATM_0 || i == ShaderConvert::DATM_1); } static bool IsDATMConvertShader(ShaderConvert i)
static bool IsDATEModePrimIDInit(u32 flag) { return flag == 1 || flag == 2; } {
return (i == ShaderConvert::DATM_0 || i == ShaderConvert::DATM_1);
}
static bool IsDATEModePrimIDInit(u32 flag)
{
return flag == 1 || flag == 2;
}
static VkAttachmentLoadOp GetLoadOpForTexture(GSTextureVK* tex) static VkAttachmentLoadOp GetLoadOpForTexture(GSTextureVK* tex)
{ {
@ -804,8 +810,8 @@ bool GSDeviceVK::CreateCommandBuffers()
} }
for (u32 i = 0; i < resources.command_buffers.size(); i++) for (u32 i = 0; i < resources.command_buffers.size(); i++)
{ {
Vulkan::SetObjectName(m_device, resources.command_buffers[i], Vulkan::SetObjectName(m_device, resources.command_buffers[i], "Frame %u %sCommand Buffer", frame_index,
"Frame %u %sCommand Buffer", frame_index, (i == 0) ? "Init" : ""); (i == 0) ? "Init" : "");
} }
VkFenceCreateInfo fence_info = {VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT}; VkFenceCreateInfo fence_info = {VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT};
@ -1540,7 +1546,8 @@ VkRenderPass GSDeviceVK::CreateCachedRenderPass(RenderPassCacheKey key)
} }
if (key.depth_format != VK_FORMAT_UNDEFINED) if (key.depth_format != VK_FORMAT_UNDEFINED)
{ {
const VkImageLayout layout = key.depth_sampling ? (UseFeedbackLoopLayout() ? VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT : const VkImageLayout layout =
key.depth_sampling ? (UseFeedbackLoopLayout() ? VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT :
VK_IMAGE_LAYOUT_GENERAL) : VK_IMAGE_LAYOUT_GENERAL) :
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
attachments[num_attachments] = {0, static_cast<VkFormat>(key.depth_format), VK_SAMPLE_COUNT_1_BIT, attachments[num_attachments] = {0, static_cast<VkFormat>(key.depth_format), VK_SAMPLE_COUNT_1_BIT,
@ -2018,8 +2025,7 @@ bool GSDeviceVK::IsSuitableDefaultRenderer()
Console.WriteLn(fmt::format("Using Vulkan GPU '{}' for automatic renderer check.", name)); Console.WriteLn(fmt::format("Using Vulkan GPU '{}' for automatic renderer check.", name));
// Any software rendering (LLVMpipe, SwiftShader). // Any software rendering (LLVMpipe, SwiftShader).
if (StringUtil::StartsWithNoCase(name, "llvmpipe") || if (StringUtil::StartsWithNoCase(name, "llvmpipe") || StringUtil::StartsWithNoCase(name, "SwiftShader"))
StringUtil::StartsWithNoCase(name, "SwiftShader"))
{ {
Console.WriteLn(Color_StrongOrange, "Not using Vulkan for software renderer."); Console.WriteLn(Color_StrongOrange, "Not using Vulkan for software renderer.");
return false; return false;
@ -2093,9 +2099,8 @@ bool GSDeviceVK::Create()
if (!CreateBuffers()) if (!CreateBuffers())
return false; return false;
if (!CompileConvertPipelines() || !CompilePresentPipelines() || if (!CompileConvertPipelines() || !CompilePresentPipelines() || !CompileInterlacePipelines() ||
!CompileInterlacePipelines() || !CompileMergePipelines() || !CompileMergePipelines() || !CompilePostProcessingPipelines() || !InitSpinResources())
!CompilePostProcessingPipelines() || !InitSpinResources())
{ {
Host::ReportErrorAsync("GS", "Failed to compile utility pipelines"); Host::ReportErrorAsync("GS", "Failed to compile utility pipelines");
return false; return false;
@ -2243,15 +2248,13 @@ std::string GSDeviceVK::GetDriverInfo() const
VK_VERSION_MAJOR(driver_version), VK_VERSION_MINOR(driver_version), VK_VERSION_PATCH(driver_version), VK_VERSION_MAJOR(driver_version), VK_VERSION_MINOR(driver_version), VK_VERSION_PATCH(driver_version),
VK_API_VERSION_MAJOR(api_version), VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version), VK_API_VERSION_MAJOR(api_version), VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version),
props.conformanceVersion.major, props.conformanceVersion.minor, props.conformanceVersion.subminor, props.conformanceVersion.major, props.conformanceVersion.minor, props.conformanceVersion.subminor,
props.conformanceVersion.patch, props.driverInfo, props.driverName, props.conformanceVersion.patch, props.driverInfo, props.driverName, m_device_properties.deviceName);
m_device_properties.deviceName);
} }
else else
{ {
ret = StringUtil::StdStringFromFormat("Driver %u.%u.%u\nVulkan %u.%u.%u\n%s", VK_VERSION_MAJOR(driver_version), ret = StringUtil::StdStringFromFormat("Driver %u.%u.%u\nVulkan %u.%u.%u\n%s", VK_VERSION_MAJOR(driver_version),
VK_VERSION_MINOR(driver_version), VK_VERSION_PATCH(driver_version), VK_API_VERSION_MAJOR(api_version), VK_VERSION_MINOR(driver_version), VK_VERSION_PATCH(driver_version), VK_API_VERSION_MAJOR(api_version),
VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version), VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version), m_device_properties.deviceName);
m_device_properties.deviceName);
} }
return ret; return ret;
@ -2344,8 +2347,8 @@ GSDevice::PresentResult GSDeviceVK::BeginPresent(bool frame_skip)
return GSDevice::PresentResult::FrameSkipped; return GSDevice::PresentResult::FrameSkipped;
const VkRenderPassBeginInfo rp = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, const VkRenderPassBeginInfo rp = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr,
GetRenderPass(swap_chain_texture->GetVkFormat(), VK_FORMAT_UNDEFINED, GetRenderPass(swap_chain_texture->GetVkFormat(), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_CLEAR,
VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_STORE_OP_STORE), VK_ATTACHMENT_STORE_OP_STORE),
fb, fb,
{{0, 0}, {static_cast<u32>(swap_chain_texture->GetWidth()), static_cast<u32>(swap_chain_texture->GetHeight())}}, {{0, 0}, {static_cast<u32>(swap_chain_texture->GetWidth()), static_cast<u32>(swap_chain_texture->GetHeight())}},
1u, &s_present_clear_color}; 1u, &s_present_clear_color};
@ -2599,7 +2602,8 @@ bool GSDeviceVK::CheckFeatures()
const bool isAMD = (vendorID == 0x1002 || vendorID == 0x1022); const bool isAMD = (vendorID == 0x1002 || vendorID == 0x1022);
// const bool isNVIDIA = (vendorID == 0x10DE); // const bool isNVIDIA = (vendorID == 0x10DE);
m_features.framebuffer_fetch = m_optional_extensions.vk_ext_rasterization_order_attachment_access && !GSConfig.DisableFramebufferFetch; m_features.framebuffer_fetch =
m_optional_extensions.vk_ext_rasterization_order_attachment_access && !GSConfig.DisableFramebufferFetch;
m_features.texture_barrier = GSConfig.OverrideTextureBarriers != 0; m_features.texture_barrier = GSConfig.OverrideTextureBarriers != 0;
m_features.broken_point_sampler = isAMD; m_features.broken_point_sampler = isAMD;
@ -2617,8 +2621,7 @@ bool GSDeviceVK::CheckFeatures()
m_features.provoking_vertex_last = m_optional_extensions.vk_ext_provoking_vertex; m_features.provoking_vertex_last = m_optional_extensions.vk_ext_provoking_vertex;
m_features.dual_source_blend = m_device_features.dualSrcBlend && !GSConfig.DisableDualSourceBlend; m_features.dual_source_blend = m_device_features.dualSrcBlend && !GSConfig.DisableDualSourceBlend;
m_features.clip_control = true; m_features.clip_control = true;
m_features.vs_expand = m_features.vs_expand = !GSConfig.DisableVertexShaderExpand && m_optional_extensions.vk_khr_shader_draw_parameters;
!GSConfig.DisableVertexShaderExpand && m_optional_extensions.vk_khr_shader_draw_parameters;
if (!m_features.dual_source_blend) if (!m_features.dual_source_blend)
Console.Warning("Vulkan driver is missing dual-source blending. This will have an impact on performance."); Console.Warning("Vulkan driver is missing dual-source blending. This will have an impact on performance.");
@ -2627,13 +2630,15 @@ bool GSDeviceVK::CheckFeatures()
Console.Warning("Texture buffers are disabled. This may break some graphical effects."); Console.Warning("Texture buffers are disabled. This may break some graphical effects.");
if (!m_optional_extensions.vk_ext_line_rasterization) if (!m_optional_extensions.vk_ext_line_rasterization)
Console.WriteLn("VK_EXT_line_rasterization or the BRESENHAM mode is not supported, this may cause rendering inaccuracies."); Console.WriteLn(
"VK_EXT_line_rasterization or the BRESENHAM mode is not supported, this may cause rendering inaccuracies.");
// Test for D32S8 support. // Test for D32S8 support.
{ {
VkFormatProperties props = {}; VkFormatProperties props = {};
vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_D32_SFLOAT_S8_UINT, &props); vkGetPhysicalDeviceFormatProperties(m_physical_device, VK_FORMAT_D32_SFLOAT_S8_UINT, &props);
m_features.stencil_buffer = ((props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0); m_features.stencil_buffer =
((props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0);
} }
// Fbfetch is useless if we don't have barriers enabled. // Fbfetch is useless if we don't have barriers enabled.
@ -2647,8 +2652,8 @@ bool GSDeviceVK::CheckFeatures()
// whether we can do point/line expand depends on the range of the device // whether we can do point/line expand depends on the range of the device
const float f_upscale = static_cast<float>(GSConfig.UpscaleMultiplier); const float f_upscale = static_cast<float>(GSConfig.UpscaleMultiplier);
m_features.point_expand = m_features.point_expand = (m_device_features.largePoints && limits.pointSizeRange[0] <= f_upscale &&
(m_device_features.largePoints && limits.pointSizeRange[0] <= f_upscale && limits.pointSizeRange[1] >= f_upscale); limits.pointSizeRange[1] >= f_upscale);
m_features.line_expand = m_features.line_expand =
(m_device_features.wideLines && limits.lineWidthRange[0] <= f_upscale && limits.lineWidthRange[1] >= f_upscale); (m_device_features.wideLines && limits.lineWidthRange[0] <= f_upscale && limits.lineWidthRange[1] >= f_upscale);
@ -2664,7 +2669,8 @@ bool GSDeviceVK::CheckFeatures()
for (u32 fmt = static_cast<u32>(GSTexture::Format::Color); fmt < static_cast<u32>(GSTexture::Format::PrimID); fmt++) for (u32 fmt = static_cast<u32>(GSTexture::Format::Color); fmt < static_cast<u32>(GSTexture::Format::PrimID); fmt++)
{ {
const VkFormat vkfmt = LookupNativeFormat(static_cast<GSTexture::Format>(fmt)); const VkFormat vkfmt = LookupNativeFormat(static_cast<GSTexture::Format>(fmt));
const VkFormatFeatureFlags bits = (static_cast<GSTexture::Format>(fmt) == GSTexture::Format::DepthStencil) ? const VkFormatFeatureFlags bits =
(static_cast<GSTexture::Format>(fmt) == GSTexture::Format::DepthStencil) ?
(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) : (VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) :
(VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); (VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
@ -2685,7 +2691,8 @@ bool GSDeviceVK::CheckFeatures()
if (!m_features.texture_barrier && !m_features.stencil_buffer) if (!m_features.texture_barrier && !m_features.stencil_buffer)
{ {
Host::AddKeyedOSDMessage("GSDeviceVK_NoTextureBarrierOrStencilBuffer", Host::AddKeyedOSDMessage("GSDeviceVK_NoTextureBarrierOrStencilBuffer",
TRANSLATE_STR("GS", "Stencil buffers and texture barriers are both unavailable, this will break some graphical effects."), TRANSLATE_STR("GS",
"Stencil buffers and texture barriers are both unavailable, this will break some graphical effects."),
Host::OSD_WARNING_DURATION); Host::OSD_WARNING_DURATION);
} }
@ -2735,8 +2742,10 @@ VkFormat GSDeviceVK::LookupNativeFormat(GSTexture::Format format) const
GSTexture* GSDeviceVK::CreateSurface(GSTexture::Type type, int width, int height, int levels, GSTexture::Format format) GSTexture* GSDeviceVK::CreateSurface(GSTexture::Type type, int width, int height, int levels, GSTexture::Format format)
{ {
const u32 clamped_width = static_cast<u32>(std::clamp<int>(width, 1, m_device_properties.limits.maxImageDimension2D)); const u32 clamped_width =
const u32 clamped_height = static_cast<u32>(std::clamp<int>(height, 1, m_device_properties.limits.maxImageDimension2D)); static_cast<u32>(std::clamp<int>(width, 1, m_device_properties.limits.maxImageDimension2D));
const u32 clamped_height =
static_cast<u32>(std::clamp<int>(height, 1, m_device_properties.limits.maxImageDimension2D));
std::unique_ptr<GSTexture> tex(GSTextureVK::Create(type, format, clamped_width, clamped_height, levels)); std::unique_ptr<GSTexture> tex(GSTextureVK::Create(type, format, clamped_width, clamped_height, levels));
if (!tex) if (!tex)
@ -2797,7 +2806,8 @@ void GSDeviceVK::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r,
// otherwise we need to do an attachment clear // otherwise we need to do an attachment clear
const bool depth = (dTexVK->GetType() == GSTexture::Type::DepthStencil); const bool depth = (dTexVK->GetType() == GSTexture::Type::DepthStencil);
OMSetRenderTargets(depth ? nullptr : dTexVK, depth ? dTexVK : nullptr, dtex_rc); OMSetRenderTargets(depth ? nullptr : dTexVK, depth ? dTexVK : nullptr, dtex_rc);
BeginRenderPassForStretchRect(dTexVK, dtex_rc, GSVector4i(destX, destY, destX + r.width(), destY + r.height())); BeginRenderPassForStretchRect(
dTexVK, dtex_rc, GSVector4i(destX, destY, destX + r.width(), destY + r.height()));
// so use an attachment clear // so use an attachment clear
VkClearAttachment ca; VkClearAttachment ca;
@ -2807,7 +2817,7 @@ void GSDeviceVK::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r,
ca.clearValue.depthStencil.stencil = 0; ca.clearValue.depthStencil.stencil = 0;
ca.colorAttachment = 0; ca.colorAttachment = 0;
const VkClearRect cr = { {{0, 0}, {static_cast<u32>(r.width()), static_cast<u32>(r.height())}}, 0u, 1u }; const VkClearRect cr = {{{0, 0}, {static_cast<u32>(r.width()), static_cast<u32>(r.height())}}, 0u, 1u};
vkCmdClearAttachments(GetCurrentCommandBuffer(), 1, &ca, 1, &cr); vkCmdClearAttachments(GetCurrentCommandBuffer(), 1, &ca, 1, &cr);
return; return;
} }
@ -2822,8 +2832,10 @@ void GSDeviceVK::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r,
dTexVK->CommitClear(); dTexVK->CommitClear();
// *now* we can do a normal image copy. // *now* we can do a normal image copy.
const VkImageAspectFlags src_aspect = (sTexVK->IsDepthStencil()) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; const VkImageAspectFlags src_aspect =
const VkImageAspectFlags dst_aspect = (dTexVK->IsDepthStencil()) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; (sTexVK->IsDepthStencil()) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
const VkImageAspectFlags dst_aspect =
(dTexVK->IsDepthStencil()) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
const VkImageCopy ic = {{src_aspect, 0u, 0u, 1u}, {r.left, r.top, 0u}, {dst_aspect, 0u, 0u, 1u}, const VkImageCopy ic = {{src_aspect, 0u, 0u, 1u}, {r.left, r.top, 0u}, {dst_aspect, 0u, 0u, 1u},
{static_cast<s32>(destX), static_cast<s32>(destY), 0u}, {static_cast<s32>(destX), static_cast<s32>(destY), 0u},
{static_cast<u32>(r.width()), static_cast<u32>(r.height()), 1u}}; {static_cast<u32>(r.width()), static_cast<u32>(r.height()), 1u}};
@ -2837,8 +2849,8 @@ void GSDeviceVK::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r,
dTexVK->TransitionToLayout( dTexVK->TransitionToLayout(
(dTexVK == sTexVK) ? GSTextureVK::Layout::TransferSelf : GSTextureVK::Layout::TransferDst); (dTexVK == sTexVK) ? GSTextureVK::Layout::TransferSelf : GSTextureVK::Layout::TransferDst);
vkCmdCopyImage(GetCurrentCommandBuffer(), sTexVK->GetImage(), vkCmdCopyImage(GetCurrentCommandBuffer(), sTexVK->GetImage(), sTexVK->GetVkLayout(), dTexVK->GetImage(),
sTexVK->GetVkLayout(), dTexVK->GetImage(), dTexVK->GetVkLayout(), 1, &ic); dTexVK->GetVkLayout(), 1, &ic);
dTexVK->SetState(GSTexture::State::Dirty); dTexVK->SetState(GSTexture::State::Dirty);
} }
@ -2989,7 +3001,8 @@ void GSDeviceVK::DoMultiStretchRects(
SetUtilityTexture(rects[0].src, rects[0].linear ? m_linear_sampler : m_point_sampler); SetUtilityTexture(rects[0].src, rects[0].linear ? m_linear_sampler : m_point_sampler);
pxAssert(shader == ShaderConvert::COPY || rects[0].wmask.wrgba == 0xf); pxAssert(shader == ShaderConvert::COPY || rects[0].wmask.wrgba == 0xf);
SetPipeline((rects[0].wmask.wrgba != 0xf) ? m_color_copy[rects[0].wmask.wrgba] : m_convert[static_cast<int>(shader)]); SetPipeline(
(rects[0].wmask.wrgba != 0xf) ? m_color_copy[rects[0].wmask.wrgba] : m_convert[static_cast<int>(shader)]);
if (ApplyUtilityState()) if (ApplyUtilityState())
DrawIndexedPrimitive(); DrawIndexedPrimitive();
@ -3025,8 +3038,8 @@ void GSDeviceVK::BeginRenderPassForStretchRect(
else else
{ {
// integer formats, etc // integer formats, etc
const VkRenderPass rp = GetRenderPass(dTex->GetVkFormat(), VK_FORMAT_UNDEFINED, const VkRenderPass rp = GetRenderPass(dTex->GetVkFormat(), VK_FORMAT_UNDEFINED, load_op,
load_op, VK_ATTACHMENT_STORE_OP_STORE, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE); VK_ATTACHMENT_STORE_OP_STORE, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE);
if (load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) if (load_op == VK_ATTACHMENT_LOAD_OP_CLEAR)
{ {
BeginClearRenderPass(rp, dtex_rc, dTex->GetClearColor()); BeginClearRenderPass(rp, dtex_rc, dTex->GetClearColor());
@ -3053,8 +3066,7 @@ void GSDeviceVK::DoStretchRect(GSTextureVK* sTex, const GSVector4& sRect, GSText
const bool is_present = (!dTex); const bool is_present = (!dTex);
const bool depth = (dTex && dTex->GetType() == GSTexture::Type::DepthStencil); const bool depth = (dTex && dTex->GetType() == GSTexture::Type::DepthStencil);
const GSVector2i size( const GSVector2i size(is_present ? GSVector2i(GetWindowWidth(), GetWindowHeight()) : dTex->GetSize());
is_present ? GSVector2i(GetWindowWidth(), GetWindowHeight()) : dTex->GetSize());
const GSVector4i dtex_rc(0, 0, size.x, size.y); const GSVector4i dtex_rc(0, 0, size.x, size.y);
const GSVector4i dst_rc(GSVector4i(dRect).rintersect(dtex_rc)); const GSVector4i dst_rc(GSVector4i(dRect).rintersect(dtex_rc));
@ -3119,12 +3131,13 @@ void GSDeviceVK::BlitRect(GSTexture* sTex, const GSVector4i& sRect, u32 sLevel,
const VkImageBlit ib{{aspect, sLevel, 0u, 1u}, {{sRect.left, sRect.top, 0}, {sRect.right, sRect.bottom, 1}}, const VkImageBlit ib{{aspect, sLevel, 0u, 1u}, {{sRect.left, sRect.top, 0}, {sRect.right, sRect.bottom, 1}},
{aspect, dLevel, 0u, 1u}, {{dRect.left, dRect.top, 0}, {dRect.right, dRect.bottom, 1}}}; {aspect, dLevel, 0u, 1u}, {{dRect.left, dRect.top, 0}, {dRect.right, dRect.bottom, 1}}};
vkCmdBlitImage(GetCurrentCommandBuffer(), sTexVK->GetImage(), vkCmdBlitImage(GetCurrentCommandBuffer(), sTexVK->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dTexVK->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &ib, dTexVK->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &ib,
linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST); linear ? VK_FILTER_LINEAR : VK_FILTER_NEAREST);
} }
void GSDeviceVK::UpdateCLUTTexture(GSTexture* sTex, float sScale, u32 offsetX, u32 offsetY, GSTexture* dTex, u32 dOffset, u32 dSize) void GSDeviceVK::UpdateCLUTTexture(
GSTexture* sTex, float sScale, u32 offsetX, u32 offsetY, GSTexture* dTex, u32 dOffset, u32 dSize)
{ {
// Super annoying, but apparently NVIDIA doesn't like floats/ints packed together in the same vec4? // Super annoying, but apparently NVIDIA doesn't like floats/ints packed together in the same vec4?
struct Uniforms struct Uniforms
@ -3143,7 +3156,8 @@ void GSDeviceVK::UpdateCLUTTexture(GSTexture* sTex, float sScale, u32 offsetX, u
m_convert[static_cast<int>(shader)], false, true); m_convert[static_cast<int>(shader)], false, true);
} }
void GSDeviceVK::ConvertToIndexedTexture(GSTexture* sTex, float sScale, u32 offsetX, u32 offsetY, u32 SBW, u32 SPSM, GSTexture* dTex, u32 DBW, u32 DPSM) void GSDeviceVK::ConvertToIndexedTexture(
GSTexture* sTex, float sScale, u32 offsetX, u32 offsetY, u32 SBW, u32 SPSM, GSTexture* dTex, u32 DBW, u32 DPSM)
{ {
struct Uniforms struct Uniforms
{ {
@ -3174,7 +3188,7 @@ void GSDeviceVK::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
const bool feedback_write_2 = PMODE.EN2 && sTex[2] != nullptr && EXTBUF.FBIN == 1; const bool feedback_write_2 = PMODE.EN2 && sTex[2] != nullptr && EXTBUF.FBIN == 1;
const bool feedback_write_1 = PMODE.EN1 && sTex[2] != nullptr && EXTBUF.FBIN == 0; const bool feedback_write_1 = PMODE.EN1 && sTex[2] != nullptr && EXTBUF.FBIN == 0;
const bool feedback_write_2_but_blend_bg = feedback_write_2 && PMODE.SLBG == 1; const bool feedback_write_2_but_blend_bg = feedback_write_2 && PMODE.SLBG == 1;
const VkSampler& sampler = linear? m_linear_sampler : m_point_sampler; const VkSampler& sampler = linear ? m_linear_sampler : m_point_sampler;
// Merge the 2 source textures (sTex[0],sTex[1]). Final results go to dTex. Feedback write will go to sTex[2]. // Merge the 2 source textures (sTex[0],sTex[1]). Final results go to dTex. Feedback write will go to sTex[2].
// If either 2nd output is disabled or SLBG is 1, a background color will be used. // If either 2nd output is disabled or SLBG is 1, a background color will be used.
// Note: background color is also used when outside of the unit rectangle area // Note: background color is also used when outside of the unit rectangle area
@ -3286,7 +3300,8 @@ void GSDeviceVK::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
static_cast<GSTextureVK*>(dTex)->TransitionToLayout(GSTextureVK::Layout::ShaderReadOnly); static_cast<GSTextureVK*>(dTex)->TransitionToLayout(GSTextureVK::Layout::ShaderReadOnly);
} }
void GSDeviceVK::DoInterlace(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderInterlace shader, bool linear, const InterlaceConstantBuffer& cb) void GSDeviceVK::DoInterlace(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect,
ShaderInterlace shader, bool linear, const InterlaceConstantBuffer& cb)
{ {
static_cast<GSTextureVK*>(dTex)->TransitionToLayout(GSTextureVK::Layout::ColorAttachment); static_cast<GSTextureVK*>(dTex)->TransitionToLayout(GSTextureVK::Layout::ColorAttachment);
@ -3374,7 +3389,8 @@ void GSDeviceVK::IASetIndexBuffer(const void* index, size_t count)
SetIndexBuffer(m_index_stream_buffer.GetBuffer(), 0, VK_INDEX_TYPE_UINT16); SetIndexBuffer(m_index_stream_buffer.GetBuffer(), 0, VK_INDEX_TYPE_UINT16);
} }
void GSDeviceVK::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i& scissor, FeedbackLoopFlag feedback_loop) void GSDeviceVK::OMSetRenderTargets(
GSTexture* rt, GSTexture* ds, const GSVector4i& scissor, FeedbackLoopFlag feedback_loop)
{ {
GSTextureVK* vkRt = static_cast<GSTextureVK*>(rt); GSTextureVK* vkRt = static_cast<GSTextureVK*>(rt);
GSTextureVK* vkDs = static_cast<GSTextureVK*>(ds); GSTextureVK* vkDs = static_cast<GSTextureVK*>(ds);
@ -3388,7 +3404,8 @@ void GSDeviceVK::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector
if (vkRt) if (vkRt)
{ {
m_current_framebuffer = vkRt->GetLinkedFramebuffer(vkDs, (feedback_loop & FeedbackLoopFlag_ReadAndWriteRT) != 0); m_current_framebuffer =
vkRt->GetLinkedFramebuffer(vkDs, (feedback_loop & FeedbackLoopFlag_ReadAndWriteRT) != 0);
} }
else else
{ {
@ -3658,9 +3675,8 @@ bool GSDeviceVK::CreateBuffers()
SetVertexBuffer(m_vertex_stream_buffer.GetBuffer(), 0); SetVertexBuffer(m_vertex_stream_buffer.GetBuffer(), 0);
if (!AllocatePreinitializedGPUBuffer(EXPAND_BUFFER_SIZE, &m_expand_index_buffer, if (!AllocatePreinitializedGPUBuffer(EXPAND_BUFFER_SIZE, &m_expand_index_buffer, &m_expand_index_buffer_allocation,
&m_expand_index_buffer_allocation, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, &GSDevice::GenerateExpansionIndexBuffer))
&GSDevice::GenerateExpansionIndexBuffer))
{ {
Host::ReportErrorAsync("GS", "Failed to allocate expansion index buffer"); Host::ReportErrorAsync("GS", "Failed to allocate expansion index buffer");
return false; return false;
@ -3798,8 +3814,8 @@ bool GSDeviceVK::CreateRenderPasses()
GET(m_utility_depth_render_pass_discard, VK_FORMAT_UNDEFINED, depth_format, false, false, GET(m_utility_depth_render_pass_discard, VK_FORMAT_UNDEFINED, depth_format, false, false,
VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_LOAD_OP_DONT_CARE); VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_LOAD_OP_DONT_CARE);
m_date_setup_render_pass = GetRenderPass(VK_FORMAT_UNDEFINED, depth_format, m_date_setup_render_pass = GetRenderPass(VK_FORMAT_UNDEFINED, depth_format, VK_ATTACHMENT_LOAD_OP_LOAD,
VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_OP_STORE, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_OP_STORE, VK_ATTACHMENT_STORE_OP_STORE, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_STORE_OP_STORE,
m_features.stencil_buffer ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE, m_features.stencil_buffer ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
m_features.stencil_buffer ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE); m_features.stencil_buffer ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE);
if (m_date_setup_render_pass == VK_NULL_HANDLE) if (m_date_setup_render_pass == VK_NULL_HANDLE)
@ -3847,14 +3863,14 @@ bool GSDeviceVK::CompileConvertPipelines()
case ShaderConvert::RGBA8_TO_16_BITS: case ShaderConvert::RGBA8_TO_16_BITS:
case ShaderConvert::FLOAT32_TO_16_BITS: case ShaderConvert::FLOAT32_TO_16_BITS:
{ {
rp = GetRenderPass(LookupNativeFormat(GSTexture::Format::UInt16), rp = GetRenderPass(LookupNativeFormat(GSTexture::Format::UInt16), VK_FORMAT_UNDEFINED,
VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_DONT_CARE); VK_ATTACHMENT_LOAD_OP_DONT_CARE);
} }
break; break;
case ShaderConvert::FLOAT32_TO_32_BITS: case ShaderConvert::FLOAT32_TO_32_BITS:
{ {
rp = GetRenderPass(LookupNativeFormat(GSTexture::Format::UInt32), rp = GetRenderPass(LookupNativeFormat(GSTexture::Format::UInt32), VK_FORMAT_UNDEFINED,
VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_DONT_CARE); VK_ATTACHMENT_LOAD_OP_DONT_CARE);
} }
break; break;
case ShaderConvert::DATM_0: case ShaderConvert::DATM_0:
@ -3865,10 +3881,8 @@ bool GSDeviceVK::CompileConvertPipelines()
break; break;
default: default:
{ {
rp = GetRenderPass( rp = GetRenderPass(LookupNativeFormat(depth ? GSTexture::Format::Invalid : GSTexture::Format::Color),
LookupNativeFormat(depth ? GSTexture::Format::Invalid : GSTexture::Format::Color), LookupNativeFormat(depth ? GSTexture::Format::DepthStencil : GSTexture::Format::Invalid),
LookupNativeFormat(
depth ? GSTexture::Format::DepthStencil : GSTexture::Format::Invalid),
VK_ATTACHMENT_LOAD_OP_DONT_CARE); VK_ATTACHMENT_LOAD_OP_DONT_CARE);
} }
break; break;
@ -3900,8 +3914,7 @@ bool GSDeviceVK::CompileConvertPipelines()
ScopedGuard ps_guard([this, &ps]() { vkDestroyShaderModule(m_device, ps, nullptr); }); ScopedGuard ps_guard([this, &ps]() { vkDestroyShaderModule(m_device, ps, nullptr); });
gpb.SetFragmentShader(ps); gpb.SetFragmentShader(ps);
m_convert[index] = m_convert[index] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
if (!m_convert[index]) if (!m_convert[index])
return false; return false;
@ -3917,36 +3930,33 @@ bool GSDeviceVK::CompileConvertPipelines()
gpb.ClearBlendAttachments(); gpb.ClearBlendAttachments();
gpb.SetBlendAttachment(0, false, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD, gpb.SetBlendAttachment(0, false, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD,
VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD, static_cast<VkColorComponentFlags>(i)); VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD, static_cast<VkColorComponentFlags>(i));
m_color_copy[i] = m_color_copy[i] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
if (!m_color_copy[i]) if (!m_color_copy[i])
return false; return false;
Vulkan::SetObjectName(m_device, m_color_copy[i], Vulkan::SetObjectName(m_device, m_color_copy[i], "Color copy pipeline (r=%u, g=%u, b=%u, a=%u)", i & 1u,
"Color copy pipeline (r=%u, g=%u, b=%u, a=%u)", i & 1u, (i >> 1) & 1u, (i >> 2) & 1u, (i >> 1) & 1u, (i >> 2) & 1u, (i >> 3) & 1u);
(i >> 3) & 1u);
} }
} }
else if (i == ShaderConvert::HDR_INIT || i == ShaderConvert::HDR_RESOLVE) else if (i == ShaderConvert::HDR_INIT || i == ShaderConvert::HDR_RESOLVE)
{ {
const bool is_setup = i == ShaderConvert::HDR_INIT; const bool is_setup = i == ShaderConvert::HDR_INIT;
VkPipeline (&arr)[2][2] = *(is_setup ? &m_hdr_setup_pipelines : &m_hdr_finish_pipelines); VkPipeline(&arr)[2][2] = *(is_setup ? &m_hdr_setup_pipelines : &m_hdr_finish_pipelines);
for (u32 ds = 0; ds < 2; ds++) for (u32 ds = 0; ds < 2; ds++)
{ {
for (u32 fbl = 0; fbl < 2; fbl++) for (u32 fbl = 0; fbl < 2; fbl++)
{ {
pxAssert(!arr[ds][fbl]); pxAssert(!arr[ds][fbl]);
gpb.SetRenderPass( gpb.SetRenderPass(GetTFXRenderPass(true, ds != 0, is_setup, DATE_RENDER_PASS_NONE, fbl != 0, false,
GetTFXRenderPass(true, ds != 0, is_setup, DATE_RENDER_PASS_NONE, fbl != 0, false,
VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_LOAD_OP_DONT_CARE), VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_LOAD_OP_DONT_CARE),
0); 0);
arr[ds][fbl] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false); arr[ds][fbl] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
if (!arr[ds][fbl]) if (!arr[ds][fbl])
return false; return false;
Vulkan::SetObjectName(m_device, arr[ds][fbl], Vulkan::SetObjectName(m_device, arr[ds][fbl], "HDR %s/copy pipeline (ds=%u, fbl=%u)",
"HDR %s/copy pipeline (ds=%u, fbl=%u)", is_setup ? "setup" : "finish", i, ds, fbl); is_setup ? "setup" : "finish", i, ds, fbl);
} }
} }
} }
@ -3957,11 +3967,11 @@ bool GSDeviceVK::CompileConvertPipelines()
{ {
for (u32 clear = 0; clear < 2; clear++) for (u32 clear = 0; clear < 2; clear++)
{ {
m_date_image_setup_render_passes[ds][clear] = m_date_image_setup_render_passes[ds][clear] = GetRenderPass(LookupNativeFormat(GSTexture::Format::PrimID),
GetRenderPass(LookupNativeFormat(GSTexture::Format::PrimID),
ds ? LookupNativeFormat(GSTexture::Format::DepthStencil) : VK_FORMAT_UNDEFINED, ds ? LookupNativeFormat(GSTexture::Format::DepthStencil) : VK_FORMAT_UNDEFINED,
VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE,
ds ? (clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD) : VK_ATTACHMENT_LOAD_OP_DONT_CARE, ds ? (clear ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_LOAD) :
VK_ATTACHMENT_LOAD_OP_DONT_CARE,
ds ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE); ds ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE);
} }
} }
@ -4001,8 +4011,8 @@ bool GSDeviceVK::CompileConvertPipelines()
bool GSDeviceVK::CompilePresentPipelines() bool GSDeviceVK::CompilePresentPipelines()
{ {
// we may not have a swap chain if running in headless mode. // we may not have a swap chain if running in headless mode.
m_swap_chain_render_pass = GetRenderPass( m_swap_chain_render_pass =
m_swap_chain ? m_swap_chain->GetTextureFormat() : VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_UNDEFINED); GetRenderPass(m_swap_chain ? m_swap_chain->GetTextureFormat() : VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_UNDEFINED);
if (m_swap_chain_render_pass == VK_NULL_HANDLE) if (m_swap_chain_render_pass == VK_NULL_HANDLE)
return false; return false;
@ -4044,8 +4054,7 @@ bool GSDeviceVK::CompilePresentPipelines()
ScopedGuard ps_guard([this, &ps]() { vkDestroyShaderModule(m_device, ps, nullptr); }); ScopedGuard ps_guard([this, &ps]() { vkDestroyShaderModule(m_device, ps, nullptr); });
gpb.SetFragmentShader(ps); gpb.SetFragmentShader(ps);
m_present[index] = m_present[index] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
if (!m_present[index]) if (!m_present[index])
return false; return false;
@ -4065,8 +4074,8 @@ bool GSDeviceVK::CompileInterlacePipelines()
return false; return false;
} }
VkRenderPass rp = GetRenderPass( VkRenderPass rp =
LookupNativeFormat(GSTexture::Format::Color), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD); GetRenderPass(LookupNativeFormat(GSTexture::Format::Color), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD);
if (!rp) if (!rp)
return false; return false;
@ -4096,8 +4105,7 @@ bool GSDeviceVK::CompileInterlacePipelines()
gpb.SetFragmentShader(ps); gpb.SetFragmentShader(ps);
m_interlace[i] = m_interlace[i] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
vkDestroyShaderModule(m_device, ps, nullptr); vkDestroyShaderModule(m_device, ps, nullptr);
if (!m_interlace[i]) if (!m_interlace[i])
return false; return false;
@ -4117,8 +4125,8 @@ bool GSDeviceVK::CompileMergePipelines()
return false; return false;
} }
VkRenderPass rp = GetRenderPass( VkRenderPass rp =
LookupNativeFormat(GSTexture::Format::Color), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD); GetRenderPass(LookupNativeFormat(GSTexture::Format::Color), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD);
if (!rp) if (!rp)
return false; return false;
@ -4146,8 +4154,8 @@ bool GSDeviceVK::CompileMergePipelines()
return false; return false;
gpb.SetFragmentShader(ps); gpb.SetFragmentShader(ps);
gpb.SetBlendAttachment(0, true, VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, gpb.SetBlendAttachment(0, true, VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_OP_ADD,
VK_BLEND_OP_ADD, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD); VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD);
m_merge[i] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false); m_merge[i] = gpb.Create(m_device, g_vulkan_shader_cache->GetPipelineCache(true), false);
vkDestroyShaderModule(m_device, ps, nullptr); vkDestroyShaderModule(m_device, ps, nullptr);
@ -4162,8 +4170,8 @@ bool GSDeviceVK::CompileMergePipelines()
bool GSDeviceVK::CompilePostProcessingPipelines() bool GSDeviceVK::CompilePostProcessingPipelines()
{ {
VkRenderPass rp = GetRenderPass( VkRenderPass rp =
LookupNativeFormat(GSTexture::Format::Color), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD); GetRenderPass(LookupNativeFormat(GSTexture::Format::Color), VK_FORMAT_UNDEFINED, VK_ATTACHMENT_LOAD_OP_LOAD);
if (!rp) if (!rp)
return false; return false;
@ -4411,8 +4419,8 @@ void GSDeviceVK::RenderImGui()
if (ApplyUtilityState()) if (ApplyUtilityState())
{ {
vkCmdDrawIndexed(GetCurrentCommandBuffer(), pcmd->ElemCount, 1, vkCmdDrawIndexed(GetCurrentCommandBuffer(), pcmd->ElemCount, 1, m_index.start + pcmd->IdxOffset,
m_index.start + pcmd->IdxOffset, vertex_offset + pcmd->VtxOffset, 0); vertex_offset + pcmd->VtxOffset, 0);
} }
} }
@ -4434,7 +4442,8 @@ void GSDeviceVK::RenderBlankFrame()
sctex->TransitionToLayout(cmdbuffer, GSTextureVK::Layout::TransferDst); sctex->TransitionToLayout(cmdbuffer, GSTextureVK::Layout::TransferDst);
constexpr VkImageSubresourceRange srr = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; constexpr VkImageSubresourceRange srr = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
vkCmdClearColorImage(cmdbuffer, sctex->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &s_present_clear_color.color, 1, &srr); vkCmdClearColorImage(
cmdbuffer, sctex->GetImage(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &s_present_clear_color.color, 1, &srr);
m_swap_chain->GetCurrentTexture()->TransitionToLayout(cmdbuffer, GSTextureVK::Layout::PresentSrc); m_swap_chain->GetCurrentTexture()->TransitionToLayout(cmdbuffer, GSTextureVK::Layout::PresentSrc);
SubmitCommandBuffer(m_swap_chain.get(), !m_swap_chain->IsPresentModeSynchronizing()); SubmitCommandBuffer(m_swap_chain.get(), !m_swap_chain->IsPresentModeSynchronizing());
@ -4443,7 +4452,8 @@ void GSDeviceVK::RenderBlankFrame()
InvalidateCachedState(); InvalidateCachedState();
} }
bool GSDeviceVK::DoCAS(GSTexture* sTex, GSTexture* dTex, bool sharpen_only, const std::array<u32, NUM_CAS_CONSTANTS>& constants) bool GSDeviceVK::DoCAS(
GSTexture* sTex, GSTexture* dTex, bool sharpen_only, const std::array<u32, NUM_CAS_CONSTANTS>& constants)
{ {
EndRenderPass(); EndRenderPass();
@ -4465,7 +4475,8 @@ bool GSDeviceVK::DoCAS(GSTexture* sTex, GSTexture* dTex, bool sharpen_only, cons
const int dispatchX = (dTex->GetWidth() + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; const int dispatchX = (dTex->GetWidth() + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
const int dispatchY = (dTex->GetHeight() + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; const int dispatchY = (dTex->GetHeight() + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
vkCmdPushConstants(cmdbuf, m_cas_pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, NUM_CAS_CONSTANTS * sizeof(u32), constants.data()); vkCmdPushConstants(cmdbuf, m_cas_pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, NUM_CAS_CONSTANTS * sizeof(u32),
constants.data());
vkCmdBindPipeline(cmdbuf, VK_PIPELINE_BIND_POINT_COMPUTE, m_cas_pipelines[static_cast<u8>(sharpen_only)]); vkCmdBindPipeline(cmdbuf, VK_PIPELINE_BIND_POINT_COMPUTE, m_cas_pipelines[static_cast<u8>(sharpen_only)]);
vkCmdDispatch(cmdbuf, dispatchX, dispatchY, 1); vkCmdDispatch(cmdbuf, dispatchX, dispatchY, 1);
@ -4747,7 +4758,8 @@ VkPipeline GSDeviceVK::CreateTFXPipeline(const PipelineSelector& p)
} }
gpb.SetPrimitiveTopology(topology_lookup[p.topology]); gpb.SetPrimitiveTopology(topology_lookup[p.topology]);
gpb.SetRasterizationState(VK_POLYGON_MODE_FILL, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE); gpb.SetRasterizationState(VK_POLYGON_MODE_FILL, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
if (p.topology == static_cast<u8>(GSHWDrawConfig::Topology::Line) && m_optional_extensions.vk_ext_line_rasterization) if (p.topology == static_cast<u8>(GSHWDrawConfig::Topology::Line) &&
m_optional_extensions.vk_ext_line_rasterization)
gpb.SetLineRasterizationMode(VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT); gpb.SetLineRasterizationMode(VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT);
gpb.SetDynamicViewportAndScissorState(); gpb.SetDynamicViewportAndScissorState();
gpb.AddDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS); gpb.AddDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
@ -5125,7 +5137,10 @@ void GSDeviceVK::UnbindTexture(GSTextureVK* tex)
} }
} }
bool GSDeviceVK::InRenderPass() { return m_current_render_pass != VK_NULL_HANDLE; } bool GSDeviceVK::InRenderPass()
{
return m_current_render_pass != VK_NULL_HANDLE;
}
void GSDeviceVK::BeginRenderPass(VkRenderPass rp, const GSVector4i& rect) void GSDeviceVK::BeginRenderPass(VkRenderPass rp, const GSVector4i& rect)
{ {
@ -5613,8 +5628,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
{ {
EndRenderPass(); EndRenderPass();
GL_PUSH("Copy RT to temp texture for fbmask {%d,%d %dx%d}", GL_PUSH("Copy RT to temp texture for fbmask {%d,%d %dx%d}", config.drawarea.left, config.drawarea.top,
config.drawarea.left, config.drawarea.top,
config.drawarea.width(), config.drawarea.height()); config.drawarea.width(), config.drawarea.height());
CopyRect(draw_rt, draw_rt_clone, config.drawarea, config.drawarea.left, config.drawarea.top); CopyRect(draw_rt, draw_rt_clone, config.drawarea, config.drawarea.left, config.drawarea.top);
@ -5659,7 +5673,8 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
// We don't need the very first barrier if this is the first draw after switching to feedback loop, // We don't need the very first barrier if this is the first draw after switching to feedback loop,
// because the layout change in itself enforces the execution dependency. HDR needs a barrier between // because the layout change in itself enforces the execution dependency. HDR needs a barrier between
// setup and the first draw to read it. TODO: Make HDR use subpasses instead. // setup and the first draw to read it. TODO: Make HDR use subpasses instead.
const bool skip_first_barrier = (draw_rt && draw_rt->GetLayout() != GSTextureVK::Layout::FeedbackLoop && !pipe.ps.hdr); const bool skip_first_barrier =
(draw_rt && draw_rt->GetLayout() != GSTextureVK::Layout::FeedbackLoop && !pipe.ps.hdr);
OMSetRenderTargets(draw_rt, draw_ds, config.scissor, static_cast<FeedbackLoopFlag>(pipe.feedback_loop_flags)); OMSetRenderTargets(draw_rt, draw_ds, config.scissor, static_cast<FeedbackLoopFlag>(pipe.feedback_loop_flags));
if (pipe.IsRTFeedbackLoop()) if (pipe.IsRTFeedbackLoop())
@ -5888,9 +5903,8 @@ void GSDeviceVK::SendHWDraw(const GSHWDrawConfig& config, GSTextureVK* draw_rt,
for (; n < draw_list_size; n++) for (; n < draw_list_size; n++)
{ {
vkCmdPipelineBarrier(GetCurrentCommandBuffer(), vkCmdPipelineBarrier(GetCurrentCommandBuffer(), VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, barrier_flags, 0, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, barrier_flags, 0, nullptr, 0, nullptr, 1, &barrier);
nullptr, 0, nullptr, 1, &barrier);
const u32 count = (*config.drawlist)[n] * indices_per_prim; const u32 count = (*config.drawlist)[n] * indices_per_prim;
DrawIndexedPrimitive(p, count); DrawIndexedPrimitive(p, count);
@ -5922,9 +5936,8 @@ void GSDeviceVK::SendHWDraw(const GSHWDrawConfig& config, GSTextureVK* draw_rt,
for (; p < config.nindices; p += indices_per_prim) for (; p < config.nindices; p += indices_per_prim)
{ {
vkCmdPipelineBarrier(GetCurrentCommandBuffer(), vkCmdPipelineBarrier(GetCurrentCommandBuffer(), VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, barrier_flags, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, barrier_flags, 0, nullptr, 0, nullptr, 1, &barrier);
0, nullptr, 0, nullptr, 1, &barrier);
DrawIndexedPrimitive(p, indices_per_prim); DrawIndexedPrimitive(p, indices_per_prim);
} }
@ -5935,9 +5948,8 @@ void GSDeviceVK::SendHWDraw(const GSHWDrawConfig& config, GSTextureVK* draw_rt,
if (config.require_one_barrier && !skip_first_barrier) if (config.require_one_barrier && !skip_first_barrier)
{ {
g_perfmon.Put(GSPerfMon::Barriers, 1); g_perfmon.Put(GSPerfMon::Barriers, 1);
vkCmdPipelineBarrier(GetCurrentCommandBuffer(), vkCmdPipelineBarrier(GetCurrentCommandBuffer(), VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, barrier_flags, 0, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, barrier_flags, 0, nullptr, 0, nullptr, 1, &barrier);
nullptr, 0, nullptr, 1, &barrier);
} }
} }

View File

@ -15,14 +15,14 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GS/GSGL.h"
#include "GS/GSPerfMon.h"
#include "GS/Renderers/Vulkan/GSDeviceVK.h" #include "GS/Renderers/Vulkan/GSDeviceVK.h"
#include "GS/Renderers/Vulkan/GSTextureVK.h" #include "GS/Renderers/Vulkan/GSTextureVK.h"
#include "GS/Renderers/Vulkan/VKBuilders.h" #include "GS/Renderers/Vulkan/VKBuilders.h"
#include "GS/GSPerfMon.h"
#include "GS/GSGL.h"
#include "common/BitUtils.h"
#include "common/Assertions.h" #include "common/Assertions.h"
#include "common/BitUtils.h"
static constexpr const VkComponentMapping s_identity_swizzle{VK_COMPONENT_SWIZZLE_IDENTITY, static constexpr const VkComponentMapping s_identity_swizzle{VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY}; VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY};
@ -52,7 +52,8 @@ static VkImageLayout GetVkImageLayout(GSTextureVK::Layout layout)
static VkAccessFlagBits GetFeedbackLoopInputAccessBits() static VkAccessFlagBits GetFeedbackLoopInputAccessBits()
{ {
return GSDeviceVK::GetInstance()->UseFeedbackLoopLayout() ? VK_ACCESS_SHADER_READ_BIT : VK_ACCESS_INPUT_ATTACHMENT_READ_BIT; return GSDeviceVK::GetInstance()->UseFeedbackLoopLayout() ? VK_ACCESS_SHADER_READ_BIT :
VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
} }
GSTextureVK::GSTextureVK(Type type, Format format, int width, int height, int levels, VkImage image, GSTextureVK::GSTextureVK(Type type, Format format, int width, int height, int levels, VkImage image,
@ -111,7 +112,8 @@ std::unique_ptr<GSTextureVK> GSTextureVK::Create(Type type, Format format, int w
case Type::RenderTarget: case Type::RenderTarget:
{ {
pxAssert(levels == 1); pxAssert(levels == 1);
ici.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | ici.usage =
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
(GSDeviceVK::GetInstance()->UseFeedbackLoopLayout() ? VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT : (GSDeviceVK::GetInstance()->UseFeedbackLoopLayout() ? VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT :
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
@ -124,7 +126,8 @@ std::unique_ptr<GSTextureVK> GSTextureVK::Create(Type type, Format format, int w
ici.usage = ici.usage =
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
(GSDeviceVK::GetInstance()->UseFeedbackLoopLayout() ? VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT : 0); (GSDeviceVK::GetInstance()->UseFeedbackLoopLayout() ? VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT :
0);
vci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; vci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
} }
break; break;
@ -430,8 +433,8 @@ bool GSTextureVK::Map(GSMap& m, const GSVector4i* r, int layer)
m_map_area = r ? *r : GetRect(); m_map_area = r ? *r : GetRect();
m_map_level = layer; m_map_level = layer;
m.pitch = m.pitch = Common::AlignUpPow2(
Common::AlignUpPow2(CalcUploadPitch(m_map_area.width()), GSDeviceVK::GetInstance()->GetBufferCopyRowPitchAlignment()); CalcUploadPitch(m_map_area.width()), GSDeviceVK::GetInstance()->GetBufferCopyRowPitchAlignment());
// see note in Update() for the reason why. // see note in Update() for the reason why.
const u32 required_size = CalcUploadSize(m_map_area.height(), m.pitch); const u32 required_size = CalcUploadSize(m_map_area.height(), m.pitch);
@ -459,7 +462,8 @@ void GSTextureVK::Unmap()
const u32 width = m_map_area.width(); const u32 width = m_map_area.width();
const u32 height = m_map_area.height(); const u32 height = m_map_area.height();
const u32 pitch = Common::AlignUpPow2(CalcUploadPitch(width), GSDeviceVK::GetInstance()->GetBufferCopyRowPitchAlignment()); const u32 pitch =
Common::AlignUpPow2(CalcUploadPitch(width), GSDeviceVK::GetInstance()->GetBufferCopyRowPitchAlignment());
const u32 required_size = CalcUploadSize(height, pitch); const u32 required_size = CalcUploadSize(height, pitch);
VKStreamBuffer& buffer = GSDeviceVK::GetInstance()->GetTextureUploadBuffer(); VKStreamBuffer& buffer = GSDeviceVK::GetInstance()->GetTextureUploadBuffer();
const u32 buffer_offset = buffer.GetCurrentOffset(); const u32 buffer_offset = buffer.GetCurrentOffset();
@ -826,7 +830,8 @@ GSDownloadTextureVK::~GSDownloadTextureVK()
std::unique_ptr<GSDownloadTextureVK> GSDownloadTextureVK::Create(u32 width, u32 height, GSTexture::Format format) std::unique_ptr<GSDownloadTextureVK> GSDownloadTextureVK::Create(u32 width, u32 height, GSTexture::Format format)
{ {
const u32 buffer_size = GetBufferSize(width, height, format, GSDeviceVK::GetInstance()->GetBufferCopyRowPitchAlignment()); const u32 buffer_size =
GetBufferSize(width, height, format, GSDeviceVK::GetInstance()->GetBufferCopyRowPitchAlignment());
const VkBufferCreateInfo bci = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, nullptr, 0u, buffer_size, const VkBufferCreateInfo bci = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, nullptr, 0u, buffer_size,
VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 0u, nullptr}; VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_SHARING_MODE_EXCLUSIVE, 0u, nullptr};

View File

@ -15,8 +15,8 @@
#pragma once #pragma once
#include "GS/GS.h"
#include "GS/Renderers/Common/GSTexture.h" #include "GS/Renderers/Common/GSTexture.h"
#include "GS/GS.h"
#include "GS/Renderers/Vulkan/VKLoader.h" #include "GS/Renderers/Vulkan/VKLoader.h"
#include <limits> #include <limits>
@ -76,8 +76,8 @@ public:
void OverrideImageLayout(Layout new_layout); void OverrideImageLayout(Layout new_layout);
void TransitionToLayout(VkCommandBuffer command_buffer, Layout new_layout); void TransitionToLayout(VkCommandBuffer command_buffer, Layout new_layout);
void TransitionSubresourcesToLayout(VkCommandBuffer command_buffer, int start_level, int num_levels, void TransitionSubresourcesToLayout(
Layout old_layout, Layout new_layout); VkCommandBuffer command_buffer, int start_level, int num_levels, Layout old_layout, Layout new_layout);
/// Framebuffers are lazily allocated. /// Framebuffers are lazily allocated.
VkFramebuffer GetFramebuffer(bool feedback_loop); VkFramebuffer GetFramebuffer(bool feedback_loop);

View File

@ -210,7 +210,7 @@ namespace Vulkan
VkSpecializationInfo m_si; VkSpecializationInfo m_si;
std::array<VkSpecializationMapEntry, MAX_SPECIALIZATION_CONSTANTS> m_smap_entries; std::array<VkSpecializationMapEntry, MAX_SPECIALIZATION_CONSTANTS> m_smap_entries;
std::array<u8, SPECIALIZATION_CONSTANT_SIZE* MAX_SPECIALIZATION_CONSTANTS> m_smap_constants; std::array<u8, SPECIALIZATION_CONSTANT_SIZE * MAX_SPECIALIZATION_CONSTANTS> m_smap_constants;
}; };
class SamplerBuilder class SamplerBuilder

View File

@ -15,10 +15,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GS/Renderers/Vulkan/VKShaderCache.h" #include "GS/GS.h"
#include "GS/Renderers/Vulkan/GSDeviceVK.h" #include "GS/Renderers/Vulkan/GSDeviceVK.h"
#include "GS/Renderers/Vulkan/VKBuilders.h" #include "GS/Renderers/Vulkan/VKBuilders.h"
#include "GS/GS.h" #include "GS/Renderers/Vulkan/VKShaderCache.h"
#include "Config.h" #include "Config.h"
#include "ShaderCacheVersion.h" #include "ShaderCacheVersion.h"
@ -44,28 +44,29 @@
std::unique_ptr<VKShaderCache> g_vulkan_shader_cache; std::unique_ptr<VKShaderCache> g_vulkan_shader_cache;
namespace { namespace
#pragma pack(push, 4)
struct VK_PIPELINE_CACHE_HEADER
{ {
#pragma pack(push, 4)
struct VK_PIPELINE_CACHE_HEADER
{
u32 header_length; u32 header_length;
u32 header_version; u32 header_version;
u32 vendor_id; u32 vendor_id;
u32 device_id; u32 device_id;
u8 uuid[VK_UUID_SIZE]; u8 uuid[VK_UUID_SIZE];
}; };
struct CacheIndexEntry struct CacheIndexEntry
{ {
u64 source_hash_low; u64 source_hash_low;
u64 source_hash_high; u64 source_hash_high;
u32 source_length; u32 source_length;
u32 shader_type; u32 shader_type;
u32 file_offset; u32 file_offset;
u32 blob_size; u32 blob_size;
}; };
#pragma pack(pop) #pragma pack(pop)
} } // namespace
static bool ValidatePipelineCacheHeader(const VK_PIPELINE_CACHE_HEADER& header) static bool ValidatePipelineCacheHeader(const VK_PIPELINE_CACHE_HEADER& header)
{ {
@ -478,7 +479,8 @@ bool VKShaderCache::FlushPipelineCache()
return false; return false;
size_t data_size; size_t data_size;
VkResult res = vkGetPipelineCacheData(GSDeviceVK::GetInstance()->GetDevice(), m_pipeline_cache, &data_size, nullptr); VkResult res =
vkGetPipelineCacheData(GSDeviceVK::GetInstance()->GetDevice(), m_pipeline_cache, &data_size, nullptr);
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
LOG_VULKAN_ERROR(res, "vkGetPipelineCacheData() failed: "); LOG_VULKAN_ERROR(res, "vkGetPipelineCacheData() failed: ");

View File

@ -16,11 +16,11 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GS/Renderers/Vulkan/GSDeviceVK.h" #include "GS/Renderers/Vulkan/GSDeviceVK.h"
#include "GS/Renderers/Vulkan/VKStreamBuffer.h"
#include "GS/Renderers/Vulkan/VKBuilders.h" #include "GS/Renderers/Vulkan/VKBuilders.h"
#include "GS/Renderers/Vulkan/VKStreamBuffer.h"
#include "common/BitUtils.h"
#include "common/Assertions.h" #include "common/Assertions.h"
#include "common/BitUtils.h"
#include "common/Console.h" #include "common/Console.h"
VKStreamBuffer::VKStreamBuffer() = default; VKStreamBuffer::VKStreamBuffer() = default;
@ -79,7 +79,8 @@ bool VKStreamBuffer::Create(VkBufferUsageFlags usage, u32 size)
VmaAllocationInfo ai = {}; VmaAllocationInfo ai = {};
VkBuffer new_buffer = VK_NULL_HANDLE; VkBuffer new_buffer = VK_NULL_HANDLE;
VmaAllocation new_allocation = VK_NULL_HANDLE; VmaAllocation new_allocation = VK_NULL_HANDLE;
VkResult res = vmaCreateBuffer(GSDeviceVK::GetInstance()->GetAllocator(), &bci, &aci, &new_buffer, &new_allocation, &ai); VkResult res =
vmaCreateBuffer(GSDeviceVK::GetInstance()->GetAllocator(), &bci, &aci, &new_buffer, &new_allocation, &ai);
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
LOG_VULKAN_ERROR(res, "vkCreateBuffer failed: "); LOG_VULKAN_ERROR(res, "vkCreateBuffer failed: ");

View File

@ -16,8 +16,8 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GS/Renderers/Vulkan/GSDeviceVK.h" #include "GS/Renderers/Vulkan/GSDeviceVK.h"
#include "GS/Renderers/Vulkan/VKSwapChain.h"
#include "GS/Renderers/Vulkan/VKBuilders.h" #include "GS/Renderers/Vulkan/VKBuilders.h"
#include "GS/Renderers/Vulkan/VKSwapChain.h"
#include "common/Assertions.h" #include "common/Assertions.h"
#include "common/CocoaTools.h" #include "common/CocoaTools.h"
@ -183,8 +183,8 @@ static VkFormat GetLinearFormat(VkFormat format)
std::optional<VkSurfaceFormatKHR> VKSwapChain::SelectSurfaceFormat(VkSurfaceKHR surface) std::optional<VkSurfaceFormatKHR> VKSwapChain::SelectSurfaceFormat(VkSurfaceKHR surface)
{ {
u32 format_count; u32 format_count;
VkResult res = VkResult res = vkGetPhysicalDeviceSurfaceFormatsKHR(
vkGetPhysicalDeviceSurfaceFormatsKHR(GSDeviceVK::GetInstance()->GetPhysicalDevice(), surface, &format_count, nullptr); GSDeviceVK::GetInstance()->GetPhysicalDevice(), surface, &format_count, nullptr);
if (res != VK_SUCCESS || format_count == 0) if (res != VK_SUCCESS || format_count == 0)
{ {
LOG_VULKAN_ERROR(res, "vkGetPhysicalDeviceSurfaceFormatsKHR failed: "); LOG_VULKAN_ERROR(res, "vkGetPhysicalDeviceSurfaceFormatsKHR failed: ");
@ -254,8 +254,8 @@ std::optional<VkPresentModeKHR> VKSwapChain::SelectPresentMode(VkSurfaceKHR surf
{ {
VkResult res; VkResult res;
u32 mode_count; u32 mode_count;
res = res = vkGetPhysicalDeviceSurfacePresentModesKHR(
vkGetPhysicalDeviceSurfacePresentModesKHR(GSDeviceVK::GetInstance()->GetPhysicalDevice(), surface, &mode_count, nullptr); GSDeviceVK::GetInstance()->GetPhysicalDevice(), surface, &mode_count, nullptr);
if (res != VK_SUCCESS || mode_count == 0) if (res != VK_SUCCESS || mode_count == 0)
{ {
LOG_VULKAN_ERROR(res, "vkGetPhysicalDeviceSurfaceFormatsKHR failed: "); LOG_VULKAN_ERROR(res, "vkGetPhysicalDeviceSurfaceFormatsKHR failed: ");
@ -376,7 +376,8 @@ bool VKSwapChain::CreateSwapChain()
GSDeviceVK::GetInstance()->GetGraphicsQueueFamilyIndex(), GSDeviceVK::GetInstance()->GetGraphicsQueueFamilyIndex(),
GSDeviceVK::GetInstance()->GetPresentQueueFamilyIndex(), GSDeviceVK::GetInstance()->GetPresentQueueFamilyIndex(),
}}; }};
if (GSDeviceVK::GetInstance()->GetGraphicsQueueFamilyIndex() != GSDeviceVK::GetInstance()->GetPresentQueueFamilyIndex()) if (GSDeviceVK::GetInstance()->GetGraphicsQueueFamilyIndex() !=
GSDeviceVK::GetInstance()->GetPresentQueueFamilyIndex())
{ {
swap_chain_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; swap_chain_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
swap_chain_info.queueFamilyIndexCount = 2; swap_chain_info.queueFamilyIndexCount = 2;
@ -462,7 +463,8 @@ bool VKSwapChain::CreateSwapChain()
ImageSemaphores sema; ImageSemaphores sema;
const VkSemaphoreCreateInfo semaphore_info = {VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0}; const VkSemaphoreCreateInfo semaphore_info = {VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0};
res = vkCreateSemaphore(GSDeviceVK::GetInstance()->GetDevice(), &semaphore_info, nullptr, &sema.available_semaphore); res = vkCreateSemaphore(
GSDeviceVK::GetInstance()->GetDevice(), &semaphore_info, nullptr, &sema.available_semaphore);
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
LOG_VULKAN_ERROR(res, "vkCreateSemaphore failed: "); LOG_VULKAN_ERROR(res, "vkCreateSemaphore failed: ");