Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

BlitzLLVM

A modern transpiler and runtime for BlitzBasic, Blitz3D and BlitzPlus projects ยท By Xaymar

Differences to the original Blitz3D and BlitzPlus Sticky

A topic by Xaymar created 10 days ago Views: 15
Viewing posts 1 to 1
Developer (3 edits)

All the differences compared to the original, in one thread. โ‡๏ธ means new and changed, ๐Ÿ› ๏ธ means changed only, โŒ means removed.

Syntax:

  • โ‡๏ธ Long type notation with :TypeName, i.e. Local MyVal:Int32 instead of Local MyVal%.
    • Available in the official Blitz3D from V1.118 onwards, for those that complain "it taints the Syntax".
  • โ‡๏ธ Additional data types for 8, 16, 32, and 64 bit signed and unsigned Integers, as well as 16, 32, and 64 bit Floats. Type conversion functions included as well!
    • Integer Types are UInt8/UByte, Int8/Byte, UInt16/UShort, Int16/Short, UInt32/UInt, Int32/Int/%, UInt64/ULong, Int64/Long/%%
    • Floating Point Types are Float16/Half, Float32/Float/Single/#, Float64/Double/##
  • โ‡๏ธ Strings are now by default UTF-8 and not Windows-1252.
  • โ‡๏ธ .bb files are treated as UTF-8 by default instead of locale specific Windows-1252.
  • โ‡๏ธ By-reference passing of arguments for functions that require multiple outputs instead of falling back to Globals or Types with In (default), Out and InOut. 
    • Example:
      Function MyFunc(In A:Int32, Out B:Int32)
          B = A
      End Function
      .
  • โ‡๏ธ A new :Void return type for functions that never return anything which automatically makes Return reject parameters with an error.
    • Example:
      Function MyFunc:Void()
        Graphics3D 800,600,32,2
      End Function
      .
  • โ‡๏ธ EndType, EndFunction and EndSelect now act as aliases for End Type, End Function and End Select. We already had an EndIf, so quiet on the complaints about tainting the language.
  • โ‡๏ธ Optional sane evaluation order available via --sane-evaluation-order argument to blitzcc to make parameter evaluation left to right. If you ever wondered why calling functions with random numbers directly results in differences, it's because the original evaluated in quite the unique order.

Compiling & Debugging

  • โ‡๏ธ Transpiler based on LLVM converting BlitzBasic, Blitz3D and BlitzPlus code to LLVM IR before handing off the work to the actual clang compiler. Windows, Linux and macOS require a system installed clang to work. Windows additionally by default ships and uses MSYS2's Windows headers instead of our own.
    • When transpiling with symbols enabled (-g) any debugger can be used to inspect the code. We recommend LLDB from LLVM but MSVC's debugger may work too.
  • โ‡๏ธ New warning and error system to help you catch mistakes much earlier than when running the code via -W0 to -W4. The default is -W2 and enables most sanity warnings.
  • โ‡๏ธ Additional tools to help you clean up code: blitz-tidy and blitz-format. blitz-tidy cleans up any warnings that are known to not have side effects, while blitz-format automatically formats your code to a unified style.
  • โ‡๏ธ Direct integration into IDEs of your choice via blitz-lsp. Currently we ship an integration into Microsoft Visual Code, our editor of choice for basically everything now.
  • โ‡๏ธ User Libraries (userlibs) can now be anywhere you want with the --userlibs-dir argument instead of always needing to be in the compiler's chosen directory.

Memory Management

  • โ‡๏ธ A fully custom memory allocator for small (<2 KiB) and medium (<32 KiB) heap allocations to significantly reduce load on the system allocator. Very effective on things that require thousands of smaller heap allocations and deallocations and fully thread safe!
  • โ‡๏ธ All objects, types included, are reference counted. A variable that points at a deleted object now properly throws a Runtime Error instead of crashing the application like it used to. A function that returns a deleted object also properly returns Null instead of an invalid address into the Type that may be filled up by a later New.
  • โ‡๏ธ Additional stack and heap guards to catch memory corruptions from poorly written code early and raise a proper Runtime Error. Some of the known published examples on official sites have actually run into this guard already.

