• Create Account

### #Actualtanzanite7

Posted 30 March 2012 - 01:03 PM

1. I am not supposed to use in/out qualifiers with structs ? Does that mean if I am going to share things between stages
they should be either interfaces or just global variables using in/out qualifiers ?

Tried to find what the rules are with struct, but was not able to discern it in the time allotted :/. edit: ok, i think i remember it now - more useful stuff after next quote.

in / out global variables and/or interface blocks are the only way to communicate between shader stages.

2. In HLSL side, I am using semantics like TEXCOORD4_centroid , and I was planning to use something like
layout(location=4) to match TEXCOORDs. And at the same time I want to specify that that variable should be sampled by
centroid sampling method

like:
layout(location=4) centroid in vec4 attr;

or, probably (edit: remembered something, interface blocks are not allowed for vertex input not fragment output), also:
// vertex shader
in struct name {
layout(location=4) centroid in vec4 attr; // note that "in" agrees with parent declaration
layout(location= ... etc for whatever other stuff
} instance_name;
// access: instance_name.attr


3. Regarding mixing in centroid with an out struct ,I was trying the code above in a vertex shader so that I want to output that struct and that is working like that.
On the other hand the compiler doesnt allow me to use centroid with out in a vertex shader but it just allows centroid in in a vertex shader.

Probably because you are mixing in and out - it can not be both at the same time.
// vertex shader
out block_name2 {
controid out vec4 attr;
...
} fs;
in block_name2 {
controid in vec4 attr;
...
} fs;
// blocknames etc get automatically matched/connected between stages by name.


### #2tanzanite7

Posted 30 March 2012 - 01:02 PM

1. I am not supposed to use in/out qualifiers with structs ? Does that mean if I am going to share things between stages
they should be either interfaces or just global variables using in/out qualifiers ?

Tried to find what the rules are with struct, but was not able to discern it in the time allotted :/. Pretty sure you can use structs IN interface blocks - if you need (i have never used them that way unfortunately).

in / out global variables and/or interface blocks are the only way to communicate between shader stages.

2. In HLSL side, I am using semantics like TEXCOORD4_centroid , and I was planning to use something like
layout(location=4) to match TEXCOORDs. And at the same time I want to specify that that variable should be sampled by
centroid sampling method

like:
layout(location=4) centroid in vec4 attr;

or, probably (edit: remembered something, interface blocks are not allowed for vertex input not fragment output), also:
// vertex shader
in struct name {
layout(location=4) centroid in vec4 attr; // note that "in" agrees with parent declaration
layout(location= ... etc for whatever other stuff
} instance_name;
// access: instance_name.attr


3. Regarding mixing in centroid with an out struct ,I was trying the code above in a vertex shader so that I want to output that struct and that is working like that.
On the other hand the compiler doesnt allow me to use centroid with out in a vertex shader but it just allows centroid in in a vertex shader.

Probably because you are mixing in and out - it can not be both at the same time.
// vertex shader
out block_name2 {
controid out vec4 attr;
...
} fs;
in block_name2 {
controid in vec4 attr;
...
} fs;
// blocknames etc get automatically matched/connected between stages by name.


### #1tanzanite7

Posted 30 March 2012 - 12:44 PM

1. I am not supposed to use in/out qualifiers with structs ? Does that mean if I am going to share things between stages
they should be either interfaces or just global variables using in/out qualifiers ?

Tried to find what the rules are with struct, but was not able to discern it in the time allotted :/. Pretty sure you can use structs IN interface blocks - if you need (i have never used them that way unfortunately).

in / out global variables and/or interface blocks are the only way to communicate between shader stages.

2. In HLSL side, I am using semantics like TEXCOORD4_centroid , and I was planning to use something like
layout(location=4) to match TEXCOORDs. And at the same time I want to specify that that variable should be sampled by
centroid sampling method

like:
layout(location=4) centroid in vec4 attr;

or, probably (never used interface blocks for thous myself as, iirc, a long time ago i had trouble with some drivers understanding it per spec [or the usage was just inconvenient] - so, my memory here is very foggy. I like to define them outside of interface blocks explicitly [using "vx" and "fb" prefixes at the two endpoints]), also:
// vertex shader
in block_name {
layout(location=4) centroid in vec4 attr;
layout(location= ... etc for whatever other stuff
} instance_name;
// access: instance_name.attr


3. Regarding mixing in centroid with an out struct ,I was trying the code above in a vertex shader so that I want to output that struct and that is working like that.
On the other hand the compiler doesnt allow me to use centroid with out in a vertex shader but it just allows centroid in in a vertex shader.

Probably because you are mixing in and out - it can not be both at the same time.
// vertex shader
out block_name2 {
controid out vec4 attr;
...
} fs;
`