gpu icon indicating copy to clipboard operation
gpu copied to clipboard

Design

Open recp opened this issue 2 years ago • 2 comments

Currently APIs are individual call

Maybe we can also provide structs to reduce func calls

for instance

GPUSetFrontFace(rce, GPUWindingCounterClockwise);
GPUSetCullMode(rce, GPUCullModeBack);
GPUSetRenderState(rce, renderState);
GPUSetDepthStencil(rce, depthStencilState);

GPUSetVertexBuffer(rce, dynamicUniformBuffer, uniformBufferOffset, BufferIndexUniforms);
GPUSetFragmentBuffer(rce, dynamicUniformBuffer, uniformBufferOffset, BufferIndexUniforms);
GPUSetFragmentTexture(rce, _colorMap, TextureIndexColor);

like

GPUNewRenderCommandEncoder(cmdb, pass, (Type){
      .frontFace    = GPUWindingCounterClockwise,
      .cullMode     = GPUCullModeBack,
      .renderState  = renderState,
      .depthStencil = depthStencilState,
      .vertexBuffer = {
        .buf = dynamicUniformBuffer,
        .off = uniformBufferOffset, 
        .idx = BufferIndexUniforms,
      },
      .fragmentBuffer = {
        .buf = dynamicUniformBuffer,
        .off = uniformBufferOffset,
        .idx = BufferIndexUniforms,
      }
    });

or with small structs...

GPUNewRenderCommandEncoder(cmdb, pass, (Type){
      .frontFace    = GPUWindingCounterClockwise,
      .cullMode     = GPUCullModeBack,
      .renderState  = renderState,
      .depthStencil = depthStencilState,
    });

both can co-exist, this is just an example

recp avatar Sep 14 '23 20:09 recp

Second example is what SDL3's GPU API, wgpu-native and sokol-gfx are doing, it's almost standard now. First one might be helpful for those migrating from OpenGL.

MatheusKS95 avatar Oct 08 '25 02:10 MatheusKS95

@MatheusKS95 many thanks for the review and suggestions,

I didn’t know about the SDL3 GPU api which looks similar to this GPU library, will take a look thanks

Its been a while bu I couldnt have enough free time :/ Ive been working on UniversalShading occasionally in my free time, it’ll be used by the GPU library, hoping to get the initial features ready soon 🔜

recp avatar Oct 08 '25 14:10 recp