Commit Graph

6957 Commits

Author SHA1 Message Date
Kartik Agaram f13576b5d2 6957
The final fix to the raytracing program involves rounding modes. It turns
out x86 processors round floats by default, unlike C which has trained
me to expect truncation. Rather than mess with the MXCSR register, I added
another instruction for truncation. Now milestone 3 emits perfectly correct
results.
2020-10-05 10:25:25 -07:00
Kartik Agaram bb3ce6cdea 6956 2020-10-05 10:16:46 -07:00
Kartik Agaram fe34dc4718 6955 2020-10-05 10:12:34 -07:00
Kartik Agaram 5c3d495dbe 6954 2020-10-05 09:28:19 -07:00
Kartik Agaram fa2092a024 6953 2020-10-05 09:26:54 -07:00
Kartik Agaram cdff5d73ce 6952 - raytracing: much better
The image is now visually indistinguishable from the baseline, though the
file isn't quite bit-for-bit correct.

I found 3 bugs:
a) I forgot to normalize the ray. After creating a helper to "automatically"
do it for me, it turns out said helper requires manually using.
b) I forgot to multiply by t at one place.
c) vec3-length was half-written.

For the umpteenth time, the bugs were all in the last place I looked. I
was worried about spending a lot of time transcribing `main` without any
feedback, but that turned out to be perfect.
2020-10-04 23:12:21 -07:00
Kartik Agaram 00af72ccb0 6951 - 4 colors for Mu as well 2020-10-04 21:24:46 -07:00
Kartik Agaram fbe6797c2c 6950 2020-10-04 21:16:38 -07:00
Kartik Agaram 5c105a7aca 6949 - snapshot of next raytracing milestone
Not yet right, but worth a snapshot just because it gives a cool result.
Here, try it out:
  $ ./translate_mu_debug apps/raytracing/3.mu
  $ ./a.elf > x.ppm
Now view x.ppm as an image.

In general, this was quite tedious to write. And a still-open question
is how to emit the progress bar to stderr. My options are to either duplicate
all my print-* functions (already proliferating) or add global variables
to Mu.
2020-10-04 21:15:28 -07:00
Kartik Agaram f5e1656d15 6948 - stress-testing prints of floats
Looks good.
2020-10-04 11:55:55 -07:00
Kartik Agaram 9f182aefbe 6947 - change exponent separator since 'e' is hex 2020-10-04 11:19:23 -07:00
Kartik Agaram b8d613e7c2 6946 - print floats somewhat intuitively in hex 2020-10-04 11:18:23 -07:00
Kartik Agaram 0371140abe 6945 2020-10-04 01:33:49 -07:00
Kartik Agaram 21ff6d831a 6944 2020-10-04 01:25:02 -07:00
Kartik Agaram 93c6352dda 6943
Move some implementation around for floating-point.

I originally thought I wouldn't bother supporting sigils like %xmm0. But
it turns out I need them to pass floats into SubX function calls. And it
turns out the sigils work fine for free.
2020-10-04 00:54:57 -07:00
Kartik Agaram 1bf5d5f44e 6942 2020-10-04 00:19:54 -07:00
Kartik Agaram faeeef34f5 6941 - detective story for the day 2020-10-03 23:17:17 -07:00
Kartik Agaram 2f5a8496e6 6940 2020-10-03 22:55:19 -07:00
Kartik Agaram b6cf4f1db3 6939 2020-10-03 22:53:05 -07:00
Kartik Agaram 93a4ada6a1 6938 - start colorizing floating-point registers 2020-10-03 20:29:31 -07:00
Kartik Agaram f6eba67645 6937 2020-10-03 20:24:14 -07:00
Kartik Agaram 6112864aea 6936 2020-10-03 20:17:43 -07:00
Kartik Agaram cce9cda971 6935 - raytracing using floats 2020-10-03 20:17:08 -07:00
Kartik Agaram 4787d7d4b8 6934 2020-10-03 20:06:27 -07:00
Kartik Agaram 7b85e97ea8 6933 2020-10-03 19:50:24 -07:00
Kartik Agaram 42500e3f47 6932 - another bug related to floats
For most of Mu's history we've selected between primitives based on types
just by checking whether a type is a literal or not. Now we've started
checking if it's a float as well. However, floats need one additional check:
the call site may have an (addr float) that is dereferenced.
2020-10-03 13:55:52 -07:00
Kartik Agaram c2ec9e21c9 6931 - support fp registers in variable lookup 2020-10-03 12:05:53 -07:00
Kartik Agaram 8719ea906d 6930 2020-10-03 11:40:26 -07:00
Kartik Agaram ac608bc72e 6929 2020-10-03 00:25:55 -07:00
Kartik Agaram 04dcb8f3c2 6928 2020-10-03 00:25:13 -07:00
Kartik Agaram b94e94e035 6927 - working on a raytracing tutorial
https://raytracing.github.io/books/RayTracingInOneWeekend.html
2020-10-03 00:24:57 -07:00
Kartik Agaram ab1cf1593a 6926 2020-10-02 09:24:16 -07:00
Kartik Agaram 4230946e6a 6925 - tile: don't try to print escape sequences 2020-10-01 22:49:31 -07:00
Kartik Agaram 8e607b128c 6924 2020-10-01 21:43:04 -07:00
Kartik Agaram d75b712974 6923 2020-10-01 20:40:22 -07:00
Kartik Agaram f3ca0e3cb3 6922 2020-10-01 20:39:56 -07:00
Kartik Agaram c79b93ca6c 6921 2020-10-01 20:35:14 -07:00
Kartik Agaram 611e9f2e08 6920 2020-10-01 00:49:09 -07:00
Kartik Agaram 3d053e34b7 6919 2020-10-01 00:46:38 -07:00
Kartik Agaram df04b364a6 6918
Fix CI.
2020-10-01 00:01:15 -07:00
Kartik Agaram 11b4bd3e60 6917 2020-09-30 23:55:01 -07:00
Kartik Agaram 7bb57da24e 6916 2020-09-30 23:52:26 -07:00
Kartik Agaram 8d32a9aab9 6915 - a new family of Mu branch instructions
The realization of commit 6916 means that we should be using jump-if-addr*
after comparing floats. Which is super ugly. Let's create aliases to them
called jump-if-float*.
2020-09-30 23:46:43 -07:00
Kartik Agaram bc3ebe820b 6914 2020-09-30 23:14:57 -07:00
Kartik Agaram 6453bbbff8 6913 - copying floats around 2020-09-30 23:12:39 -07:00
Kartik Agaram d44bd51f90 6912 2020-09-30 22:56:45 -07:00
Kartik Agaram 656b840e7f 6911 - comparing floats
It turns out floating-point operations set different flags than most instructions.
We have to branch on them using unsigned jumps.

https://stackoverflow.com/questions/7057501/x86-assembler-floating-point-compare/7057771#7057771
2020-09-30 22:53:14 -07:00
Kartik Agaram d564633b24 6910 - emulate most floating-point operations 2020-09-30 22:09:26 -07:00
Kartik Agaram 8b215b65cf 6909 2020-09-30 21:33:14 -07:00
Kartik Agaram 72c42f90cf 6908 - compiling all floating-point operations
We don't yet support emulating these instructions in `bootstrap`. But generated
binaries containing them run natively just fine.
2020-09-30 21:17:37 -07:00