hlsl interface/function pointer implementation of pingpong-buffer

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

Hi, my goal is a fairly simple mechanism to implement a ping-ponging buffer within hlsl. The basic process would be like:. AllContent Blogs Forums News Tutorials LogIn SignUp  Login Username/Email Password Rememberme Forgotpassword? Login or Don'thaveaGameDev.netaccount?Signup  Forgotyourpassword? EmailAddress ResetPassword Pleasecontactusifyouhaveanytroubleresettingyourpassword. Home Blogs Careers Careers Forums News Portfolios Projects Tutorials New?Learnaboutgamedevelopment FollowUs ChatintheGameDev.netDiscord! BacktoGraphicsandGPUProgramming hlslinterface/functionpointerimplementationofpingpong-buffer GraphicsandGPUProgramming Programming Startedby Wh0p October18,201310:26AM -1 comments,lastbyWh0p8 years,8 monthsago Advertisement Wh0p Author 407 October18,201310:26AM Hi,mygoalisafairlysimplemechanismtoimplementaping-pongingbufferwithinhlsl. Thebasicprocesswouldbelike: CalculatesomethinginBuffer0. UseBuffer0tocalculatesomethinginBuffer1. UseBuffer1tocalculatesomethinginBuffer0. ... SincetherearenopointerstoBufferdatatypesIwassearchingforanothermethodtogeneralizethisfairlysimplecode. EventuallyIleraned,thatIcanabuseinterfacesformypurposemadeupsomethinglikethis: interfacePingPongBufferBase { voidSwap(); BUFFER_TYPEGet(BUFFER_POS_TYPEpos); }; classPingPongBuffer:PingPongBufferBase { boolfirst; voidSwap() { first=!first; } BUFFER_TYPEGet(BUFFER_POS_TYPEpos) { if(first) {returnPingPongBuffer0[pos];} else {returnPingPongBuffer1[pos];} } }; ByinstatiatingthePingPongBufferclassinashader/functionIcouldusetheGet()andSwap()toaccessallwaysthecurrentBufferandswitchBuffersifIneedto. Soaretherereallynosmoothermethodstoachievethis?Ihaven'tbeenfortoolongintothe"highlevel"ofhlslbutiwaswonderingwhysuchaneasytaskturnesouttobesuchunintuitivetoimplement... Cancel Save Share: Thistopicisclosedtonewreplies. Advertisement Advertisement PopularTopics [Discussion]BrowsergamingvsWeb3.0? GDNetLounge movingspriteonahexgrid ForBeginners Mapcreation:needadviseaboutamistake GeneralandGameplayProgramming NewVlogSeries-offeringfreeadvice,inputandthoughtsonlifeasaworkingcomposer/sounddesigner MusicandSoundFX Aregamedevsisolated? GDNetLounge [Fragmentshaderproblem] ForBeginners Reticulatingsplines AboutGameDev.net TermsofService PrivacyPolicy ContactUs Copyright(c)1999-2021GameDev.net,LLC BacktoTop



請為這篇文章評分?