ipdf/code.git
10 years agoTester based on Handbook of Floating-Point Arithmetic 1.1
Sam Moore [Tue, 22 Apr 2014 10:34:43 +0000 (18:34 +0800)]
Tester based on Handbook of Floating-Point Arithmetic 1.1

See also ipdf/documents

10 years agoHideously useless buffer perf optimization.
David Gow [Tue, 22 Apr 2014 08:35:52 +0000 (16:35 +0800)]
Hideously useless buffer perf optimization.

10 years agoFix Makefile
Sam Moore [Tue, 22 Apr 2014 07:53:33 +0000 (15:53 +0800)]
Fix Makefile

The $(BIN) target needed to include the dependencies for header files included via main.cpp

10 years agoHorrible debug font bufferification. (Sorry)
David Gow [Tue, 22 Apr 2014 07:43:45 +0000 (15:43 +0800)]
Horrible debug font bufferification. (Sorry)

10 years agoDon't re-render the display if nothing has changed
David Gow [Tue, 22 Apr 2014 03:29:25 +0000 (11:29 +0800)]
Don't re-render the display if nothing has changed

We now render to an offscreen buffer, and blit that
to the screen. This probably breaks the bitmap stuff, and I'll
fix that soon.

10 years agoSlightly less broken GraphicsBuffer implementation.
David Gow [Tue, 22 Apr 2014 02:14:55 +0000 (10:14 +0800)]
Slightly less broken GraphicsBuffer implementation.

I copied the original out of some terrible code I'd
written ages ago. It now is less overtly broken.

I'd still like to do an optimized version with Persistant
Mapped Buffers and manual memory control, but that can wait
until post-shaderification.

10 years agoReal that uses Fast2Sum for addition
Sam Moore [Mon, 21 Apr 2014 16:55:49 +0000 (00:55 +0800)]
Real that uses Fast2Sum for addition

I have a feeling this isn't going to improve things at all.

10 years agoAbility to define Real as long double
Sam Moore [Mon, 21 Apr 2014 08:47:20 +0000 (16:47 +0800)]
Ability to define Real as long double

`make DEF=-DREAL=2` to compile using long double as Real

Also changed calculatepi to include long double.
And also, only actually integrate using Real if it is something other than float, double, long double.

10 years agoRemove DebugDumpObjects call
Sam Moore [Mon, 21 Apr 2014 06:27:00 +0000 (14:27 +0800)]
Remove DebugDumpObjects call

You almost crashed my gedit embedded terminal plugin!

10 years agoStore everything in a VBO, making things faster.
David Gow [Mon, 21 Apr 2014 05:46:46 +0000 (13:46 +0800)]
Store everything in a VBO, making things faster.

Also 1024*1024 grid of boxes, for extreme slowness. Yay!

10 years agoMerge branch 'master' of git.ucc.asn.au:ipdf/code
David Gow [Mon, 21 Apr 2014 04:35:36 +0000 (12:35 +0800)]
Merge branch 'master' of git.ucc.asn.au:ipdf/code

Conflicts:
src/Makefile
src/main.h
src/real.h
src/screen.cpp
src/view.h

This was one hell of a merge. I have more code coming, but
it breaks other things, so it'll take a little while.

10 years agoSupport doing coordinate transforms on the CPU
David Gow [Sun, 20 Apr 2014 04:31:41 +0000 (12:31 +0800)]
Support doing coordinate transforms on the CPU

So because OpenGL (by default at least), does everything with
32-bit IEEE floats, even when our "Real" type is a double, we lost
precision when rendering it.

This commit adds support for running the coordinate transform on the
CPU using the Real datatype, and only truncating the results, making
things work properly with doubles. This will be slower on documents
with a large number of objects, but there's no real difference in
our unoptimized code at the moment.

Right-click to switch between CPU and GPU transforms.

