* start of pipeline restructuring to make the pipeline more similar to the one in the Laine/Karras paper
   * the goal of this is to ensure correct triangle ordering while also better utilizing the hardware (less numerous global memory accesses, both atomic and non-atomic; more batching; use of local memory for work-group internal synchronization)
   * increased bin size to 128*128px (this might become variable later on depending on the viewport size and hardware capabilities)
   * triangle transformed data (transform stage output) is not condensed any more in the transform stage to ensure a 1:1 input:output mapping (this gets rid of the atomic triangle counter and will make restructuring/using the binner easier; note: this doesn't increase the necessary buffer size, since this was already large enough for the worst-case, or the all-triangles-pass case to be precise)
   * culled/discarded triangles that don't pass the transform stage are now flagged as such (last uint of the internal transform data)
   * for testing purposes: sort triangles in the rasterization stage (this is only temporary until the restructuring is done)
   * full triangle count is now part of the draw_state (usable from every pipeline stage)
 * more opencl device and kernel info output for debugging/development purposes
 * added internal-debug (internal program debug) premake option which sets the OCLRASTER_INTERNAL_PROGRAM_DEBUG define + removed the necessity of this only to be usable when compiling in debug mode
 * moved binning clipping code to the transform stage (-> all triangle clipping and culling is now directly done in the transform stage)
 * instead of flagging a triangle as culled or non-culled, simply set its depth to INFINITY and test for this (frees up one uint in the internal transform data struct)
 * compute min/max x/y bounds in the transform stage for now (at a later point it would be a good idea to output the triangles 2D screen coordinates instead and to compute the bins more precisely, where applicable)
 * removed old bin/triangle queue handling code + removed queue buffer creation (this will be done in the binning_stage directly from now on); note: _reserve_memory call is no longer necessary!
 * added new binning code (host + kernel side); still very much wip
 * added some research info on how opencl kernel binaries are stored in os x 10.7+ and how they can be disassembled (x86 mach and nvidia elf/cubin); this will probably be implemented at a later point
 * more thoughts and testing on how to implement the new binner:
   -> set batch size to 256 triangles, so triangle indices within a batch can be stored as uchars (-> coarse and fine rasterizer will have "unpack"/recompute the actual triangle id later on (one uint add), but this is negligible considering the amount of saved memory)
   -> each binner work-item handles one bin (this basically turns the previous and the Laine/Karras method on its head: instead of "one work-item = one triangle -> put into bins", it's "one work-item = one bin -> iterate over triangles")
      this is necessary, since OpenCL has absolutely no means of intra-work-group communication aside from atomics (which are unusably slow when accessing one single address for communication purposes across all work-items),
	  which is, by itself, necessary for maintaining the input order guarantee
   -> so: iterate over 256 triangles
   -> for valid triangles: store loop indices inside a private memory queue (256 bytes or 2 ulong16s; theoretically, I could also store this inside a bit mask, which would allow arbitrary batch sizes, but it would make "packing"/"unpacking" more complex/insane - maybe at a later point)
   -> make 2 vstore16(ulong16...) calls to the global memory batch queue buffer
   -> repeat / next batch
   -> also: could use async work-group copy to pull in all required triangle data (on the other hand, this might already be cached, since it's accessed sequentially by all work-item)
 * lowered bin size to 64*64px due to needing more bins (-> one work-item = one bin); might make this dynamic again at a later point
 * added initial and rudimentary opencl profiling support (still wip; always on for now)
 * added config option for opencl kernel binary logging (opencl.log_binaries)
 * added opencl binary "unpacking" and disassembling on os x (requires otool for x86/x64 cpu binaries and cuobjdump for nvidia binaries)
 * fixed internal transformed buffer size (size must be a multiple of 256 elements due to 256 element copy in the binner)
 * for culled triangles, x_bounds.x is now set to INFINITY to flag them as culled (-> only need to read 4 floats in the binner now -> float4)
 * implemented async copy of triangle bounds in the binner (+lots of alignment that seems to be necessary even though opencl doesn't require it)
 * implemented bin queue output via vstore16
 * initial work on the restructering of the rasterization stage (similar setup to the binner, with work-groups dynamically requesting bins to be processed by them)
 * scrapped the idea of doing a coarse rasterization stage (for now; 64*64px = 4096px per bin for a work-group size of 1024 seem okay/nice)
 * store bin count and batch size+count in the draw_state, so it can be accessed across stages
 * clear atomic counters on the kernel side, not the host side (-> faster, since memory doesn't have to mapped on the host side)
 * killed rasterization constant buffer, since it's not needed any more (everything is either done implicitly (triangle count) or passed in via normal kernel parameters)
 * don't store "internal" opencl devices in an extra container any more, but in the device_object directly (this fixes some issues where internal devices != actual/used devices)
 * on os x: handle opencl device restrictions much earlier, before context creation, so the context doesn't contain unwanted devices, even if those wouldn't get accessed + handle special case where opengl sharing is enabled, but gpu devices are disallowed
 * renamed pipeline kernels to oclraster_* ("bin" or "program" for user programs)
 * more work on the restructering of the binner and the rasterization stage (rendering is semi-functional again)
 * rasterization stage is almost done (I just need to iterate over the remaining fragments of a bin; for now it will only compute #work-items pixels per bin)
 * fixed a few sync issues in the binner and the rasterizer (as it turns out, work-items do _not_ execute a kernel synchronously -> more barriers)
 * fixed a few dumb mistakes in the binner (triangle_id_offset instead of triangle_id; triangles_in_queue not being reset in the inner loop)
 * batches (bin queue output batches) of a bin are now stored sequentially in memory (these will be completely copied into local memory in the rasterization stage in the future; for now it's still read in 256 byte chunks)
 * the triangle count of a bin batch is now stored implicitly (non-empty queues are 0-terminated, empty queues have a 0xFFFF start "token")
 * temporarily added a function to dump the bin queue buffer
 * BATCH_SIZE is a compile-time define now (no longer a kernel parameter; will do the same for BIN_SIZE)
 * restructering of the binner and rasterization stage is pretty much finished now (rendering is fully functional again)
 * split the binning kernel into a gpu version and a cpu version (the latter uses no barriers, no group-waiting and no local memory, which seems to be preferable for cpus; note that this also requires different global and local sizes/ranges: global: bin count * max work group size; local: max work group size; this way, a work-item directly knows which bin and batch it has to compute; a high batch count is thus much desirable)
 * added a define to the rasterization stage whether to use local memory or not (disabled for cpus)
 * in case local memory is used in the rasterization stage: all queues of a bin are now copied into local memory in one huge async work-group copy (currently limited to 32 queues, but ~192 queues seem possible on recent nvidia gpus (48k local memory))
 * rasterization stage: if there are less work-items than fragments to be computed, loop
 * opencl profiling is now enabled via a compile time define (also added this to premake: use the "cl-profiling" option)
 * added a flip_faces function to a2m
 * added device specific "LOCAL_MEM_SIZE" define (build option) for all opencl kernels (this contains the device local memory size in bytes)
 * added cpu path to the rasterization stage (no barriers, no group-waiting and no local memory)
 * global range for the cpu path is #bins * work-group size (note that the work-group size is set to 1, which is a lot faster than the max possible 128 size ... for whatever reason; -> global range = #bins)
 * fixed dump mistake when setting the binner kernel range (always used the cpu path)
 * added the possibility to flag oclraster_output buffers as const for oclraster_programs (non-const in transform_program, const in rasterization_program)
 * cleaned up "pipeline restructuring" (moved new transform/rasterization template kernels into the source; removed debug code; misc)
 * added OCLRASTER_BIN_SIZE and OCLRASTER_BATCH_SIZE global defines (+added these to the build options of the corresponding kernels: transform/rasterization/binning)
 * rasterization_program: don't copy data from global output buffers into private memory first, but use it directly (faster)
 * version bump to 0.0.2-d1
 * merged pipeline_restructuring (look at the log for the changes I made; in short: faster and input order correctness)