~denovodavid/rendering

๐Ÿ“ The graphics programming.
๐Ÿงน tidy things up
๐Ÿ› fix some prelude defs
๐Ÿ“„ add license

refs

master
browse  log 
articles/starting-with-c
browse  .tar.gz 

clone

read-only
https://git.sr.ht/~denovodavid/rendering
read/write
git@git.sr.ht:~denovodavid/rendering

You can also use your local clone with git send-email.

#Rendering

current focus: c11 + win32 + d3d12

#License

Unless specified otherwise, source code and assets are under CC0 1.0 and are dedicated to the public domain.

#Resources

DirectX:

The C Programming Language:

Voxels:

#road to minecraft

  • [x] render a triangle
  • [x] first person camera controller
  • [x] render a textured cube
  • [ ] render a chunk of cubes
    • base on: https://guide.handmade-seattle.com/c/2022/optimism-in-design/
    • 64^3 chunk
    • voxel_index: u32 i = x + (z * 64) + (y * 64 * 64);
      • u8 x = i % 64;
      • u8 z = (i / 64) % 64;
      • u8 y = (i / 64 / 64) % 64;
    • voxel type id, e.g. grass, dirt, air, etc.
    • meshing:
      • [x] none - render every face individually
      • [x] naive meshing (cube) - render every block touching air
      • [ ] naive meshing (quad) - render every face touching air
      • [ ] greedy meshing - join faces of types
      • [ ] binary greedy meshing - join non-air faces; move types to gpu
      • [ ] global lattice haha!?? - static mesh all the way
  • [ ] procedurally render chunks when moving
  • [ ] more...

#stupid things

  • update windows
  • install the latest of every c/c++/win32/d3d related thing with visual studio installer
  • (re)install the "Optional Feature" "Graphics Tools" to get d3dSDKLayers.dll (debugging)
  • use -gdwarf for debug symbols on win32
  • #include <initguid.h> first for uuid to work in C
  • lldb comes with llvm, which can be installed with scoop or through msys
  • gdb can be installed through msys

#DirectX 12 Agility SDK

I tried to get this working, but there is a problem with the zig "libc" header files. they're just a bit old, specifically, error: incorrect <rpcndr.h> version. Use the header that matches with the MIDL compiler. Version 500 is required for the Agility SDK, but zig currently only has version 475 (so close). I could probably link into the actual system libraries, which has version 501, but I don't really know how to do that without the dreaded visual studio, plus that also defeats cross-compilation.

// download and place the agility sdk in src/external
// put before windows.h (but maybe after initguid.h)
#include "external/d3d12/build/native/include/d3d12.h"
#if DEBUG_D3D12
#include "external/d3d12/build/native/include/d3d12sdklayers.h"
#endif

// ...
#include <windows.h>
// ...

// try and use it (this may require "-fdeclspec" compiler flag maybe idk)
__declspec(dllexport) extern const UINT D3D12SDKVersion = 608;
__declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";

#PIX on Windows

I'm literally just rendering a blue screen at the moment, but using PIX is pretty easy to get GPU and CPU info from the program. I just build in release mode, then launch the application with PIX for GPU Capture, then I can click a button to capture up to 10 frames at once. Run some analysis on that bad boi and badabing-badaboom you got yourself a spicy graphics pipeline view.

  • transitioning the back bufffer to the current render texture takes on average 4,433.10ns
  • clearing the rt to blue averages 55,008.10ns
  • and transitioning the buffer back averages 1,083.40ns

pretty cool stuff! In the future, I could use the "WinPixEventRuntime" to label specific GPU/CPU events to view and debug.

#Platform code

Following from Handmade Hero Day 011, I can do a "unity" build to support different platforms by basically building win32_main.c for windows, linux_main.c for linux, etc. Avoiding virtualising the platform code more than necessary.

Then we have two (2) types of interactions between platform code and application code; services provided to the application by the platform, and services provided to the platform by the application. Example: The application layer calls LoadFile("shader.hlsl") of the platform code, which returns the contents of the file. Example: The platform layer calls Update(delta_time) of the application code, providing the time elapsed between update loops.