2

I'm trying to run my shaders on an Intel card. I found that samplers types cannot be declared as structure fields... It was disappointing.

My shaders, on NVIDIA platforms, compile and run fine, with samplers arrays and struct with sampler fields. I know that NVIDIA platform is more permissive than others, w.t.r. the GLSL syntax, but I think that sampler types should be allowed in structures and arrays.

But, after having read this page, I get more confused. In particoular, I have found interesting the following quotes:

Arrays of sampler types are special. Under GLSL version 3.30, sampler arrays can be declared

Structs cannot contain variables of sampler types.

So, I have investigate on GLSL specifications, and while searching I found that the sampler type in a basic one (para 4.1), the array can be composed by basic types (para ), and the same for structure member declarations (para 4.1.9). Am I misinterpreting the specification, or the Intel driver is too "strict"?

Someone could point a spot on this question? The final question should be "Sampler types are considered a basic one?"

4

1 に答える 1

1

What part of this is unclear?

Samplers are basic types. Basic types can be in arrays. And samplers:

They can only be declared as function parameters or uniform variables (see section 4.3.5 “Uniform” ).

Fields in a struct are neither function parameters nor uniform variables. The struct itself can later be declared as a uniform, but the member declaration isn't a uniform yet. Therefore, it is illegal to declare a sampler within a struct.

It is best to not think of samplers and other opaque types as types, but instead as placeholders for special constructs (like textures and such).

于 2012-08-07T12:23:06.633 に答える