GL: Remove texture storage workaround

# Conflicts:
#	source/blender/gpu/opengl/gl_backend.cc
This commit is contained in:
Clément Foucault
2024-01-31 16:04:51 +01:00
committed by Clément Foucault
parent 0673ad344c
commit 856daa13a5
3 changed files with 3 additions and 63 deletions

View File

@@ -321,7 +321,6 @@ static void detect_workarounds()
GLContext::geometry_shader_invocations = false;
GLContext::texture_cube_map_array_support = false;
GLContext::texture_gather_support = false;
GLContext::texture_storage_support = false;
#endif
return;
@@ -511,7 +510,6 @@ bool GLContext::texture_barrier_support = false;
bool GLContext::texture_cube_map_array_support = false;
bool GLContext::texture_filter_anisotropic_support = false;
bool GLContext::texture_gather_support = false;
bool GLContext::texture_storage_support = false;
/** Workarounds. */
@@ -606,7 +604,6 @@ void GLBackend::capabilities_init()
GLContext::texture_filter_anisotropic_support = epoxy_has_gl_extension(
"GL_EXT_texture_filter_anisotropic");
GLContext::texture_gather_support = epoxy_has_gl_extension("GL_ARB_texture_gather");
GLContext::texture_storage_support = epoxy_gl_version() >= 43;
/* Disabled until it is proven to work. */
GLContext::framebuffer_fetch_support = false;

View File

@@ -64,7 +64,6 @@ class GLContext : public Context {
static bool texture_cube_map_array_support;
static bool texture_filter_anisotropic_support;
static bool texture_gather_support;
static bool texture_storage_support;
/** Workarounds. */

View File

@@ -76,72 +76,18 @@ bool GLTexture::init_internal()
GLenum internal_format = to_gl_internal_format(format_);
const bool is_cubemap = bool(type_ == GPU_TEXTURE_CUBE);
const bool is_layered = bool(type_ & GPU_TEXTURE_ARRAY);
const bool is_compressed = bool(format_flag_ & GPU_FORMAT_COMPRESSED);
const int dimensions = (is_cubemap) ? 2 : this->dimensions_count();
GLenum gl_format = to_gl_data_format(format_);
GLenum gl_type = to_gl(to_data_format(format_));
auto mip_size = [&](int h, int w = 1, int d = 1) -> size_t {
return divide_ceil_u(w, 4) * divide_ceil_u(h, 4) * divide_ceil_u(d, 4) *
to_block_size(format_);
};
switch (dimensions) {
default:
case 1:
if (GLContext::texture_storage_support) {
glTexStorage1D(target_, mipmaps_, internal_format, w_);
}
else {
for (int i = 0, w = w_; i < mipmaps_; i++) {
if (is_compressed) {
glCompressedTexImage1D(target_, i, internal_format, w, 0, mip_size(w), nullptr);
}
else {
glTexImage1D(target_, i, internal_format, w, 0, gl_format, gl_type, nullptr);
}
w = max_ii(1, (w / 2));
}
}
glTexStorage1D(target_, mipmaps_, internal_format, w_);
break;
case 2:
if (GLContext::texture_storage_support) {
glTexStorage2D(target_, mipmaps_, internal_format, w_, h_);
}
else {
for (int i = 0, w = w_, h = h_; i < mipmaps_; i++) {
for (int f = 0; f < (is_cubemap ? 6 : 1); f++) {
GLenum target = (is_cubemap) ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + f : target_;
if (is_compressed) {
glCompressedTexImage2D(target, i, internal_format, w, h, 0, mip_size(w, h), nullptr);
}
else {
glTexImage2D(target, i, internal_format, w, h, 0, gl_format, gl_type, nullptr);
}
}
w = max_ii(1, (w / 2));
h = is_layered ? h_ : max_ii(1, (h / 2));
}
}
glTexStorage2D(target_, mipmaps_, internal_format, w_, h_);
break;
case 3:
if (GLContext::texture_storage_support) {
glTexStorage3D(target_, mipmaps_, internal_format, w_, h_, d_);
}
else {
for (int i = 0, w = w_, h = h_, d = d_; i < mipmaps_; i++) {
if (is_compressed) {
glCompressedTexImage3D(
target_, i, internal_format, w, h, d, 0, mip_size(w, h, d), nullptr);
}
else {
glTexImage3D(target_, i, internal_format, w, h, d, 0, gl_format, gl_type, nullptr);
}
w = max_ii(1, (w / 2));
h = max_ii(1, (h / 2));
d = is_layered ? d_ : max_ii(1, (d / 2));
}
}
glTexStorage3D(target_, mipmaps_, internal_format, w_, h_, d_);
break;
}
this->mip_range_set(0, mipmaps_ - 1);
@@ -182,8 +128,6 @@ bool GLTexture::init_internal(GPUVertBuf *vbo)
bool GLTexture::init_internal(GPUTexture *src, int mip_offset, int layer_offset, bool use_stencil)
{
BLI_assert(GLContext::texture_storage_support);
const GLTexture *gl_src = static_cast<const GLTexture *>(unwrap(src));
GLenum internal_format = to_gl_internal_format(format_);
target_ = to_gl_target(type_);