Comments (5)
Interesting! It seems like a worthwhile tradeoff then to keep track of the GPU state and reduce redundant calls at the expense of complexity?
from webgl.
@ianmackenzie shared this article, that indicates that avoiding redundant WebGL calls can be a big win: https://emscripten.org/docs/optimizing/Optimizing-WebGL.html#avoid-redundant-calls
from webgl.
@MartinSStewart thanks! I am aware of this happening. Basically each entity assumes it starts with a clean state, and then sets all the needed settings by making the function calls, and then resets them after the draw call.
Alternatively, we could store a virtual copy of the current gl state and diff each setting against that. This is a possible optimisation, but it assumes that diffing would be performing better than the redundant function calls. Is there any information on how slow these kind of calls are?
from webgl.
I counted up the duration of all the redundant draw calls for this specific capture and got approximately 0.845 (for some baffling reason sceptor's UI doesn't say what unit that's in but I'm guessing it's milliseconds). I don't know how reliable that value is though.
My gut feeling is that yes it's worthwhile to diff on the CPU rather than send redundant calls to the GPU. I can't find any direct evidence to support this though. I think the best approach is to try it and benchmark the results. If you'd like I can provide the source code for my game if you need something to profile.
from webgl.
Saw the pull request. Thanks for all the hard work! I'll go ahead and close this issue then.
from webgl.
Related Issues (20)
- Memory leak when creating a mesh in update/view HOT 1
- Version 1.1.0 Runtime error "Uncaught Error: Trying to use (==)"
- Mesh instancing support HOT 5
- Use gl.drawArrays for non-indexed meshes
- Hot-reloading corrupts shaders HOT 2
- Allow efficiently clearing depth and stencil buffers
- Allow creation of Textures from existing image data HOT 1
- Add support for OES_standard_derivatives extension?
- Add premultiply option for texture loading
- Cache attribute locations for a program
- WebGL content can fail to show up immediately on Edge HOT 1
- Parallelise shader compilation and programs linking
- Don't bind attribute buffers for the same program if they don't change
- Enable OES_element_index_uint
- Workaround for uniform array type inference failure HOT 2
- Inconsistent default behavior for WebGL.entity between Firefox and Chrome HOT 4
- Texture colors altered on some browsers
- How to build a Shader without the [glsl|...|] syntax ? HOT 2
- GLSL with apostrophes breaks JS output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webgl.