Jump to content
  • Advertisement

MasterReDWinD

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

1 Neutral

About MasterReDWinD

  • Rank
    Newbie

Personal Information

  • Role
    Amateur / Hobbyist
  • Interests
    Programming
  1. MasterReDWinD

    Accessing AppendStructuredBuffer count

    Thanks for the update. I've settled on a mix of RWStructuredBuffer and Append/Consume buffers at the moment. I've had some fun with race conditions already
  2. MasterReDWinD

    Accessing AppendStructuredBuffer count

    Thanks a lot for your reply. I had come across IncrementCounter and thought I might need to make the buffer manually. Your example really helps. ComputeBuffer.CopyCount copies the counter from one buffer to another buffer on the CPU side. I use it at the moment to get the size of the Append buffers. Luckily, from looking at the documentation it sounds like it supports any buffer created with the D3D11_BUFFER_UAV_FLAG_COUNTER flag, which means it should work still when manually implementing the Append buffer logic.
  3. Hi, I am using a Unity compute shader to create a vertex buffer and index buffer. The vertex buffer is an AppendStructuredBuffer<float3> vertexBuffer Each thread calculates a vertex and then calls vertexBuffer.Append(vertex) Later in that same function (in that same kernel) I have a RWStructuredBuffer<int> indexBuffer I would like to add the index of the vertex just placed in vertexBuffer to indexbuffer. However there doesn't seem to be any way to get the index of the last item added to the vertex Append buffer? I'm aware of CopyCount but that doesn't seem appropriate here. I've also looked into CopyStructureCount but I don't think that can be called in a Unity compute shader? Thanks
  4. MasterReDWinD

    Compute shader return values

    Thanks again. I managed to get it to compile.
  5. MasterReDWinD

    Compute shader return values

    Many thanks for your reply Valakor. I've had a go at getting this working. This is what I have so far: void CornerPoints(float x, float y, float z, out int corners[8*3]) { ... corners = { // Front x0, y0, z0, // front bottom left x0, y1, z0, // front top left x1, y1, z0, // front top right x1, y0, z0, // front bottom right // Rear x0, y0, z1, // rear bottom left x0, y1, z1, // rear top left x1, y1, z1, // rear top right x1, y0, z1 // rear bottom right }; In the calling function I have: int corners[8 * 3]; CornerPoints(x, y, z, out corners); Unfortunately I'm getting a couple of errors: Shader error in 'VoxelShaderTest.compute': syntax error: unexpected token '{' at kernel CalculateMaterials at VoxelShaderTest.compute(124) (on d3d11) Shader error in 'VoxelShaderTest.compute': 'CornerPoints': no matching 0 parameter function at kernel CalculateMaterials at VoxelShaderTest.compute(144) (on d3d11) Shader error in 'VoxelShaderTest.compute': syntax error: unexpected token 'out' at kernel CalculateMaterials at VoxelShaderTest.compute(144) (on d3d11) Do you have any ideas on these? I think you're right on the array needing to be flattened.
  6. Hi, I am trying to move some of my C# code for a noise implementation onto a Unity HLSL compute shader. Unfortunately some of the functions returns arrays. I have looked at several resources in an attempt to find out how to do this but I still don't have a working solution. I did find a similar question on here (see the bottom of this post). In this case using `out' was suggested. Is this the correct way to handle this? If so what would the correct syntax be for a function which also has three parameters, such as: int[] CornerPoints(float x, float y, float z) In this case the returned array will be a multidimensional array. int[8,3] .Any pointers in the right direction would be much appreciated.
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!