Fix MSAA texture creation logic

This commit is contained in:
Alex Szpakowski
2020-02-09 12:46:52 -04:00
parent 694bc9c5b7
commit aa636381d0
4 changed files with 12 additions and 18 deletions
+1 -1
View File
@@ -1373,7 +1373,7 @@ void Graphics::initCapabilities()
capabilities.limits[LIMIT_VOLUME_TEXTURE_SIZE] = gl.getMax3DTextureSize();
capabilities.limits[LIMIT_CUBE_TEXTURE_SIZE] = gl.getMaxCubeTextureSize();
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();
static_assert(LIMIT_MAX_ENUM == 8, "Graphics::initCapabilities must be updated when adding a new system limit!");
+5 -5
View File
@@ -102,7 +102,7 @@ OpenGL::OpenGL()
, maxCubeTextureSize(0)
, maxTextureArrayLayers(0)
, maxRenderTargets(1)
, maxRenderbufferSamples(0)
, maxSamples(1)
, maxTextureUnits(1)
, maxPointSize(1)
, coreProfile(false)
@@ -474,10 +474,10 @@ void OpenGL::initMaxValues()
|| GLAD_EXT_framebuffer_multisample || GLAD_APPLE_framebuffer_multisample
|| GLAD_ANGLE_framebuffer_multisample)
{
glGetIntegerv(GL_MAX_SAMPLES, &maxRenderbufferSamples);
glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
}
else
maxRenderbufferSamples = 0;
maxSamples = 1;
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
@@ -1358,9 +1358,9 @@ int OpenGL::getMaxRenderTargets() const
return std::min(maxRenderTargets, MAX_COLOR_RENDER_TARGETS);
}
int OpenGL::getMaxRenderbufferSamples() const
int OpenGL::getMaxSamples() const
{
return maxRenderbufferSamples;
return maxSamples;
}
int OpenGL::getMaxTextureUnits() const
+3 -3
View File
@@ -363,9 +363,9 @@ public:
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.
@@ -436,7 +436,7 @@ private:
int maxCubeTextureSize;
int maxTextureArrayLayers;
int maxRenderTargets;
int maxRenderbufferSamples;
int maxSamples;
int maxTextureUnits;
float maxPointSize;
+3 -9
View File
@@ -280,10 +280,7 @@ bool Texture::createTexture()
}
if (mipsize > 0)
{
GLenum gltarget = OpenGL::getGLTextureType(texType);
glCompressedTexImage3D(gltarget, mip, fmt.internalformat, w, h, d, 0, mipsize, nullptr);
}
glCompressedTexImage3D(gltype, mip, fmt.internalformat, w, h, d, 0, mipsize, nullptr);
}
for (int slice = 0; slice < slicecount; slice++)
@@ -352,10 +349,7 @@ bool Texture::loadVolatile()
samplerState.mipmapFilter = SamplerState::MIPMAP_FILTER_NONE;
}
// getMaxRenderbufferSamples will be 0 on systems that don't support
// multisampled renderbuffers / don't export FBO multisample extensions.
actualSamples = std::min(getRequestedMSAA(), gl.getMaxRenderbufferSamples());
actualSamples = std::max(actualSamples, 1);
actualSamples = std::max(1, std::min(getRequestedMSAA(), gl.getMaxSamples()));
while (glGetError() != GL_NO_ERROR); // Clear errors.
@@ -363,7 +357,7 @@ bool Texture::loadVolatile()
{
if (isReadable())
createTexture();
if (!isReadable() && actualSamples > 1)
if (!isReadable() || actualSamples > 1)
createRenderbuffer();
GLenum glerr = glGetError();