Is WebGL capable of using the GPU's full power?

文章推薦指數: 80 %
投票人數:10人

I tried running a GPU intensive WebGL shader and couldnt get my GPU to peak over ~30% usage in task manager, even when visiting pages that ... Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. LearnmoreaboutCollectives Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams IsWebGLcapableofusingtheGPU'sfullpower? AskQuestion Asked 3years,4monthsago Modified 3years,4monthsago Viewed 4ktimes 3 1 ItriedrunningaGPUintensiveWebGLshaderandcouldntgetmyGPUtopeakover~30%usageintaskmanager,evenwhenvisitingpagesthatbenchmarkwildWebGLsimulationslikethisonewhichrenders30,000fishinacomplexenvironment.PerhapsthisisaWebGLsecurityfeature?Isthereanywayprogramatically,evenifitinvolvesdisablingsecuritysettingsinthebrowser(anybrowser),toforceWebGLtoutilize100%oftheGPU? webgl Share Improvethisquestion Follow askedApr6,2019at19:41 J.ToddJ.Todd 60111goldbadge1010silverbadges2828bronzebadges Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 3 Whatdidyoutry?It'strivaltouse100%ofyourGPUspower.Justgiveitsomethingtodrawthattakesalongtime.Theaquariumyoulinkedtoisnotdesignedtodothat. Here'satrivalone constgl=document.createElement('canvas').getContext('webgl'); gl.canvas.width=2048; gl.canvas.height=2048; constvs=` attributevec4position; voidmain(){ gl_Position=position; } `; constfs=` precisionmediumpfloat; voidmain(){ gl_FragColor=vec4(1); } `; constquad=[ -1,-1, 1,-1, -1,1, -1,1, 1,-1, 1,1, ]; constmaxQuads=50000; constquads=[]; for(leti=0;i{ count=Math.min(parseInt(e.target.value),maxQuads); });

increasenumbertoincreaseGPUusage.LargenumberswillgetthebrowserorOStoresettheGPU.

Formeavalueof30saturatedtheGPUandalsomadeeverythingslow(theOSneedstheGPUtoobutwe'rehoggingit) At30eachdrawcallisdrawing2048x2048x30pixels.That's125.8millionpixelsperdrawcall. Share Improvethisanswer Follow editedApr7,2019at13:26 answeredApr6,2019at22:35 gmangman 93.9k2929goldbadges239239silverbadges355355bronzebadges 3 LookingattheopenGLdocsfordrawArraysInstancednowbutImatotalnewbieonGLingeneral,wouldthat(inverynaiveterms)actuallyresultinthefragmentshaderbeingcalledmoretimes? – J.Todd Apr6,2019at23:12 IthasnothingtodowithdrawArrayInstancedthat'swasjusttheeasiestwaytodrawlotsofstuff.Couldjusthaseasilymademorequads.InfactchangedtousedrawArrayssinceyoumadethemistakeofthinkingithadanythingtodowithwhichfunctionsarecalledratherthanhavingtodowithhowmuchworktheGPUisbeingaskedtodo.ThisisnodifferentthanaCPUloopfor(i=0;i



請為這篇文章評分?