File indexing completed on 2026-04-09 07:49:11
0001 #include <csignal>
0002 #include "QTexMaker.hh"
0003
0004 #include "scuda.h"
0005 #include "NP.hh"
0006 #include "QTex.hh"
0007 #include "SLOG.hh"
0008
0009 const plog::Severity QTexMaker::LEVEL = SLOG::EnvLevel("QTexMaker", "DEBUG");
0010
0011
0012 QTex<float4>* QTexMaker::Make2d_f4( const NP* icdf, char filterMode, bool normalizedCoords )
0013 {
0014 unsigned ndim = icdf->shape.size();
0015 LOG(info) << " ndim " << ndim ;
0016 unsigned hd_factor = icdf->get_meta<unsigned>("hd_factor", 0) ;
0017 LOG(info) << " hd_factor " << hd_factor ;
0018
0019 LOG_IF(fatal, filterMode == 'P' ) << " filtermode 'P' without interpolation is in use : appropriate for basic tex machinery tests only " ;
0020
0021 LOG(info)
0022 << "["
0023 << " icdf " << icdf->sstr()
0024 << " ndim " << ndim
0025 << " hd_factor " << hd_factor
0026 << " filterMode " << filterMode
0027 ;
0028
0029 assert( ndim == 3 && icdf->shape[ndim-1] == 4 );
0030
0031 QTex<float4>* tex = QTexMaker::Make2d_f4_(icdf, filterMode, normalizedCoords );
0032 tex->setHDFactor(hd_factor);
0033 tex->uploadMeta();
0034
0035 LOG(LEVEL) << "]" ;
0036
0037 return tex ;
0038 }
0039
0040
0041
0042
0043 QTex<float4>* QTexMaker::Make2d_f4_( const NP* a, char filterMode, bool normalizedCoords )
0044 {
0045 assert( a->ebyte == 4 && "need to narrow double precision arrays first ");
0046 unsigned ndim = a->shape.size();
0047 bool ndim_expect = ndim == 3 ;
0048 assert( ndim_expect );
0049 if(!ndim_expect) std::raise(SIGINT);
0050
0051 unsigned ni = a->shape[0] ;
0052 unsigned nj = a->shape[1] ;
0053 unsigned nk = a->shape[2] ;
0054
0055 bool nk_expect = nk == 4 ;
0056 assert( nk_expect );
0057 if(!nk_expect) std::raise(SIGINT);
0058
0059 size_t height = ni ;
0060 size_t width = nj ;
0061 const void* src = (const void*)a->bytes();
0062
0063
0064
0065
0066 QTex<float4>* tex = new QTex<float4>( width, height, src, filterMode, normalizedCoords, a );
0067 tex->setOrigin(a);
0068
0069 return tex ;
0070 }
0071