MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / _fastTextureLoad

Function _fastTextureLoad

Engine/source/gfx/gl/gfxGLTextureManager.cpp:229–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227//-----------------------------------------------------------------------------
228
229static void _fastTextureLoad(GFXGLTextureObject* texture, GBitmap* pDL)
230{
231 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture->getBuffer());
232 U32 bufSize = pDL->getWidth(0) * pDL->getHeight(0) * pDL->getBytesPerPixel();
233 glBufferData(GL_PIXEL_UNPACK_BUFFER, bufSize, NULL, GL_STREAM_DRAW);
234
235 if(pDL->getFormat() == GFXFormatR8G8B8A8 || pDL->getFormat() == GFXFormatR8G8B8X8)
236 {
237 PROFILE_SCOPE(Swizzle32_Upload);
238 U8* pboMemory = (U8*)dMalloc(bufSize);
239 GFX->getDeviceSwizzle32()->ToBuffer(pboMemory, pDL->getBits(0), bufSize);
240 glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, bufSize, pboMemory );
241 dFree(pboMemory);
242 }
243 else
244 {
245 PROFILE_SCOPE(SwizzleNull_Upload);
246 glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, bufSize, pDL->getBits(0) );
247 }
248
249 if(texture->getBinding() == GL_TEXTURE_2D)
250 glTexSubImage2D(texture->getBinding(), 0, 0, 0, pDL->getWidth(0), pDL->getHeight(0), GFXGLTextureFormat[pDL->getFormat()], GFXGLTextureType[pDL->getFormat()], NULL);
251 else
252 glTexSubImage1D(texture->getBinding(), 0, 0, (pDL->getWidth(0) > 1 ? pDL->getWidth(0) : pDL->getHeight(0)), GFXGLTextureFormat[pDL->getFormat()], GFXGLTextureType[pDL->getFormat()], NULL);
253
254 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
255}
256
257static void _slowTextureLoad(GFXGLTextureObject* texture, GBitmap* pDL)
258{

Callers 1

_loadTextureMethod · 0.85

Calls 10

getDeviceSwizzle32Method · 0.80
dFreeFunction · 0.50
getBufferMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
getBytesPerPixelMethod · 0.45
getFormatMethod · 0.45
ToBufferMethod · 0.45
getBitsMethod · 0.45
getBindingMethod · 0.45

Tested by

no test coverage detected