4.5.1
Question
Can anyone explain the project killing issue to me? Simple compute buffering not returning expected results
My shader…
#[compute]
#version 450
layout(local_size_x=1,local_size_y=1,local_size_z=1) in;
layout(set=0,binding=0,std430) restrict buffer InputBuffer
{
vec3 vector[];
} inputData;
layout(set=0,binding=1,std430) restrict buffer OutputBuffer
{
vec3 vector[];
} outputData;
void main()
{
outputData.vector[0] =inputData.vector[0];
outputData.vector[1] =inputData.vector[1];
outputData.vector[2] =inputData.vector[2];
}
My C#
RenderingDevice renderingDevice = RenderingServer.CreateLocalRenderingDevice();
RDShaderFile shader = GD.Load<RDShaderFile>("res://ComputeTest/testComputeShader.glsl");
RDShaderSpirV shaderSpirV = shader.GetSpirV();
Rid shaderID = renderingDevice.ShaderCreateFromSpirV(shaderSpirV);
Vector3[] inputVectors = {
new Vector3(0.8506508f, 0, 0.5257311f),
new Vector3(0.8506508f, 0, -0.5257311f),
new Vector3(0.52573115f, -0.85065085f, 0)
};
byte[] inputVectorBytes = GD.VarToBytes(inputVectors);
Rid inputVectorBufferID = renderingDevice.StorageBufferCreate((uint)inputVectorBytes.Length, inputVectorBytes);
RDUniform inputVectorUniform = new RDUniform
{
UniformType = RenderingDevice.UniformType.StorageBuffer,
Binding = 0
};
inputVectorUniform.AddId(inputVectorBufferID);
byte[] outputVectorBytes = new byte[inputVectorBytes.Length];
Rid outputVectorBufferID = renderingDevice.StorageBufferCreate((uint)inputVectorBytes.Length, outputVectorBytes);
RDUniform outputVectorUniform = new RDUniform
{
UniformType = RenderingDevice.UniformType.StorageBuffer,
Binding = 1
};
outputVectorUniform.AddId(outputVectorBufferID);
Rid uniformsID = renderingDevice.UniformSetCreate([inputVectorUniform, outputVectorUniform], shaderID, 0);
Rid pipeline = renderingDevice.ComputePipelineCreate(shaderID);
long computeList = renderingDevice.ComputeListBegin();
renderingDevice.ComputeListBindComputePipeline(computeList, pipeline);
renderingDevice.ComputeListBindUniformSet(computeList, uniformsID, 0);
renderingDevice.ComputeListDispatch(computeList, (uint)1, (uint)1, (uint)1);
renderingDevice.ComputeListEnd();
renderingDevice.Submit();
renderingDevice.Sync();
byte[] outputData = renderingDevice.BufferGetData(outputVectorBufferID);
Vector3[] outVectors = GD.BytesToVar(outputData).AsVector3Array();
GD.Print(string.Join(", ", inputVectors));
GD.Print(string.Join(", ", outVectors));
renderingDevice.FreeRid(uniformsID);
renderingDevice.FreeRid(pipeline);
renderingDevice.FreeRid(inputVectorBufferID);
renderingDevice.FreeRid(outputVectorBufferID);
renderingDevice.FreeRid(shaderID);
renderingDevice.Free();
Response…
(0.8506508, 0, 0.5257311), (0.8506508, 0, -0.5257311), (0.52573115, -0.85065085, 0)
(0.8506508, 0, 0.5257311), (0.8506508, 0, 0), (0.52573115, -0.85065085, 0)
Why is the Z of the second vertex zero???