Spectrum ConnectBDPT(const Scene &scene, Vertex *lightVertices, Vertex *cameraVertices, int s, int t, const Distribution1D &lightDistr, const Camera &camera, Sampler &sampler, Point2f *pRaster, Float *misWeightPtr) { Spectrum L(0.f); // Ignore invalid connections related to infinite area lights if (t > 1 && s != 0 && cameraVertices[t - 1].type == VertexType::Light) return Spectrum(0.f); // Perform connection and write contribution to _L_ Vertex sampled; if (s == 0) { // Interpret the camera subpath as a complete path const Vertex &pt = cameraVertices[t - 1]; if (pt.IsLight()) L = pt.Le(scene, cameraVertices[t - 2]) * pt.beta; Assert(!L.HasNaNs()); } else if (t == 1) { // Sample a point on the camera and connect it to the light subpath const Vertex &qs = lightVertices[s - 1]; if (qs.IsConnectible()) { VisibilityTester vis; Vector3f wi; Float pdf; Spectrum Wi = camera.Sample_Wi(qs.GetInteraction(), sampler.Get2D(), &wi, &pdf, pRaster, &vis); if (pdf > 0 && !Wi.IsBlack()) { // Initialize dynamically sampled vertex and _L_ for $t=1$ case sampled = Vertex::CreateCamera(&camera, vis.P1(), Wi / pdf); L = qs.beta * qs.f(sampled) * sampled.beta; if (qs.IsOnSurface()) L *= AbsDot(wi, qs.ns()); Assert(!L.HasNaNs()); // Only check visibility after we know that the path would // make a non-zero contribution. if (!L.IsBlack()) L *= vis.Tr(scene, sampler); } } } else if (s == 1) { // Sample a point on a light and connect it to the camera subpath const Vertex &pt = cameraVertices[t - 1]; if (pt.IsConnectible()) { Float lightPdf; VisibilityTester vis; Vector3f wi; Float pdf; int lightNum = lightDistr.SampleDiscrete(sampler.Get1D(), &lightPdf); const std::shared_ptr<Light> &light = scene.lights[lightNum]; Spectrum lightWeight = light->Sample_Li( pt.GetInteraction(), sampler.Get2D(), &wi, &pdf, &vis); if (pdf > 0 && !lightWeight.IsBlack()) { EndpointInteraction ei(vis.P1(), light.get()); sampled = Vertex::CreateLight(ei, lightWeight / (pdf * lightPdf), 0); sampled.pdfFwd = sampled.PdfLightOrigin(scene, pt, lightDistr); L = pt.beta * pt.f(sampled) * sampled.beta; if (pt.IsOnSurface()) L *= AbsDot(wi, pt.ns()); // Only check visibility if the path would carry radiance. if (!L.IsBlack()) L *= vis.Tr(scene, sampler); } } } else { // Handle all other bidirectional connection cases const Vertex &qs = lightVertices[s - 1], &pt = cameraVertices[t - 1]; if (qs.IsConnectible() && pt.IsConnectible()) { L = qs.beta * qs.f(pt) * pt.f(qs) * pt.beta; if (!L.IsBlack()) L *= G(scene, sampler, qs, pt); } } ++totalPaths; if (L.IsBlack()) ++zeroRadiancePaths; ReportValue(pathLength, s + t - 2); // Compute MIS weight for connection strategy Float misWeight = L.IsBlack() ? 0.f : MISWeight(scene, lightVertices, cameraVertices, sampled, s, t, lightDistr); Assert(!std::isnan(misWeight)); L *= misWeight; if (misWeightPtr) *misWeightPtr = misWeight; return L; }
int main(int argc, char** argv) { Shape inShape = NULL; Shape outShape= NULL; int i,c; int doVTable=0; int *oTable, *mTable; float *vTable; int counter; float tester; if(argc != 3) { fprintf(stderr,"Usage:\n\t%s inFile outFile.\n",argv[0]); return 1; } inShape = readShapeFromFile(argv[1]); if(inShape == NULL) return 1; /* printf("Let's see what's in the inShape!\n");*/ #ifdef DEBUG printf("There are %d vertices.\n",inShape->numVertices); #endif /*printf("The vTable contains:\n");*/ for(c=0;c<inShape->numVertices*3;c+=3) { /* printf("%d => %f %f %f\n",c,inShape->vTable[c], inShape->vTable[c+1], inShape->vTable[c+2]);*/ } //printf("The tTable contains %d triangles\n\n",numTriangles(inShape)); // for(c=0;c<numTriangles(inShape)*3;c+=3) // { // printf("%d => %d %d %d\n", c,inShape->tTable[c], // inShape->tTable[c+1], // inShape->tTable[c+2]); // } oTable = malloc(sizeof(int)*numTriangles(inShape)*3); /*oTable = malloc(sizeof(int)*99999);*/ /* for(c=0;c<inShape->numVertices*3;c++)*/ for(c=0;c<numTriangles(inShape)*3;c++) { oTable[c] = -1; } /* for(c=0;c<numTriangles(inShape)*3;c++) for(i=c+1;i<inShape->numVertices*3;i++)*/ // printf("There are %d iterations of c and i\n",numTriangles(inShape)*3); for(c=0;c<numTriangles(inShape)*3;c++) for(i=c+1;i<numTriangles(inShape)*3;i++) { // if(c<10) // printf("Trying to match %d and %d..V(N(c))=%d, V(P(i))=%d, V(P(c)=%d,v(N(i))=%d\n",c,i,V(inShape,N(c)),V(inShape,P(i)),V(inShape,P(c)),V(inShape,N(i))); if((V(inShape,N(c)) == V(inShape,P(i))) &&(V(inShape,P(c)) == V(inShape,N(i)))) { // printf("Match found!\n"); oTable[c] = i; oTable[i] = c; } } printf("This is the oTable:\n"); for(c=0;c<numTriangles(inShape)*3;c++) { printf("%d => %d\n",c,oTable[c]); } for(c=0;c<numTriangles(inShape)*3;c++) if(oTable[c] == -1) { printf("MISALIGNMENT in corner %d!!!\n",c); printf("Cannot find a corner (opposite than at %d) with N(c)=%d and P(c)=%d\n", V(inShape,c),V(inShape,P(c)),V(inShape,N(c))); return 1; } /*mTable = malloc(sizeof(int)*inShape->numVertices*3);*/ mTable = malloc(sizeof(int)*numTriangles(inShape)*3); /* for(c=0;c<inShape->numVertices*3;c++)*/ for(c=0;c<numTriangles(inShape)*3;c++) mTable[c] = -1; /*outShape = createShape(4*inShape->numVertices-6);*/ outShape = createShape(4*inShape->numVertices,4*numTriangles(inShape)); printf("outShape has %d vertices\n",outShape->numVertices); printf("outShape has %d Triangles\n",numTriangles(outShape)); if(outShape == NULL) return 5; for(doVTable = 0;doVTable < inShape->numTables; doVTable++) { outShape->vTable = outShape->vTables[doVTable]; inShape->vTable = inShape->vTables[doVTable]; for(c=0;c<inShape->numVertices*3;c++) /* for(c=0;c<numTriangles(inShape)*3;c++)*/ { outShape->vTable[c] = inShape->vTable[c]; } } counter = inShape->numVertices - 1; printf("Counter starts at: %d\n",counter); /*for(c=0;c<inShape->numVertices*3;c++)*/ for(c=0;c<numTriangles(inShape)*3;c++) { if(mTable[c] == -1) { counter++; for(doVTable=0;doVTable<inShape->numTables;doVTable++) { outShape->vTable = outShape->vTables[doVTable]; inShape->vTable = inShape->vTables[doVTable]; vTable = inShape->vTable; outShape->vTable[counter*3]=0; outShape->vTable[counter*3]= (vTable[3*V(inShape,N(c))]+ vTable[3*V(inShape,P(c))])/2; outShape->vTable[counter*3]+= ( ( vTable[3*V(inShape,c)] + vTable[3*V(inShape,oTable[c])] )/2 - ( vTable[3*L(inShape,c,oTable)] + vTable[3*R(inShape,c,oTable)] +vTable[3*L(inShape,oTable[c],oTable)] + vTable[3*R(inShape,oTable[c],oTable)] )/4 )/4; outShape->vTable[counter*3+1]= (vTable[3*(V(inShape,N(c)))+1]+ vTable[3*(V(inShape,P(c)))+1])/2 + ( ( vTable[3*(V(inShape,c))+1] + vTable[3*(V(inShape,oTable[c]))+1] )/2 - ( vTable[3*(L(inShape,c,oTable))+1] + vTable[3*(R(inShape,c,oTable))+1] +vTable[3*(L(inShape,oTable[c],oTable))+1] + vTable[3*(R(inShape,oTable[c],oTable))+1] )/4 )/4; outShape->vTable[counter*3+2]= (vTable[3*(V(inShape,N(c)))+2]+ vTable[3*(V(inShape,P(c)))+2])/2 + ( ( vTable[3*(V(inShape,c))+2] + vTable[3*(V(inShape,oTable[c]))+2] )/2 - ( vTable[3*(L(inShape,c,oTable))+2] + vTable[3*(R(inShape,c,oTable))+2] +vTable[3*(L(inShape,oTable[c],oTable))+2] + vTable[3*(R(inShape,oTable[c],oTable))+2] )/4 )/4; } /* outShape->vTable[counter*3] = (vTable[3*V(inShape,N(c))] + vTable[3*V(inShape,P(c))])/2; outShape->vTable[counter*3+1] = (vTable[3*(V(inShape,N(c)))+1] + vTable[3*(V(inShape,P(c)))+1])/2; outShape->vTable[counter*3+2] = (vTable[3*(V(inShape,N(c)))+2] + vTable[3*(V(inShape,P(c)))+2])/2; */ printf("counter is %d\n",counter); printf("----\n"); mTable[c] = counter; mTable[oTable[c]] = counter; } } outShape->numVertices = counter+1; printf("outShape has %d vertices\n",outShape->numVertices); /* printf("mTable:\n"); for(c=0;c<inShape->numVertices*3;c++) printf("\t%d => %d\n",c,mTable[c]);*/ /*printf("new vTable:\n");*/ /* for(c=0;c<outShape->numVertices;c++) printf("\t%d => %f %f %f\n",c,outShape->vTable[c*3], outShape->vTable[c*3+1], outShape->vTable[c*3+2]);*/ /* printf("Counter finishes at: %d\n",counter);*/ printf("there are %d triangles\n",numTriangles(inShape)); for(c=0;c<numTriangles(inShape)*3;c+=3) { printf("Triangle %d %d %d becomes: \n",V(inShape,c),V(inShape,c+1), V(inShape,c+2)); outShape->tTable[c*4] = V(inShape,c); outShape->tTable[c*4+1]=mTable[c+2]; outShape->tTable[c*4+2]=mTable[c+1]; /* printf("\tTriangle %d %d %d\n", outShape->tTable[c*4], outShape->tTable[c*4+1], outShape->tTable[c*4+2]);*/ outShape->tTable[c*4+3]=mTable[c+1]; outShape->tTable[c*4+4]=mTable[c]; outShape->tTable[c*4+5]=V(inShape,c+2); /* printf("\tTriangle %d %d %d\n", outShape->tTable[c*4+3], outShape->tTable[c*4+4], outShape->tTable[c*4+5]);*/ outShape->tTable[c*4+6]=mTable[c+2]; outShape->tTable[c*4+7]=V(inShape,c+1); outShape->tTable[c*4+8]=mTable[c]; /* printf("\tTriangle %d %d %d\n", outShape->tTable[c*4+6], outShape->tTable[c*4+7], outShape->tTable[c*4+8]);*/ outShape->tTable[c*4+9]=mTable[c]; outShape->tTable[c*4+10]=mTable[c+1]; outShape->tTable[c*4+11]=mTable[c+2]; /* printf("\tTriangle %d %d %d\n", outShape->tTable[c*4+9], outShape->tTable[c*4+10], outShape->tTable[c*4+11]);*/ } printf("new tTable:\n"); for(c=0;c<numTriangles(outShape);c++) { printf("%d => %d %d %d\n",c,outShape->tTable[c*3], outShape->tTable[c*3+1], outShape->tTable[c*3+2]); } writeShapeToFile(outShape,argv[2]); printf("Hey there!!!!!\n\n\n");fflush(stdout); destroyShape(inShape); destroyShape(outShape); printf("Hey there!!!!!\n\n\n");fflush(stdout); return 0; }
void labelip6(void) { wmove(wnd, 0, 0); wclrtoeol(wnd); #define L(row, str) mvwprintw(wnd, row, 10, str) #define R(row, str) mvwprintw(wnd, row, 45, str); L(1, "IPv6 Input"); R(1, "IPv6 Output"); L(2, "total packets received"); R(2, "total packets sent"); L(3, "- too short for header"); R(3, "- generated locally"); L(4, "- too short for data"); R(4, "- output drops"); L(5, "- with invalid version"); R(5, "output fragments generated"); L(6, "total fragments received"); R(6, "- fragmentation failed"); L(7, "- fragments dropped"); R(7, "destinations unreachable"); L(8, "- fragments timed out"); R(8, "packets output via raw IP"); L(9, "- fragments overflown"); L(10, "- packets reassembled ok"); R(10, "Input next-header histogram"); L(11, "packets forwarded"); R(11, " - destination options"); L(12, "- unreachable dests"); R(12, " - hop-by-hop options"); L(13, "- redirects generated"); R(13, " - IPv4"); L(14, "option errors"); R(14, " - TCP"); L(15, "unwanted multicasts"); R(15, " - UDP"); L(16, "delivered to upper layer"); R(16, " - IPv6"); L(17, "bad scope packets"); R(17, " - routing header"); L(18, "address selection failed"); R(18, " - fragmentation header"); R(19, " - ICMP6"); R(20, " - none"); #undef L #undef R }
int query(int x, int y, int id = 1, int l = 0, int r = sz) { if(y <= l || r <= x) return INF; if(x <= l && r <= y) return st[id]; int mid = (l + r) >> 1; return min(query(x, y, L(id), l, mid), query(x, y, R(id), mid, r)); }
void DBConnectionPool::release(const string& host, DBClientBase *c) { scoped_lock L(_mutex); _pools[PoolKey(host,c->getSoTimeout())].done(this,c); }
void InitEAX(void){ ALCdevice *pDevice = NULL; ALCcontext *pContext = NULL; pContext = qalcGetCurrentContext(); pDevice = qalcGetContextsDevice(pContext); if (qalcIsExtensionPresent(pDevice, (ALCchar*)ALC_EXT_EFX_NAME)){ L(alGenEffects); L(alDeleteEffects); L(alIsEffect); L(alEffecti); L(alEffectiv); L(alEffectf); L(alEffectfv); L(alGetEffecti); L(alGetEffectiv); L(alGetEffectf); L(alGetEffectfv); L(alGenFilters); L(alDeleteFilters); L(alIsFilter); L(alFilteri); L(alFilteriv); L(alFilterf); L(alFilterfv); L(alGetFilteri); L(alGetFilteriv); L(alGetFilterf); L(alGetFilterfv); L(alGenAuxiliaryEffectSlots); L(alDeleteAuxiliaryEffectSlots); L(alIsAuxiliaryEffectSlot); L(alAuxiliaryEffectSloti); L(alAuxiliaryEffectSlotiv); L(alAuxiliaryEffectSlotf); L(alAuxiliaryEffectSlotfv); L(alGetAuxiliaryEffectSloti); L(alGetAuxiliaryEffectSlotiv); L(alGetAuxiliaryEffectSlotf); L(alGetAuxiliaryEffectSlotfv); }else{ SPRaise("Extension not found: '%s'", ALC_EXT_EFX_NAME); } }
void testprob() { int count, graph, i, iter, j, min_n_stations, n_stations, *stations, sum, t_sum, upper_bound; int n_explored, n_generated, n_states; double best_first_cpu, bfs_bbr_cpu, best_hoffman_cpu, hoffman_cpu, total_cpu; clock_t start_time; sum = 0; printf("%s\n",prob_file); read_problem(prob_file); close_pred(); if (run_forward == -1) { std::vector<int> E(n_tasks + 1); std::vector<int> L(n_tasks + 1); // Determine whether to run in forward or reverse for (int j = 1; j <= n_tasks; ++j) { double ftime = t[j]; double rtime = t[j]; for (int i = 1; i <= n_tasks; ++i) { if (closed_predecessor_matrix[i][j]) ftime += t[i]; // If task i precedes task j if (closed_predecessor_matrix[j][i]) rtime += t[i]; // If task j precedes task i } E[j] = ceil(ftime/cycle); L[j] = ceil(rtime/cycle); } unsigned int f = 1; //changed by AS 2013/06/10 unsigned int r = 1; //changed by AS 2013/06/10 for (int m = 1; m <= 5; ++m) { unsigned int fcount = 0; //changed by AS 2013/06/08 unsigned int rcount = 0; //changed by AS 2013/06/08 for (int j = 1; j <= n_tasks; ++j) { if (E[j] <= m) ++fcount; if (L[j] <= m) ++rcount; } f *= fcount; r *= rcount; } if (r < f) { printf("running in reverse %d %d\n", f, r); reverse_pred(); for (int j = 1; j <= n_tasks; ++j) free(closed_predecessor_matrix[j]); free(closed_predecessor_matrix); close_pred(); } else printf("running forward %d %d\n", f, r); } else if (run_forward == 0) { printf("running in reverse\n"); reverse_pred(); for (int j = 1; j <= n_tasks; ++j) free(closed_predecessor_matrix[j]); free(closed_predecessor_matrix); close_pred(); } find_successors(); //prn_successors(); compute_potentially_dominates(); //prn_pred(potentially_dominates); compute_positional_weights(); //prn_vec(n_predecessors, n_tasks); prn_vec(n_successors, n_tasks); prn_vec(positional_weight, n_tasks); compute_descending_order(); MALLOC(root_degrees, n_tasks+1, char); t_sum = 0; for(i = 1; i <= n_tasks; i++) { t_sum += t[i]; count = 0; for(j = 1; j <= n_tasks; j++) { if(predecessor_matrix[j][i] == 1) count++; } root_degrees[i] = count; } MALLOC(stations, n_tasks+1, int); MALLOC(states, STATE_SPACE+1, state); search_info.start_time = clock(); //cycle = 1000; // Use Hoffman type heuristic to find a reasonably good upper bound. start_time = clock(); best_hoffman_cpu = 0.0; initialize_hoffman(); min_n_stations = BIG_INT; for (alpha = 0.000; alpha <= 0.02; alpha += 0.005) { for (beta = 0.000; beta <= 0.02; beta += 0.005) { for (gimmel = 0; gimmel <= 0.03; gimmel += 0.01) { n_stations = hoffman(root_degrees, 1000, 1, 5000); if(n_stations < min_n_stations) { min_n_stations = n_stations; best_hoffman_cpu = (double) (clock() - start_time) / CLOCKS_PER_SEC; } } } } upper_bound = min_n_stations; UB = min_n_stations; free_hoffman(); hoffman_cpu = (double) (clock() - start_time) / CLOCKS_PER_SEC; printf("MHH upper bound: %d (%0.2fs)\n", UB, hoffman_cpu); compute_LB2_values(); compute_LB3_values(); best_first_cpu = 0.0; bfs_bbr_cpu = 0.0; n_explored = 0; n_generated = 0; n_states = 0; printf("First lower bound: %d\n", (int)ceil((double)t_sum / (double)cycle)); global_start_time = clock(); if (ceil((double) t_sum / (double) cycle) < upper_bound) { start_time = clock(); initialize_best_first_bbr(); if (bin_pack_lb == 1) initialize_bin_packing(); best_first_bbr(upper_bound); n_explored = search_info.n_explored; n_generated = search_info.n_generated; n_states = search_info.n_states; search_info.n_explored = 0; search_info.n_generated = 0; search_info.n_states = 0; free_heaps(); free_best_first_bbr(); reinitialize_states(); if ((verified_optimality != 0) && (bin_pack_lb == 1)) free_bin_packing(); best_first_cpu = (double) (clock() - start_time) / CLOCKS_PER_SEC; if (verified_optimality == 0) { verified_optimality = 1; start_time = clock(); initialize_bfs_bbr(); bfs_bbr(UB); free_bfs_bbr(); if (bin_pack_lb == 1) free_bin_packing(); bfs_bbr_cpu = (double) (clock() - start_time) / CLOCKS_PER_SEC; } } else printf("Optimality proved by LB1\n"); total_cpu = (double) (clock() - search_info.start_time) / CLOCKS_PER_SEC; printf("Solution with %d stations\n ",optimalsolution[0]); //added by AS 2013/06/06 for(j = 1; j <= n_tasks; j++) { printf("%d\t%d\n", j,optimalsolution[j]); } write_solution(prob_file); //added by AS 2013/06/06 free(stations); for(j = 1; j <= n_tasks; j++) { free(predecessor_matrix[j]); free(closed_predecessor_matrix[j]); free(potentially_dominates[j]); free(successors[j]); free(predecessors[j]); } free(predecessor_matrix); free(closed_predecessor_matrix); free(potentially_dominates); free(predecessors); free(successors); free(t); free(n_successors); free(n_predecessors); free(positional_weight); free(hash_values); free(LB2_values); free(LB3_values); free(sorted_task_times); free(descending_order); free(states); free(root_degrees); }
void compile(RuntimeBlockInfo* block, bool force_checks, bool reset, bool staging, bool optimise) { mov(rax, (size_t)&cycle_counter); sub(dword[rax], block->guest_cycles); sub(rsp, 0x28); for (size_t i = 0; i < block->oplist.size(); i++) { shil_opcode& op = block->oplist[i]; switch (op.op) { case shop_ifb: if (op.rs1._imm) { mov(rax, (size_t)&next_pc); mov(dword[rax], op.rs2._imm); } mov(call_regs[0], op.rs3._imm); call((void*)OpDesc[op.rs3._imm]->oph); break; case shop_jcond: case shop_jdyn: { mov(rax, (size_t)op.rs1.reg_ptr()); mov(ecx, dword[rax]); if (op.rs2.is_imm()) { add(ecx, op.rs2._imm); } mov(rdx, (size_t)op.rd.reg_ptr()); mov(dword[rdx], ecx); } break; case shop_mov32: { verify(op.rd.is_reg()); verify(op.rs1.is_reg() || op.rs1.is_imm()); sh_to_reg(op.rs1, mov, ecx); reg_to_sh(op.rd, ecx); } break; case shop_mov64: { verify(op.rd.is_reg()); verify(op.rs1.is_reg() || op.rs1.is_imm()); sh_to_reg(op.rs1, mov, rcx); reg_to_sh(op.rd, rcx); } break; case shop_readm: { sh_to_reg(op.rs1, mov, call_regs[0]); sh_to_reg(op.rs3, add, call_regs[0]); u32 size = op.flags & 0x7f; if (size == 1) { call((void*)ReadMem8); movsx(rcx, al); } else if (size == 2) { call((void*)ReadMem16); movsx(rcx, ax); } else if (size == 4) { call((void*)ReadMem32); mov(rcx, rax); } else if (size == 8) { call((void*)ReadMem64); mov(rcx, rax); } else { die("1..8 bytes"); } if (size != 8) reg_to_sh(op.rd, ecx); else reg_to_sh(op.rd, rcx); } break; case shop_writem: { u32 size = op.flags & 0x7f; sh_to_reg(op.rs1, mov, call_regs[0]); sh_to_reg(op.rs3, add, call_regs[0]); if (size != 8) sh_to_reg(op.rs2, mov, call_regs[1]); else sh_to_reg(op.rs2, mov, call_regs64[1]); if (size == 1) call((void*)WriteMem8); else if (size == 2) call((void*)WriteMem16); else if (size == 4) call((void*)WriteMem32); else if (size == 8) call((void*)WriteMem64); else { die("1..8 bytes"); } } break; default: shil_chf[op.op](&op); break; } } mov(rax, (size_t)&next_pc); switch (block->BlockType) { case BET_StaticJump: case BET_StaticCall: //next_pc = block->BranchBlock; mov(dword[rax], block->BranchBlock); break; case BET_Cond_0: case BET_Cond_1: { //next_pc = next_pc_value; //if (*jdyn == 0) //next_pc = branch_pc_value; mov(dword[rax], block->NextBlock); if (block->has_jcond) mov(rdx, (size_t)&Sh4cntx.jdyn); else mov(rdx, (size_t)&sr.T); cmp(dword[rdx], block->BlockType & 1); Xbyak::Label branch_not_taken; jne(branch_not_taken, T_SHORT); mov(dword[rax], block->BranchBlock); L(branch_not_taken); } break; case BET_DynamicJump: case BET_DynamicCall: case BET_DynamicRet: //next_pc = *jdyn; mov(rdx, (size_t)&Sh4cntx.jdyn); mov(edx, dword[rdx]); mov(dword[rax], edx); break; case BET_DynamicIntr: case BET_StaticIntr: if (block->BlockType == BET_DynamicIntr) { //next_pc = *jdyn; mov(rdx, (size_t)&Sh4cntx.jdyn); mov(edx, dword[rdx]); mov(dword[rax], edx); } else { //next_pc = next_pc_value; mov(dword[rax], block->NextBlock); } call((void*)UpdateINTC); break; default: die("Invalid block end type"); } add(rsp, 0x28); ret(); ready(); block->code = (DynarecCodeEntryPtr)getCode(); emit_Skip(getSize()); }
Spectrum *CreateFilter(int width, int height, FilterType option, int orientation, double numAngles) { Spectrum *result = CreateSpectrum(width, height); double wi = -M_PI; double dwi = (2.0*M_PI)/height; double dwj = (2.0*M_PI)/width; double thetak = orientation*M_PI/numAngles; double thetak0 = (orientation-1)*M_PI/numAngles; double theta = 0; int i,j; for (i=0; i<height; i++) { double wj = -M_PI; for (j=0; j<width; j++) { double r = sqrt(wi*wi+wj*wj); double value = 0.0; if (option == BandPass) { if(thetak > 0 && thetak <= M_PI/2) theta = atan2(wj,wi); else if(thetak > M_PI/2 && thetak <= M_PI) theta = atan2(wj,wi)+M_PI; if(theta < 0 ) theta += M_PI; if((theta >= thetak0 && theta <= thetak)) { value = H(r)*L(r); } else if((theta >= thetak0 + M_PI && theta <= thetak + M_PI)) { value = H(r)*L(r); } } else if (option == LowPass) { value = L(r); } result->real[result->tbrow[i] + j] = value; result->imag[result->tbrow[i] + j] = 0.0; wj += dwj; } wi += dwi; } return result; }
void CUnitTable::ReadModConfig() { L(ai, "[CUnitTable::ReadModConfig()]"); std::string cfgFileName = GetModCfgName(); std::fstream cfgFile; std::stringstream msg; int cfgVersion = 0; if (ai->cb->GetFileSize(cfgFileName.c_str()) != -1) { if (!ai->luaParser->Execute(cfgFileName, "config")) { msg << "\tparse-error in existing mod configuration file \""; msg << cfgFileName << "\": " << ai->luaParser->GetError(); L(ai, msg.str()); return; } else { msg << "\tparsed existing mod configuration file \""; msg << cfgFileName << "\""; L(ai, msg.str()); } const LuaTable* rootTbl = ai->luaParser->GetRootTbl(); const LuaTable* unitTbl = NULL; const UnitDef* unitDef = NULL; if (rootTbl->GetIntVal("version", cfgVersion) > CFGVERSION) { msg.str(""); msg << "\tconfig-file version (" << cfgVersion << ") is newer than current version (" << CFGVERSION << ")"; return; } UnitType* unitType = NULL; UnitCategory defUnitCat = CAT_LAST; UnitCategory cfgUnitCat = CAT_LAST; std::list<std::string> keys; rootTbl->GetStrTblKeys(&keys); for (std::list<std::string>::const_iterator it = keys.begin(); it != keys.end(); ++it) { unitDef = ai->cb->GetUnitDef((*it).c_str()); if (unitDef == NULL) { msg.str(""); msg << "\t\t.cfg entry \"" << (*it) << "\" does not refer to a valid unit-type"; L(ai, msg.str()); continue; } unitTbl = rootTbl->GetTblVal(*it); unitType = &unitTypes[unitDef->id]; unitType->costMultiplier = unitTbl->GetIntVal("costMult", 100) / 100.0f; unitType->techLevel = unitTbl->GetIntVal("techLevel", -1); defUnitCat = unitType->category; cfgUnitCat = UnitCategory(unitTbl->GetIntVal("category", CAT_LAST)); { msg.str(""); msg << "\t\tunitDef->id: " << unitDef->id << ", unitDef->name: " << unitDef->name; msg << ", default cat.: " << defUnitCat << ", .cfg cat.: " << cfgUnitCat; L(ai, msg.str()); } /* * TODO: look for any possible "side-effects" that might arise * from overriding categories like this, then enable overrides * other than builder --> attacker (ie. SEGV when an *unarmed* * CAT_BUILDER unit masquerading as a CAT_G_ATTACK'er wants to * or is attacked, due to NULL weapondefs) */ if (defUnitCat != cfgUnitCat) { if (cfgUnitCat < 0 || cfgUnitCat >= CAT_LAST) { // invalid unit-category number continue; } if (cfgUnitCat == CAT_G_ATTACK && defUnitCat == CAT_BUILDER) { { msg.str(""); msg << "\t\t\t.cfg unit category (CAT_G_ATTACK) overrides unitType->category (CAT_BUILDER)"; L(ai, msg.str()); } std::vector<int>::iterator vit; std::vector<int>& oldDefs = categoryData.GetDefsForUnitCat(defUnitCat); std::vector<int>& newDefs = categoryData.GetDefsForUnitCat(cfgUnitCat); for (vit = oldDefs.begin(); vit != oldDefs.end(); vit++) { const int unitDefID = *vit; if (unitDefID == unitDef->id) { oldDefs.erase(vit); newDefs.push_back(unitDefID); vit--; } } unitType->category = cfgUnitCat; } } } } else { { msg.str(""); msg << "\twriting new mod configuration file \""; msg << cfgFileName << "\""; L(ai, msg.str()); } cfgFile.open(cfgFileName.c_str(), std::ios::out); cfgFile << "config = {\n"; cfgFile << "\tversion = " << CFGVERSION << ",\n\n"; for (int i = 1; i <= numDefs; i++) { UnitType* unitType = &unitTypes[i]; // assign and write default values for costMultiplier // and techLevel, category is already set in ::Init() unitType->costMultiplier = 1.0f; unitType->techLevel = -1; cfgFile << "\t" << unitType->def->name << " = {\n"; cfgFile << "\t\tcostMult = " << unitType->costMultiplier << " * 100" << ",\n"; cfgFile << "\t\ttechLevel = " << unitType->techLevel << ",\n"; cfgFile << "\t\tcategory = " << unitType->category << ",\n"; cfgFile << "\t},\n"; } cfgFile << "}\n"; cfgFile.close(); } }
void CUnitTable::DebugPrint() { const char* listCategoryNames[12] = { "GROUND-FACTORY", "GROUND-BUILDER", "GROUND-ATTACKER", "METAL-EXTRACTOR", "METAL-MAKER", "METAL-STORAGE", "ENERGY-STORAGE", "GROUND-ENERGY", "GROUND-DEFENSE", "NUKE-SILO", "SHIELD-GENERATOR", "LAST-CATEGORY" }; std::stringstream msg; std::string logFileName = GetDbgLogName(); FILE* f = fopen(logFileName.c_str(), "w"); if (f == NULL) { msg << "[CUnitTable::DebugPrint()] could not open "; msg << "debug log " << logFileName << " for writing"; L(ai, msg.str()); return; } for (int i = 1; i <= numDefs; i++) { const UnitType* utype = &unitTypes[i]; const UnitDef* udef = unitDefs[i - 1]; msg << "UnitDef ID: " << i << "\n"; msg << "\tName: " << udef->name; msg << " (\"" << udef->humanName << "\")\n"; msg << "\tCan Build:\n"; for (unsigned int j = 0; j != utype->canBuildList.size(); j++) { const UnitType* buildOption = &unitTypes[utype->canBuildList[j]]; const char* buildOptName = buildOption->def->humanName.c_str(); msg << "\t\t\"" << buildOptName << "\"\n"; } /* msg << "\tBuilt By:\n"; for (unsigned int k = 0; k != utype->builtByList.size(); k++) { UnitType* parent = &unitTypes[utype->builtByList[k]]; for (std::set<int>::iterator it = parent->sides.begin(); it != parent->sides.end(); it++) { const char* sideName = sideNames[*it].c_str(); const char* parentName = parent->def->humanName.c_str(); msg << "\t\t(\"" << sideName << "\") \"" << parentName << "\"\n"; } } */ msg << "\n\n"; } for (int defCatIdx = int(CAT_GROUND_FACTORY); defCatIdx <= int(CAT_NUKE_SILO); defCatIdx++) { msg << "units grouped under category \""; msg << listCategoryNames[defCatIdx]; msg << "\":\n"; const UnitDefCategory c = UnitDefCategory(defCatIdx); const std::vector<int>& defs = categoryData.GetDefsForUnitDefCat(c); for (unsigned int i = 0; i != defs.size(); i++) { const UnitDef* udef = unitTypes[defs[i]].def; msg << "\t" << udef->name << " (\""; msg << udef->humanName << "\")\n"; } msg << "\n"; } msg << "\n\n"; fprintf(f, "%s", msg.str().c_str()); fclose(f); }
void Peer::AddPeerNode(PeerNodePtr pNode) { boost::recursive_mutex::scoped_lock L(m_mutex); m_peerNodeList.push_back(pNode); }
/** Purpose ------- ZGESSM applies the factors L computed by ZGETRF_INCPIV to a complex M-by-N tile A. Arguments --------- @param[in] m INTEGER The number of rows of the matrix A. M >= 0. @param[in] n INTEGER The number of columns of the matrix A. N >= 0. @param[in] k INTEGER The number of columns of the matrix L. K >= 0. @param[in] ib INTEGER The inner-blocking size. IB >= 0. @param[in] ipiv INTEGER array on the cpu. The pivot indices array of size K as returned by ZGETRF_INCPIV. @param[in] dL1 DOUBLE COMPLEX array, dimension(LDDL1, N) The IB-by-K matrix in which is stored L^(-1) as returned by GETRF_INCPIV @param[in] lddl1 INTEGER The leading dimension of the array L1. LDDL1 >= max(1,2*IB). @param[in] dL DOUBLE COMPLEX array, dimension(LDDL, N) The M-by-K lower triangular tile on the gpu. @param[in] lddl INTEGER The leading dimension of the array L. LDDL >= max(1,M). @param[in,out] dA DOUBLE COMPLEX array, dimension (LDDA, N) On entry, the M-by-N tile A on the gpu. On exit, updated by the application of L on the gpu. @param[in] ldda INTEGER The leading dimension of the array A. LDDA >= max(1,M). @ingroup magma_zgesv_tile ********************************************************************/ extern "C" magma_int_t magma_zgessm_gpu( magma_order_t order, magma_int_t m, magma_int_t n, magma_int_t k, magma_int_t ib, magma_int_t *ipiv, magmaDoubleComplex *dL1, magma_int_t lddl1, magmaDoubleComplex *dL, magma_int_t lddl, magmaDoubleComplex *dA, magma_int_t ldda, magma_int_t *info) { #define AT(i,j) (dAT + (i)*ldda + (j) ) #define L(i,j) (dL + (i) + (j)*lddl ) #define dL1(j) (dL1 + (j)*lddl1) magmaDoubleComplex c_one = MAGMA_Z_ONE; magmaDoubleComplex c_neg_one = MAGMA_Z_NEG_ONE; int i, s, sb; magmaDoubleComplex *dAT; /* Check arguments */ *info = 0; if (m < 0) *info = -1; else if (n < 0) *info = -2; else if (ldda < max(1,m)) *info = -4; if (*info != 0) { magma_xerbla( __func__, -(*info) ); return *info; } /* Quick return if possible */ if (m == 0 || n == 0) return *info; if ( order == MagmaColMajor ) { magmablas_zgetmo_in( dA, dAT, ldda, m, n ); } else { dAT = dA; } s = k / ib; for (i = 0; i < k; i += ib) { sb = min(ib, k-i); magmablas_zlaswp( n, dAT, ldda, i+1, i+sb, ipiv, 1 ); #ifndef WITHOUTTRTRI magma_ztrmm( MagmaRight, MagmaLower, MagmaTrans, MagmaUnit, n, sb, c_one, dL1(i), lddl1, AT(i, 0), ldda); #else magma_ztrsm( MagmaRight, MagmaLower, MagmaTrans, MagmaUnit, n, sb, c_one, L( i, i), lddl, AT(i, 0), ldda); #endif if ( (i+sb) < m) { magma_zgemm( MagmaNoTrans, MagmaTrans, n, m-(i+sb), sb, c_neg_one, AT(i, 0), ldda, L( i+sb, i), lddl, c_one, AT(i+sb, 0), ldda ); } } if ( order == MagmaColMajor ) { magmablas_zgetmo_in( dA, dAT, ldda, m, n ); } return *info; } /* magma_zgessm_gpu */
ESR_ReturnCode SR_RecognizerResult_GetValue(const SR_RecognizerResult* self, const size_t nbest, const LCHAR* key, LCHAR* value, size_t* len) { SR_RecognizerResultImpl* impl = (SR_RecognizerResultImpl*) self; ArrayList* results; SR_SemanticResult* result; SR_SemanticResultImpl* resultImpl; LCHAR* lValue; size_t actualLen = 0, i, resultCount; ESR_ReturnCode rc; ESR_BOOL noMatch = ESR_TRUE; /* Choose nbest-list entry */ CHKLOG(rc, impl->results->get(impl->results, nbest, (void **)&results)); /* Get the number of semantic results for the entry */ CHKLOG(rc, results->getSize(results, &resultCount)); for (i = 0; i < resultCount; ++i) { /* Choose semantic result */ CHKLOG(rc, results->get(results, i, (void **)&result)); resultImpl = (SR_SemanticResultImpl*) result; rc = resultImpl->results->get(resultImpl->results, key, (void**) & lValue); if (rc == ESR_SUCCESS) { noMatch = ESR_FALSE; actualLen += LSTRLEN(lValue); } else if (rc != ESR_NO_MATCH_ERROR) return rc; } if (noMatch) return ESR_NO_MATCH_ERROR; ++actualLen; /* Check for overflow */ if (actualLen + 1 > *len) { /* Unfortunately some people are using get value functions to get the size of the value by * passing a zero length buffer which causes errors to be logged. I am adding code so * that the error is not logged when the length is zero, thus preventing lots of logs from * flooding the system. SteveR */ if ( ( *len ) != 0 ) PLogError(L("Buffer Overflow while fetching value for %s of choice %d Len %d"), key, nbest, *len ); *len = actualLen + 1; return ESR_BUFFER_OVERFLOW; } *len = actualLen; LSTRCPY(value, L("")); for (i = 0; i < resultCount; ++i) { /* Choose semantic result */ CHKLOG(rc, results->get(results, i, (void **)&result)); resultImpl = (SR_SemanticResultImpl*) result; rc = resultImpl->results->get(resultImpl->results, key, (void **) & lValue); if (rc == ESR_SUCCESS) LSTRCAT(value, lValue); else if (rc != ESR_NO_MATCH_ERROR) return rc; /* Separate semantic results with '#' token */ if (i < resultCount - 1) { int len = LSTRLEN(value); value[len] = MULTIPLE_MEANING_JOIN_CHAR; value[len+1] = 0; } } return ESR_SUCCESS; CLEANUP: return rc; }
void BedShapePanel::build_panel(ConfigOptionPoints* default_pt) { // on_change(nullptr); auto box = new wxStaticBox(this, wxID_ANY, _(L("Shape"))); auto sbsizer = new wxStaticBoxSizer(box, wxVERTICAL); // shape options m_shape_options_book = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(25*wxGetApp().em_unit(), -1), wxCHB_TOP); sbsizer->Add(m_shape_options_book); auto optgroup = init_shape_options_page(_(L("Rectangular"))); ConfigOptionDef def; def.type = coPoints; def.default_value = new ConfigOptionPoints{ Vec2d(200, 200) }; def.label = L("Size"); def.tooltip = L("Size in X and Y of the rectangular plate."); Option option(def, "rect_size"); optgroup->append_single_option_line(option); def.type = coPoints; def.default_value = new ConfigOptionPoints{ Vec2d(0, 0) }; def.label = L("Origin"); def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle."); option = Option(def, "rect_origin"); optgroup->append_single_option_line(option); optgroup = init_shape_options_page(_(L("Circular"))); def.type = coFloat; def.default_value = new ConfigOptionFloat(200); def.sidetext = L("mm"); def.label = L("Diameter"); def.tooltip = L("Diameter of the print bed. It is assumed that origin (0,0) is located in the center."); option = Option(def, "diameter"); optgroup->append_single_option_line(option); optgroup = init_shape_options_page(_(L("Custom"))); Line line{ "", "" }; line.full_width = 1; line.widget = [this](wxWindow* parent) { auto btn = new wxButton(parent, wxID_ANY, _(L("Load shape from STL...")), wxDefaultPosition, wxDefaultSize); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(btn); btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { load_stl(); })); return sizer; }; optgroup->append_line(line); Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e) { update_shape(); })); // right pane with preview canvas m_canvas = new Bed_2D(this); m_canvas->m_bed_shape = default_pt->values; // main sizer auto top_sizer = new wxBoxSizer(wxHORIZONTAL); top_sizer->Add(sbsizer, 0, wxEXPAND | wxLeft | wxTOP | wxBOTTOM, 10); if (m_canvas) top_sizer->Add(m_canvas, 1, wxEXPAND | wxALL, 10) ; SetSizerAndFit(top_sizer); set_shape(default_pt); update_preview(); }
static cairo_time_t draw_spiral (cairo_t *cr, cairo_fill_rule_t fill_rule, align_t align, close_t close, int width, int height, int loops) { int i; int n=0; double x[MAX_SEGMENTS]; double y[MAX_SEGMENTS]; int step = 3; int side = width < height ? width : height; assert(5*(side/step/2+1)+2 < MAX_SEGMENTS); #define L(x_,y_) (x[n] = (x_), y[n] = (y_), n++) #define M(x_,y_) L(x_,y_) #define v(t) L(x[n-1], y[n-1] + (t)) #define h(t) L(x[n-1] + (t), y[n-1]) switch (align) { case PIXALIGN: M(0,0); break; case NONALIGN: M(0.1415926, 0.7182818); break; } while (side >= step && side >= 0) { v(side); h(side); v(-side); h(-side+step); v(step); side -= 2*step; } switch (close) { case RECTCLOSE: L(x[n-1],y[0]); break; case DIAGCLOSE: L(x[0],y[0]); break; } assert(n < MAX_SEGMENTS); cairo_save (cr); cairo_set_source_rgb (cr, 0, 0, 0); cairo_paint (cr); cairo_translate (cr, 1, 1); cairo_set_fill_rule (cr, fill_rule); cairo_set_source_rgb (cr, 1, 0, 0); cairo_new_path (cr); cairo_move_to (cr, x[0], y[0]); for (i = 1; i < n; i++) { cairo_line_to (cr, x[i], y[i]); } cairo_close_path (cr); cairo_perf_timer_start (); cairo_perf_set_thread_aware (cr, FALSE); while (loops--) { if (loops == 0) cairo_perf_set_thread_aware (cr, TRUE); cairo_fill_preserve (cr); } cairo_perf_timer_stop (); cairo_restore (cr); return cairo_perf_timer_elapsed (); }
void GaussianWhiteNoise::setCovarianceMatrix(const Matrix & cov) { checkMatrix_(cov); Matrix L( cov.llt().matrixL()); std_=L; }
// SamplerIntegrator Method Definitions void SamplerIntegrator::Render(const Scene &scene) { ProfilePhase p(Prof::IntegratorRender); Preprocess(scene, *sampler); // Render image tiles in parallel // Compute number of tiles, _nTiles_, to use for parallel rendering Bounds2i sampleBounds = camera->film->GetSampleBounds(); Vector2i sampleExtent = sampleBounds.Diagonal(); const int tileSize = 16; Point2i nTiles((sampleExtent.x + tileSize - 1) / tileSize, (sampleExtent.y + tileSize - 1) / tileSize); ProgressReporter reporter(nTiles.x * nTiles.y, "Rendering"); { StatTimer timer(&renderingTime); ParallelFor2D([&](Point2i tile) { // Render section of image corresponding to _tile_ // Allocate _MemoryArena_ for tile MemoryArena arena; // Get sampler instance for tile int seed = tile.y * nTiles.x + tile.x; std::unique_ptr<Sampler> tileSampler = sampler->Clone(seed); // Compute sample bounds for tile int x0 = sampleBounds.pMin.x + tile.x * tileSize; int x1 = std::min(x0 + tileSize, sampleBounds.pMax.x); int y0 = sampleBounds.pMin.y + tile.y * tileSize; int y1 = std::min(y0 + tileSize, sampleBounds.pMax.y); Bounds2i tileBounds(Point2i(x0, y0), Point2i(x1, y1)); // Get _FilmTile_ for tile std::unique_ptr<FilmTile> filmTile = camera->film->GetFilmTile(tileBounds); // Loop over pixels in tile to render them for (Point2i pixel : tileBounds) { { ProfilePhase pp(Prof::StartPixel); tileSampler->StartPixel(pixel); } do { // Initialize _CameraSample_ for current sample CameraSample cameraSample = tileSampler->GetCameraSample(pixel); // Generate camera ray for current sample RayDifferential ray; Float rayWeight = camera->GenerateRayDifferential(cameraSample, &ray); ray.ScaleDifferentials( 1 / std::sqrt((Float)tileSampler->samplesPerPixel)); ++nCameraRays; // Evaluate radiance along camera ray Spectrum L(0.f); if (rayWeight > 0) L = Li(ray, scene, *tileSampler, arena); // Issue warning if unexpected radiance value returned if (L.HasNaNs()) { Error( "Not-a-number radiance value returned " "for image sample. Setting to black."); L = Spectrum(0.f); } else if (L.y() < -1e-5) { Error( "Negative luminance value, %f, returned " "for image sample. Setting to black.", L.y()); L = Spectrum(0.f); } else if (std::isinf(L.y())) { Error( "Infinite luminance value returned " "for image sample. Setting to black."); L = Spectrum(0.f); } // Add camera ray's contribution to image filmTile->AddSample(cameraSample.pFilm, L, rayWeight); // Free _MemoryArena_ memory from computing image sample // value arena.Reset(); } while (tileSampler->StartNextSample()); } // Merge image tile into _Film_ camera->film->MergeFilmTile(std::move(filmTile)); reporter.Update(); }, nTiles); reporter.Done(); } // Save final image after rendering camera->film->WriteImage(); }
void Link(void) { SPLog("Linking with OpenAL library."); L(alEnable); L(alDisable); L(alIsEnabled); L(alGetString); L(alGetBooleanv); L(alGetIntegerv); L(alGetFloatv); L(alGetDoublev); L(alGetBoolean); L(alGetInteger); L(alGetFloat); L(alGetDouble); L(alGetError); L(alIsExtensionPresent); L(alGetProcAddress); L(alGetEnumValue); L(alListenerf); L(alListener3f); L(alListenerfv); L(alListeneri); L(alGetListenerf); L(alGetListener3f); L(alGetListenerfv); L(alGetListeneri); L(alGenSources); L(alDeleteSources); L(alIsSource); L(alSourcef); L(alSource3f); L(alSourcefv); L(alSourcei); L(alSource3i); L(alGetSourcef); L(alGetSource3f); L(alGetSourcefv); L(alGetSourcei); L(alSourcePlayv); L(alSourceStopv); L(alSourceRewindv); L(alSourcePausev); L(alSourcePlay); L(alSourceStop); L(alSourceRewind); L(alSourcePause); L(alSourceQueueBuffers); L(alSourceUnqueueBuffers); L(alGenBuffers); L(alDeleteBuffers); L(alIsBuffer); L(alBufferData); L(alGetBufferf); L(alGetBufferi); L(alDopplerFactor); L(alDopplerVelocity); L(alDistanceModel); L(alcCreateContext); L(alcMakeContextCurrent); L(alcProcessContext); L(alcSuspendContext); L(alcDestroyContext); L(alcGetCurrentContext); L(alcGetContextsDevice); L(alcOpenDevice); L(alcCloseDevice); L(alcGetError); L(alcIsExtensionPresent); L(alcGetProcAddress); L(alcGetEnumValue); L(alcGetString); L(alcGetIntegerv); }
static void vcc_ParseFunction(struct vcc *tl) { int m, i; vcc_NextToken(tl); vcc_ExpectCid(tl, "function"); ERRCHK(tl); m = IsMethod(tl->t); if (m == -2) { VSB_printf(tl->sb, "VCL sub's named 'vcl*' are reserved names.\n"); vcc_ErrWhere(tl, tl->t); VSB_printf(tl->sb, "Valid vcl_* methods are:\n"); for (i = 0; method_tab[i].name != NULL; i++) VSB_printf(tl->sb, "\t%s\n", method_tab[i].name); return; } else if (m != -1) { assert(m < VCL_MET_MAX); tl->fb = tl->fm[m]; if (tl->mprocs[m] == NULL) { (void)vcc_AddDef(tl, tl->t, SYM_SUB); vcc_AddRef(tl, tl->t, SYM_SUB); tl->mprocs[m] = vcc_AddProc(tl, tl->t); } tl->curproc = tl->mprocs[m]; Fb(tl, 1, " /* ... from "); vcc_Coord(tl, tl->fb, NULL); Fb(tl, 0, " */\n"); } else { tl->fb = tl->fc; i = vcc_AddDef(tl, tl->t, SYM_SUB); if (i > 1) { VSB_printf(tl->sb, "Function %.*s redefined\n", PF(tl->t)); vcc_ErrWhere(tl, tl->t); return; } tl->curproc = vcc_AddProc(tl, tl->t); Fh(tl, 0, "int VGC_function_%.*s " "(VRT_CTX);\n", PF(tl->t)); Fc(tl, 1, "\nint __match_proto__(vcl_func_t)\n"); Fc(tl, 1, "VGC_function_%.*s(VRT_CTX)\n", PF(tl->t)); } vcc_NextToken(tl); tl->indent += INDENT; Fb(tl, 1, "{\n"); L(tl, vcc_Compound(tl)); if (m == -1) { /* * non-method subroutines must have an explicit non-action * return in case they just fall through the bottom. */ Fb(tl, 1, " return(0);\n"); } Fb(tl, 1, "}\n"); tl->indent -= INDENT; tl->fb = NULL; tl->curproc = NULL; }
void os_write(std::ostream& s, const V& v, fas::type_list<H, L> ) { os_write(s, v, L() ); }
TError TNlLink::AddXVlan(const std::string &vlantype, const std::string &master, uint32_t type, const std::string &hw, int mtu) { TError error = TError::Success(); int ret; uint32_t masterIdx; struct nl_msg *msg; struct nlattr *linkinfo, *infodata; struct ifinfomsg ifi = { 0 }; struct ether_addr *ea = nullptr; auto Name = GetName(); if (hw.length()) { // FIXME THREADS ea = ether_aton(hw.c_str()); if (!ea) return TError(EError::Unknown, "Invalid " + vlantype + " mac address " + hw); } TNlLink masterLink(Nl, master); error = masterLink.Load(); if (error) return error; masterIdx = masterLink.GetIndex(); msg = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_CREATE); if (!msg) return TError(EError::Unknown, "Unable to add " + vlantype + ": no memory"); ret = nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO); if (ret < 0) { error = TError(EError::Unknown, "Unable to add " + vlantype + ": " + nl_geterror(ret)); goto free_msg; } /* link configuration */ ret = nla_put(msg, IFLA_LINK, sizeof(uint32_t), &masterIdx); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_LINK: ") + nl_geterror(ret)); goto free_msg; } ret = nla_put(msg, IFLA_IFNAME, Name.length() + 1, Name.c_str()); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_IFNAME: ") + nl_geterror(ret)); goto free_msg; } if (mtu > 0) { ret = nla_put(msg, IFLA_MTU, sizeof(int), &mtu); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_MTU: ") + nl_geterror(ret)); goto free_msg; } } if (ea) { struct nl_addr *addr = nl_addr_build(AF_LLC, ea, ETH_ALEN); ret = nla_put(msg, IFLA_ADDRESS, nl_addr_get_len(addr), nl_addr_get_binary_addr(addr)); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_ADDRESS: ") + nl_geterror(ret)); goto free_msg; } nl_addr_put(addr); } /* link type */ linkinfo = nla_nest_start(msg, IFLA_LINKINFO); if (!linkinfo) { error = TError(EError::Unknown, "Unable to add " + vlantype + ": can't nest IFLA_LINKINFO"); goto free_msg; } ret = nla_put(msg, IFLA_INFO_KIND, vlantype.length() + 1, vlantype.c_str()); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_INFO_KIND: ") + nl_geterror(ret)); goto free_msg; } /* xvlan specific */ infodata = nla_nest_start(msg, IFLA_INFO_DATA); if (!infodata) { error = TError(EError::Unknown, "Unable to add " + vlantype + ": can't nest IFLA_INFO_DATA"); goto free_msg; } if (vlantype == "macvlan") { ret = nla_put(msg, IFLA_MACVLAN_MODE, sizeof(uint32_t), &type); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_MACVLAN_MODE: ") + nl_geterror(ret)); goto free_msg; } #ifdef IFLA_IPVLAN_MAX } else if (vlantype == "ipvlan") { uint16_t mode = type; ret = nla_put(msg, IFLA_IPVLAN_MODE, sizeof(uint16_t), &mode); if (ret < 0) { error = TError(EError::Unknown, std::string("Unable to put IFLA_IPVLAN_MODE: ") + nl_geterror(ret)); goto free_msg; } #endif } nla_nest_end(msg, infodata); nla_nest_end(msg, linkinfo); L() << "netlink: add " << vlantype << " " << Name << " master " << master << " type " << type << " hw " << hw << " mtu " << mtu << std::endl; ret = nl_send_sync(GetSock(), msg); if (ret) return Error(ret, "Cannot add " + vlantype); return Load(); free_msg: nlmsg_free(msg); return error; }
float CDamageControl::GetCurrentDamageScore(const UnitDef* unit) { //L("Getting CombatScore for : " << unit->humanName << " number of units: " << NumOfUnitTypes); float score = 0; int category = GCAT(unit); bool foundaunit = false; if(category == CAT_ATTACK || category == CAT_ARTILLERY || category == CAT_ASSAULT){ for(int i = 1; i <= NumOfUnitTypes; i++){ if(TheirUnitsAll[i].Cost > 0 && ai->ut->unittypearray[unit->id].DPSvsUnit[i] > 0 && ai->ut->unittypearray[i].AverageDPS > 0){ //L("unit->id: " << unit->id << " I: " << i); //L("DPSvsUnit[i] " << ai->ut->unittypearray[unit->id].DPSvsUnit[i] << " TheirUnitsAll[i].Cost " << TheirUnitsAll[i].Cost); score+= ai->ut->unittypearray[unit->id].DPSvsUnit[i] * TheirUnitsAll[i].Cost / TheirUnitsAll[i].Hitpoints / (MyArmy[i].Damage + 1); // kill the stuff with the best value //L("Score:" << score); //score+= 0; // This was for making a debug brakepoint foundaunit = true; } } if(!foundaunit){ // if nothing found try to kill his movable units (comm and builders) for(int i = 1; i <= NumOfUnitTypes; i++){ if(TheirUnitsAll[i].Cost > 0 && ai->ut->unittypearray[unit->id].DPSvsUnit[i] > 0 && ai->ut->unittypearray[i].def->speed > 0){ score+= ai->ut->unittypearray[unit->id].DPSvsUnit[i] * TheirUnitsAll[i].Cost / TheirUnitsAll[i].Hitpoints / (MyArmy[i].Damage + 1); // kill the stuff with the best value foundaunit = true; } } } if(!foundaunit){ // if all fails just get whatever hes got and try to hit it for(int i = 1; i <= NumOfUnitTypes; i++){ if(TheirUnitsAll[i].Cost > 0 && ai->ut->unittypearray[unit->id].DPSvsUnit[i] > 0){ score+= ai->ut->unittypearray[unit->id].DPSvsUnit[i] * TheirUnitsAll[i].Cost / TheirUnitsAll[i].Hitpoints / (MyArmy[i].Damage + 1); // kill the stuff with the best value } } } } else if(category == CAT_DEFENCE){ for(int i = 1; i <= NumOfUnitTypes; i++){ if(TheirArmy[i].Cost > 0 && ai->ut->unittypearray[unit->id].DPSvsUnit[i] > 0 && (ai->ut->unittypearray[i].category == CAT_ATTACK || ai->ut->unittypearray[i].category == CAT_ARTILLERY || ai->ut->unittypearray[i].category == CAT_ASSAULT)){ //L("unit->id: " << unit->id << " I: " << i); //L("DPSvsUnit[i] " << ai->ut->unittypearray[unit->id].DPSvsUnit[i] << " TheirUnitsAll[i].Cost " << TheirUnitsAll[i].Cost); score+= ai->ut->unittypearray[unit->id].DPSvsUnit[i] * TheirArmy[i].Cost / TheirArmy[i].Hitpoints / (MyDefences[i].Damage + 1); // kill the stuff with the best value //L("Score:" << score); //score+= 0; // This was for making a debug brakepoint foundaunit = true; } } if(!foundaunit){ // if nothing found try to kill his movable units (comm and builders) for(int i = 1; i <= NumOfUnitTypes; i++){ if(TheirUnitsAll[i].Cost > 0 && ai->ut->unittypearray[unit->id].DPSvsUnit[i] > 0 && ai->ut->unittypearray[i].def->speed > 0){ score+= ai->ut->unittypearray[unit->id].DPSvsUnit[i] * TheirUnitsAll[i].Cost / TheirUnitsAll[i].Hitpoints / (MyArmy[i].Damage + 1); // kill the stuff with the best value foundaunit = true; } } } if(!foundaunit){ // if all fails just get whatever hes got and try to hit it for(int i = 1; i <= NumOfUnitTypes; i++){ if(TheirUnitsAll[i].Cost > 0 && ai->ut->unittypearray[unit->id].DPSvsUnit[i] > 0){ score+= ai->ut->unittypearray[unit->id].DPSvsUnit[i] * TheirUnitsAll[i].Cost / TheirUnitsAll[i].Hitpoints / (MyArmy[i].Damage + 1); // kill the stuff with the best value } } } } //L(" score " << score << " TheirTotalCost " << TheirTotalCost); if (TheirTotalArmyCost <= 0) return 1; if (category == CAT_ATTACK || category == CAT_ARTILLERY || category == CAT_ASSAULT) { return score / TheirTotalArmyCost / (TheirUnitsAll[unit->id].Damage + 1); } else if (category == CAT_DEFENCE) { return score / TheirTotalArmyCost / (TheirArmy[unit->id].Damage + 1); } L("***** Getdamagescore Error! *****"); return 1; }
bool ON_Localizer::IsZero( const ON_BoundingBox& bbox ) const { bool rc = false; ON_BoundingBox loc_bbox; bool bTestLocBox = false; double d; switch ( m_type ) { case cylinder_type: { ON_3dPointArray corners; bbox.GetCorners(corners); int i; double t0, t1; t0 = t1 = (corners[0]-m_P)*m_V; for ( i = 1; i < 8; i++ ) { d = (corners[i]-m_P)*m_V; if ( d < t0 ) t0 = d; else if (d > t1 ) t1 = d; } ON_Line L(m_P+t0*m_V,m_P+t1*m_V); if ( m_d[0] > m_d[1] ) { // function is supported along the line d = bbox.MinimumDistanceTo(L); if ( d >= m_d[0] ) rc = true; } else { // function is supported outside cylinder d = bbox.MaximumDistanceTo(L); if ( d <= m_d[0] ) rc = true; } } break; case plane_type: { ON_PlaneEquation e; e.x = m_V.x; e.y = m_V.y; e.z = m_V.z; e.d = m_P.x; e.d -= m_d[0]; if ( m_d[0] > m_d[1] ) { e.x = -e.x; e.y = -e.y; e.z = -e.z; e.d = -e.d; } if ( e.MaximumValueAt(bbox) <= 0.0 ) rc = true; } break; case sphere_type: loc_bbox.m_min = m_P; loc_bbox.m_max = m_P; bTestLocBox = true; break; case curve_type: if ( m_nurbs_curve) { loc_bbox = m_nurbs_curve->BoundingBox(); bTestLocBox = true; } break; case surface_type: if ( m_nurbs_surface) { loc_bbox = m_nurbs_surface->BoundingBox(); bTestLocBox = true; } break; case distance_type: rc = false; break; default: rc = true; } if ( bTestLocBox ) { if ( m_d[1] < m_d[0] && m_d[0] > 0.0 ) { // function is zero outside loc_bbox + m_d[0] double d = loc_bbox.MinimumDistanceTo(bbox); if ( d > m_d[0] ) rc = true; } else if ( m_d[0] > 0.0 ) { // function is zero inside loc_bbox-m_d[0] loc_bbox.m_min.x += m_d[0]; loc_bbox.m_min.y += m_d[0]; loc_bbox.m_min.z += m_d[0]; loc_bbox.m_max.x -= m_d[0]; loc_bbox.m_max.y -= m_d[0]; loc_bbox.m_max.z -= m_d[0]; if ( loc_bbox.IsValid() && loc_bbox.Includes(bbox) ) rc = true; } } return rc; }
void GPTableGenerator::generate_constants_table() { int i; bind("gp_constants"); static const GPTemplate gp_templates[] = { GP_SYMBOLS_DO(DEFINE_GP_POINTER, DEFINE_GP_VALUE) {NULL, 0, 0, 0} }; for (const GPTemplate* tmpl = gp_templates; tmpl->name; tmpl++) { if (tmpl->is_pointer) { char buff[120]; jvm_sprintf(buff, "gp_%s_ptr", tmpl->name); bind(buff); Label L(tmpl->name); if (!tmpl->is_asm) { import(L); } define_long(L); } else { if (jvm_strcmp(tmpl->name, "current_thread") == 0) { bind("jvm_fast_globals"); } char buff[120]; jvm_sprintf(buff, "_%s", tmpl->name); bind(buff); if (jvm_strcmp(tmpl->name, "bit_selector") == 0) { // IMPL_NOTE: create a common framework to define initial values define_long(0x80808080); } else { define_zeros(tmpl->size); } } } if (!GenerateGPTableOnly) { // Some constants to check we've linked with the right ROM Label L1(XSTR(_ROM_LINKCHECK_HLE)); import(L1); define_long(L1); Label L2(XSTR(_ROM_LINKCHECK_MFFD)); import(L2); define_long(L2); Label L3(XSTR(_ROM_LINKCHECK_MFFL)); import(L3); define_long(L3); } if (ENABLE_THUMB_GP_TABLE && GenerateGPTableOnly) { // These symbols are necessary to link romgen. // We define a long for each entry, since they // should be bound to different addresses. bind("jvm_ladd"); define_long(0); bind("jvm_lsub"); define_long(0); bind("jvm_land"); define_long(0); bind("jvm_lor"); define_long(0); bind("jvm_lxor"); define_long(0); bind("jvm_lcmp"); define_long(0); bind("jvm_lmin"); define_long(0); bind("jvm_lmax"); define_long(0); bind("jvm_lmul"); define_long(0); bind("jvm_lshl"); define_long(0); bind("jvm_lshr"); define_long(0); bind("jvm_lushr"); define_long(0); } bind("gp_constants_end"); }
static int tolua_cWorld_DoExplosionAt(lua_State * tolua_S) { /* Function signature: World:DoExplosionAt(ExplosionSize, BlockX, BlockY, BlockZ, CanCauseFire, SourceType, [SourceData]) */ cLuaState L(tolua_S); if ( !L.CheckParamUserType (1, "cWorld") || !L.CheckParamNumber (2, 5) || !L.CheckParamBool (6) || !L.CheckParamNumber (7) || !L.CheckParamEnd (9) ) { return 0; } // Read the params: cWorld * World; double ExplosionSize; int BlockX, BlockY, BlockZ; bool CanCauseFire; int SourceTypeInt; if (!L.GetStackValues(1, World, ExplosionSize, BlockX, BlockY, BlockZ, CanCauseFire, SourceTypeInt)) { LOGWARNING("World:DoExplosionAt(): invalid parameters"); L.LogStackTrace(); return 0; } if ((SourceTypeInt < 0) || (SourceTypeInt >= esMax)) { LOGWARNING("World:DoExplosionAt(): Invalid source type"); L.LogStackTrace(); return 0; } eExplosionSource SourceType; void * SourceData; switch (SourceTypeInt) { case esBed: { // esBed receives a Vector3i SourceData param: Vector3i * pos = nullptr; L.GetStackValue(8, pos); SourceType = esBed; SourceData = pos; break; } case esEnderCrystal: case esGhastFireball: case esMonster: case esPrimedTNT: case esWitherBirth: case esWitherSkull: { // These all receive a cEntity descendant SourceData param: cEntity * ent = nullptr; L.GetStackValue(8, ent); SourceType = static_cast<eExplosionSource>(SourceTypeInt); SourceData = ent; break; } case esOther: case esPlugin: { // esOther and esPlugin ignore their SourceData params SourceType = static_cast<eExplosionSource>(SourceTypeInt); SourceData = nullptr; break; } default: { LOGWARNING("cWorld:DoExplosionAt(): invalid SourceType parameter: %d", SourceTypeInt); L.LogStackTrace(); return 0; } } // Create the actual explosion: World->DoExplosionAt(ExplosionSize, BlockX, BlockY, BlockZ, CanCauseFire, SourceType, SourceData); return 0; }
Spectrum AggregateVolume::Lve(const PbrtPoint &p, const Vector &w, float time) const { Spectrum L(0.); for (uint32_t i = 0; i < regions.size(); ++i) L += regions[i]->Lve(p, w, time); return L; }
static int tolua_cWorld_PrepareChunk(lua_State * tolua_S) { /* Function signature: World:PrepareChunk(ChunkX, ChunkZ, Callback) */ // Check the param types: cLuaState L(tolua_S); if ( !L.CheckParamUserType (1, "cWorld") || !L.CheckParamNumber (2, 3) || !L.CheckParamFunctionOrNil(4) ) { return 0; } // Read the params: cWorld * world = nullptr; int chunkX = 0; int chunkZ = 0; L.GetStackValues(1, world, chunkX, chunkZ); if (world == nullptr) { LOGWARNING("World:PrepareChunk(): invalid world parameter"); L.LogStackTrace(); return 0; } // Wrap the Lua callback inside a C++ callback class: class cCallback: public cChunkCoordCallback { public: cCallback(lua_State * a_LuaState): m_LuaState(a_LuaState), m_Callback(m_LuaState, 4) { } // cChunkCoordCallback override: virtual void Call(int a_CBChunkX, int a_CBChunkZ, bool a_IsSuccess) override { if (m_Callback.IsValid()) { m_LuaState.Call(m_Callback, a_CBChunkX, a_CBChunkZ, a_IsSuccess); } // This is the last reference of this object, we must delete it so that it doesn't leak: delete this; } protected: cLuaState m_LuaState; cLuaState::cRef m_Callback; }; // Call the chunk preparation: world->PrepareChunk(chunkX, chunkZ, cpp14::make_unique<cCallback>(tolua_S)); return 0; }
void initVncServer(int argc, char **argv) { vncbuf = calloc(screenformat.width * screenformat.height, screenformat.bitsPerPixel/CHAR_BIT); cmpbuf = calloc(screenformat.width * screenformat.height, screenformat.bitsPerPixel/CHAR_BIT); assert(vncbuf != NULL); assert(cmpbuf != NULL); if (rotation==0 || rotation==180) vncscr = rfbGetScreen(&argc, argv, screenformat.width , screenformat.height, 0 /* not used */ , 3, screenformat.bitsPerPixel/CHAR_BIT); else vncscr = rfbGetScreen(&argc, argv, screenformat.height, screenformat.width, 0 /* not used */ , 3, screenformat.bitsPerPixel/CHAR_BIT); assert(vncscr != NULL); vncscr->desktopName = "Android"; vncscr->frameBuffer =(char *)vncbuf; vncscr->port = VNC_PORT; vncscr->kbdAddEvent = keyEvent; vncscr->ptrAddEvent = ptrEvent; vncscr->newClientHook = (rfbNewClientHookPtr)clientHook; vncscr->setXCutText = CutText; if (strcmp(VNC_PASSWORD,"")!=0) { char **passwords = (char **)malloc(2 * sizeof(char **)); passwords[0] = VNC_PASSWORD; passwords[1] = NULL; vncscr->authPasswdData = passwords; vncscr->passwordCheck = rfbCheckPasswordByList; } vncscr->httpDir = "webclients/"; // vncscr->httpEnableProxyConnect = TRUE; vncscr->sslcertfile = "self.pem"; vncscr->serverFormat.redShift = screenformat.redShift; vncscr->serverFormat.greenShift = screenformat.greenShift; vncscr->serverFormat.blueShift = screenformat.blueShift; vncscr->serverFormat.redMax = (( 1 << screenformat.redMax) -1); vncscr->serverFormat.greenMax = (( 1 << screenformat.greenMax) -1); vncscr->serverFormat.blueMax = (( 1 << screenformat.blueMax) -1); vncscr->serverFormat.trueColour = TRUE; vncscr->serverFormat.bitsPerPixel = screenformat.bitsPerPixel; vncscr->alwaysShared = TRUE; vncscr->handleEventsEagerly = TRUE; vncscr->deferUpdateTime = 5; rfbInitServer(vncscr); //assign update_screen depending on bpp if (vncscr->serverFormat.bitsPerPixel == 32) update_screen=&CONCAT2E(update_screen_,32); else if (vncscr->serverFormat.bitsPerPixel == 16) update_screen=&CONCAT2E(update_screen_,16); else if (vncscr->serverFormat.bitsPerPixel == 8) update_screen=&CONCAT2E(update_screen_,8); else { L("Unsupported pixel depth: %d\n", vncscr->serverFormat.bitsPerPixel); sendMsgToGui("~SHOW|Unsupported pixel depth, please send bug report.\n"); close_app(); exit(-1); } /* Mark as dirty since we haven't sent any updates at all yet. */ rfbMarkRectAsModified(vncscr, 0, 0, vncscr->width, vncscr->height); }
void BDPTIntegrator::Render(const Scene &scene) { ProfilePhase p(Prof::IntegratorRender); // Compute _lightDistr_ for sampling lights proportional to power std::unique_ptr<Distribution1D> lightDistr = ComputeLightPowerDistribution(scene); // Partition the image into tiles Film *film = camera->film; const Bounds2i sampleBounds = film->GetSampleBounds(); const Vector2i sampleExtent = sampleBounds.Diagonal(); const int tileSize = 16; const int nXTiles = (sampleExtent.x + tileSize - 1) / tileSize; const int nYTiles = (sampleExtent.y + tileSize - 1) / tileSize; ProgressReporter reporter(nXTiles * nYTiles, "Rendering"); // Allocate buffers for debug visualization const int bufferCount = (1 + maxDepth) * (6 + maxDepth) / 2; std::vector<std::unique_ptr<Film>> weightFilms(bufferCount); if (visualizeStrategies || visualizeWeights) { for (int depth = 0; depth <= maxDepth; ++depth) { for (int s = 0; s <= depth + 2; ++s) { int t = depth + 2 - s; if (t == 0 || (s == 1 && t == 1)) continue; std::string filename = StringPrintf("bdpt_d%02i_s%02i_t%02i.exr", depth, s, t); weightFilms[BufferIndex(s, t)] = std::unique_ptr<Film>(new Film( film->fullResolution, Bounds2f(Point2f(0, 0), Point2f(1, 1)), std::unique_ptr<Filter>(CreateBoxFilter(ParamSet())), film->diagonal * 1000, filename, 1.f)); } } } // Render and write the output image to disk if (scene.lights.size() > 0) { StatTimer timer(&renderingTime); ParallelFor2D([&](const Point2i tile) { // Render a single tile using BDPT MemoryArena arena; int seed = tile.y * nXTiles + tile.x; std::unique_ptr<Sampler> tileSampler = sampler->Clone(seed); int x0 = sampleBounds.pMin.x + tile.x * tileSize; int x1 = std::min(x0 + tileSize, sampleBounds.pMax.x); int y0 = sampleBounds.pMin.y + tile.y * tileSize; int y1 = std::min(y0 + tileSize, sampleBounds.pMax.y); Bounds2i tileBounds(Point2i(x0, y0), Point2i(x1, y1)); std::unique_ptr<FilmTile> filmTile = camera->film->GetFilmTile(tileBounds); for (Point2i pPixel : tileBounds) { tileSampler->StartPixel(pPixel); if (!InsideExclusive(pPixel, pixelBounds)) continue; do { // Generate a single sample using BDPT Point2f pFilm = (Point2f)pPixel + tileSampler->Get2D(); // Trace the camera and light subpaths Vertex *cameraVertices = arena.Alloc<Vertex>(maxDepth + 2); Vertex *lightVertices = arena.Alloc<Vertex>(maxDepth + 1); int nCamera = GenerateCameraSubpath( scene, *tileSampler, arena, maxDepth + 2, *camera, pFilm, cameraVertices); int nLight = GenerateLightSubpath( scene, *tileSampler, arena, maxDepth + 1, cameraVertices[0].time(), *lightDistr, lightVertices); // Execute all BDPT connection strategies Spectrum L(0.f); for (int t = 1; t <= nCamera; ++t) { for (int s = 0; s <= nLight; ++s) { int depth = t + s - 2; if ((s == 1 && t == 1) || depth < 0 || depth > maxDepth) continue; // Execute the $(s, t)$ connection strategy and // update _L_ Point2f pFilmNew = pFilm; Float misWeight = 0.f; Spectrum Lpath = ConnectBDPT( scene, lightVertices, cameraVertices, s, t, *lightDistr, *camera, *tileSampler, &pFilmNew, &misWeight); if (visualizeStrategies || visualizeWeights) { Spectrum value; if (visualizeStrategies) value = misWeight == 0 ? 0 : Lpath / misWeight; if (visualizeWeights) value = Lpath; weightFilms[BufferIndex(s, t)]->AddSplat( pFilmNew, value); } if (t != 1) L += Lpath; else film->AddSplat(pFilmNew, Lpath); } } filmTile->AddSample(pFilm, L); arena.Reset(); } while (tileSampler->StartNextSample()); } film->MergeFilmTile(std::move(filmTile)); reporter.Update(); }, Point2i(nXTiles, nYTiles)); reporter.Done(); } film->WriteImage(1.0f / sampler->samplesPerPixel); // Write buffers for debug visualization if (visualizeStrategies || visualizeWeights) { const Float invSampleCount = 1.0f / sampler->samplesPerPixel; for (size_t i = 0; i < weightFilms.size(); ++i) if (weightFilms[i]) weightFilms[i]->WriteImage(invSampleCount); } }