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

Creating query logs debug message #144

Closed vorg closed 2 months ago

vorg commented 2 months ago
 query(opts) {
      console.debug(NAMESPACE, "query", opts);
      return this.resource(createQuery(this, opts));
    },

https://github.com/pex-gl/pex-context/blob/main/index.js#L638

it should happen only in debug mode

dmnsgn commented 2 months ago

Should all resource creation method (ctx.vertexBuffer/program/pass/pipeline/vertexArray/texture2D/textureCube/framebuffer/renderbuffer/vertexBuffer/indexBuffer) have their console.debug under debuMode too ? Aka debug logs only in debugMode.

vorg commented 2 months ago

I don't think any of them log anything. I think that query log message could be also removed.

dmnsgn commented 2 months ago

I don't think any of them log anything.

What do you mean? Basic example debug logs every resource created:

image

I think that query log message could be also removed.

So remove console.debug call?

vorg commented 2 months ago

Ok. I see.

texture2D(opts) {
      console.debug(NAMESPACE, "texture2D", opts);

Then the only difference is that texture2D is called rarely and query every frame.

In that case all of the console.debug calls should be moved behind this.debugMode check, including query. What do you think?

dmnsgn commented 2 months ago

There will be a difference in workflow. Right now we create resources and if anything is wrong we just open devtools to see if any malformed parameters were sent. If we put them all under debugMode, we'll have to ctx.debug(true) then recreates resources.

debugMode could be kept for debugCommands list, all ctx.applyPass/Uniforms/etc and ctx.update, actions assumed to happened on every frame.

Q: do you need to create queries on every frame? Would you get same timer results with:


const query1 = ctx.query();

ctx.frame(() => {
  if (query1.state === ctx.QueryState.Ready && query1.result) {
    console.log("query1", query1.result);
  }

  ctx.submit(clearCmd, () => {
    ctx.beginQuery(query1);
    ctx.submit(drawFloorCmd);
    ctx.endQuery(query1);
  });
});
vorg commented 2 months ago

Queries can indeed be reused. Just tested it in my graph. Not sure why i though they are one off. All good then.

dmnsgn commented 2 months ago

Queries can indeed be reused. Just tested it in my graph. Not sure why i though they are one off. All good then.

Maybe it was something about query.result not available right away, that made you think that. Because they are asynchronous.