mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Fix MSAA texture creation logic
This commit is contained in:
@@ -1373,7 +1373,7 @@ void Graphics::initCapabilities()
|
|||||||
capabilities.limits[LIMIT_VOLUME_TEXTURE_SIZE] = gl.getMax3DTextureSize();
|
capabilities.limits[LIMIT_VOLUME_TEXTURE_SIZE] = gl.getMax3DTextureSize();
|
||||||
capabilities.limits[LIMIT_CUBE_TEXTURE_SIZE] = gl.getMaxCubeTextureSize();
|
capabilities.limits[LIMIT_CUBE_TEXTURE_SIZE] = gl.getMaxCubeTextureSize();
|
||||||
capabilities.limits[LIMIT_RENDER_TARGETS] = gl.getMaxRenderTargets();
|
capabilities.limits[LIMIT_RENDER_TARGETS] = gl.getMaxRenderTargets();
|
||||||
capabilities.limits[LIMIT_TEXTURE_MSAA] = gl.getMaxRenderbufferSamples();
|
capabilities.limits[LIMIT_TEXTURE_MSAA] = gl.getMaxSamples();
|
||||||
capabilities.limits[LIMIT_ANISOTROPY] = gl.getMaxAnisotropy();
|
capabilities.limits[LIMIT_ANISOTROPY] = gl.getMaxAnisotropy();
|
||||||
static_assert(LIMIT_MAX_ENUM == 8, "Graphics::initCapabilities must be updated when adding a new system limit!");
|
static_assert(LIMIT_MAX_ENUM == 8, "Graphics::initCapabilities must be updated when adding a new system limit!");
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ OpenGL::OpenGL()
|
|||||||
, maxCubeTextureSize(0)
|
, maxCubeTextureSize(0)
|
||||||
, maxTextureArrayLayers(0)
|
, maxTextureArrayLayers(0)
|
||||||
, maxRenderTargets(1)
|
, maxRenderTargets(1)
|
||||||
, maxRenderbufferSamples(0)
|
, maxSamples(1)
|
||||||
, maxTextureUnits(1)
|
, maxTextureUnits(1)
|
||||||
, maxPointSize(1)
|
, maxPointSize(1)
|
||||||
, coreProfile(false)
|
, coreProfile(false)
|
||||||
@@ -474,10 +474,10 @@ void OpenGL::initMaxValues()
|
|||||||
|| GLAD_EXT_framebuffer_multisample || GLAD_APPLE_framebuffer_multisample
|
|| GLAD_EXT_framebuffer_multisample || GLAD_APPLE_framebuffer_multisample
|
||||||
|| GLAD_ANGLE_framebuffer_multisample)
|
|| GLAD_ANGLE_framebuffer_multisample)
|
||||||
{
|
{
|
||||||
glGetIntegerv(GL_MAX_SAMPLES, &maxRenderbufferSamples);
|
glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
maxRenderbufferSamples = 0;
|
maxSamples = 1;
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
||||||
|
|
||||||
@@ -1358,9 +1358,9 @@ int OpenGL::getMaxRenderTargets() const
|
|||||||
return std::min(maxRenderTargets, MAX_COLOR_RENDER_TARGETS);
|
return std::min(maxRenderTargets, MAX_COLOR_RENDER_TARGETS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenGL::getMaxRenderbufferSamples() const
|
int OpenGL::getMaxSamples() const
|
||||||
{
|
{
|
||||||
return maxRenderbufferSamples;
|
return maxSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenGL::getMaxTextureUnits() const
|
int OpenGL::getMaxTextureUnits() const
|
||||||
|
|||||||
@@ -363,9 +363,9 @@ public:
|
|||||||
int getMaxRenderTargets() const;
|
int getMaxRenderTargets() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum supported number of MSAA samples for renderbuffers.
|
* Returns the maximum supported number of MSAA sampless.
|
||||||
**/
|
**/
|
||||||
int getMaxRenderbufferSamples() const;
|
int getMaxSamples() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum number of accessible texture units.
|
* Returns the maximum number of accessible texture units.
|
||||||
@@ -436,7 +436,7 @@ private:
|
|||||||
int maxCubeTextureSize;
|
int maxCubeTextureSize;
|
||||||
int maxTextureArrayLayers;
|
int maxTextureArrayLayers;
|
||||||
int maxRenderTargets;
|
int maxRenderTargets;
|
||||||
int maxRenderbufferSamples;
|
int maxSamples;
|
||||||
int maxTextureUnits;
|
int maxTextureUnits;
|
||||||
float maxPointSize;
|
float maxPointSize;
|
||||||
|
|
||||||
|
|||||||
@@ -280,10 +280,7 @@ bool Texture::createTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mipsize > 0)
|
if (mipsize > 0)
|
||||||
{
|
glCompressedTexImage3D(gltype, mip, fmt.internalformat, w, h, d, 0, mipsize, nullptr);
|
||||||
GLenum gltarget = OpenGL::getGLTextureType(texType);
|
|
||||||
glCompressedTexImage3D(gltarget, mip, fmt.internalformat, w, h, d, 0, mipsize, nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int slice = 0; slice < slicecount; slice++)
|
for (int slice = 0; slice < slicecount; slice++)
|
||||||
@@ -352,10 +349,7 @@ bool Texture::loadVolatile()
|
|||||||
samplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_NONE;
|
samplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getMaxRenderbufferSamples will be 0 on systems that don't support
|
actualSamples = std::max(1, std::min(getRequestedMSAA(), gl.getMaxSamples()));
|
||||||
// multisampled renderbuffers / don't export FBO multisample extensions.
|
|
||||||
actualSamples = std::min(getRequestedMSAA(), gl.getMaxRenderbufferSamples());
|
|
||||||
actualSamples = std::max(actualSamples, 1);
|
|
||||||
|
|
||||||
while (glGetError() != GL_NO_ERROR); // Clear errors.
|
while (glGetError() != GL_NO_ERROR); // Clear errors.
|
||||||
|
|
||||||
@@ -363,7 +357,7 @@ bool Texture::loadVolatile()
|
|||||||
{
|
{
|
||||||
if (isReadable())
|
if (isReadable())
|
||||||
createTexture();
|
createTexture();
|
||||||
if (!isReadable() && actualSamples > 1)
|
if (!isReadable() || actualSamples > 1)
|
||||||
createRenderbuffer();
|
createRenderbuffer();
|
||||||
|
|
||||||
GLenum glerr = glGetError();
|
GLenum glerr = glGetError();
|
||||||
|
|||||||
Reference in New Issue
Block a user