2015年3月4日水曜日

GLSL のコンパイルエラーメッセージにファイル名を含める

ソースコードの頭に #line ディレクティブでファイル名を書いておくと:

#version 430 core
#line 3 "append.fs.glsl"

layout(binding = 0, offset = 0) uniform atomic_uint fill_counter;
layout(binding = 0, r32i) coherent uniform uimage2D heap_pointer;

struct list_item {
 vec4 color;
 float depth;
 int facing;
 uint next;
};

layout(binding = 0, std430) buffer list_item_block {
 list_item item[];
}

in VS_OUT {
 vec4 pos;
 vec4 color;
} fs_in;

void main(void)
{
 ivec2 P = ivec2(gl_FragCoord.xy);
 uint index = atomicCounterIncrement(fill_counter);
 uint old_head = imageAtomicExchange(heap_pointer, P, index);
 item[index].color = fs_in.color;
 item[index].depth = gl_FragCoord.z;
 item[index].facing = gl_FontFacing ? 1 : 0;
 item[index].nex = old_head;
}

glGetShaderInfoLog() の出力にファイル名が出るようになる。

append.fs.glsl(5) : error C1318: can't apply layout(r32i) to image type "uimage2D"
append.fs.glsl(18) : error C0000: syntax error, unexpected reserved word "in" at token "in"
append.fs.glsl(21) : error C0000: syntax error, unexpected '}' at token "}"

#line の次の数値は #line ディレクティブの次の行がソースコード中の何行目に当たるかを指定するもの。

0 件のコメント:

コメントを投稿