gl: Drop use of the retired glNamedBufferStorageEXT function

- The DSA_EXT fallback is now GLES-only.
- We introduce a wrapper to act as a fallback for older GPUs - NamedBufferStorageEX.
This commit is contained in:
kd-11 2026-06-10 23:22:39 +03:00 committed by kd-11
parent 41a7cd29f8
commit 06c8a87534
9 changed files with 59 additions and 5 deletions

View File

@ -588,6 +588,7 @@ if(NOT ANDROID AND NOT APPLE)
RSX/GL/glutils/buffer_object.cpp
RSX/GL/glutils/capabilities.cpp
RSX/GL/glutils/common.cpp
RSX/GL/glutils/ex.cpp
RSX/GL/glutils/fbo.cpp
RSX/GL/glutils/image.cpp
RSX/GL/glutils/program.cpp

View File

@ -248,7 +248,7 @@ OPENGL_PROC(PFNGLCOPYIMAGESUBDATAPROC, CopyImageSubData);
// ARB_Buffer_Storage
OPENGL_PROC(PFNGLNAMEDBUFFERSTORAGEPROC, NamedBufferStorage);
OPENGL_PROC(PFNGLNAMEDBUFFERSTORAGEEXTPROC, NamedBufferStorageEXT);
OPENGL_PROC(PFNGLBUFFERSTORAGEPROC, BufferStorage);
// ARB_sync
OPENGL_PROC(PFNGLFENCESYNCPROC, FenceSync);

View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "buffer_object.h"
#include "common.h"
#include "ex.h"
namespace gl
{
@ -44,7 +45,7 @@ namespace gl
flags |= GL_CLIENT_STORAGE_BIT;
}
DSA_CALL2(NamedBufferStorage, m_id, size, data_, flags);
DSA_CALL_EX(NamedBufferStorage, m_id, static_cast<GLenum>(m_target), size, data_, flags);
m_size = size;
}
else

View File

@ -25,19 +25,31 @@
#define GL_COMPUTE_BUFFER_SLOT(index) SSBO_SLOT(2 + index)
#define GL_COMPUTE_IMAGE_SLOT(index) SSBO_SLOT(index)
//Function call wrapped in ARB_DSA vs EXT_DSA compat check
// Function call wrapped in ARB_DSA vs EXT_DSA compat check
#define DSA_CALL(func, object_name, target, ...)\
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_CALL_EX(func, object_name, target, ...)\
if (::gl::get_driver_caps().ARB_direct_state_access_supported)\
gl##func(object_name, __VA_ARGS__);\
else\
gl##func##EX(object_name, target, __VA_ARGS__);
#define DSA_CALL2(func, ...)\
if (::gl::get_driver_caps().ARB_direct_state_access_supported)\
gl##func(__VA_ARGS__);\
else\
gl##func##EXT(__VA_ARGS__);
#define DSA_CALL2_EX(func, ...)\
if (::gl::get_driver_caps().ARB_direct_state_access_supported)\
gl##func(__VA_ARGS__);\
else\
gl##func##EX(__VA_ARGS__);
#define DSA_CALL2_RET(func, ...)\
(::gl::get_driver_caps().ARB_direct_state_access_supported) ?\
gl##func(__VA_ARGS__) :\

View File

@ -0,0 +1,19 @@
#include "stdafx.h"
#include "ex.h"
namespace gl::ex
{
void glNamedBufferStorageEX(GLuint buffer, GLenum target, GLsizeiptr size, const void* data, GLbitfield flags)
{
GLint restore = GL_NONE;
glGetIntegerv(target, &restore);
glBindBuffer(target, buffer);
glBufferStorage(target, size, data, flags);
if (restore != buffer)
{
glBindBuffer(target, restore);
}
}
}

View File

@ -0,0 +1,12 @@
#pragma once
#include "capabilities.h"
namespace gl::ex
{
// Fallback EX implementation of NamedBufferStorage. The official EXT_DSA variant was dropped from desktop spec as it was originally meant for GLES only.
// Target parameter reintroduced as an optimization to avoid side effects.
void glNamedBufferStorageEX(GLuint buffer, GLenum target, GLsizeiptr size, const void* data, GLbitfield flags);
}
using namespace ::gl::ex;

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ring_buffer.h"
#include "ex.h"
namespace gl
{
@ -17,7 +18,7 @@ namespace gl
GLbitfield buffer_storage_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
if (gl::get_driver_caps().vendor_MESA) buffer_storage_flags |= GL_CLIENT_STORAGE_BIT;
DSA_CALL2(NamedBufferStorage, m_id, size, data, buffer_storage_flags);
DSA_CALL_EX(NamedBufferStorage, m_id, static_cast<GLenum>(m_target), size, data, buffer_storage_flags);
m_memory_mapping = DSA_CALL2_RET(MapNamedBufferRange, m_id, 0, size, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
ensure(m_memory_mapping != nullptr);
@ -206,7 +207,7 @@ namespace gl
buffer::create();
save_binding_state save(current_target(), *this);
DSA_CALL2(NamedBufferStorage, m_id, size, data, GL_MAP_WRITE_BIT);
DSA_CALL_EX(NamedBufferStorage, m_id, static_cast<GLenum>(m_target), size, data, GL_MAP_WRITE_BIT);
m_data_loc = 0;
m_size = ::narrow<u32>(size);

View File

@ -66,6 +66,7 @@
<ClInclude Include="Emu\RSX\GL\glutils\buffer_object.h" />
<ClInclude Include="Emu\RSX\GL\glutils\capabilities.h" />
<ClInclude Include="Emu\RSX\GL\glutils\common.h" />
<ClInclude Include="Emu\RSX\GL\glutils\ex.h" />
<ClInclude Include="Emu\RSX\GL\glutils\fbo.h" />
<ClInclude Include="Emu\RSX\GL\glutils\pixel_settings.hpp" />
<ClInclude Include="Emu\RSX\GL\glutils\program.h" />
@ -102,6 +103,7 @@
<ClCompile Include="Emu\RSX\GL\glutils\buffer_object.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\capabilities.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\common.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\ex.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\fbo.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\program.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\ring_buffer.cpp" />

View File

@ -49,6 +49,9 @@
</ClCompile>
<ClCompile Include="Emu\RSX\GL\GLDMA.cpp" />
<ClCompile Include="Emu\RSX\GL\GLResolveHelper.cpp" />
<ClCompile Include="Emu\RSX\GL\glutils\ex.cpp">
<Filter>glutils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Emu\RSX\GL\GLTexture.h" />
@ -125,6 +128,9 @@
<ClInclude Include="Emu\RSX\GL\glutils\barriers.h">
<Filter>glutils</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\GL\glutils\ex.h">
<Filter>glutils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="glutils">