321 const vector<double>&
invLut,
328 const vigra::Diff2D
destUL,
336 long t1,
t3,
t5,
t6,
t7,
t9,
t10,
t11,
t12,
t13,
t14,
t15,
t16,
t17,
t18,
t19,
t21;
346 cout <<
"destStart=[" <<
xstart <<
", " <<
ystart <<
"]" << endl
347 <<
"destEnd=[" <<
xend <<
", " <<
yend <<
"]" << endl
348 <<
"destSize=[" <<
destSize <<
"]" << endl
349 <<
"srcSize=[" <<
srcSize <<
"]" << endl
385 cout <<
"Retrieving GL_MAX_RECTANGLE_TEXTURE_SIZE: " <<
maxTextureSize << std::endl;
393 cout <<
"Retrieving GL_MAX_TEXTURE_SIZE: " <<
maxTextureSize << std::endl;
414 cerr <<
"nona: Can't allocate texture with a size of at least 1024 pixels." << std::endl;;
429#define GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX 0x9048
439#define TEXTURE_FREE_MEMORY_ATI 0x87FC
473 "failed to subdivide source and dest images into pieces small enough to fit in gpu memory.");
477 cout <<
"Source chunks:" << endl;
479 cout <<
" " << *
rI << endl;
481 cout <<
"Dest chunks:" << endl;
483 cout <<
" " << *
rI << endl;
494 cout <<
"Interpolator chunks:" << endl;
496 cout <<
" " << *
rI << endl;
511 std::ostringstream
oss;
512 oss << std::setprecision(20) << std::showpoint;
513 oss <<
"#version 110" << endl
514 <<
"#extension GL_ARB_texture_rectangle : enable" << endl
515 <<
"uniform sampler2DRect SrcTexture;" << endl
516 <<
"float sinh(in float x) { return (exp(x) - exp(-x)) / 2.0; }" << endl
517 <<
"float cosh(in float x) { return (exp(x) + exp(-x)) / 2.0; }" << endl;
523 oss <<
"float atan2_xge0(const in float y, const in float x) {" << endl
524 <<
" if (abs(y) > x) {" << endl
525 <<
" return sign(y) * (" << (
M_PI/2.0) <<
" - atan(x, abs(y)));" << endl
526 <<
" } else {" << endl
527 <<
" return atan(y, x);" << endl
530 <<
"float atan2_safe(const in float y, const in float x) {" << endl
531 <<
" if (x >= 0.0) return atan2_xge0(y, x);" << endl
532 <<
" else return (sign(y) * " <<
M_PI <<
") - atan2_xge0(y, -x);" << endl
534 <<
"float atan_safe(const in float yx) {" << endl
535 <<
" if (abs(yx) > 1.0) {" << endl
536 <<
" return sign(yx) * (" << (
M_PI/2.0) <<
" - atan(1.0/abs(yx)));" << endl
537 <<
" } else {" << endl
538 <<
" return atan(yx);" << endl
542 oss <<
"float atan2_xge0(const in float y, const in float x) {" << endl
543 <<
" return atan(y, x);" << endl
545 <<
"float atan2_safe(const in float y, const in float x) {" << endl
546 <<
" return atan(y, x);" << endl
548 <<
"float atan_safe(const in float yx) {" << endl
549 <<
" return atan(yx);" << endl
553 oss <<
"void main(void)" << endl
555 <<
" float discardA = 1.0;" << endl
556 <<
" float discardB = 0.0;" << endl
558 <<
" src = src * discardA + vec2(-1000.0, -1000.0) * discardB;" << endl
559 <<
" gl_FragColor = vec4(src.s, 0.0, 0.0, src.t);" << endl
597 oss << std::setprecision(20) << std::showpoint;
598 oss <<
"#version 110" << endl
599 <<
"#extension GL_ARB_texture_rectangle : enable" << endl
600 <<
"uniform sampler2DRect CoordTexture;" << endl
601 <<
"uniform sampler2DRect SrcTexture;" << endl
602 <<
"uniform sampler2DRect AccumTexture;" << endl
603 <<
"uniform vec2 SrcUL;" << endl
604 <<
"uniform vec2 SrcLR;" << endl
605 <<
"uniform vec2 KernelUL;" << endl
606 <<
"uniform vec2 KernelWH;" << endl
607 <<
"float w(const in float i, const in float f) {" << endl
610 <<
"void main(void)" << endl
612 <<
" vec2 src = texture2DRect(CoordTexture, gl_TexCoord[0].st).sq;" << endl
613 <<
" vec4 accum = texture2DRect(AccumTexture, gl_TexCoord[0].st);" << endl
628 oss <<
" src -= SrcUL;" << endl
629 <<
" vec2 t = floor(src) + " << (1.5 - (
interpolatorSize / 2)) <<
";" << endl
630 <<
" vec2 f = fract(src);" << endl
631 <<
" vec2 k = vec2(0.0, 0.0);" << endl
636 oss <<
" for (float ky = 0.0; ky < " <<
static_cast<double>(
firstInterpolatorChunk.height()) <<
"; ky += 1.0) {" << endl;
638 oss <<
" for (float ky = 0.0; ky < KernelWH.t; ky += 1.0) {" << endl;
641 oss <<
" k.t = ky + KernelUL.t;" << endl
642 <<
" float wy = w(k.t, f.t);" << endl;
647 oss <<
" for (float kx = 0.0; kx < KernelWH.s; kx += 1.0) {" << endl;
651 oss <<
" k.s = kx + KernelUL.s;" << endl
652 <<
" float wx = w(k.s, f.s);" << endl
653 <<
" vec2 ix = t + k;" << endl
654 <<
" vec4 sp = texture2DRect(SrcTexture, ix);" << endl
655 <<
" float weight = wx * wy * sp.a;" << endl
656 <<
" accum += sp * weight;" << endl
677 <<
" gl_FragColor = accum;" << endl
704 oss << std::setprecision(20) << std::showpoint;
705 oss <<
"#version 120" << endl
706 <<
"#extension GL_ARB_texture_rectangle : enable" << endl
707 <<
"uniform sampler2DRect NormTexture;" << endl
708 <<
"uniform sampler2DRect CoordTexture;" << endl;
711 oss <<
"uniform sampler2DRect InvLutTexture;" << endl;
715 oss <<
"uniform sampler2DRect DestLutTexture;" << endl;
718 oss <<
"void main(void)" << endl
720 <<
" // Normalization" << endl
721 <<
" vec4 n = texture2DRect(NormTexture, gl_TexCoord[0].st);" << endl
722 <<
" vec4 p = vec4(0.0, 0.0, 0.0, 0.0);" << endl
723 <<
" if (n.a >= 0.2) p = n / n.a;" << endl
725 <<
" // Photometric" << endl
728 <<
" gl_FragColor = p;" << endl
752 for (
int i = 0;
i <
invLut.size(); ++
i) {
791 cout <<
"gpu shader program compile time = " << ((
t21 -
t1)/1000.0) << endl;
960 cout <<
"gpu shader texture/framebuffer setup time = " << ((
getms()-
t21)/1000.0) << endl;
989 cout <<
"gpu dest chunk=" << *
dI <<
" coord image render time = " << ((
t4-
t3)/1000.0) << endl;
1021 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src upload = " << ((
t6-
t5)/1000.0) << endl;
1039 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src alpha upload = " << ((
t7-
t6)/1000.0) << endl;
1054 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src+alpha render = " << ((
getms()-
t7)/1000.0) << endl;
1074 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src upload = " << ((
t6-
t5)/1000.0) << endl;
1090 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src alpha upload = " << ((
t7-
t6)/1000.0) << endl;
1111 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src+alpha render = " << ((
getms()-
t7)/1000.0) << endl;
1136 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" src render = " << ((
t7-
t6)/1000.0) << endl;
1194 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" interpolation chunk=" << *
iI <<
" setup = " << ((
t10-
t9)/1000.0) << endl;
1211 cout <<
"gpu dest chunk=" << *
dI <<
" source chunk=" << *
sI <<
" interpolation chunk=" << *
iI <<
" render = " << ((
t11-
t10)/1000.0) << endl;
1255 cout <<
"gpu dest chunk=" << *
dI <<
" normalization setup = " << ((
t12-
t11)/1000.0) << endl;
1271 cout <<
"gpu dest chunk=" << *
dI <<
" normalization render = " << ((
t13-
t12)/1000.0) << endl;
1278#if defined(__APPLE__) && defined(__aarch64__)
1288#define APPLE_PACK_WORKAROUND
1290#if defined APPLE_PACK_WORKAROUND
1338 cout <<
"gpu dest chunk=" << *
dI <<
" rgb readback = " << ((
t14-
t13)/1000.0) << endl;
1357 cout <<
"gpu dest chunk=" << *
dI <<
" dest rgb disassembly setup = " << ((
t14-
t13)/1000.0) << endl;
1377 cout <<
"gpu dest chunk=" << *
dI <<
" dest rgb disassembly render = " << ((
t15-
t14)/1000.0) << endl;
1390 cout <<
"gpu dest chunk=" << *
dI <<
" rgb readback = " << ((
t16-
t15)/1000.0) << endl;
1394#if defined APPLE_PACK_WORKAROUND
1398 for (
int y = 0; y <
dI->height(); ++y)
1407#if defined APPLE_PACK_WORKAROUND
1430 cout <<
"gpu dest chunk=" << *
dI <<
" dest alpha disassembly setup = " << ((
t17-
t16)/1000.0) << endl;
1450 cout <<
"gpu dest chunk=" << *
dI <<
" dest alpha disassembly render = " << ((
t18-
t17)/1000.0) << endl;
1460#if defined APPLE_PACK_WORKAROUND
1464 for (
int y = 0; y <
dI->height(); ++y)
1476 cout <<
"gpu dest chunk=" << *
dI <<
" alpha readback = " << ((
t19-
t18)/1000.0) << endl;
1480#if defined APPLE_PACK_WORKAROUND
1527 cout <<
"gpu destruct time = " << ((
t20-
t19)/1000.0) << endl;
1528 cout <<
"gpu total time = " << ((
t20-
t1)/1000.0) << endl;
bool transformImageGPUIntern(const std::string &coordXformGLSL, const std::string &interpolatorGLSL, const int interpolatorSize, const std::string &photometricGLSL, const vector< double > &invLut, const vector< double > &destLut, const vigra::Diff2D srcSize, const void *const srcBuffer, const int srcGLInternalFormat, const int srcGLTransferFormat, const int srcGLFormat, const int srcGLType, const void *const srcAlphaBuffer, const int srcAlphaGLType, const vigra::Diff2D destUL, const vigra::Diff2D destSize, void *const destBuffer, const int destGLInternalFormat, const int destGLTransferFormat, const int destGLFormat, const int destGLType, void *const destAlphaBuffer, const int destAlphaGLType, const bool warparound)
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.