Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
411 views
in Technique[技术] by (71.8m points)

c# - Unexpected token struct in compute shader

I'm using a compute shader to speed up parallel processing of a 3D space computation. The shader gives me compile error Shader error in 'Polygonize': syntax error: unexpected token 'struct' at kernel Polygonize at Polygonize.compute(10) (on d3d11). Polygonize.compute is the shader file. The weirdest thing is that the first struct doesn't cause an error but the second one does. This is the code: (there's more later but the error occurs at the declaration of the second struct)

#pragma kernel Polygonize


struct Points {
  float value;
  int material;
  float3 location;
}

struct vertex {
  float3 location;
  bool weld;
  int weldnumber;
}
question from:https://stackoverflow.com/questions/65883617/unexpected-token-struct-in-compute-shader

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Afaik in shaders (HLSL) the definition of structs ends with ;

so it should be

struct Points {
  float value;
  int material;
  float3 location;
};

struct vertex {
  float3 location;
  bool weld;
  int weldnumber;
};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...