Rendering:

  • โ‡๏ธ New rendering engine built up from the ground on top of Vulkan instead of DirectDraw / Direct3D 7 / GDI+ like the original.
    • The next major update integrates a proper fallback for Direct3D 11 and OpenGL 4 on systems that don't support Vulkan.
  • โ‡๏ธ All 2D rendering emulated via 3D commands instead of relying on the CPU to do the heavy lifting. Graphics is simply an alias of Graphics3D.
  • ๐Ÿ› ๏ธ There is no default Graphics/Graphics3D window, they must be created via Graphics or Graphics3D. This allows for offscreen rendering by default.
  • โ‡๏ธ Graphics/Graphics3D mode 1 (Fullscreen) is now a borderless fullscreen window with proper black bars instead of modifying the desktop resolution. Mode 0 is always a window in all types of compiling.
    • There's also mode 4 now which creates a borderless window by default.
  • โ‡๏ธ Flip now has a new mode 2 for mailbox type rendering. Unlimited rendering up to 3x Vertical Sync rate, while maintaining full tear-less flipping.
  • ๐Ÿ› ๏ธ Graphics/Graphics3D's depth only picks the internal buffer and not the final output buffer shown to the screen. It also now has additional options: 8 for palette mode (GraphicsPalette), 12 for R4G4B4A4, 15 for R5G5B5A1, 16 for R5G6B5, 24 for R8G8B8, 30 for R10G10B10A2, 32 for R8G8B8A8, and 64 for R16G16B16A16.
    • Depth mode 30 enables significantly better colors and blending at no additional rendering cost. Very useful when combined with Dither and AntiAlias.
    • A future update brings AutoHDR commands to enable automatic HDR scaling of drawn colors.
  • ๐Ÿ› ๏ธ VWait is a fixed 60 FPS timer as there's no Vertical Sync feedback on modern APIs anymore. Similarly, ScanLine always returns 0 due to the same modern behavior. Use Flip 1 or Flip 2 with CreateTimer instead.
  • โ‡๏ธ AvailVidMem and TotalVidMem now have 64bit counterparts AvailVidMem64 and TotalVidMem64 in order to support modern GPUs. The original would corrupt the numbers while ours clamps to exactly 2GB for both.
  • โ‡๏ธ Smooth device recovery when a device crashes instead of completely losing everything. GraphicsLost() is now only a marker for GPU-only resources (render targets, buffers written to with Write/CopyPixel commands).
  • ๐Ÿ› ๏ธ Read/Write/CopyPixel(Fast) commands are batched together which unfortunately means that a Read can't read a prior Write made.
  • โ‡๏ธ AntiAlias(1) and AntiAlias(2) implemented as SMAA and SMAA T2x instead of the very costly SSAA that drivers defaulted to (if at all supported).
  • โ‡๏ธ Dither(1) implemented as temporal Interleaved Gradient Noise which at refresh rates above 30 fps can already trick eyes into seeing more color than there really is.
  • โ‡๏ธ Textures can now be marked as sRGB (2048) which properly converts them from sRGB into the rendered format.
  • โ‡๏ธ Textures can now be render targets with a new flag (4096) to allow for screen-space effects to be possible.
  • โ‡๏ธ Textures with mip-maps now default to tri-linear filtering while the original relied on bi-linear filtering only even if mip-maps were available. Only DDS textures were able to override this behavior before.
  • โ‡๏ธ LoadTexture/LoadImage now accepts flag (2048) for loading images saved as sRGB. 
  • โ‡๏ธ LoadTexture now loads mip-maps stored inside DDS files instead of re-generating them.
  • โ‡๏ธ WBuffer (reverse Z / inverse Z) is the default now for significantly less Z-fighting over distance.
  • โ‡๏ธ Maximum lights raised from 8 to 127 with automatic selection of the 8 best lights that affect each entity for performance.
  • โ‡๏ธ Optional per-pixel lighting that can be enabled with EntityLighting(Entity, 1).
  • โ‡๏ธ Light channel support for complex effects requiring entities to only be affected by some lights using EntityLightChannel(Entity, ChannelFlags:Int64).
  • โ‡๏ธ Excessively large triangles are split into smaller triangles automatically which was something some Direct3D7 capable devices did automatically
  • ๐Ÿ› ๏ธ Gamma manipulation functions are emulated instead of affecting the whole system.
  • โ‡๏ธ Additional formats now supported for images, textures and meshes: .jxl (Jpeg-XL), .webp, .avif, .3ds, .x (all modes), .dds (all types), .glTF, .glB, and probably more.
  • โ‡๏ธ Actual culling of not drawn entities by default instead of having to implement this yourself via EntityInView.
    • CameraCulling Camera%, ModeFlags% now offers control over what culling is done: 0 by itself for no culling (Original behavior), 1 for frustum culling (Default), 2 for GPU Triangle Culling, and 4 for GPU Backface Culling (only if bit 2 is set).
  • โ‡๏ธ New distance based fog available via CameraFogMode ..., 2 that applies fog by distance to the camera instead of distance to the Z near plane. No more turning the camera to see something poke out of the fog clearly - it's always in fog until you get closer.
  • and so much more - post is getting way too big.

