-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Prerequisites
- I have verified this issue is present in the
developbranch - I have searched open and closed issues to ensure it has not already been reported.
MonoGame Version
MonoGame.Framework.Compute.DesktopGL 3.8.3
Which MonoGame platform are you using?
MonoGame Cross-Platform Desktop Application (mgdesktopgl)
Operating System
Windows
Description
I have a struct of 3 floats. It takes three bytes. When I generate elements {111,222,333} in a shader and get it back through GetData() data becomes corrupted. Looks like it tries to extend stride to 16 bytes. If I add another float to my structure it works well (I think because of a stride becomes a multiple of 16 bytes)
Steps to Reproduce
shader code:
RWStructuredBuffer<particle> buf;
struct particle2
{
float3 position;
// float w;
};
[numthreads(1,1,1)]
void EmitParticles(uint3 id : SV_DispatchThreadID)
{
particle2 p;
p.position = float3(111,222,333);
buf[id.x] = p;
}
c# code:
public struct Particle2
{
public float X;
public float Y;
public float Z;
// public float W;
}
_shader.DispatchIndirect(0, 0, _argsBuffer);
var data = new Particle2[100];
_testBuffer.GetData(data);
If I uncomment a third component in both shader and c# it works as it should.
Minimal Example Repo
No response
Expected Behavior
GetData() should not corrupt data. If it is impossible to operate structs which stride is not a multiple of 16 an exception should be thrown.
Resulting Behavior
I have a struct of 3 floats. It takes three bytes. When I generate elements {111,222,333} in a shader and get it back through GetData() data becomes corrupted. Looks like it tries to extend stride to 16 bytes. If I add another float to my structure it works well (I think because of a stride becomes a multiple of 16 bytes)
Files
No response
