mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
gl: Reimplement driver capabilities detection in a more sane way
This commit is contained in:
parent
14575f3efd
commit
023221bd3b
9 changed files with 78 additions and 176 deletions
|
@ -155,7 +155,7 @@ void GLGSRender::update_draw_state()
|
|||
gl_state.depth_func(gl::comparison_op(rsx::method_registers.depth_func()));
|
||||
}
|
||||
|
||||
if (gl::get_driver_caps().EXT_depth_bounds_test && (gl_state.enable(rsx::method_registers.depth_bounds_test_enabled(), GL_DEPTH_BOUNDS_TEST_EXT)))
|
||||
if (gl::get_driver_caps().EXT_depth_bounds_test_supported && (gl_state.enable(rsx::method_registers.depth_bounds_test_enabled(), GL_DEPTH_BOUNDS_TEST_EXT)))
|
||||
{
|
||||
gl_state.depth_bounds(rsx::method_registers.depth_bounds_min(), rsx::method_registers.depth_bounds_max());
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ void GLFragmentDecompilerThread::insertHeader(std::stringstream & OS)
|
|||
}
|
||||
else
|
||||
{
|
||||
ensure(driver_caps.ARB_shader_texture_image_samples, "MSAA support on OpenGL requires a driver running OpenGL 4.5 or supporting GL_ARB_shader_texture_image_samples.");
|
||||
ensure(driver_caps.ARB_shader_texture_image_samples_supported, "MSAA support on OpenGL requires a driver running OpenGL 4.5 or supporting GL_ARB_shader_texture_image_samples.");
|
||||
required_extensions.push_back("GL_ARB_shader_texture_image_samples");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,12 +151,12 @@ void GLGSRender::on_init_thread()
|
|||
auto& gl_caps = gl::get_driver_caps();
|
||||
|
||||
std::vector<std::string> exception_reasons;
|
||||
if (!gl_caps.ARB_texture_buffer_supported)
|
||||
if (!gl_caps.ARB_texture_buffer_object_supported)
|
||||
{
|
||||
exception_reasons.push_back("GL_ARB_texture_buffer_object is required but not supported by your GPU");
|
||||
}
|
||||
|
||||
if (!gl_caps.ARB_dsa_supported && !gl_caps.EXT_dsa_supported)
|
||||
if (!gl_caps.ARB_direct_state_access_supported && !gl_caps.EXT_direct_state_access_supported)
|
||||
{
|
||||
exception_reasons.push_back("GL_ARB_direct_state_access or GL_EXT_direct_state_access is required but not supported by your GPU");
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ void GLGSRender::on_init_thread()
|
|||
backend_config.supports_normalized_barycentrics = false;
|
||||
}
|
||||
|
||||
if (gl_caps.AMD_pinned_memory && g_cfg.video.host_label_synchronization)
|
||||
if (gl_caps.AMD_pinned_memory_supported && g_cfg.video.host_label_synchronization)
|
||||
{
|
||||
backend_config.supports_host_gpu_labels = true;
|
||||
|
||||
|
|
|
@ -631,7 +631,7 @@ namespace gl
|
|||
{
|
||||
const GLsizei size = layout.width_in_block * layout.height_in_block * format_block_size;
|
||||
ensure(usz(size) <= staging_buffer.size());
|
||||
if (gl::get_driver_caps().ARB_dsa_supported)
|
||||
if (gl::get_driver_caps().ARB_direct_state_access_supported)
|
||||
{
|
||||
glCompressedTextureSubImage3D(dst->id(), layout.level, 0, 0, layout.layer, layout.width_in_texel, layout.height_in_texel, 1, gl_format, size, staging_buffer.data());
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace gl
|
|||
|
||||
void buffer::copy_to(buffer* other, u64 src_offset, u64 dst_offset, u64 size)
|
||||
{
|
||||
if (get_driver_caps().ARB_dsa_supported)
|
||||
if (get_driver_caps().ARB_direct_state_access_supported)
|
||||
{
|
||||
glCopyNamedBufferSubData(this->id(), other->id(), src_offset, dst_offset, size);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "Utilities/StrUtil.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
version_info::version_info(const char* version_string, int major_scale)
|
||||
|
@ -20,20 +22,8 @@ namespace gl
|
|||
version = static_cast<u16>(version_major * major_scale) + version_minor;
|
||||
}
|
||||
|
||||
bool capabilities::check(const std::string& ext_name, const char* test)
|
||||
{
|
||||
if (ext_name == test)
|
||||
{
|
||||
rsx_log.notice("Extension %s is supported", ext_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void capabilities::initialize()
|
||||
{
|
||||
int find_count = 19;
|
||||
int ext_count = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &ext_count);
|
||||
|
||||
|
@ -47,146 +37,61 @@ namespace gl
|
|||
std::string version_string = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
std::string renderer_string = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
|
||||
std::unordered_set<std::string> all_extensions;
|
||||
for (int i = 0; i < ext_count; i++)
|
||||
{
|
||||
if (!find_count) break;
|
||||
|
||||
const std::string ext_name = reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i));
|
||||
|
||||
if (check(ext_name, "GL_ARB_shader_draw_parameters"))
|
||||
{
|
||||
ARB_shader_draw_parameters_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_EXT_direct_state_access"))
|
||||
{
|
||||
EXT_dsa_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_direct_state_access"))
|
||||
{
|
||||
ARB_dsa_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_bindless_texture"))
|
||||
{
|
||||
ARB_bindless_texture_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_buffer_storage"))
|
||||
{
|
||||
ARB_buffer_storage_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_texture_buffer_object"))
|
||||
{
|
||||
ARB_texture_buffer_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_depth_buffer_float"))
|
||||
{
|
||||
ARB_depth_buffer_float_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_texture_barrier"))
|
||||
{
|
||||
ARB_texture_barrier_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_NV_texture_barrier"))
|
||||
{
|
||||
NV_texture_barrier_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_NV_gpu_shader5"))
|
||||
{
|
||||
NV_gpu_shader5_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_AMD_gpu_shader_half_float"))
|
||||
{
|
||||
AMD_gpu_shader_half_float_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_compute_shader"))
|
||||
{
|
||||
ARB_compute_shader_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_EXT_depth_bounds_test"))
|
||||
{
|
||||
EXT_depth_bounds_test = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_NV_depth_buffer_float"))
|
||||
{
|
||||
NV_depth_buffer_float_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_shader_stencil_export"))
|
||||
{
|
||||
ARB_shader_stencil_export_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_NV_fragment_shader_barycentric"))
|
||||
{
|
||||
NV_fragment_shader_barycentric_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_AMD_pinned_memory"))
|
||||
{
|
||||
AMD_pinned_memory = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_ARB_shader_texture_image_samples"))
|
||||
{
|
||||
ARB_shader_texture_image_samples = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (check(ext_name, "GL_EXT_texture_compression_s3tc"))
|
||||
{
|
||||
EXT_texture_compression_s3tc_supported = true;
|
||||
find_count--;
|
||||
continue;
|
||||
}
|
||||
all_extensions.emplace(reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i)));
|
||||
}
|
||||
|
||||
#define CHECK_EXTENSION_SUPPORT(extension_short_name)\
|
||||
do {\
|
||||
if (all_extensions.contains("GL_"#extension_short_name)) {\
|
||||
extension_short_name##_supported = true;\
|
||||
rsx_log.success("[CAPS] Using GL_"#extension_short_name);\
|
||||
continue;\
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_shader_draw_parameters);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(EXT_direct_state_access);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_direct_state_access);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_bindless_texture);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_buffer_storage);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_texture_buffer_object);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_depth_buffer_float);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_texture_barrier);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(NV_texture_barrier);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(NV_gpu_shader5);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(AMD_gpu_shader_half_float);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_compute_shader);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(EXT_depth_bounds_test);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(NV_depth_buffer_float);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_shader_stencil_export);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(NV_fragment_shader_barycentric);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(AMD_pinned_memory);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(ARB_shader_texture_image_samples);
|
||||
|
||||
CHECK_EXTENSION_SUPPORT(EXT_texture_compression_s3tc);
|
||||
|
||||
#undef CHECK_EXTENSION_SUPPORT
|
||||
|
||||
// Set GLSL version
|
||||
glsl_version = version_info(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
|
||||
|
||||
|
@ -228,17 +133,17 @@ namespace gl
|
|||
|
||||
// Texture buffers moved into core at GL 3.3
|
||||
if (version_major > 3 || (version_major == 3 && version_minor >= 3))
|
||||
ARB_texture_buffer_supported = true;
|
||||
ARB_texture_buffer_object_supported = true;
|
||||
|
||||
// Check for expected library entry-points for some required functions
|
||||
if (!ARB_buffer_storage_supported && glNamedBufferStorage && glMapNamedBufferRange)
|
||||
ARB_buffer_storage_supported = true;
|
||||
|
||||
if (!ARB_dsa_supported && glGetTextureImage && glTextureBufferRange)
|
||||
ARB_dsa_supported = true;
|
||||
if (!ARB_direct_state_access_supported && glGetTextureImage && glTextureBufferRange)
|
||||
ARB_direct_state_access_supported = true;
|
||||
|
||||
if (!EXT_dsa_supported && glGetTextureImageEXT && glTextureBufferRangeEXT)
|
||||
EXT_dsa_supported = true;
|
||||
if (!EXT_direct_state_access_supported && glGetTextureImageEXT && glTextureBufferRangeEXT)
|
||||
EXT_direct_state_access_supported = true;
|
||||
}
|
||||
else if (!vendor_MESA && vendor_string.find("nvidia") != umax)
|
||||
{
|
||||
|
|
|
@ -23,13 +23,13 @@ namespace gl
|
|||
bool initialized = false;
|
||||
version_info glsl_version;
|
||||
|
||||
bool EXT_dsa_supported = false;
|
||||
bool EXT_depth_bounds_test = false;
|
||||
bool AMD_pinned_memory = false;
|
||||
bool ARB_dsa_supported = false;
|
||||
bool EXT_direct_state_access_supported = false;
|
||||
bool EXT_depth_bounds_test_supported = false;
|
||||
bool AMD_pinned_memory_supported = false;
|
||||
bool ARB_direct_state_access_supported = false;
|
||||
bool ARB_bindless_texture_supported = false;
|
||||
bool ARB_buffer_storage_supported = false;
|
||||
bool ARB_texture_buffer_supported = false;
|
||||
bool ARB_texture_buffer_object_supported = false;
|
||||
bool ARB_shader_draw_parameters_supported = false;
|
||||
bool ARB_depth_buffer_float_supported = false;
|
||||
bool ARB_texture_barrier_supported = false;
|
||||
|
@ -40,7 +40,7 @@ namespace gl
|
|||
bool ARB_compute_shader_supported = false;
|
||||
bool NV_depth_buffer_float_supported = false;
|
||||
bool NV_fragment_shader_barycentric_supported = false;
|
||||
bool ARB_shader_texture_image_samples = false;
|
||||
bool ARB_shader_texture_image_samples_supported = false;
|
||||
bool EXT_texture_compression_s3tc_supported = false;
|
||||
|
||||
bool vendor_INTEL = false; // has broken GLSL compiler
|
||||
|
@ -52,9 +52,6 @@ namespace gl
|
|||
bool subvendor_ATI = false; // Pre-GCN cards (terascale, evergreen)
|
||||
|
||||
void initialize();
|
||||
|
||||
private:
|
||||
bool check(const std::string& ext_name, const char* test);
|
||||
};
|
||||
|
||||
const capabilities& get_driver_caps();
|
||||
|
|
|
@ -27,24 +27,24 @@
|
|||
|
||||
//Function call wrapped in ARB_DSA vs EXT_DSA compat check
|
||||
#define DSA_CALL(func, object_name, target, ...)\
|
||||
if (::gl::get_driver_caps().ARB_dsa_supported)\
|
||||
if (::gl::get_driver_caps().ARB_direct_state_access_supported)\
|
||||
gl##func(object_name, __VA_ARGS__);\
|
||||
else\
|
||||
gl##func##EXT(object_name, target, __VA_ARGS__);
|
||||
|
||||
#define DSA_CALL2(func, ...)\
|
||||
if (::gl::get_driver_caps().ARB_dsa_supported)\
|
||||
if (::gl::get_driver_caps().ARB_direct_state_access_supported)\
|
||||
gl##func(__VA_ARGS__);\
|
||||
else\
|
||||
gl##func##EXT(__VA_ARGS__);
|
||||
|
||||
#define DSA_CALL2_RET(func, ...)\
|
||||
(::gl::get_driver_caps().ARB_dsa_supported) ?\
|
||||
(::gl::get_driver_caps().ARB_direct_state_access_supported) ?\
|
||||
gl##func(__VA_ARGS__) :\
|
||||
gl##func##EXT(__VA_ARGS__)
|
||||
|
||||
#define DSA_CALL3(funcARB, funcDSA, ...)\
|
||||
if (::gl::get_driver_caps().ARB_dsa_supported)\
|
||||
if (::gl::get_driver_caps().ARB_direct_state_access_supported)\
|
||||
gl##funcARB(__VA_ARGS__);\
|
||||
else\
|
||||
gl##funcDSA##EXT(__VA_ARGS__);
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace gl
|
|||
}
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
{
|
||||
if (get_driver_caps().ARB_dsa_supported)
|
||||
if (get_driver_caps().ARB_direct_state_access_supported)
|
||||
{
|
||||
glTextureSubImage3D(m_id, level, region.x, region.y, region.z, region.width, region.height, region.depth, static_cast<GLenum>(format), static_cast<GLenum>(type), src);
|
||||
}
|
||||
|
@ -246,12 +246,12 @@ namespace gl
|
|||
if (!region.x && !region.y && !region.z &&
|
||||
region.width == m_width && region.height == m_height && region.depth == m_depth)
|
||||
{
|
||||
if (caps.ARB_dsa_supported)
|
||||
if (caps.ARB_direct_state_access_supported)
|
||||
glGetTextureImage(m_id, level, static_cast<GLenum>(format), static_cast<GLenum>(type), s32{ smax }, dst);
|
||||
else
|
||||
glGetTextureImageEXT(m_id, static_cast<GLenum>(m_target), level, static_cast<GLenum>(format), static_cast<GLenum>(type), dst);
|
||||
}
|
||||
else if (caps.ARB_dsa_supported)
|
||||
else if (caps.ARB_direct_state_access_supported)
|
||||
{
|
||||
glGetTextureSubImage(m_id, level, region.x, region.y, region.z, region.width, region.height, region.depth,
|
||||
static_cast<GLenum>(format), static_cast<GLenum>(type), s32{ smax }, dst);
|
||||
|
|
Loading…
Add table
Reference in a new issue