hlsl interface/function pointer implementation of pingpong-buffer
文章推薦指數: 80 %
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
延伸文章資訊
- 1Advanced HLSL using closures and function pointers - code4k
Hacking function pointers in HLSL. The principle is very simple: Instead of using interface and c...
- 2Tutorial 4: Buffers, Shaders, and HLSL - RasterTek
fx HLSL shader program through the technique pointer. The first step in this function is to set o...
- 3Attributes in Clang — Clang 15.0.0git documentation
Use __attribute__((alloc_align(<alignment>)) on a function declaration to specify that the return...
- 4Example of VK_KHR_buffer_device_address? : r/vulkan - Reddit
I know this was probably added mainly to support raytracing shaders, but is there a good example ...
- 5Alexandre Mutel on Twitter: "Advanced HLSL using closures ...
Advanced HLSL using closures and function pointers: Shader languages like HLSL, Cg or GLSL are no...