Omniscient

Celeritas #001

Published: Last updated:
  • #log
  • #celeritas

Today's progress

// --- GPU Resources
typedef enum gpu_texture_type {
TEXTURE_TYPE_2D,
TEXTURE_TYPE_3D,
TEXTURE_TYPE_2D_ARRAY,
TEXTURE_TYPE_CUBE_MAP,
TEXTURE_TYPE_COUNT
} gpu_texture_type;

typedef enum gpu_texture_format {
TEXTURE_FORMAT_8_8_8_8_RGBA_UNORM,
TEXTURE_FORMAT_DEPTH_DEFAULT,
TEXTURE_FORMAT_COUNT
} gpu_texture_format;

texture_handle texture_create(core* core, const char *debug_name, gpu_texture_type type, gpu_texture_format format, u32x3 dimensions);

Created some types and a function for the above that I can now use to abstract over texture creation. Internally this calls a function in OpenGL specific backend.

There's still some more work to do handles better with some sort of pool allocator. Right now the handle is just holding the opengl texture id.

Then created the bindings for the types and the function so I can call it from OCaml. The end product being our Texture type now must be provided more info

type resource =
| Buffer
| Texture of RenderDSL.TextureType.t *
RenderDSL.TextureFormat.t *
(int * int)
| Backbuffer (** Special resource indicating the final composited frame *)

E.g. creating a depth texture for the upcoming shadow maps and inserting it into render graph

let depth_texture =
Texture ( TextureType.Texture2D,TextureFormat.DepthDefault,(1024, 1024)) in
let depth_texture_node =
RG.insert_node (Resource ("depth_prepass_texture", depth_texture)) graph in
...

The code compiles and runs but I haven't really tested it out yet 😂 since I need to get some of the light data being passed through before implementing shadow maps.