10 years agoHacky debug font system, performance counter.
David Gow [Sat, 19 Apr 2014 12:46:15 +0000 (20:46 +0800)]
Hacky debug font system, performance counter.

10 years agoAllow setting type of Real at compilation time
Sam Moore [Thu, 17 Apr 2014 12:04:35 +0000 (20:04 +0800)]
Allow setting type of Real at compilation time

Use a REAL preprocessor definition.
Pass it from the Makefile in variable DEF

Can change using `make DEF=REAL=X`

Also allowed changing bounds with arguments in main.
Probably not that useful. Might remove later.

Tried to make a tester that overlays a series of BMPs but
the RenderBMP -> ScreenShot approach only works once; subsequent attempts lead to entirely filled images.

10 years agoMerge branch 'master' of git.ucc.asn.au:/ipdf/code
Sam Moore [Thu, 17 Apr 2014 06:31:36 +0000 (14:31 +0800)]
Merge branch 'master' of git.ucc.asn.au:/ipdf/code

Conflicts:
src/screen.cpp

David's way is better.

10 years agoFix Screen::ScreenShot
Sam Moore [Thu, 17 Apr 2014 06:05:34 +0000 (14:05 +0800)]
Fix Screen::ScreenShot

Something to do with the OpenGL buffers meant that the rendered BMP wasn't in the buffer before the glReadPixels call.

I have no idea why the screenshot worked for the rectangles and not for a texture, but oh well.

10 years agoBunch-a-bugfixes!
David Gow [Thu, 17 Apr 2014 06:00:16 +0000 (14:00 +0800)]
Bunch-a-bugfixes!

- Screenshots work properly.
- Alpha works properly
- New screen clear function, so we don't throw away things we need.

10 years agoFix colour in ScreenShot
Sam Moore [Thu, 17 Apr 2014 05:02:02 +0000 (13:02 +0800)]
Fix colour in ScreenShot

GL_RGBA -> GL_BGRA

Although... should probably have a means to detect which it is supposed to be
since it might be different on other machines?

10 years agoMerge branch 'master' of git.ucc.asn.au:ipdf/code
David Gow [Thu, 17 Apr 2014 02:52:45 +0000 (10:52 +0800)]
Merge branch 'master' of git.ucc.asn.au:ipdf/code

10 years agoCan render a BMP but things are still going wrong
Sam Moore [Wed, 16 Apr 2014 18:00:36 +0000 (02:00 +0800)]
Can render a BMP but things are still going wrong

If Screen::RenderBMP is called before Screen::ScreenShot, the resulting BMP is blank.

NOTE: Testing colours: If -c 1 0 0 1 is passed, rectangle is rendered RED.
However, if Screen::ScreenShot is called, the rectangle is BLUE.

Something stupid going on with colours?
Tried messing with alpha channel, but things seem to always render regardless of their alpha value.

Should give up and do something actually important.

10 years agoImplement Pointless Broken Things
Sam Moore [Wed, 16 Apr 2014 16:22:06 +0000 (00:22 +0800)]
Implement Pointless Broken Things

Trying to overlay the screenshot on an existing bmp to make it easier to combine the outputs of
different implementations (ie: Recompile program with a different typedef instead of using templates).

Rendering the existing bmp is proving to be a pain.

This is also using ancient opengl.

Cannot see what is wrong. I get something in the window but it does not resemble the bmp I saved at all.
And then the screenshot of *that* is just totally black.

10 years agoAdd grid lines
Sam Moore [Tue, 15 Apr 2014 18:34:15 +0000 (02:34 +0800)]
Add grid lines

It seemed like a good idea at the time.

10 years agoScreenshot using glReadPixels instead
Sam Moore [Tue, 15 Apr 2014 17:50:18 +0000 (01:50 +0800)]
Screenshot using glReadPixels instead

Which SDL2 is calling underneath somewhere in that "SDL_RenderReadPixels" call.

