Browse Source

GPU: Note buffer alignment requirements

cosmonaut 2 months ago
parent
commit
799093799a
1 changed files with 9 additions and 0 deletions
  1. 9 0
      include/SDL3/SDL_gpu.h

+ 9 - 0
include/SDL3/SDL_gpu.h

@@ -2494,6 +2494,9 @@ extern SDL_DECLSPEC SDL_GPUTexture *SDLCALL SDL_CreateGPUTexture(
  * Note that certain combinations of usage flags are invalid. For example, a
  * buffer cannot have both the VERTEX and INDEX flags.
  *
+ * If you use a STORAGE flag, the data in the buffer must respect std140 layout conventions.
+ * In practical terms this means you must ensure that vec3 and vec4 fields are 16-byte aligned.
+ *
  * For better understanding of underlying concepts and memory management with
  * SDL GPU API, you may refer
  * [this blog post](https://moonside.games/posts/sdl-gpu-concepts-cycling/)
@@ -2796,6 +2799,9 @@ extern SDL_DECLSPEC SDL_GPUCommandBuffer *SDLCALL SDL_AcquireGPUCommandBuffer(
  *
  * Subsequent draw calls will use this uniform data.
  *
+ * The data being pushed must respect std140 layout conventions.
+ * In practical terms this means you must ensure that vec3 and vec4 fields are 16-byte aligned.
+ *
  * \param command_buffer a command buffer.
  * \param slot_index the vertex uniform slot to push data to.
  * \param data client data to write.
@@ -2835,6 +2841,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_PushGPUFragmentUniformData(
  * Pushes data to a uniform slot on the command buffer.
  *
  * Subsequent draw calls will use this uniform data.
+
+ * The data being pushed must respect std140 layout conventions.
+ * In practical terms this means you must ensure that vec3 and vec4 fields are 16-byte aligned.
  *
  * \param command_buffer a command buffer.
  * \param slot_index the uniform slot to push data to.