Jump to content
  • Advertisement
Sign in to follow this  
Papaboo

Passing groupshared memory to functions

This topic is 686 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

Hey all.
 
I'm new to DirectX and hlsl syntax, so maybe I'm missing something completely obvious, but I haven't been able to google my way to a solution.
 
I'm trying to write a general purpose blockwide subset sum function and in order to properly manage and reuse my memory I would like to pass my shared memory as a parameter to the function, but so far I haven't found any syntax that lets me do it.
 
What I would like conceptually in pseudo C is something along the lines of 
 

int subsetsum(int value, int threadIndex, int* sharedScratchMemory, int elementCount) {
   // Reduce
}

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

I'm pretty sure you can't do that yet, sadly. The best you can probably do is define a pile of shared memory and index into it in various ways. Or possibly do some preprocessor nonsense.

Share this post


Link to post
Share on other sites

The equivalent to pass-by-pointer for mutable parameters is the out or inout keywords:

void WriteTo( out float4 result, float4 data )
{
    result = data;
}
groupshared float4 g_data; 
void test()
{
  WriteTo( g_data, float4(1,2,3,4) )
}
void WriteTo( out float4 result[8][8], float4 data, uint2 thread )
{
    result[thread.y][thread.x] = data;
}
groupshared float4 g_tile8x8[8][8]; 
void test(uint2 thread : SV_GroupThreadID)
{
  WriteTo( g_tile8x8, float4(1,2,3,4), thread )
}
Edited by Hodgman

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!