10 years agoScreenshot using convoluted SDL2 approach
Sam Moore [Tue, 15 Apr 2014 17:19:33 +0000 (01:19 +0800)]
Screenshot using convoluted SDL2 approach

David has just told me I should have used glReadPixels
Stay tuned for another commit.

10 years agoActual fix for when `uname -i` doesn't work
Sam Moore [Mon, 14 Apr 2014 16:29:51 +0000 (00:29 +0800)]
Actual fix for when `uname -i` doesn't work

Just use `uname -m`

10 years agoReflect fixes to I/O in ipdf/vfpu
Sam Moore [Mon, 14 Apr 2014 15:28:19 +0000 (23:28 +0800)]
Reflect fixes to I/O in ipdf/vfpu

Commits in ipdf/vfpu:
 354bf006d86abdfad9dbb915facec36f99af77bc
 e005897cffaf46cbbed14b3cc1ef74a390c93fef

Only using 1 hex character for opcode (3 bits) and rmode (2 bits) as opposed to 1 char per bit (...)
Also no need to print extra newline; it was a bug in ipdf/vfpu

10 years agoRemove REAL_HALF as it doesn't actually implement a half precision float
Sam Moore [Fri, 11 Apr 2014 09:31:41 +0000 (17:31 +0800)]
Remove REAL_HALF as it doesn't actually implement a half precision float

More to it than just masking bits because the sizes of the exponent differ.
Could just mask bits in the mantissa but I have horrible plans involving VFPU...

10 years agoAllow VFPU to save output vcd file
Sam Moore [Fri, 11 Apr 2014 07:12:30 +0000 (15:12 +0800)]
Allow VFPU to save output vcd file

That was amazingly simple.
Can run `gtkwave` on the output vcd file to see all the signals!

10 years agoModify symlinks
Sam Moore [Fri, 11 Apr 2014 05:36:31 +0000 (13:36 +0800)]
Modify symlinks

Using a symlink to a symlink... I don't know why. Because I can.

10 years agoAdd rounding mode to VFPU
Sam Moore [Fri, 11 Apr 2014 05:30:53 +0000 (13:30 +0800)]
Add rounding mode to VFPU

For some reason it needs an extra newline?
It would be much better if this used binary read/write.

Will look into getting that to happen in the ipdf/vfpu repo at some point.

10 years agoVFPU now using std::bitset instead of just float typedef
Sam Moore [Wed, 9 Apr 2014 17:45:06 +0000 (01:45 +0800)]
VFPU now using std::bitset instead of just float typedef

It's still 32 bits. However it might not break if I change it?
Can't test it at the moment because the virtual FPU is 32 bits still.

10 years agoAn interface for a FPU compiled from VHDL
Sam Moore [Wed, 9 Apr 2014 15:41:58 +0000 (23:41 +0800)]
An interface for a FPU compiled from VHDL

I have tested with the FPU from https://github.com/jop-devel/jop

The way this works is really awful...

1. Make (or steal from jop) a VHDL FPU
2. Make (or steal from jop) a testbench that uses stdio to read operands and ops
   - The jop one reads from a generated file, but it is trivial to change to "STD_INPUT" and remove all the assertion tests.
3. Compile testbench into an executable with ghdl
4. Call VFPU::Start which does the following:
   - Create a socketpair(2)
   - fork(2) and in the child dup(2) stdin/stdout to the socketpair
     - Redirect stderr to /dev/null because the testbench generates 10^3 warning messages
   - in the child, exec(3) the testbench FPU
5. Call VFPU::Exec passing the desired operands and opcodes
   - The operands and opcodes are written as hex strings over the socketpair
   - The child executing the FPU program does its thing
   - The result is read back as a hex string
6. When finished, call VFPU::Halt to kill(2) the FPU

I tried to get ghdl and gcc/g++ to make a static library to call ghdl_main instead
of exec'ing things. But that didn't work. The fork and socketpair would have still been
required for that approach anyway.

TODO:
  - Make the interface (not the FPU) deal with arbitrary size registers
  - Wrap a Real type around it so we can #define REAL_SIMULATED_FPU

I haven't put any of the VHDL in the git repo for obvious reasons.
If I actually start messing with it, it will probably get a seperate repo.

This may end up being a complete waste of time?
Although potentially being able to run an arbitrary FPU albeit in a horrible manner does seem cool.

10 years agoMerge branch 'master' of git.ucc.asn.au:ipdf/code
David Gow [Wed, 9 Apr 2014 12:17:14 +0000 (20:17 +0800)]
Merge branch 'master' of git.ucc.asn.au:ipdf/code

10 years agoFix RealToFloat test (hopefully)
David Gow [Wed, 9 Apr 2014 08:22:34 +0000 (16:22 +0800)]
Fix RealToFloat test (hopefully)

10 years agoUse x86_64 when uname is broken
Sam Moore [Wed, 9 Apr 2014 08:10:27 +0000 (16:10 +0800)]
Use x86_64 when uname is broken

Wierd...

>> sam@daedalus:~$ uname -i
>> unknown
>> sam@daedalus:~$ uname -a
>> Linux daedalus 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 GNU/Linux

10 years agoZoom in and out with the mouse wheel.
David Gow [Wed, 9 Apr 2014 08:01:54 +0000 (16:01 +0800)]
Zoom in and out with the mouse wheel.

Note that zoom-out is totally broken with half-precision,
so single-precision is the default. You can still see some artefacts
in single precision mode if you zoom in enough.

Zoom into the corner of a rectangle and then click on the corner an try to drag it.
Eventually you'll notice the reduced precision, and the rectangle will jump around.

10 years agoDon't get Filled and Outline the wrong way around.
David Gow [Wed, 9 Apr 2014 06:54:25 +0000 (14:54 +0800)]
Don't get Filled and Outline the wrong way around.

10 years agoYou can move around a document with Click+Drag!
David Gow [Wed, 9 Apr 2014 06:40:43 +0000 (14:40 +0800)]
You can move around a document with Click+Drag!

Uses some scary C++11 features, so no idea if this will break the CS Lab machines
and their ancient version of gcc.

10 years agoIt works on the lab machines now, I swear.
David Gow [Mon, 7 Apr 2014 04:28:51 +0000 (12:28 +0800)]
It works on the lab machines now, I swear.

10 years agoMagic SDL2 sauce! Now with 32-bit!
David Gow [Mon, 7 Apr 2014 04:18:23 +0000 (12:18 +0800)]
Magic SDL2 sauce! Now with 32-bit!

(My deepest and most sincere apologies to anyone who tries to read the Makefile now)

10 years agoDavid's secret SDL2 magic sauce!
David Gow [Mon, 7 Apr 2014 03:58:59 +0000 (11:58 +0800)]
David's secret SDL2 magic sauce!

10 years agoAdd tester for numerical calculation of PI
Sam Moore [Thu, 3 Apr 2014 09:19:35 +0000 (17:19 +0800)]
Add tester for numerical calculation of PI

Calculate PI using float, double and Real and compare the error and performance.

Traditional floats have a point (hardware dependent) where the error starts to behave unpredictably
rather than decreasing with number of intervals - due to rounding/precision errors.
Can see that doubles are better than single precision floats but they still do it.

An infinite precision Real would not have these problems (hah!)
We can at least aim to do better than double.

Based on PHYS CQM/pprog courses from 2012.
Should probably find a literature reference for this.

10 years agoSave/Load chunks.
David Gow [Mon, 31 Mar 2014 12:48:09 +0000 (20:48 +0800)]
Save/Load chunks.

10 years agoTester to compare custom Real to IEEE float
Sam Moore [Wed, 26 Mar 2014 17:42:04 +0000 (01:42 +0800)]
Tester to compare custom Real to IEEE float

Also got the endianness right this time. I think.

