【发布时间】:2020-11-10 01:45:59
【问题描述】:
我想使用如下着色器中的宏访问统一块实例成员:
#version 450 core
layout(std140, set=0, binding=0) uniform UBlock {
float value;
} uInstance;
#define value uInstance.value
#define saturate(X) clamp( X, 0, 1 )
layout(location = 0) out float Out;
void main ()
{
Out = value;
Out = saturate(value);
}
但每当我将重新定义的符号传递给另一个宏时,glsllangValidator 都会返回以下错误:
ERROR: D:/shader_translation/glsl_preprocessor.frag:15: 'uInstance' : no such field in structure
ERROR: D:/shader_translation/glsl_preprocessor.frag:15: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
有没有办法让它工作? 它适用于 cpp: (https://onlinegdb.com/SJ-B3A8tP)
【问题讨论】:
标签: opengl glsl shader preprocessor vulkan