OGL: Use ARB_texture_storage to allocate TextureCache entries
This ensures that they are complete textures by decoding time, as when using compute shaders we write directly to the destination texture.
This commit is contained in:
parent
c8cbbd831d
commit
a8876a29fe
|
@ -65,7 +65,7 @@ GLuint FramebufferManager::CreateTexture(GLenum texture_type, GLenum internal_fo
|
|||
}
|
||||
else if (texture_type == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
||||
{
|
||||
if (g_ogl_config.bSupports3DTextureStorage)
|
||||
if (g_ogl_config.bSupports3DTextureStorageMultisample)
|
||||
glTexStorage3DMultisample(texture_type, m_msaaSamples, internal_format, m_targetWidth,
|
||||
m_targetHeight, m_EFBLayers, false);
|
||||
else
|
||||
|
@ -74,7 +74,7 @@ GLuint FramebufferManager::CreateTexture(GLenum texture_type, GLenum internal_fo
|
|||
}
|
||||
else if (texture_type == GL_TEXTURE_2D_MULTISAMPLE)
|
||||
{
|
||||
if (g_ogl_config.bSupports2DTextureStorage)
|
||||
if (g_ogl_config.bSupports2DTextureStorageMultisample)
|
||||
glTexStorage2DMultisample(texture_type, m_msaaSamples, internal_format, m_targetWidth,
|
||||
m_targetHeight, false);
|
||||
else
|
||||
|
|
|
@ -451,10 +451,11 @@ Renderer::Renderer()
|
|||
g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array");
|
||||
g_ogl_config.bSupportsDebug =
|
||||
GLExtensions::Supports("GL_KHR_debug") || GLExtensions::Supports("GL_ARB_debug_output");
|
||||
g_ogl_config.bSupports3DTextureStorage =
|
||||
g_ogl_config.bSupportsTextureStorage = GLExtensions::Supports("GL_ARB_texture_storage");
|
||||
g_ogl_config.bSupports3DTextureStorageMultisample =
|
||||
GLExtensions::Supports("GL_ARB_texture_storage_multisample") ||
|
||||
GLExtensions::Supports("GL_OES_texture_storage_multisample_2d_array");
|
||||
g_ogl_config.bSupports2DTextureStorage =
|
||||
g_ogl_config.bSupports2DTextureStorageMultisample =
|
||||
GLExtensions::Supports("GL_ARB_texture_storage_multisample");
|
||||
g_ogl_config.bSupportsEarlyFragmentTests =
|
||||
GLExtensions::Supports("GL_ARB_shader_image_load_store");
|
||||
|
@ -486,6 +487,7 @@ Renderer::Renderer()
|
|||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSLES_300;
|
||||
g_ogl_config.bSupportsAEP = false;
|
||||
g_ogl_config.bSupportsTextureStorage = true;
|
||||
g_Config.backend_info.bSupportsGeometryShaders = false;
|
||||
}
|
||||
else if (GLExtensions::Version() == 310)
|
||||
|
@ -500,9 +502,10 @@ Renderer::Renderer()
|
|||
g_Config.backend_info.bSupportsSSAA = g_ogl_config.bSupportsAEP;
|
||||
g_Config.backend_info.bSupportsFragmentStoresAndAtomics = true;
|
||||
g_ogl_config.bSupportsMSAA = true;
|
||||
g_ogl_config.bSupports2DTextureStorage = true;
|
||||
g_ogl_config.bSupportsTextureStorage = true;
|
||||
g_ogl_config.bSupports2DTextureStorageMultisample = true;
|
||||
if (g_ActiveConfig.iStereoMode > 0 && g_ActiveConfig.iMultisamples > 1 &&
|
||||
!g_ogl_config.bSupports3DTextureStorage)
|
||||
!g_ogl_config.bSupports3DTextureStorageMultisample)
|
||||
{
|
||||
// GLES 3.1 can't support stereo rendering and MSAA
|
||||
OSD::AddMessage("MSAA Stereo rendering isn't supported by your GPU.", 10000);
|
||||
|
@ -524,8 +527,9 @@ Renderer::Renderer()
|
|||
g_ogl_config.bSupportsGLBaseVertex = true;
|
||||
g_ogl_config.bSupportsDebug = true;
|
||||
g_ogl_config.bSupportsMSAA = true;
|
||||
g_ogl_config.bSupports2DTextureStorage = true;
|
||||
g_ogl_config.bSupports3DTextureStorage = true;
|
||||
g_ogl_config.bSupportsTextureStorage = true;
|
||||
g_ogl_config.bSupports2DTextureStorageMultisample = true;
|
||||
g_ogl_config.bSupports3DTextureStorageMultisample = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -51,8 +51,9 @@ struct VideoConfig
|
|||
bool bSupportsCopySubImage;
|
||||
u8 SupportedESPointSize;
|
||||
ES_TEXBUF_TYPE SupportedESTextureBuffer;
|
||||
bool bSupports2DTextureStorage;
|
||||
bool bSupports3DTextureStorage;
|
||||
bool bSupportsTextureStorage;
|
||||
bool bSupports2DTextureStorageMultisample;
|
||||
bool bSupports3DTextureStorageMultisample;
|
||||
bool bSupportsEarlyFragmentTests;
|
||||
bool bSupportsConservativeDepth;
|
||||
bool bSupportsAniso;
|
||||
|
|
|
@ -119,13 +119,22 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConf
|
|||
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, config.levels - 1);
|
||||
|
||||
if (g_ogl_config.bSupportsTextureStorage)
|
||||
{
|
||||
glTexStorage3D(GL_TEXTURE_2D_ARRAY, config.levels, GL_RGBA8, config.width, config.height,
|
||||
config.layers);
|
||||
}
|
||||
|
||||
if (config.rendertarget)
|
||||
{
|
||||
for (u32 level = 0; level < config.levels; level++)
|
||||
if (!g_ogl_config.bSupportsTextureStorage)
|
||||
{
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, std::max(config.width >> level, 1u),
|
||||
std::max(config.height >> level, 1u), config.layers, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nullptr);
|
||||
for (u32 level = 0; level < config.levels; level++)
|
||||
{
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, std::max(config.width >> level, 1u),
|
||||
std::max(config.height >> level, 1u), config.layers, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, nullptr);
|
||||
}
|
||||
}
|
||||
glGenFramebuffers(1, &entry->framebuffer);
|
||||
FramebufferManager::SetFramebuffer(entry->framebuffer);
|
||||
|
@ -188,8 +197,16 @@ void TextureCache::TCacheEntry::Load(const u8* buffer, u32 width, u32 height, u3
|
|||
if (expanded_width != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
||||
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, width, height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
if (g_ogl_config.bSupportsTextureStorage)
|
||||
{
|
||||
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, 0, 0, 0, width, height, 1, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, width, height, 1, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, buffer);
|
||||
}
|
||||
|
||||
if (expanded_width != width)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
|
Loading…
Reference in New Issue