#1302·sokol

Resource views update 2

Author: flooohCreated Jul 25, 2025Updated Sep 14, 2026
Labelsplanningsokol-gfx

NOTE: Postpone the rest of the implementation until an actual use case pop up.

...postpone the following things into a separate update to not delay the first resource view update too much:

Implemented in https://github.com/floooh/sokol/pull/1328:

  • clarify/fix image and view slice counts:
    • SG_IMAGETYPE_2D: exactly 1 slice
    • SG_IMAGETYPE_CUBE: exactly 6 slices
    • SG_IMAGETYPE_ARRAY: 1..N slices
    • SG_IMAGETYPE_3D: exactly 1 slice
  • validate: if slice count is given in image and view creation, they must be one of the above
  • get rid of the idea of separate 'cubemap faces', these are slices!

To be implemented in https://github.com/floooh/sokol/pull/1330:

  • make the max-bindings-per-stage constants a runtime limit (well, still keep the max-constants, but make them private and 'big enough') - also max-color-attachments!

Todo:

  • clarify/fix rendering/resolve to depth slice (allow a non-zero slice) (note: at least the d3d11 backend allows this, was this a GL limitation?)
  • image views can 'cast' to a different compatible pixel format (this requires to extend sg_image_desc by a view_pixel_formats[] array because at least WebGPU needs to know the potential view pixel formats at texture creation time
  • also allow to create a view as a different image type(?)
  • maybe: make the hardwired 256 alignment for storage buffer offsets dynamic (really not sure about that yet since it requires to explicitly request the limit on WebGPU device creation)