pex-gl / pex-context

Modern WebGL state wrapper for PEX: allocate GPU resources (textures, buffers), setup state pipelines and passes, and combine them into commands.
http://pex-gl.github.io/pex-context/
MIT License
160 stars 12 forks source link

Move from manual bind/draw to CommandQueue #10

Closed vorg closed 7 years ago

vorg commented 8 years ago

I've started a CommandQueue class inspired by Vulkan and regl

https://github.com/pex-gl/pex-renderer/blob/master/Skybox.js#L21

this._drawCommand = cmdQueue.createDrawCommand({
    depthTest: false,
    program: this._skyboxProgram,
    mesh: this._fsqMesh,
    uniforms: {
      uEnvMap: this._envMap,
      uFlipEnvMap: this._envMap.getFlipEnvMap ? this._envMap.getFlipEnvMap() : -1
    }
  })

This could form a base of pex-context@2.0.0 with state and matrix stack removed (with maybe just the most recent state for temporary bindings like texture uploads or buffer updates.

Open poblems

Specifying FBO attachments

https://github.com/pex-gl/pex-renderer/blob/master/local_modules/pex-render-to-cubemap/index.js

//ugly
framebuffer: fbo,
framebufferColorAttachments: {
  '0': { target: ctx.TEXTURE_CUBE_MAP_POSITIVE_X + sideIndex, handle: cubemap.getHandle(), level: level }
},

Texture content uploads (after initial creation)

createUpdateCommand?

State stack via subcommands

Inspired by regl

var renderCmd = cmdList.createCommand({
  framebuffer: fbo
})

cmdQueue.submit(renderCmd, {}, function() {
   // render your scene to the FBO
   cmdQueue.submit(drawCubeCmd)
})
vorg commented 7 years ago

Currently being implemented in v2 branch