소스 검색

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.

AzaezelX 5 년 전
부모
커밋
24e6d8c73c
3개의 변경된 파일21개의 추가작업 그리고 16개의 파일을 삭제
  1. 1 1
      Engine/source/gfx/gl/gfxGLCubemap.cpp
  2. 19 14
      Engine/source/gfx/gl/gfxGLDevice.cpp
  3. 1 1
      Engine/source/gfx/gl/gfxGLTextureObject.cpp

+ 1 - 1
Engine/source/gfx/gl/gfxGLCubemap.cpp

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

+ 19 - 14
Engine/source/gfx/gl/gfxGLDevice.cpp

@@ -475,28 +475,33 @@ void GFXGLDevice::copyResource(GFXTextureObject* pDst, GFXCubemap* pSrc, const U
 
 
    const bool isCompressed = ImageUtil::isCompressedFormat(format);
    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++)
    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);
       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
       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);
+
+         glBindTexture(gGLDst->getBinding(), gGLDst->getHandle());
+         if (isCompressed)
+         {
+            const U32 mipDataSize = getCompressedSurfaceSize(format, pGLSrc->getSize(), pGLSrc->getSize(), 0);
 
 
-      delete[] pixelData;
+            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;
+      }
    }
    }
 }
 }
 
 

+ 1 - 1
Engine/source/gfx/gl/gfxGLTextureObject.cpp

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