clean the usage of glCopyImageSubData and provide a fall back for 4.2)

This commit is contained in:
samcake 2017-02-08 11:35:50 -08:00
parent a137659a35
commit 8a40e951ac

View file

@ -438,34 +438,36 @@ void GL45Texture::stripToMip(uint16_t newMinMip) {
// Copy the contents of the old texture to the new // Copy the contents of the old texture to the new
{ {
PROFILE_RANGE(render_gpu_gl, "Blit"); PROFILE_RANGE(render_gpu_gl, "Blit");
/* // Preferred path only available in 4.3
GLuint fbo { 0 }; if (GLEW_VERSION_4_3) {
glCreateFramebuffers(1, &fbo); for (uint16 targetMip = _minMip; targetMip <= _maxMip; ++targetMip) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); uint16 sourceMip = targetMip + mipDelta;
for (uint16 targetMip = _minMip; targetMip <= _maxMip; ++targetMip) { Vec3u mipDimensions = _gpuObject.evalMipDimensions(targetMip + _mipOffset);
uint16 sourceMip = targetMip + mipDelta; for (GLenum target : getFaceTargets(_target)) {
Vec3u mipDimensions = _gpuObject.evalMipDimensions(targetMip + _mipOffset); glCopyImageSubData(
for (GLenum target : getFaceTargets(_target)) { oldId, target, sourceMip, 0, 0, 0,
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, oldId, sourceMip); _id, target, targetMip, 0, 0, 0,
(void)CHECK_GL_ERROR(); mipDimensions.x, mipDimensions.y, 1
glCopyTextureSubImage2D(_id, targetMip, 0, 0, 0, 0, mipDimensions.x, mipDimensions.y); );
(void)CHECK_GL_ERROR(); (void)CHECK_GL_ERROR();
}
} }
} } else {
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); GLuint fbo { 0 };
glDeleteFramebuffers(1, &fbo); glCreateFramebuffers(1, &fbo);
*/ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
for (uint16 targetMip = _minMip; targetMip <= _maxMip; ++targetMip) { for (uint16 targetMip = _minMip; targetMip <= _maxMip; ++targetMip) {
uint16 sourceMip = targetMip + mipDelta; uint16 sourceMip = targetMip + mipDelta;
Vec3u mipDimensions = _gpuObject.evalMipDimensions(targetMip + _mipOffset); Vec3u mipDimensions = _gpuObject.evalMipDimensions(targetMip + _mipOffset);
for (GLenum target : getFaceTargets(_target)) { for (GLenum target : getFaceTargets(_target)) {
glCopyImageSubData( glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, oldId, sourceMip);
oldId, target, sourceMip, 0, 0, 0, (void)CHECK_GL_ERROR();
_id, target, targetMip, 0, 0, 0, glCopyTextureSubImage2D(_id, targetMip, 0, 0, 0, 0, mipDimensions.x, mipDimensions.y);
mipDimensions.x, mipDimensions.y, 1 (void)CHECK_GL_ERROR();
); }
(void)CHECK_GL_ERROR();
} }
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glDeleteFramebuffers(1, &fbo);
} }
glDeleteTextures(1, &oldId); glDeleteTextures(1, &oldId);