I get an error every time I try to instantiate a compute buffer or try to dispatch a compute shader.
When I try to instantiate a compute buffer, it says:
Failed to create Compute Buffer, HRESULT: 0x80070057
Dispatching a compute shader returns:
Platform does not support compute shaders
UnityEngine.ComputeShader:Dispatch(Int32, Int32, Int32, Int32)
Fluid:Update() (at Assets/Fluid.cs:103)
Here’s my CPU code:
public class Fluid : MonoBehaviour {
public RenderTexture mTex;
public ComputeShader CSMain;
public ComputeBuffer fluid, fluidin, forces;
public float v = 0;
public float W = 1, dt = 1f/24f;
public int x = 64, y = 64, z = 64, w = 64;
private int NavKernal, EmitKernal;
int count(int i, int j, int k, int l)
{
return (i * y * z * w) + (j * z * w) + (k * w) + l;
}
struct voxel
{
public float density, temp, pressure;
public Vector4 vel, vort;
};
struct force
{
uint x,y,z,w;
Vector4 mag;
};
// Use this for initialization
void Start () {
//mTex.enableRandomWrite = true;
//mTex.Create();
NavKernal = CSMain.FindKernel("CSMain");
EmitKernal = CSMain.FindKernel("CSEmit");
CSMain.SetInt("numForces", 0);
CSMain.SetInt("x", x);
CSMain.SetInt("y", y);
CSMain.SetInt("z", z);
CSMain.SetInt("w", w);
voxel[] vox = new voxel[x * y * z * w];
for(int i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
for (int k =0; k< z;k++)
{
for(int l = 0; l < w; l++)
{
voxel mvox = new voxel();
mvox.density = 0;
vox[count(i, j, k, l)] = new voxel();
}
}
}
}
fluidin = new ComputeBuffer(x * y * z * w, sizeof(float)* 11);
fluid = new ComputeBuffer(x * y * z * w, sizeof(float) * 11);
forces = new ComputeBuffer(1, sizeof(float) * 8);
fluidin.SetData(vox);
fluid.SetData(vox);
force[] forceArr = new force[1];
forceArr[0] = new force();
forces.SetData(forceArr);
CSMain.SetBuffer(EmitKernal, "fluid", fluid);
CSMain.SetBuffer(EmitKernal, "fluidin", fluidin);
CSMain.SetBuffer(EmitKernal, "forces", forces);
CSMain.SetTexture(EmitKernal, "Result", mTex);
CSMain.SetBuffer(NavKernal, "fluid", fluid);
CSMain.SetBuffer(NavKernal, "fluidin", fluidin);
CSMain.SetBuffer(NavKernal, "forces", forces);
CSMain.SetTexture(NavKernal, "Result", mTex);
}
void OnDestroy()
{
if (fluid != null) fluid.Release();
if (fluidin != null) fluid.Release();
if (forces != null) forces.Release();
}
// Update is called once per frame
void Update () {
CSMain.SetFloat("viscosity", v);
CSMain.SetFloat("W", W);
CSMain.Dispatch(EmitKernal, (x * y * z * w) / 64, 1, 1);
CSMain.Dispatch(NavKernal, (x * y * z * w) / 64, 1, 1);
}
}
My dxdiag report: DXDiag
For the record, I am running an old switchable graphics card. It’s an AMD Radeon HD 7670M.
Any help would be greatly appreciated.