- Notifications
You must be signed in to change notification settings - Fork6
Utility for estimating the power of the GPU in the browser using WebGL debug parameters.
License
gkjohnson/webgl-gpu-power-estimation
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Catering a 3d web-based experience to the power of a target platform is difficult with such a small amount of information available about the current graphics hardware. This utility aims to provide performance information about the current hardware by guessing the type of graphics hardware using webglUNMASKED_RENDERER_WEBGL
parameter and looking it up in a provided list of hardware.
See your hardware infohere!
Data used in the example is for demonstration purposes. See thewebgl-gpu-power-estimation-data repo for more information.
The values fromUNMASKED_RENDERER_WEBGL
are irregular and relatively unpredictable. To find the corresponding hardware in the database list we
- Check if there is a version number in the current GPU hardware name.
- Filter the database of GPUs to those that include that version number (or to those that have no version number if none was found).
- From that list pick the hardware the has the most matching tokens between the names.
The package can be installed using npm via the Github repo by adding this to the package.json dependencies. See [here] for more information.
"webgl-gpu-power-estimation":"gkjohnson/webgl-gpu-power-estimation@<release>"
import{getDetailedInfo,getBasicInfo}from'gpu-power-estimate';fetch('./path/to/database.json').then(res=>res.json()).then(database=>{// get the hardware informationconstcanvas=document.createElement('canvas');constgl=canvas.getContext('webgl');constbasicInfo=getBasicInfo(gl);constdetailedInfo=getDetailedInfo(database,gl);// scale the applicationconstcapability=detailedInfo ?detailedInfo.performance :0;if(capability>6000){// initialize highest fidelity scene}elseif(capability>3000){// initialize moderately complex scene}else{// initialize simplified scene}});
getBasicInfo(context=null :WebGLContext) :Object|null
Returns some basic info about the hardware based on theWEBGL_debug_renderer_info
extension ornull
if it's unavailable.
If the context is not provided then a temporary one will be created.
{// The full graphics hardwarename,// A guess as to whether or not the hardware is integrated graphicsintegrated,// The raw unmasked fields returned from the extensionunmasked:{ vendor, renderer}}
getDetailedInfo(database :Object,contextOrCard=null :WebGLContext|string) :Object|null
Returns more detailed hardware information based on the information in the provided database. The database is expected to be an object where the keys are the names of graphics hardware and the values are objects with detail information.
Thedatabase
argument is expected to be an object with GPU names as key entries and an object of detailed information as a result. The value of the closest matching key will be returned.
If a WebGL contextor card name to search is not provided then a temporary context will be created.
For privacy reasons the availability of theUNMASKED_RENDERER_WEBGL
parameter may be disabled in which case no estimate can be provided.
Infomation on the WebGL debug extension
Blog with information about the extension and sampling of possible values
About
Utility for estimating the power of the GPU in the browser using WebGL debug parameters.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.