mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 07:05:40 +00:00
GPU/Vulkan: Fix MSAA
And disable sample rate shading ("SSAA") on AMD, Intel, and broken mobile drivers, because it doesn't work.
This commit is contained in:
parent
0e6efb2241
commit
0da14a5442
|
@ -1049,8 +1049,9 @@ void GPU_HW::DestroyPipelines()
|
||||||
|
|
||||||
void GPU_HW::UpdateVRAMReadTexture()
|
void GPU_HW::UpdateVRAMReadTexture()
|
||||||
{
|
{
|
||||||
const auto scaled_rect = m_vram_dirty_rect * m_resolution_scale;
|
GL_SCOPE("UpdateVRAMReadTexture()");
|
||||||
|
|
||||||
|
const auto scaled_rect = m_vram_dirty_rect * m_resolution_scale;
|
||||||
if (m_vram_texture->IsMultisampled())
|
if (m_vram_texture->IsMultisampled())
|
||||||
{
|
{
|
||||||
if (g_gpu_device->GetFeatures().partial_msaa_resolve)
|
if (g_gpu_device->GetFeatures().partial_msaa_resolve)
|
||||||
|
|
|
@ -348,9 +348,9 @@ bool OpenGLDevice::CheckFeatures(bool* buggy_pbo)
|
||||||
{
|
{
|
||||||
const bool is_gles = m_gl_context->IsGLES();
|
const bool is_gles = m_gl_context->IsGLES();
|
||||||
|
|
||||||
// bool vendor_id_amd = false;
|
bool vendor_id_amd = false;
|
||||||
// bool vendor_id_nvidia = false;
|
//bool vendor_id_nvidia = false;
|
||||||
// bool vendor_id_intel = false;
|
bool vendor_id_intel = false;
|
||||||
bool vendor_id_arm = false;
|
bool vendor_id_arm = false;
|
||||||
bool vendor_id_qualcomm = false;
|
bool vendor_id_qualcomm = false;
|
||||||
bool vendor_id_powervr = false;
|
bool vendor_id_powervr = false;
|
||||||
|
@ -361,7 +361,7 @@ bool OpenGLDevice::CheckFeatures(bool* buggy_pbo)
|
||||||
std::strstr(vendor, "ATI"))
|
std::strstr(vendor, "ATI"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("AMD GPU detected.");
|
Log_InfoPrint("AMD GPU detected.");
|
||||||
// vendor_id_amd = true;
|
vendor_id_amd = true;
|
||||||
}
|
}
|
||||||
else if (std::strstr(vendor, "NVIDIA Corporation"))
|
else if (std::strstr(vendor, "NVIDIA Corporation"))
|
||||||
{
|
{
|
||||||
|
@ -371,7 +371,7 @@ bool OpenGLDevice::CheckFeatures(bool* buggy_pbo)
|
||||||
else if (std::strstr(vendor, "Intel"))
|
else if (std::strstr(vendor, "Intel"))
|
||||||
{
|
{
|
||||||
Log_InfoPrint("Intel GPU detected.");
|
Log_InfoPrint("Intel GPU detected.");
|
||||||
// vendor_id_intel = true;
|
vendor_id_intel = true;
|
||||||
}
|
}
|
||||||
else if (std::strstr(vendor, "ARM"))
|
else if (std::strstr(vendor, "ARM"))
|
||||||
{
|
{
|
||||||
|
@ -452,7 +452,10 @@ bool OpenGLDevice::CheckFeatures(bool* buggy_pbo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_features.per_sample_shading = GLAD_GL_VERSION_4_0 || GLAD_GL_ES_VERSION_3_2 || GLAD_GL_ARB_sample_shading;
|
// Sample rate shading is broken on AMD and Intel.
|
||||||
|
// If AMD and Intel can't get it right, I very much doubt broken mobile drivers can.
|
||||||
|
m_features.per_sample_shading = (GLAD_GL_VERSION_4_0 || GLAD_GL_ES_VERSION_3_2 || GLAD_GL_ARB_sample_shading) &&
|
||||||
|
(!vendor_id_amd && !vendor_id_intel && !is_shitty_mobile_driver);
|
||||||
|
|
||||||
// noperspective is not supported in GLSL ES.
|
// noperspective is not supported in GLSL ES.
|
||||||
m_features.noperspective_interpolation = !is_gles;
|
m_features.noperspective_interpolation = !is_gles;
|
||||||
|
|
|
@ -365,6 +365,7 @@ bool VulkanDevice::SelectDeviceFeatures()
|
||||||
m_device_features.largePoints = available_features.largePoints;
|
m_device_features.largePoints = available_features.largePoints;
|
||||||
m_device_features.wideLines = available_features.wideLines;
|
m_device_features.wideLines = available_features.wideLines;
|
||||||
m_device_features.samplerAnisotropy = available_features.samplerAnisotropy;
|
m_device_features.samplerAnisotropy = available_features.samplerAnisotropy;
|
||||||
|
m_device_features.sampleRateShading = available_features.sampleRateShading;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2208,7 +2209,7 @@ bool VulkanDevice::CheckFeatures()
|
||||||
Log_WarningPrintf("Vulkan driver is missing dual-source blending. This will have an impact on performance.");
|
Log_WarningPrintf("Vulkan driver is missing dual-source blending. This will have an impact on performance.");
|
||||||
|
|
||||||
m_features.noperspective_interpolation = true;
|
m_features.noperspective_interpolation = true;
|
||||||
m_features.per_sample_shading = true;
|
m_features.per_sample_shading = m_device_features.sampleRateShading;
|
||||||
m_features.supports_texture_buffers = true;
|
m_features.supports_texture_buffers = true;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -2326,12 +2327,19 @@ void VulkanDevice::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u
|
||||||
VulkanTexture* S = static_cast<VulkanTexture*>(src);
|
VulkanTexture* S = static_cast<VulkanTexture*>(src);
|
||||||
const VkCommandBuffer cmdbuf = GetCurrentCommandBuffer();
|
const VkCommandBuffer cmdbuf = GetCurrentCommandBuffer();
|
||||||
|
|
||||||
S->CommitClear(cmdbuf);
|
if (S->GetState() == GPUTexture::State::Cleared)
|
||||||
D->CommitClear(cmdbuf);
|
S->CommitClear(cmdbuf);
|
||||||
|
if (D->IsRenderTargetOrDepthStencil() && D->GetState() == GPUTexture::State::Cleared)
|
||||||
|
{
|
||||||
|
if (width < dst->GetWidth() || height < dst->GetHeight())
|
||||||
|
D->CommitClear(cmdbuf);
|
||||||
|
else
|
||||||
|
D->SetState(GPUTexture::State::Dirty);
|
||||||
|
}
|
||||||
|
|
||||||
S->TransitionSubresourcesToLayout(cmdbuf, 0, 1, 0, 1, S->GetLayout(), VulkanTexture::Layout::TransferSrc);
|
S->TransitionSubresourcesToLayout(cmdbuf, 0, 1, 0, 1, S->GetLayout(), VulkanTexture::Layout::TransferSrc);
|
||||||
D->TransitionSubresourcesToLayout(cmdbuf, dst_layer, 1, dst_level, 1, D->GetLayout(),
|
D->TransitionSubresourcesToLayout(cmdbuf, dst_layer, 1, dst_level, 1, D->GetLayout(),
|
||||||
VulkanTexture::Layout::TransferSrc);
|
VulkanTexture::Layout::TransferDst);
|
||||||
|
|
||||||
const VkImageResolve resolve = {{VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, 1u},
|
const VkImageResolve resolve = {{VK_IMAGE_ASPECT_COLOR_BIT, 0u, 0u, 1u},
|
||||||
{static_cast<s32>(src_x), static_cast<s32>(src_y), 0},
|
{static_cast<s32>(src_x), static_cast<s32>(src_y), 0},
|
||||||
|
@ -2342,7 +2350,7 @@ void VulkanDevice::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &resolve);
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &resolve);
|
||||||
|
|
||||||
S->TransitionSubresourcesToLayout(cmdbuf, 0, 1, 0, 1, VulkanTexture::Layout::TransferSrc, S->GetLayout());
|
S->TransitionSubresourcesToLayout(cmdbuf, 0, 1, 0, 1, VulkanTexture::Layout::TransferSrc, S->GetLayout());
|
||||||
D->TransitionSubresourcesToLayout(cmdbuf, dst_layer, 1, dst_level, 1, VulkanTexture::Layout::TransferSrc,
|
D->TransitionSubresourcesToLayout(cmdbuf, dst_layer, 1, dst_level, 1, VulkanTexture::Layout::TransferDst,
|
||||||
D->GetLayout());
|
D->GetLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,9 @@ std::unique_ptr<VulkanTexture> VulkanTexture::Create(u32 width, u32 height, u32
|
||||||
0,
|
0,
|
||||||
VK_IMAGE_TYPE_2D,
|
VK_IMAGE_TYPE_2D,
|
||||||
vk_format,
|
vk_format,
|
||||||
{static_cast<u32>(width), static_cast<u32>(height), 1},
|
{width, height, 1u},
|
||||||
static_cast<u32>(levels),
|
levels,
|
||||||
1,
|
layers,
|
||||||
static_cast<VkSampleCountFlagBits>(samples),
|
static_cast<VkSampleCountFlagBits>(samples),
|
||||||
VK_IMAGE_TILING_OPTIMAL};
|
VK_IMAGE_TILING_OPTIMAL};
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ bool VulkanTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
|
||||||
// if we're an rt and have been cleared, and the full rect isn't being uploaded, do the clear
|
// if we're an rt and have been cleared, and the full rect isn't being uploaded, do the clear
|
||||||
if (m_type == Type::RenderTarget)
|
if (m_type == Type::RenderTarget)
|
||||||
{
|
{
|
||||||
if (x != 0 || y != 0 || width != m_width || height != m_height)
|
if (m_state == State::Cleared && (x != 0 || y != 0 || width != m_width || height != m_height))
|
||||||
CommitClear(cmdbuf);
|
CommitClear(cmdbuf);
|
||||||
else
|
else
|
||||||
m_state = State::Dirty;
|
m_state = State::Dirty;
|
||||||
|
@ -979,7 +979,8 @@ std::unique_ptr<GPUFramebuffer> VulkanDevice::CreateFramebuffer(GPUTexture* rt_o
|
||||||
|
|
||||||
const VkRenderPass render_pass =
|
const VkRenderPass render_pass =
|
||||||
GetRenderPass(RT ? RT->GetVkFormat() : VK_FORMAT_UNDEFINED, DS ? DS->GetVkFormat() : VK_FORMAT_UNDEFINED,
|
GetRenderPass(RT ? RT->GetVkFormat() : VK_FORMAT_UNDEFINED, DS ? DS->GetVkFormat() : VK_FORMAT_UNDEFINED,
|
||||||
VK_SAMPLE_COUNT_1_BIT, RT ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
|
static_cast<VkSampleCountFlagBits>(RT ? RT->GetSamples() : DS->GetSamples()),
|
||||||
|
RT ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||||
RT ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE,
|
RT ? VK_ATTACHMENT_STORE_OP_STORE : VK_ATTACHMENT_STORE_OP_DONT_CARE,
|
||||||
DS ? VK_ATTACHMENT_LOAD_OP_LOAD : VK_ATTACHMENT_LOAD_OP_DONT_CARE,
|
DS ? 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);
|
||||||
|
|
Loading…
Reference in a new issue