partial followup to #202.

largely cleanups, though does include glCopyImageSubData for gl revs that support it
TODOS:
1) non glCopyImageSubData for `void GFXGLCubemapArray::copyTo(GFXCubemapArray *pDstCubemap)`
2) while we don't get corruption showing in >0 mips for irradiance maps using the newer code, it nevertheless renders wrong.
not 100% sure if renderdoc is showing blank mips because it expects it due to size, or if we are in fact generating em even though we don't use em in the end for irradiance references.
This commit is contained in:
AzaezelX 2020-06-25 17:34:48 -05:00
parent 3e1795ba1d
commit 24e6d8c73c
3 changed files with 21 additions and 16 deletions

View file

@ -227,7 +227,7 @@ void GFXGLCubemap::initDynamic(U32 texSize, GFXFormat faceFormat, U32 mipLevels)
}
}
if( !isCompressed )
if( !isCompressed && !mipLevels)
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
mInitialized = true;
}

View file

@ -475,28 +475,33 @@ void GFXGLDevice::copyResource(GFXTextureObject* pDst, GFXCubemap* pSrc, const U
const bool isCompressed = ImageUtil::isCompressedFormat(format);
U32 mipLevels = pGLSrc->getMipMapLevels();
if (mipLevels < 1) mipLevels = 1;//ensure we loop at least the once
U32 mipLevels = gGLDst->getMipLevels();
for (U32 mip = 0; mip < mipLevels; mip++)
{
U8* pixelData = pGLSrc->getTextureData(face, mip);
glBindTexture(gGLDst->getBinding(), gGLDst->getHandle());
const U32 mipSize = getMax(U32(1), pGLSrc->getSize() >> mip);
if (isCompressed)
if (GFXGL->mCapabilities.copyImage)
{
const U32 mipDataSize = getCompressedSurfaceSize(format, pGLSrc->getSize(), pGLSrc->getSize(), 0);
glCompressedTexSubImage2D(gGLDst->getBinding(), mip, 0, 0, mipSize, mipSize, GFXGLTextureFormat[format], mipDataSize, pixelData);
glCopyImageSubData(pGLSrc->mCubemap, GL_TEXTURE_CUBE_MAP, mip, 0, 0, face, gGLDst->getHandle(), GL_TEXTURE_2D, mip, 0, 0, 0, mipSize, mipSize, 1);
}
else
{
//glCopyImageSubData(pGLSrc->mCubemap, GFXGLCubemap::getEnumForFaceNumber(face), mip, 0, 0, face, gGLDst->getHandle(), GL_TEXTURE_2D, mip, 0, 0, 0, mipSize, mipSize, mip);
glTexSubImage2D(gGLDst->getBinding(), mip, 0, 0, mipSize, mipSize, GFXGLTextureFormat[format], GFXGLTextureType[format], pixelData);
}
glBindTexture(gGLDst->getBinding(), 0);
U8* pixelData = pGLSrc->getTextureData(face, mip);
delete[] pixelData;
glBindTexture(gGLDst->getBinding(), gGLDst->getHandle());
if (isCompressed)
{
const U32 mipDataSize = getCompressedSurfaceSize(format, pGLSrc->getSize(), pGLSrc->getSize(), 0);
glCompressedTexSubImage2D(gGLDst->getBinding(), mip, 0, 0, mipSize, mipSize, GFXGLTextureFormat[format], mipDataSize, pixelData);
}
else
{
glTexSubImage2D(gGLDst->getBinding(), mip, 0, 0, mipSize, mipSize, GFXGLTextureFormat[format], GFXGLTextureType[format], pixelData);
}
glBindTexture(gGLDst->getBinding(), 0);
delete[] pixelData;
}
}
}

View file

@ -177,7 +177,6 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
U32 mipLevels = getMipLevels();
if (mipLevels < 1) mipLevels = 1;//ensure we loop at least the once
for (U32 mip = 0; mip < mipLevels; mip++)
{
U32 srcPixelCount = bmp->getSurfaceSize(mip)/ srcBytesPerPixel;
@ -207,6 +206,7 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
}
}
}
glBindTexture(mBinding, NULL);
PROFILE_END();
return true;