Graphical User Interface:

  • โ‡๏ธ GUI Elements emulated via IMGUI and 3D commands in their own device chain, with native elements where easily available. Did not want to drag in 46 MiB of LGPLv3 licensed Qt6 code just for this.
  • โ‡๏ธ Canvases are always render targets and backed by VRAM. They act as RGBA8 targets for obvious reasons.
  • ๐Ÿ› ๏ธ FlipCanvas runs at desktop window manager refresh rate instead of graphics refresh rate and is always either VSync or Mailbox.
  • โŒ The DesktopBuffer() call is now always blank as this would have required complex reconstruction of what GDI+ used to provide. You also can't write to it at all as that was also a GDI+ feature.

Audio, Video & Movie:

  • โ‡๏ธ Audio based entirely on SDL3 with instead of SoLoud or FMOD3 with compatible volume falloff for either of the two integrations.
  • ๐Ÿ› ๏ธ Sound resampling is done properly instead of via dirty linear interpolation as done by the original. This results in less high pitched whine accompanying upsampled sounds and causes them to sound duller but much more correct. Particularly noticable in Stranded 2 which relied on it for their rain sound.
  • โŒ No support for MIDI, MOD, S3M, XM, IT or WMA. Would drag in too much additional library for little gain.
  • โ‡๏ธ New format support for modern MP3, Vorbis (OGG) and Opus (OGG), plus a few more via FFmpeg.
  • ๐Ÿ› ๏ธ 3D sounds follow the original Fmod falloff curve instead of the Soloud curve.
    • Fmod is if(m > 1, (m^-rolloff), 1) which stays at near 100% volume for crazy distances.
    • Soloud is if(m > 1, 1/(1+rolloff*(m-1)), 1) which similarly stays at near 100% volume for crazy distances.
    • New is 1/(1+rolloff*m*0.05) which is much more drastic and closer to reality.
  • โ‡๏ธ Doppler effect is properly calculated for up to 90% the speed of sound and smoothed over time instead of being instant.
  • โ‡๏ธ All audio changes (Pitch, Pan, etc.) are applied instantly instead of delayed like in Fmod and Soloud Blitz. This fixes a variety of clicking or snapping sounds caused by the original playing audio at center without applying changes for a few frames.
  • โ‡๏ธ Video (Movie) based entirely on FFmpeg (LGPL) with integration of Opus playback to avoid dragging in additional encoding libraries for playback of some formats.
  • โ‡๏ธ Movies now support looping, play/pause, stopping and can be used as a texture directly.

Optimizations & Physics:

  • Physics: Collision and Picking now use Jolt physics library as it is on average 4 to 10 times faster than our implementation.
  • Rendering: Entities that do not get changed in any way are automatically promoted to a GPU-only list of commands which speeds up rendering slightly.
    • EntityStatic Entity%, Mode% allows Entities to be marked always static (1) or never static (-1)
  • Asynchronous loading and saving that can be opted in via AsyncLoading(True) and AsyncSaving(True). API is currently work in progress.
  • Multi-threading is everywhere where possible so that we take advantage of every CPU core, and not just one.
  • Probably so much more that I can't remember. I think we even pull out the age old linear memory trick used to make old consoles hit 60fps in certain titles.

Other Differences:

  • DirectPlay Multiplayer is emulated on TCP port 40050 and does not require an external library.
  • User Libraries ("userlibs") can now be placed into your own project and passed to the compiler with --userlibs-dir.
  • Lack of MIDI, module/tracker, CD Audio, and WMA support.

There's just so much to list up that it never ends. The original had so many undiscovered bugs that people silently worked around or silently had their game accept without causing too much chaos.