• Advertisement
Sign in to follow this  

hlsl interface/function pointer implementation of pingpong-buffer

This topic is 1584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, my goal is a fairly simple mechanism to implement a ping-ponging buffer within hlsl.

The basic process would be like:

Calculate something in Buffer0.

Use Buffer0 to calculate something in Buffer1.

Use Buffer1 to calculate something in Buffer0.



Since there are no pointers to Buffer datatypes I was searching for another method to generalize this fairly simple code.

Eventually I leraned, that I can abuse interfaces for my purpose made up something like this:

interface PingPongBufferBase
	void Swap ();

class PingPongBuffer : PingPongBufferBase
	bool first;

	void Swap ()
		first = !first;

		if (first)
		{ return PingPongBuffer0[pos]; }
		{ return PingPongBuffer1[pos]; }

By instatiating the PingPongBuffer class in a shader/function I could use the Get() and Swap() to access allways the current Buffer and switch Buffers if I need to.


So are there really no smoother methods toachieve this? I haven't been for too long into the "high level" of hlsl but i was wondering why such an easy task turnes out to be such unintuitive to implement...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement