I can clarify a bit more for you. This code compiles and runs on Windows 8.1 but not on Windows 7.0.
Here are the listings and errors from Windows 7.0
#version 440
#extension GL_EXT_gpu_shader4 : enable
#extension GL_ARB_separate_shader_objects : enable
// default vertices
#define VERTEX_BINDINGS_POSITION 0
#define VERTEX_BINDINGS_COLOUR 1
#define VERTEX_BINDINGS_NORMAL 2
#define VERTEX_BINDINGS_TEXTURE0 3
#define VERTEX_BINDINGS_TEXTURE1 4
#define VERTEX_BINDINGS_TEXTURE3 6
// extras for cylinders, wedges and spheres
#define VERTEX_BINDINGS_RADIUS 2
#define VERTEX_BINDINGS_CLIP0 3
#define VERTEX_BINDINGS_CLIP1 4
#define VERTEX_BINDINGS_M0 6
#define VERTEX_BINDINGS_M1 7
#define VERTEX_BINDINGS_M2 8
// 2D vertices
// #define VERTEX_BINDINGS_POSITION 0
// #define VERTEX_BINDINGS_COLOUR 1
#define VERTEX_BINDINGS_DARKCOLOUR 2
// #define VERTEX_BINDINGS_TEXTURE0 3
// #define VERTEX_BINDINGS_TEXTURE1 4
// #define VERTEX_BINDINGS_TEXTURE3 6
struct vertex_NC_struct
{
vec4 colour;
vec4 fragmentNormal;
vec4 worldPos;
};
struct vertex_struct
{
vec4 colour;
vec4 fragmentNormal;
vec2 texture0;
vec2 texture1;
vec4 worldPos;
};
layout(std140) uniform SharedSunlightBuffer
{
mat4 u_SunlightProjection; // sunlight to screen projection
mat4 u_SunlightModelView; // model to sun
mat4 u_LightVPSBMatrices[4]; // camera to light view-model-proj matrix for cascade
vec4 u_NormalizedFarPlanes; // far planes for cascaded shadow map
vec4 u_LightDirection; // light direction
vec4 u_Viewport[4]; // viewports for frustrum
vec4 u_Ambient;
vec4 u_AmbientLightLevel;
vec4 u_Rayleigh;
vec4 u_Mie;
vec4 u_ESun;
vec4 u_Sum;
};
#define MAX_CAMERA_FRUSTUM_SPLIT_COUNT 4
#define LIGHT_TEXTURE_SIZE 4096
layout(triangles) in;
layout(triangle_strip, max_vertices = 12) out;
uniform int u_NbrUserClippingPlanes;
in vertex_struct vgData[];
out vertex_struct vData;
// converts clip coordinates into window coordinates for a given viewport
vec2 getWindowPos(vec4 clip_Pos, uint viewport)
{
vec2 ndc_Pos = (clip_Pos.xy / clip_Pos.w); // -1 to 1
vec2 blend_factor = (ndc_Pos + 1.0) * 0.5; // 0 to 1
vec2 view_Pos = (u_Viewport[viewport].zw * blend_factor) + u_Viewport[viewport].xy;
return view_Pos;
}
// checks if two 2d bounding boxes intersect
bool checkIntersection(vec4 bbox0, vec4 bbox1)
{
bool xmiss = bbox0.x > bbox1.z || bbox0.z < bbox1.x;
bool ymiss = bbox0.y > bbox1.w || bbox0.w < bbox1.y;
return !xmiss && !ymiss;
}
// emit a primitive for a given viewport
void sendPrimitive(int p_ViewportIndex)
{
for (int i = 0; i < gl_in.length(); ++i)
{
gl_Position = gl_in[i].gl_Position;
if (u_NbrUserClippingPlanes > 0)
{
gl_ClipDistance[0] = gl_in[i].gl_ClipDistance[0];
gl_ClipDistance[1] = gl_in[i].gl_ClipDistance[1];
gl_ClipDistance[2] = gl_in[i].gl_ClipDistance[2];
gl_ClipDistance[3] = gl_in[i].gl_ClipDistance[3];
}
vData = vgData[i];
gl_ViewportIndex = p_ViewportIndex;
gl_Layer = p_ViewportIndex;
EmitVertex();
}
EndPrimitive();
}
void main(void)
{
const vec4 mapBounds = vec4(0, 0, LIGHT_TEXTURE_SIZE, LIGHT_TEXTURE_SIZE);
for (int segment = 0; segment < MAX_CAMERA_FRUSTUM_SPLIT_COUNT; ++segment)
{
vec2 start_Pos = getWindowPos(gl_in[0].gl_Position, segment);
vec4 primBounds = vec4(start_Pos, start_Pos); // minx, miny, maxx, maxy
for (int i = 1; i < gl_in.length(); ++i)
{
vec2 window_Pos = getWindowPos(gl_in[i].gl_Position, segment);
primBounds.x = min(primBounds.x, window_Pos.x);
primBounds.y = min(primBounds.y, window_Pos.y);
primBounds.z = max(primBounds.x, window_Pos.x);
primBounds.w = max(primBounds.y, window_Pos.y);
}
// we should only emit the primitive if its bounding box intersects the current viewport
// if (checkIntersection(primBounds, mapBounds))
{
sendPrimitive(segment);
}
}
}
0(100) : error C7531: global variable gl_ClipDistance requires "#extension GL_ARB_compatibility : enable" before use
Shader compile failed12dViewerd.exe has triggered a breakpoint.
other version
#version 440
#extension GL_ARB_compatibility : enable
#extension GL_EXT_gpu_shader4 : enable
#extension GL_ARB_separate_shader_objects : enable
// default vertices
#define VERTEX_BINDINGS_POSITION 0
#define VERTEX_BINDINGS_COLOUR 1
#define VERTEX_BINDINGS_NORMAL 2
#define VERTEX_BINDINGS_TEXTURE0 3
#define VERTEX_BINDINGS_TEXTURE1 4
#define VERTEX_BINDINGS_TEXTURE3 6
// extras for cylinders, wedges and spheres
#define VERTEX_BINDINGS_RADIUS 2
#define VERTEX_BINDINGS_CLIP0 3
#define VERTEX_BINDINGS_CLIP1 4
#define VERTEX_BINDINGS_M0 6
#define VERTEX_BINDINGS_M1 7
#define VERTEX_BINDINGS_M2 8
// 2D vertices
// #define VERTEX_BINDINGS_POSITION 0
// #define VERTEX_BINDINGS_COLOUR 1
#define VERTEX_BINDINGS_DARKCOLOUR 2
// #define VERTEX_BINDINGS_TEXTURE0 3
// #define VERTEX_BINDINGS_TEXTURE1 4
// #define VERTEX_BINDINGS_TEXTURE3 6
struct vertex_NC_struct
{
vec4 colour;
vec4 fragmentNormal;
vec4 worldPos;
};
struct vertex_struct
{
vec4 colour;
vec4 fragmentNormal;
vec2 texture0;
vec2 texture1;
vec4 worldPos;
};
layout(std140) uniform SharedSunlightBuffer
{
mat4 u_SunlightProjection; // sunlight to screen projection
mat4 u_SunlightModelView; // model to sun
mat4 u_LightVPSBMatrices[4]; // camera to light view-model-proj matrix for cascade
vec4 u_NormalizedFarPlanes; // far planes for cascaded shadow map
vec4 u_LightDirection; // light direction
vec4 u_Viewport[4]; // viewports for frustrum
vec4 u_Ambient;
vec4 u_AmbientLightLevel;
vec4 u_Rayleigh;
vec4 u_Mie;
vec4 u_ESun;
vec4 u_Sum;
};
#define MAX_CAMERA_FRUSTUM_SPLIT_COUNT 4
#define LIGHT_TEXTURE_SIZE 4096
layout(triangles) in;
layout(triangle_strip, max_vertices = 12) out;
uniform int u_NbrUserClippingPlanes;
in vertex_struct vgData[];
out vertex_struct vData;
// converts clip coordinates into window coordinates for a given viewport
vec2 getWindowPos(vec4 clip_Pos, uint viewport)
{
vec2 ndc_Pos = (clip_Pos.xy / clip_Pos.w); // -1 to 1
vec2 blend_factor = (ndc_Pos + 1.0) * 0.5; // 0 to 1
vec2 view_Pos = (u_Viewport[viewport].zw * blend_factor) + u_Viewport[viewport].xy;
return view_Pos;
}
// checks if two 2d bounding boxes intersect
bool checkIntersection(vec4 bbox0, vec4 bbox1)
{
bool xmiss = bbox0.x > bbox1.z || bbox0.z < bbox1.x;
bool ymiss = bbox0.y > bbox1.w || bbox0.w < bbox1.y;
return !xmiss && !ymiss;
}
// emit a primitive for a given viewport
void sendPrimitive(int p_ViewportIndex)
{
for (int i = 0; i < gl_in.length(); ++i)
{
gl_Position = gl_in[i].gl_Position;
if (u_NbrUserClippingPlanes > 0)
{
gl_ClipDistance[0] = gl_in[i].gl_ClipDistance[0];
gl_ClipDistance[1] = gl_in[i].gl_ClipDistance[1];
gl_ClipDistance[2] = gl_in[i].gl_ClipDistance[2];
gl_ClipDistance[3] = gl_in[i].gl_ClipDistance[3];
}
vData = vgData[i];
gl_ViewportIndex = p_ViewportIndex;
gl_Layer = p_ViewportIndex;
EmitVertex();
}
EndPrimitive();
}
void main(void)
{
const vec4 mapBounds = vec4(0, 0, LIGHT_TEXTURE_SIZE, LIGHT_TEXTURE_SIZE);
for (int segment = 0; segment < MAX_CAMERA_FRUSTUM_SPLIT_COUNT; ++segment)
{
vec2 start_Pos = getWindowPos(gl_in[0].gl_Position, segment);
vec4 primBounds = vec4(start_Pos, start_Pos); // minx, miny, maxx, maxy
for (int i = 1; i < gl_in.length(); ++i)
{
vec2 window_Pos = getWindowPos(gl_in[i].gl_Position, segment);
primBounds.x = min(primBounds.x, window_Pos.x);
primBounds.y = min(primBounds.y, window_Pos.y);
primBounds.z = max(primBounds.x, window_Pos.x);
primBounds.w = max(primBounds.y, window_Pos.y);
}
// we should only emit the primitive if its bounding box intersects the current viewport
// if (checkIntersection(primBounds, mapBounds))
{
sendPrimitive(segment);
}
}
}
0(3) : error C0207: ARB_compatibility is not supported in GLSL version 440. Use compatibility profile.
Shader compile failed12dViewerd.exe has triggered a breakpoint.