我正在尝试Uniform
使用 gfx-rs 将 s 列表传递给顶点着色器。数据定义如下
gfx_defines! {
vertex Vertex { ... }
constant MyConst {
valoo: i32 = "my_val",
}
pipeline pipe {
my_const: gfx::ConstantBuffer<MyConst> = "my_const",
vbuf: gfx::VertexBuffer<Vertex> = (),
out: gfx::RenderTarget<ColorFormat> = "Target0",
}
}
顶点着色器如下:
#version 150 core
struct MyConst
{
uint my_val;
};
in vec2 a_Pos;
in vec3 a_Color;
uniform MyConst my_const[];
out vec4 v_Color;
void main() {
MyConst cc = my_const[0];
v_Color = vec4(a_Color, 1.0);
gl_Position = vec4(a_Pos, 0.0, 1.0);
}
当我在 中引入第一行时main()
,应用程序崩溃并出现以下错误:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DescriptorInit(GlobalConstant("my_const[0].my_val", None))'