Restrictions on function parameters · Issue #1139 - GitHub

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

Regarding pointer arguments: In SPIR-V for Vulkan, a pointer operand to a function must be into one of the following storage classes: ... Skiptocontent {{message}} gpuweb / gpuweb Public Notifications Fork 231 Star 3.1k Code Issues 346 Pullrequests 44 Discussions Actions Wiki Security Insights More Code Issues Pullrequests Discussions Actions Wiki Security Insights Newissue Haveaquestionaboutthisproject?SignupforafreeGitHubaccounttoopenanissueandcontactitsmaintainersandthecommunity. Pickausername EmailAddress Password SignupforGitHub Byclicking“SignupforGitHub”,youagreetoourtermsofserviceand privacystatement.We’lloccasionallysendyouaccountrelatedemails. AlreadyonGitHub? Signin toyouraccount Jumptobottom Restrictionsonfunctionparameters #1139 Closed dneto0openedthisissue Oct7,2020 ·14comments Closed Restrictionsonfunctionparameters #1139 dneto0openedthisissue Oct7,2020 ·14comments Assignees Labels wgsl WebGPUShadingLanguageIssues Projects WGSL Comments Copylink Contributor dneto0 commented Oct7,2020 Whataretherestrictionsonfunctionparameters? Wecanhavedifferentrulesbetweenbuiltinfunctionsanduser-writtenfunctions. Regardingpointerarguments: InSPIR-VforVulkan,apointeroperandtoafunctionmustbeintooneofthefollowingstorageclasses:UniformConstant,Function,Private,Workgroup.SonoUBOorSSBOpointersareallowed. Inrecentdiscussion@kvarkrecalledthatwehadalreadydecidedtodisallowpassingtexturesandsamplersasfunctionparameters(andalsopointers-to-these-things). GLSLallowsopaquetypestobe"in"parameterstofunctions.However,I'vefoundsomeconcerningbehaviour(a.k.a.abug?)forpassingaformattedwrite-onlystorageimageintoauser-definedhelperfunction.SeeKhronosGroup/glslang#2415 Iwanttoavoidanyworkaroundthatrequiresinliningthecalledfunction. SoIwouldmuchpreferforWGSLtodisallowtexturesandsamplers(orpointerstothem)tobepassedintouser-definedfunctions. Thetextwasupdatedsuccessfully,buttheseerrorswereencountered: Allreactions dneto0 added the wgsl WebGPUShadingLanguageIssues label Oct7,2020 Copylink johnkslang commented Oct7,2020 Thewrite-onlyimage-without-formatthingislike.01%ofwhatisimportantforpassingtextures/samplerstouserfunctions,sothatonecornercaseshouldprobablynotbedecidingwhattodofortherestofthe99.99%ofthisspace. Areyoureallysuggestinguserscannotwriteafunctiontooperateonatexture/image/samplerchosenatacallsite?That'squiteastepbackwardinfunctionalitythat'sexistedsince2003inGLSL.MaybeI'mnotunderstanding. Allreactions Sorry,somethingwentwrong. Copylink Contributor Author dneto0 commented Oct8,2020 FYI@johnkslangpointedmeatKhronosGroup/GLSL#57whichcoversthisformatted-vs-unformatedissueprettythoroughlyfromtheGLSLspecperspective. Areyoureallysuggestinguserscannotwriteafunctiontooperateonatexture/image/samplerchosenatacallsite?That'squiteastepbackwardinfunctionalitythat'sexistedsince2003inGLSL.MaybeI'mnotunderstanding. Thatwouldbetheconservativechoice.I'mnotclaimingthat'sagreatsolution. Workingthroughthissomemore,inaslightlydifferentcontext:SPIR-VforVulkandoespermitpointer-to-texture/samplertobepassedintohelperfunctions.Inthiscasetheformat(includingUnknown)ispartoftheparametertype.Ifthedriversupportsitwell,thenwe'redone.Ifnot,thenthebrowsercanmodifytheSPIR-Vtoinlinetheoffendingfunctionsasneeded. Now,inpastwe'vehadaprincipleofnotrequiringinliningforshadertranslationsfromWGSLtounderlyingplatformshaderlanguages.Sothispathcomesclosetothatline:theinliningisonlyrequiredifthedriverhasabug,essentially. Allreactions Sorry,somethingwentwrong. Copylink Contributor Author dneto0 commented Oct8,2020 Steppingbackalittlebit: Ihaveassumedsofarthattheformalparametertypemustbethesameastheformalargumenttype(moduloWGSLtypealiasing).Thatis,noimplicitconversionsareperformedatfunctioncallboundary. Also,Iassumethatforstoragetextures,thestoragetexturetypeisparameterizedbythetexelformat.(E.g.whenyouhaveadifferenttexelformat,thenyouhaveadifferenttype.)(ThisisthecaseforSPIR-V,butnotthecaseforGLSL.) Thatsaid,forSPIR-VandVulkan,forpointerarguments: apointer-to-storage-textureisokasafunctionparameter,asarguedabove. apointer-to-sampled-textureisokasafunctionparameter:SampledimagestypesinSPIR-Varenotparameterizedbyatexelformat.Theyareparameterizedbythesampledtype,oneoff32,i32,oru32.AndasJohnKsaidthisisfunctionalitythathaslongsupport assumingbasefunctionality,wedon'thaveVariablePointersorVariablePointerStorageBuffercapability,andsoallpointersare"logicalpointers",andfromuniversalvalidationruleswehave: apointeroperandtoafunctioncallmustbeinoneoftheUniformConstant(handle),Function,Private,Workgroupstorageclasses.(AtomicCounterdoesn'texistinVulkan;it'sforOpenGL)NotethismeansnofunctionparametersthatarepointerstoUBOorSSBO.(Note!) apointeroperandtoafunctioncallmustbeeither: -a"memoryobjectdeclaration",i.e.thepointerforthebaseofavariable,orafunctionparameterthatitselfisapointervalue. -orthepointertoanelementofanarrayoftexturesorsamplers,wherethebasepointerofthearrayitselfisamemoryobjectdeclaration.WGSLdoesn'tyethavearraysoftexturesorsamplers,butIexpectthiswillcomeinthefuture. Allreactions Sorry,somethingwentwrong. grorg addedthistoUnderDiscussion inWGSL Oct13,2020 grorg movedthisfromUnderDiscussion toForNextMeeting inWGSL Oct13,2020 grorg changedthetitle restrictionsonfunctionparameters Restrictionsonfunctionparameters Oct13,2020 Copylink Contributor grorg commented Oct19,2020 Discussedatthe2020-10-19VirtualF2F Allreactions Sorry,somethingwentwrong. Copylink Contributor grorg commented Oct19,2020 • edited Currentresolutionistoallowtextureparameterstofunctionsviaptr<>,assumingthatMicrosoftisokwithit(i.e.isitsupportedinHLSL?).@pow2clk@RafaelCintron Allreactions Sorry,somethingwentwrong. Copylink Contributor kvark commented Oct19,2020 Idon'tthinkptr<>iseitherhelpfulornecessarythere,fwiw.Ibelieve@litherumexpressedasimilarconcern. Allreactions Sorry,somethingwentwrong. Copylink Contributor Author dneto0 commented Oct19,2020 Discussion,andresolutionsofar. SPIR-V/Vulkanallowspointer-to-textureandpointer-to-samplerasfunctionarguments.Otherstorageclassesdon'thavethatfreedom(e.g.pointertoSSBOandpointertoUBOarenotpermittedasfunctionparameters.) Don'tknowifHLSLpermitsthis.NeedMicrosoft'sinput. Discussionaboutwhatthetexture+samplerparameterslooklike.InSPIR-Vtheparameterispointer-to-andtheloadisdoneatthepointofuseinthetexturebuiltin/instruction. Keepthedecisionthattexture/samplerresourcesaredeclaredatmodulescope. Allreactions Sorry,somethingwentwrong. Copylink Contributor pow2clk commented Oct19,2020 Texturesandsamplerscanbepassedintouserfunctions.Averycommonwaytoenableold-styleHLSLcodethatusesTex2Distodefineauserfunctionforit: float4Tex2D(Texture2Dt, SamplerStates,float2c){ returnt.Sample(s,c); } Idon'tknowwhattheptr<>businessisfor.Doyouwanttobeabletomodifythetextureorsamplerbyreference? Allreactions Sorry,somethingwentwrong. Copylink Contributor grorg commented Nov10,2020 Discussedatthe2020-11-10meeting. Allreactions Sorry,somethingwentwrong. dneto0 self-assignedthis Nov10,2020 dneto0 movedthisfromForNextMeeting toNeedsInvestigation inWGSL Nov10,2020 Copylink Contributor Author dneto0 commented Nov10,2020 I'lltakethistomakeaconcreteproposal. Allreactions Sorry,somethingwentwrong. dneto0 mentionedthisissue Jan8,2021 Removingptrandaddingref #1334 Closed Copylink Contributor Author dneto0 commented Feb8,2021 TheMSLmanualsection"5.2FunctionArgumentsandVariables"listswhatcanbeafunctionargument. ThatwillconstrainwhatwecandoinWGSL. Allreactions Sorry,somethingwentwrong. Copylink Contributor Author dneto0 commented Feb12,2021 SPIR-V2.16.1UniversalValidationRulessaythat,ifwedon'thaveavariablepointerscapability,thenforlogicalpointertypes(whichisallwe'llhaverightnowinWGSL): AnypointeroperandtoanOpFunctionCallmustbe amemoryobjectdeclaration,or apointertoanelementinanarraythatisamemoryobjectdeclaration,wheretheelementtypeisOpTypeSamplerorOpTypeImage. AmemoryobjectdeclarationiseitheranOpVariable,oranOpFunctionParameterofpointertype(orothercasesforphysicalstoragebufferextension). Sobyapplyinginduction(ok,justthinkabouttracing),apointerargumentmustultimatelyrefertothestorageforawholevariable. Allreactions Sorry,somethingwentwrong. alan-baker addedacommit toalan-baker/gpuweb thatreferenced thisissue Apr26,2021 Addfunctionrestrictions … 620ebf9 Fixesgpuweb#1567,gpuweb#1471,gpuweb#1457,gpuweb#1139 *Norecursion *Nocallingentrypoints *fragmentshadermustreturnposition *aliasingrestrictions *pointerrestrictions alan-baker mentionedthisissue Apr26,2021 Addfunctionrestrictions #1674 Merged dneto0 pushedacommit thatreferenced thisissue May6,2021 Addfunctionrestrictions(#1674) … 73966b5 *Addfunctionrestrictions Fixes#1567,#1471,#1457,#1139 *Norecursion *Nocallingentrypoints *fragmentshadermustreturnposition *aliasingrestrictions *pointerrestrictions *Fixtypo:fragment->vertex *Changesforreview *clarifypossiblereturntypestodisallowhandles *clarifyaliasing *Disallowhandlepointerparameters *changesforreview Copylink Contributor kdashg commented Sep29,2021 @dneto0Istheremoretobedoneherepost-#1674? Allreactions Sorry,somethingwentwrong. Copylink Contributor Author dneto0 commented Dec20,2021 thisisalldone.Closing. Allreactions Sorry,somethingwentwrong. dneto0 closedthisascompleted Dec20,2021 WGSL automation movedthisfromToDo toDone Dec20,2021 Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Assignees dneto0 Labels wgsl WebGPUShadingLanguageIssues Projects WGSL Done Milestone Nomilestone Development Nobranchesorpullrequests 6participants Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.



請為這篇文章評分?