int ri_inter (void) { /* This is the shortest version of the interpreter, containing only those RASL operators which * are produced by the REFAL compiler. */ /* July, 27, 1985. D.T. */ /* Some macros have been expanded because the PC compiler can't handle too many macros. (its stack overflows.) * DT July 1 1986. */ /* Some other macros have been replaced by functions to reduce the size of object module. March 7 1987. DT. */ register short n; int error; char c, ins = 0; long mdig, bifnum; char *arg; /* short m;*/ error = 0; restart: while (error == 0) { ins = *p; # if MDEBUG if (dump_toggle) printf ("%lx: %d\n", p, ins); # endif switch (ins) { case ACT1: ASGN_CHARP (++p, arg); p += sizeof (char *); act1 (arg); curk ++; break; case BL: p++; bl; break; case BLR: p++; ri_blr (); break; case BR: p++; br; break; case CL: p++; cl; break; case SYM: c = (unsigned char) * ++p; p++; sym (c); break; case SYMR: c = (unsigned char) * ++p; p++; symr (c); break; case EMP: p++; emp; break; case EST: curk --; est; p = break0; break; case MULE: /* n = * ++p; ++p; mule ((int) n); */ ASGN_LONG (++p, mdig); p += sizeof (long); mule (mdig); break; case MULS: /*n = * ++p; muls (n); p++; break;*/ ASGN_LONG (++p, mdig); p += sizeof (long); muls (mdig); break; case PLEN: p++; plen; p++; break; case PLENS: p++; plens; break; case PLENP: p++; plenp; break; case PS: ++p; ps; break; case PSR: ++p; psr; break; case OEXP: n = (unsigned char) * ++p; ++p; oexp (n); break; case OEXPR: n = (unsigned char) * ++p; ++p; oexpr (n); break; case OVSYM: n = (unsigned char) * ++p; ovsym (n); ++p; break; case OVSYMR: n = (unsigned char) * ++p; ovsymr (n); p++; break; case TERM: p++; term; break; case TERMR: p++; termr; break; case RDY: n = (unsigned char) * ++p; ++p; rdy (n); break; case SETB: /* n = (unsigned char) * ++p; m = (unsigned char) * ++p; ++p; setb (n,m); break; */ { long l_n, l_m; ASGN_LONG (++p, l_n); p += sizeof (long); ASGN_LONG (p, l_m); p += sizeof (long); setb (l_n, l_m); } break; case LEN: p++; len; break; case LENS: c = (unsigned char) *++p; p++; lens (c); break; case LENP: ++p; lenp; break; case SYMS: n = (unsigned char) * ++p; p++; syms (n); break; case SYMSR: n = (unsigned char) * ++p; p++; symsr (n) break; case TEXT: n = (unsigned char) * ++p; p++; text (n); break; case NS: c = (unsigned char) * ++p; ++p; ns (c); break; case TPLE: /* n = * ++p; p++; tple (n); break; */ ASGN_LONG (++p, mdig); p += sizeof (long); tple (mdig); break; case TPLS: /* n = * ++p; p++; tpls (n); break; */ ASGN_LONG (++p, mdig); p += sizeof (long); tpls (mdig); break; case TRAN: ASGN_CHARP (++p, arg); p += sizeof (char *); tran (arg); break; case VSYM: p++; vsym; break; case VSYMR: ++p; vsymr; break; case OUTEST: curk --; out (2); est; p = break0; break; case ECOND: if (tel - te + nel + 100 >= size_table_element) { if (fp_debugInfo != NULL) ri_print_error_code(fp_debugInfo,13); ri_error (13); } ASGN_CHARP (++p, arg); b = st[sp].b1; b = st[sp].b1; act1 (arg); tel += (teoff = nel); est; p = break0; break; case POPVF: ++p; tel -= teoff; nel = teoff + 3; sp = stoff-1; teoff = st[sp].nel; stoff = (long) st[sp].b2; break; case PUSHVF: if (sp + 20 >= size_local_stack) { if (fp_debugInfo != NULL) ri_print_error_code(fp_debugInfo,14); ri_error (14); } ++p; b = tbel (2) -> prec; blr; pushst (b->prec,b,NULL,NULL); sp++; pushst (b,stoff,teoff, IMP_); b = b -> prec; stoff = sp + 1; break; case STLEN: ++p; sp = stoff; break; case CSYM: ASGN_CHARP (++p, arg); p += sizeof (char *); csym (arg); break; case CSYMR: ASGN_CHARP (++p, arg); p += sizeof (char *); csymr (arg); break; case NSYM: ASGN_LONG (++p, mdig); p += sizeof (long); nsym (mdig); break; case NSYMR: ASGN_LONG (++p, mdig); p += sizeof (long); nsymr (mdig); break; case NCS: ASGN_CHARP (++p, arg); p += sizeof (char *); ncs (arg); break; case NNS: ASGN_LONG (++p, mdig); p += sizeof (long); nns (mdig); break; /* builtin functions: R.N. - 20 Jul 85 */ case BUILT_IN: /* a call to a built in function no arguments. */ curk --; ASGN_LONG (p+1, bifnum); error = ri_bif (bifnum,NULL); p = break0; break; /* builtin functions with one argument: D.T. - July 27, 1985. */ case BUILT_IN1: /* a call to a function with one argument. */ /* Arguments are stored before function address. */ curk --; ASGN_CHARP(++p, arg); ASGN_LONG (p + (sizeof (char *)), bifnum); error = ri_bif (bifnum, arg); p = break0; break; default: ri_default (ins, &error); break; } } if (error != 0) { fprintf (stderr,"RASL instruction: %4d at address: %lx\n", *p, (unsigned long) p); if (fp_debugInfo != NULL) fprintf (fp_debugInfo,"RASL instruction: %4d at address: %lx\n", *p, (unsigned long) p); ri_error(4); } return 0; }
bool GeometryShadersWindow::CreateScene() { std::string filename; #if defined(USE_DRAW_DIRECT) filename = mEnvironment.GetPath("RandomSquares.hlsl"); #else filename = mEnvironment.GetPath("RandomSquaresIndirect.hlsl"); #endif std::shared_ptr<VisualProgram> program = mProgramFactory.CreateFromFiles(filename, filename, filename); if (!program) { return false; } // Create particles used by direct and indirect drawing. struct Vertex { Vector3<float> position; Vector3<float> color; float size; }; // Use a Mersenne twister engine for random numbers. std::mt19937 mte; std::uniform_real_distribution<float> symr(-1.0f, 1.0f); std::uniform_real_distribution<float> unir(0.0f, 1.0f); std::uniform_real_distribution<float> posr(0.01f, 0.1f); int const numParticles = 128; std::vector<Vertex> particles(numParticles); for (auto& particle : particles) { particle.position = { symr(mte), symr(mte), symr(mte) }; particle.color = { unir(mte), unir(mte), unir(mte) }; particle.size = posr(mte); } // Create the constant buffer used by direct and indirect drawing. mMatrices = std::make_shared<ConstantBuffer>( 2 * sizeof(Matrix4x4<float>), true); program->GetGShader()->Set("Matrices", mMatrices); #if defined(USE_DRAW_DIRECT) // Create a mesh for direct drawing. VertexFormat vformat; vformat.Bind(VA_POSITION, DF_R32G32B32_FLOAT, 0); vformat.Bind(VA_COLOR, DF_R32G32B32_FLOAT, 0); vformat.Bind(VA_TEXCOORD, DF_R32_FLOAT, 0); std::shared_ptr<VertexBuffer> vbuffer(new VertexBuffer(vformat, numParticles)); Memcpy(vbuffer->GetData(), &particles[0], numParticles*sizeof(Vertex)); #else // Create a mesh for indirect drawing. std::shared_ptr<VertexBuffer> vbuffer(new VertexBuffer(numParticles)); mParticles = std::make_shared<StructuredBuffer>(numParticles, sizeof(Vertex)); Memcpy(mParticles->GetData(), &particles[0], numParticles*sizeof(Vertex)); gshader->Set("particles", mParticles); #endif std::shared_ptr<IndexBuffer> ibuffer(new IndexBuffer(IP_POLYPOINT, numParticles)); std::shared_ptr<VisualEffect> effect = std::make_shared<VisualEffect>(program); mMesh = std::make_shared<Visual>(vbuffer, ibuffer, effect); return true; }