sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

Feature request: PrimitiveBatch with subbuffers

Open aganm opened this issue 3 years ago • 0 comments

I'm not sure how much work it would be to add this feature but it's something I had on my mind.

The way PrimitiveBatch currently works is by taking a single pointer to an interleaved buffer.

I would like if PrimitiveBatch also had a way to take multiple pointers to distinct subbuffers of packed data instead (implemented with glBufferSubData).

If this is the current PrimitiveBatch API

DECLSPEC void SDLCALL
GPU_PrimitiveBatch(
    GPU_Image* image,
    GPU_Target* target,
    GPU_PrimitiveEnum primitive_type,
    unsigned int num_vertices,
    float* values,
    unsigned int num_indices,
    unsigned int* indices,
    GPU_BatchFlagEnum flags);

This is what I imagine this new API could look like

typedef struct GPU_SubBuffers {
       float *x_values;
       float *y_values;
       float *z_values;
       float *s_values;
       float *t_values;
       float *r_values;
       float *g_values;
       float *b_values;
       float *a_values;
       uint8_t *r8_values;
       uint8_t *g8_values;
       uint8_t *b8_values;
       uint8_t *a8_values;
} GPU_SubBuffers;

DECLSPEC void SDLCALL
GPU_PrimitiveBatchSub(
    GPU_Image* image,
    GPU_Target* target,
    GPU_PrimitiveEnum primitive_type,
    unsigned int num_vertices,
    const GPU_SubBuffers *values,
    unsigned int num_indices,
    unsigned int* indices,
    GPU_BatchFlagEnum flags);

aganm avatar Jun 06 '22 20:06 aganm