0

In a Cg tutorial it says that Cg uses dynamic compilation. I've noticed it's compiler has some similarities with an interpreter, in that they don't need to compile all the code in the first pass, and if an error exists you will find it when running the exe.

However, what's difference between them. Can anyone give me some details? Thanks a lot.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
TonyLic
  • 647
  • 1
  • 13
  • 26

1 Answers1

0

In this case, the Cg code is compiled at run time. This is similar to an interpreter that compiles down to an intermediate form (e.g. p-code etc). The main reason for doing this, on a GPU, is because there may be slight differences in the compiled result depending on the runtime computer's configuration. Cg compiles (usually) to OpenGL assembler (e.g., 'fp40' or 'arbfp' for fragment programs).

It's true that this compiled assembler code is compiled even further into microcode by the GPU driver, but that process is completely hidden from programmers (unless they work at NVIDIA etc).

bjorke
  • 3,295
  • 1
  • 16
  • 20