VideoBackends:Metal: MSAA support

This commit is contained in:
TellowKrinkle
2022-06-21 02:07:35 -05:00
parent c0fd128171
commit 6ee0248eab
14 changed files with 95 additions and 6 deletions

View File

@ -111,6 +111,7 @@ void VideoBackend::FillBackendInfo()
g_Config.backend_info.bSupportsLodBiasInSampler = true;
g_Config.backend_info.bSupportsLogicOp = D3D::SupportsLogicOp(g_Config.iAdapter);
g_Config.backend_info.bSupportsSettingObjectNames = true;
g_Config.backend_info.bSupportsPartialMultisampleResolve = true;
g_Config.backend_info.Adapters = D3DCommon::GetAdapterNames();
g_Config.backend_info.AAModes = D3D::GetAAModes(g_Config.iAdapter);

View File

@ -86,6 +86,7 @@ void VideoBackend::FillBackendInfo()
g_Config.backend_info.bSupportsTextureQueryLevels = true;
g_Config.backend_info.bSupportsLodBiasInSampler = true;
g_Config.backend_info.bSupportsSettingObjectNames = true;
g_Config.backend_info.bSupportsPartialMultisampleResolve = true;
// We can only check texture support once we have a device.
if (g_dx_context)

View File

@ -141,7 +141,16 @@ void Metal::VideoBackend::InitBackendInfo()
@autoreleasepool
{
Util::PopulateBackendInfo(&g_Config);
Util::PopulateBackendInfoAdapters(&g_Config, Util::GetAdapterList());
auto adapters = Util::GetAdapterList();
Util::PopulateBackendInfoAdapters(&g_Config, adapters);
if (!adapters.empty())
{
// Use the selected adapter, or the first to fill features.
size_t index = static_cast<size_t>(g_Config.iAdapter);
if (index >= adapters.size())
index = 0;
Util::PopulateBackendInfoFeatures(&g_Config, adapters[index]);
}
}
}

View File

@ -311,6 +311,7 @@ public:
fragment_shader = static_cast<const Shader*>(cfg.pixel_shader);
framebuffer.color_texture_format = cfg.framebuffer_state.color_texture_format.Value();
framebuffer.depth_texture_format = cfg.framebuffer_state.depth_texture_format.Value();
framebuffer.samples = cfg.framebuffer_state.samples.Value();
blend.colorupdate = cfg.blending_state.colorupdate.Value();
blend.alphaupdate = cfg.blending_state.alphaupdate.Value();
if (cfg.blending_state.blendenable)
@ -416,6 +417,7 @@ public:
// clang-format on
}
FramebufferState fs = config.framebuffer_state;
[desc setRasterSampleCount:fs.samples];
[color0 setPixelFormat:Util::FromAbstract(fs.color_texture_format)];
[desc setDepthAttachmentPixelFormat:Util::FromAbstract(fs.depth_texture_format)];
if (Util::HasStencil(fs.depth_texture_format))

View File

@ -68,6 +68,8 @@ void Metal::Util::PopulateBackendInfo(VideoConfig* config)
config->backend_info.bSupportsTextureQueryLevels = true;
config->backend_info.bSupportsLodBiasInSampler = false;
config->backend_info.bSupportsSettingObjectNames = true;
// Metal requires multisample resolve to be done on a render pass
config->backend_info.bSupportsPartialMultisampleResolve = false;
}
void Metal::Util::PopulateBackendInfoAdapters(VideoConfig* config,
@ -201,6 +203,14 @@ void Metal::Util::PopulateBackendInfoFeatures(VideoConfig* config, id<MTLDevice>
config->backend_info.bSupportsBPTCTextures = supports_mac1;
config->backend_info.bSupportsFramebufferFetch = true;
#endif
config->backend_info.AAModes.clear();
for (u32 i = 1; i <= 64; i <<= 1)
{
if ([device supportsTextureSampleCount:i])
config->backend_info.AAModes.push_back(i);
}
if (char* env = getenv("MTL_UNIFIED_MEMORY"))
g_features.unified_memory = env[0] == '1' || env[0] == 'y' || env[0] == 'Y';
else if (@available(macOS 10.15, iOS 13.0, *))

View File

@ -59,6 +59,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsTextureQueryLevels = false;
g_Config.backend_info.bSupportsLodBiasInSampler = false;
g_Config.backend_info.bSupportsSettingObjectNames = false;
g_Config.backend_info.bSupportsPartialMultisampleResolve = true;
// aamodes: We only support 1 sample, so no MSAA
g_Config.backend_info.Adapters.clear();

View File

@ -93,6 +93,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsShaderBinaries = false;
g_Config.backend_info.bSupportsPipelineCacheData = false;
g_Config.backend_info.bSupportsLodBiasInSampler = true;
g_Config.backend_info.bSupportsPartialMultisampleResolve = true;
// TODO: There is a bug here, if texel buffers or SSBOs/atomics are not supported the graphics
// options will show the option when it is not supported. The only way around this would be

View File

@ -88,6 +88,7 @@ void VideoSoftware::InitBackendInfo()
g_Config.backend_info.bSupportsTextureQueryLevels = false;
g_Config.backend_info.bSupportsLodBiasInSampler = false;
g_Config.backend_info.bSupportsSettingObjectNames = false;
g_Config.backend_info.bSupportsPartialMultisampleResolve = true;
// aamodes
g_Config.backend_info.AAModes = {1};

View File

@ -294,6 +294,7 @@ void VulkanContext::PopulateBackendInfo(VideoConfig* config)
config->backend_info.bSupportsTextureQueryLevels = true; // Assumed support.
config->backend_info.bSupportsLodBiasInSampler = false; // Dependent on OS.
config->backend_info.bSupportsSettingObjectNames = false; // Dependent on features.
config->backend_info.bSupportsPartialMultisampleResolve = true; // Assumed support.
}
void VulkanContext::PopulateBackendInfoAdapters(VideoConfig* config, const GPUList& gpu_list)