1
着色器进/出变量的顺序和/或大小是否会影响内存使用或性能?例如,有这些:glsl着色器进/出变量包装
相当于// vert example:
out vec4 colorRadius;
// tess control example:
out vec4 colorRadius[];
// frag example:
in smooth vec4 colorRadius;
这些:
// vert example:
out vec3 color;
out float radius;
// tess control example:
out vec3 color[];
out float radius[];
// frag example:
in smooth vec3 color;
in smooth float radius;
是否存在与第二种形式的任何额外费用或将编译器在内存中把它们捆绑在一起,并把它们完全一样?
总的来说,我同意“优化瓶颈”哲学,但同时我也学会尽可能地尽量优化,只要它不会对易读性产生不利影响。 – atb
@atb:不可能“在编写时进行优化”,因为几乎不可能评估代码的所有不同类型的副作用。如果通过分析发现,还有一些不成熟的优化很可能会使您陷入死胡同,您最好优化一些不同的东西,但是您的早期“优化”需要完全重写才能做到这一点。 – datenwolf