citra-emu
/
citra
Archived
1
0
Fork 0

Revert "Use immutable storage when available (#5053)" (#5151)

This reverts commit 407fd15515.
This commit is contained in:
Marshall Mohror 2020-03-26 19:01:18 -05:00 committed by GitHub
parent 4008be436f
commit 5dbf334ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 33 deletions

View File

@ -5,7 +5,6 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <atomic> #include <atomic>
#include <cmath>
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
#include <memory> #include <memory>
@ -321,14 +320,8 @@ static void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tup
cur_state.Apply(); cur_state.Apply();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
if (GL_ARB_texture_storage) { glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0,
// Allocate all possible mipmap levels upfront format_tuple.format, format_tuple.type, nullptr);
auto levels = std::log2(std::max(width, height)) + 1;
glTexStorage2D(GL_TEXTURE_2D, levels, format_tuple.internal_format, width, height);
} else {
glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0,
format_tuple.format, format_tuple.type, nullptr);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -348,22 +341,17 @@ static void AllocateTextureCube(GLuint texture, const FormatTuple& format_tuple,
cur_state.texture_cube_unit.texture_cube = texture; cur_state.texture_cube_unit.texture_cube = texture;
cur_state.Apply(); cur_state.Apply();
glActiveTexture(TextureUnits::TextureCube.Enum()); glActiveTexture(TextureUnits::TextureCube.Enum());
if (GL_ARB_texture_storage) {
// Allocate all possible mipmap levels in case the game uses them later for (auto faces : {
auto levels = std::log2(width) + 1; GL_TEXTURE_CUBE_MAP_POSITIVE_X,
glTexStorage2D(GL_TEXTURE_CUBE_MAP, levels, format_tuple.internal_format, width, width); GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
} else { GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
for (auto faces : { GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, }) {
GL_TEXTURE_CUBE_MAP_NEGATIVE_X, glTexImage2D(faces, 0, format_tuple.internal_format, width, width, 0, format_tuple.format,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, format_tuple.type, nullptr);
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
}) {
glTexImage2D(faces, 0, format_tuple.internal_format, width, width, 0,
format_tuple.format, format_tuple.type, nullptr);
}
} }
// Restore previous texture bindings // Restore previous texture bindings
@ -1562,14 +1550,9 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Pica::Texture::TextureInf
width = surface->GetScaledWidth(); width = surface->GetScaledWidth();
height = surface->GetScaledHeight(); height = surface->GetScaledHeight();
} }
// If we are using ARB_texture_storage then we've already allocated all of the mipmap for (u32 level = surface->max_level + 1; level <= max_level; ++level) {
// levels glTexImage2D(GL_TEXTURE_2D, level, format_tuple.internal_format, width >> level,
if (!GL_ARB_texture_storage) { height >> level, 0, format_tuple.format, format_tuple.type, nullptr);
for (u32 level = surface->max_level + 1; level <= max_level; ++level) {
glTexImage2D(GL_TEXTURE_2D, level, format_tuple.internal_format, width >> level,
height >> level, 0, format_tuple.format, format_tuple.type,
nullptr);
}
} }
if (surface->is_custom) { if (surface->is_custom) {
// TODO: proper mipmap support for custom textures // TODO: proper mipmap support for custom textures