Remove the NPOT texture support checks
We require OpenGL 2.0 which always supports NPOT textures.
This commit is contained in:
parent
181afc85fe
commit
edb0751cba
11 changed files with 28 additions and 70 deletions
|
@ -174,7 +174,7 @@ bool ContrastEffect::enabledByDefault()
|
|||
|
||||
bool ContrastEffect::supported()
|
||||
{
|
||||
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported() && GLTexture::NPOTTextureSupported();
|
||||
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported();
|
||||
|
||||
if (supported) {
|
||||
int maxTexSize;
|
||||
|
|
|
@ -154,7 +154,7 @@ bool BlurEffect::enabledByDefault()
|
|||
|
||||
bool BlurEffect::supported()
|
||||
{
|
||||
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported() && GLTexture::NPOTTextureSupported();
|
||||
bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported();
|
||||
|
||||
if (supported) {
|
||||
int maxTexSize;
|
||||
|
|
|
@ -105,7 +105,7 @@ void LogoutEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|||
} else if (!blurTexture) {
|
||||
blurSupported = false;
|
||||
delete blurTarget; // catch as we just tested the texture ;-P
|
||||
if (effects->isOpenGLCompositing() && GLTexture::NPOTTextureSupported() && GLRenderTarget::blitSupported() && useBlur) {
|
||||
if (effects->isOpenGLCompositing() && GLRenderTarget::blitSupported() && useBlur) {
|
||||
// TODO: It seems that it is not possible to create a GLRenderTarget that has
|
||||
// a different size than the display right now. Most likely a KWin core bug.
|
||||
// Create texture and render target
|
||||
|
|
|
@ -94,17 +94,10 @@ void LookingGlassEffect::reconfigure(ReconfigureFlags)
|
|||
|
||||
bool LookingGlassEffect::loadData()
|
||||
{
|
||||
// If NPOT textures are not supported, use nearest power-of-two sized
|
||||
// texture. It wastes memory, but it's possible to support systems without
|
||||
// NPOT textures that way
|
||||
const QSize screenSize = effects->virtualScreenSize();
|
||||
int texw = screenSize.width();
|
||||
int texh = screenSize.height();
|
||||
if (!GLTexture::NPOTTextureSupported()) {
|
||||
qWarning() << "NPOT textures not supported, wasting some memory" ;
|
||||
texw = nearestPowerOfTwo(texw);
|
||||
texh = nearestPowerOfTwo(texh);
|
||||
}
|
||||
|
||||
// Create texture and render target
|
||||
m_texture = new GLTexture(texw, texh);
|
||||
m_texture->setFilter(GL_LINEAR_MIPMAP_LINEAR);
|
||||
|
|
|
@ -110,13 +110,7 @@ void ScreenShotEffect::postPaintScreen()
|
|||
QScopedPointer<GLTexture> offscreenTexture;
|
||||
QScopedPointer<GLRenderTarget> target;
|
||||
if (effects->isOpenGLCompositing()) {
|
||||
int w = width;
|
||||
int h = height;
|
||||
if (!GLTexture::NPOTTextureSupported()) {
|
||||
w = nearestPowerOfTwo(w);
|
||||
h = nearestPowerOfTwo(h);
|
||||
}
|
||||
offscreenTexture.reset(new GLTexture(w, h));
|
||||
offscreenTexture.reset(new GLTexture(width, height));
|
||||
offscreenTexture->setFilter(GL_LINEAR);
|
||||
offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
|
||||
target.reset(new GLRenderTarget(*offscreenTexture));
|
||||
|
|
|
@ -746,9 +746,7 @@ bool GlxTexture::loadTexture(xcb_pixmap_t pixmap, const QSize &size, xcb_visuali
|
|||
if (!info || info->fbconfig == nullptr)
|
||||
return false;
|
||||
|
||||
if ((info->texture_targets & GLX_TEXTURE_2D_BIT_EXT) &&
|
||||
(GLTexture::NPOTTextureSupported() ||
|
||||
(isPowerOfTwo(size.width()) && isPowerOfTwo(size.height())))) {
|
||||
if (info->texture_targets & GLX_TEXTURE_2D_BIT_EXT) {
|
||||
m_target = GL_TEXTURE_2D;
|
||||
m_scale.setWidth(1.0f / m_size.width());
|
||||
m_scale.setHeight(1.0f / m_size.height());
|
||||
|
|
|
@ -103,10 +103,7 @@ void LanczosFilter::updateOffscreenSurfaces()
|
|||
{
|
||||
int w = displayWidth();
|
||||
int h = displayHeight();
|
||||
if (!GLTexture::NPOTTextureSupported()) {
|
||||
w = nearestPowerOfTwo(w);
|
||||
h = nearestPowerOfTwo(h);
|
||||
}
|
||||
|
||||
if (!m_offscreenTex || m_offscreenTex->width() != w || m_offscreenTex->height() != h) {
|
||||
if (m_offscreenTex) {
|
||||
delete m_offscreenTex;
|
||||
|
|
|
@ -42,7 +42,6 @@ namespace KWin
|
|||
// GLTexture
|
||||
//****************************************
|
||||
|
||||
bool GLTexturePrivate::sNPOTTextureSupported = false;
|
||||
bool GLTexturePrivate::sFramebufferObjectSupported = false;
|
||||
GLenum GLTexturePrivate::sTextureFormat = GL_RGBA; // custom dummy, GL_BGRA is not present on GLES
|
||||
uint GLTexturePrivate::s_textureObjectCounter = 0;
|
||||
|
@ -86,27 +85,26 @@ GLTexture::GLTexture(int width, int height)
|
|||
: d_ptr(new GLTexturePrivate())
|
||||
{
|
||||
Q_D(GLTexture);
|
||||
if (NPOTTextureSupported() || (isPowerOfTwo(width) && isPowerOfTwo(height))) {
|
||||
d->m_target = GL_TEXTURE_2D;
|
||||
d->m_scale.setWidth(1.0 / width);
|
||||
d->m_scale.setHeight(1.0 / height);
|
||||
d->m_size = QSize(width, height);
|
||||
d->m_canUseMipmaps = true;
|
||||
|
||||
d->updateMatrix();
|
||||
d->m_target = GL_TEXTURE_2D;
|
||||
d->m_scale.setWidth(1.0 / width);
|
||||
d->m_scale.setHeight(1.0 / height);
|
||||
d->m_size = QSize(width, height);
|
||||
d->m_canUseMipmaps = true;
|
||||
|
||||
glGenTextures(1, &d->m_texture);
|
||||
bind();
|
||||
d->updateMatrix();
|
||||
|
||||
if (!GLPlatform::instance()->isGLES()) {
|
||||
glTexImage2D(d->m_target, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
|
||||
} else {
|
||||
glTexImage2D(d->m_target, 0, GLTexturePrivate::sTextureFormat, width, height,
|
||||
0, GLTexturePrivate::sTextureFormat, GL_UNSIGNED_BYTE, 0);
|
||||
}
|
||||
glGenTextures(1, &d->m_texture);
|
||||
bind();
|
||||
|
||||
unbind();
|
||||
if (!GLPlatform::instance()->isGLES()) {
|
||||
glTexImage2D(d->m_target, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
|
||||
} else {
|
||||
glTexImage2D(d->m_target, 0, GLTexturePrivate::sTextureFormat, width, height,
|
||||
0, GLTexturePrivate::sTextureFormat, GL_UNSIGNED_BYTE, 0);
|
||||
}
|
||||
|
||||
unbind();
|
||||
}
|
||||
|
||||
GLTexture::GLTexture(const QSize &size)
|
||||
|
@ -159,11 +157,9 @@ GLTexturePrivate::~GLTexturePrivate()
|
|||
void GLTexturePrivate::initStatic()
|
||||
{
|
||||
if (!GLPlatform::instance()->isGLES()) {
|
||||
sNPOTTextureSupported = hasGLExtension(QByteArrayLiteral("GL_ARB_texture_non_power_of_two"));
|
||||
sFramebufferObjectSupported = hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object"));
|
||||
sTextureFormat = GL_BGRA;
|
||||
} else {
|
||||
sNPOTTextureSupported = true;
|
||||
sFramebufferObjectSupported = true;
|
||||
if (hasGLExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888")))
|
||||
sTextureFormat = GL_BGRA_EXT;
|
||||
|
@ -174,7 +170,6 @@ void GLTexturePrivate::initStatic()
|
|||
|
||||
void GLTexturePrivate::cleanup()
|
||||
{
|
||||
sNPOTTextureSupported = false;
|
||||
sFramebufferObjectSupported = false;
|
||||
sTextureFormat = GL_RGBA; // custom dummy, GL_BGRA is not present on GLES
|
||||
}
|
||||
|
@ -199,18 +194,12 @@ bool GLTexture::load(const QImage& image, GLenum target)
|
|||
Q_D(GLTexture);
|
||||
if (image.isNull())
|
||||
return false;
|
||||
QImage img = image;
|
||||
|
||||
d->m_target = target;
|
||||
|
||||
if (d->m_target != GL_TEXTURE_RECTANGLE_ARB) {
|
||||
if (!NPOTTextureSupported()
|
||||
&& (!isPowerOfTwo(image.width()) || !isPowerOfTwo(image.height()))) {
|
||||
// non-rectangular target requires POT texture
|
||||
img = img.scaled(nearestPowerOfTwo(image.width()),
|
||||
nearestPowerOfTwo(image.height()));
|
||||
}
|
||||
d->m_scale.setWidth(1.0 / img.width());
|
||||
d->m_scale.setHeight(1.0 / img.height());
|
||||
d->m_scale.setWidth(1.0 / image.width());
|
||||
d->m_scale.setHeight(1.0 / image.height());
|
||||
d->m_canUseMipmaps = true;
|
||||
} else {
|
||||
d->m_scale.setWidth(1.0);
|
||||
|
@ -218,12 +207,12 @@ bool GLTexture::load(const QImage& image, GLenum target)
|
|||
d->m_canUseMipmaps = false;
|
||||
}
|
||||
|
||||
d->m_size = img.size();
|
||||
d->m_size = image.size();
|
||||
d->m_yInverted = true;
|
||||
|
||||
d->updateMatrix();
|
||||
|
||||
img = d->convertToGLFormat(img);
|
||||
const QImage img = d->convertToGLFormat(image);
|
||||
|
||||
if (isNull()) {
|
||||
glGenTextures(1, &d->m_texture);
|
||||
|
@ -317,9 +306,7 @@ void GLTexture::bind()
|
|||
if (d->m_filterChanged) {
|
||||
if (d->m_filter == GL_LINEAR_MIPMAP_LINEAR) {
|
||||
// trilinear filtering requested, but is it possible?
|
||||
if (d->sNPOTTextureSupported
|
||||
&& d->sFramebufferObjectSupported
|
||||
&& d->m_canUseMipmaps) {
|
||||
if (d->sFramebufferObjectSupported && d->m_canUseMipmaps) {
|
||||
glTexParameteri(d->m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(d->m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glGenerateMipmap(d->m_target);
|
||||
|
@ -595,11 +582,6 @@ QMatrix4x4 GLTexture::matrix(TextureCoordinateType type) const
|
|||
return d->m_matrix[type];
|
||||
}
|
||||
|
||||
bool GLTexture::NPOTTextureSupported()
|
||||
{
|
||||
return GLTexturePrivate::sNPOTTextureSupported;
|
||||
}
|
||||
|
||||
bool GLTexture::framebufferObjectSupported()
|
||||
{
|
||||
return GLTexturePrivate::sFramebufferObjectSupported;
|
||||
|
|
|
@ -104,7 +104,6 @@ public:
|
|||
void setWrapMode(GLenum mode);
|
||||
void setDirty();
|
||||
|
||||
static bool NPOTTextureSupported();
|
||||
static bool framebufferObjectSupported();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -70,7 +70,6 @@ public:
|
|||
|
||||
static void initStatic();
|
||||
|
||||
static bool sNPOTTextureSupported;
|
||||
static bool sFramebufferObjectSupported;
|
||||
static GLenum sTextureFormat;
|
||||
static uint s_fbo;
|
||||
|
|
|
@ -357,10 +357,6 @@ void OpenGLPaintRedirector::resizePixmaps(const QRect *rects)
|
|||
size.rwidth() = align(size.width(), 128);
|
||||
|
||||
effects->makeOpenGLContextCurrent();
|
||||
if (!GLTexture::NPOTTextureSupported()) {
|
||||
size.rwidth() = nearestPowerOfTwo(size.width());
|
||||
size.rheight() = nearestPowerOfTwo(size.height());
|
||||
}
|
||||
|
||||
if (m_texture && m_texture->size() == size)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue