From de940a5fd6a07728c51d53ebdab7489aa03cdb55 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 5 Mar 2017 15:17:54 -0800 Subject: [PATCH] VideoConfig: add bSupportsFragmentStoresAndAtomics --- Source/Core/Core/Analytics.cpp | 2 ++ Source/Core/VideoBackends/D3D/main.cpp | 3 ++- Source/Core/VideoBackends/D3D12/main.cpp | 3 ++- Source/Core/VideoBackends/OGL/BoundingBox.cpp | 6 ++++-- Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp | 2 +- Source/Core/VideoBackends/OGL/Render.cpp | 4 +++- Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | 4 +++- Source/Core/VideoCommon/PixelShaderGen.cpp | 1 + Source/Core/VideoCommon/VideoConfig.h | 1 + 9 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Analytics.cpp b/Source/Core/Core/Analytics.cpp index 8638b79dba..a3060833c9 100644 --- a/Source/Core/Core/Analytics.cpp +++ b/Source/Core/Core/Analytics.cpp @@ -239,6 +239,8 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("gpu-has-early-z", g_Config.backend_info.bSupportsEarlyZ); builder.AddData("gpu-has-binding-layout", g_Config.backend_info.bSupportsBindingLayout); builder.AddData("gpu-has-bbox", g_Config.backend_info.bSupportsBBox); + builder.AddData("gpu-has-fragment-stores-and-atomics", + g_Config.backend_info.bSupportsFragmentStoresAndAtomics); builder.AddData("gpu-has-gs-instancing", g_Config.backend_info.bSupportsGSInstancing); builder.AddData("gpu-has-post-processing", g_Config.backend_info.bSupportsPostProcessing); builder.AddData("gpu-has-palette-conversion", g_Config.backend_info.bSupportsPaletteConversion); diff --git a/Source/Core/VideoBackends/D3D/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp index 2fc00dc037..e8a51d3441 100644 --- a/Source/Core/VideoBackends/D3D/main.cpp +++ b/Source/Core/VideoBackends/D3D/main.cpp @@ -112,7 +112,8 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported; // Requires full UAV functionality (only available in shader model 5) - g_Config.backend_info.bSupportsBBox = shader_model_5_supported; + g_Config.backend_info.bSupportsBBox = + g_Config.backend_info.bSupportsFragmentStoresAndAtomics = shader_model_5_supported; // Requires the instance attribute (only available in shader model 5) g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported; diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp index bae916e0f8..7a48647c0e 100644 --- a/Source/Core/VideoBackends/D3D12/main.cpp +++ b/Source/Core/VideoBackends/D3D12/main.cpp @@ -120,7 +120,8 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsEarlyZ = true; // Requires full UAV functionality (only available in shader model 5) - g_Config.backend_info.bSupportsBBox = true; + g_Config.backend_info.bSupportsBBox = + g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true; // Requires the instance attribute (only available in shader model 5) g_Config.backend_info.bSupportsGSInstancing = true; diff --git a/Source/Core/VideoBackends/OGL/BoundingBox.cpp b/Source/Core/VideoBackends/OGL/BoundingBox.cpp index 0ee4bd2afe..6bce10754e 100644 --- a/Source/Core/VideoBackends/OGL/BoundingBox.cpp +++ b/Source/Core/VideoBackends/OGL/BoundingBox.cpp @@ -17,7 +17,7 @@ namespace OGL { void BoundingBox::Init() { - if (g_ActiveConfig.backend_info.bSupportsBBox) + if (g_ActiveConfig.backend_info.bSupportsFragmentStoresAndAtomics) { int initial_values[4] = {0, 0, 0, 0}; glGenBuffers(1, &s_bbox_buffer_id); @@ -29,8 +29,10 @@ void BoundingBox::Init() void BoundingBox::Shutdown() { - if (g_ActiveConfig.backend_info.bSupportsBBox) + if (g_ActiveConfig.backend_info.bSupportsFragmentStoresAndAtomics) + { glDeleteBuffers(1, &s_bbox_buffer_id); + } } void BoundingBox::Set(int index, int value) diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index ef91b01f02..508d6e41ed 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -618,7 +618,7 @@ void ProgramShaderCache::CreateHeader() "#define SAMPLER_BINDING(x)\n", // Input/output blocks are matched by name during program linking "#define VARYING_LOCATION(x)\n", - !is_glsles && g_ActiveConfig.backend_info.bSupportsBBox ? + !is_glsles && g_ActiveConfig.backend_info.bSupportsFragmentStoresAndAtomics ? "#extension GL_ARB_shader_storage_buffer_object : enable" : "", v < GLSL_400 && g_ActiveConfig.backend_info.bSupportsGSInstancing ? diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index f898d73722..341e6b3686 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -411,7 +411,7 @@ Renderer::Renderer() g_Config.backend_info.bSupportsPrimitiveRestart = !DriverDetails::HasBug(DriverDetails::BUG_PRIMITIVE_RESTART) && ((GLExtensions::Version() >= 310) || GLExtensions::Supports("GL_NV_primitive_restart")); - g_Config.backend_info.bSupportsBBox = + g_Config.backend_info.bSupportsBBox = g_Config.backend_info.bSupportsFragmentStoresAndAtomics = GLExtensions::Supports("GL_ARB_shader_storage_buffer_object"); g_Config.backend_info.bSupportsGSInstancing = GLExtensions::Supports("GL_ARB_gpu_shader5"); g_Config.backend_info.bSupportsSSAA = GLExtensions::Supports("GL_ARB_gpu_shader5") && @@ -498,6 +498,7 @@ Renderer::Renderer() g_Config.backend_info.bSupportsGeometryShaders && g_ogl_config.SupportedESPointSize > 0; g_Config.backend_info.bSupportsSSAA = g_ogl_config.bSupportsAEP; g_Config.backend_info.bSupportsBBox = true; + g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true; g_ogl_config.bSupportsMSAA = true; g_ogl_config.bSupports2DTextureStorage = true; if (g_ActiveConfig.iStereoMode > 0 && g_ActiveConfig.iMultisamples > 1 && @@ -519,6 +520,7 @@ Renderer::Renderer() g_Config.backend_info.bSupportsPaletteConversion = true; g_Config.backend_info.bSupportsSSAA = true; g_Config.backend_info.bSupportsBBox = true; + g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true; g_ogl_config.bSupportsCopySubImage = true; g_ogl_config.bSupportsGLBaseVertex = true; g_ogl_config.bSupportsDebug = true; diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index 1487e09afc..74e7786130 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -240,6 +240,7 @@ void VulkanContext::PopulateBackendInfo(VideoConfig* config) config->backend_info.bSupportsGeometryShaders = false; // Dependent on features. config->backend_info.bSupportsGSInstancing = false; // Dependent on features. config->backend_info.bSupportsBBox = false; // Dependent on features. + config->backend_info.bSupportsFragmentStoresAndAtomics = false; // Dependent on features. config->backend_info.bSupportsSSAA = false; // Dependent on features. config->backend_info.bSupportsDepthClamp = false; // Dependent on features. config->backend_info.bSupportsReversedDepthRange = false; // No support yet due to driver bugs. @@ -264,7 +265,8 @@ void VulkanContext::PopulateBackendInfoFeatures(VideoConfig* config, VkPhysicalD config->backend_info.bSupportsDualSourceBlend = (features.dualSrcBlend == VK_TRUE); config->backend_info.bSupportsGeometryShaders = (features.geometryShader == VK_TRUE); config->backend_info.bSupportsGSInstancing = (features.geometryShader == VK_TRUE); - config->backend_info.bSupportsBBox = (features.fragmentStoresAndAtomics == VK_TRUE); + config->backend_info.bSupportsBBox = config->backend_info.bSupportsFragmentStoresAndAtomics = + (features.fragmentStoresAndAtomics == VK_TRUE); config->backend_info.bSupportsSSAA = (features.sampleRateShading == VK_TRUE); // Disable geometry shader when shaderTessellationAndGeometryPointSize is not supported. diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 608248fab8..6360a68a37 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -172,6 +172,7 @@ PixelShaderUid GetPixelShaderUid() uid_data->genMode_numtexgens = bpmem.genMode.numtexgens; uid_data->per_pixel_lighting = g_ActiveConfig.bEnablePixelLighting; uid_data->bounding_box = g_ActiveConfig.backend_info.bSupportsBBox && + g_ActiveConfig.backend_info.bSupportsFragmentStoresAndAtomics && g_ActiveConfig.bBBoxEnable && BoundingBox::active; uid_data->rgba6_format = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24 && !g_ActiveConfig.bForceTrueColor; diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index ec79e6de48..b8e348157d 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -189,6 +189,7 @@ struct VideoConfig final bool bSupportsPaletteConversion; bool bSupportsClipControl; // Needed by VertexShaderGen, so must stay in VideoCommon bool bSupportsSSAA; + bool bSupportsFragmentStoresAndAtomics; // a.k.a. OpenGL SSBOs a.k.a. Direct3D UAVs bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon bool bSupportsReversedDepthRange; bool bSupportsMultithreading;