10 years agoMake real.h so we can change reals
Sam Moore [Wed, 26 Mar 2014 17:20:20 +0000 (01:20 +0800)]
Make real.h so we can change reals

Needed to fix view.cpp to call Float where it expects GLfloat
Had an attempt at making a half precision float, but it didn't go very well.

I don't think half precision floats are *that* terrible...
Probably got the bit masking wrong.

10 years agoMerge branch 'master' of git.ucc.asn.au:/ipdf/code
Sam Moore [Wed, 26 Mar 2014 16:27:44 +0000 (00:27 +0800)]
Merge branch 'master' of git.ucc.asn.au:/ipdf/code

Conflicts:
src/main.cpp

Fixed that and also fixed other things.

10 years agoTweak Makefile to make testing nicer
Sam Moore [Wed, 26 Mar 2014 16:17:12 +0000 (00:17 +0800)]
Tweak Makefile to make testing nicer

Who said you needed fancy high level languages to do unit testing?

It can't just be done using Make though; a bash script was also needed.

10 years agoCrazy std::vector<T> loader and saver.
David Gow [Wed, 26 Mar 2014 16:15:01 +0000 (00:15 +0800)]
Crazy std::vector<T> loader and saver.

10 years agoCMake support. We don't have to use it, but it's there if we do.
David Gow [Wed, 26 Mar 2014 15:57:37 +0000 (23:57 +0800)]
CMake support. We don't have to use it, but it's there if we do.

10 years agoIt now is all the working.
David Gow [Wed, 26 Mar 2014 10:54:18 +0000 (18:54 +0800)]
It now is all the working.

10 years agoMerge branch 'master' of git.ucc.asn.au:ipdf/code
David Gow [Wed, 26 Mar 2014 10:50:28 +0000 (18:50 +0800)]
Merge branch 'master' of git.ucc.asn.au:ipdf/code

10 years agoAdd ObjectType for Object Type
Sam Moore [Wed, 26 Mar 2014 10:50:14 +0000 (18:50 +0800)]
Add ObjectType for Object Type

10 years agoInitial outline rendering.
David Gow [Wed, 26 Mar 2014 10:49:25 +0000 (18:49 +0800)]
Initial outline rendering.

10 years agoImplement document saving and loading
Sam Moore [Wed, 26 Mar 2014 10:23:11 +0000 (18:23 +0800)]
Implement document saving and loading

Also implemented a tester to test it doesn't explode.

We should set this up to make replacing main() easy.

10 years agoAll of the SDL2 graphics stuff.
David Gow [Wed, 26 Mar 2014 10:17:00 +0000 (18:17 +0800)]
All of the SDL2 graphics stuff.

(With deprecated, obsolete OpenGL functions! Woo!)

10 years agoFix makefile.
David Gow [Wed, 26 Mar 2014 09:19:13 +0000 (17:19 +0800)]
Fix makefile.

10 years agoAdded Document and View classes
Sam Moore [Wed, 26 Mar 2014 09:17:14 +0000 (17:17 +0800)]
Added Document and View classes

And member functions for doing stuff.

Document Format completed (not really).

10 years agoipdf.h and Real type
Sam Moore [Wed, 26 Mar 2014 08:33:02 +0000 (16:33 +0800)]
ipdf.h and Real type

Real == float for now. Can make a class and overload it later.

Naming convention:

void ThisIsAFunction(Type this_is_a_var);

10 years agoSome makefile changes
David Gow [Wed, 26 Mar 2014 08:29:53 +0000 (16:29 +0800)]
Some makefile changes

10 years agoAdd basic code
Sam Moore [Wed, 26 Mar 2014 08:20:30 +0000 (16:20 +0800)]
Add basic code

Log functions & Makefil

10 years agoThe code repository exists....?
David Gow [Wed, 26 Mar 2014 07:36:34 +0000 (15:36 +0800)]
The code repository exists....?

UCC git Repository :: git.ucc.asn.au