X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=builtin_data%2F_builtin.glsl;h=124a117b120397ec6a56d1345080f6a175eddce7;hb=305b62cf4f7e2a4ca3cc56109003aed6bde61c25;hp=df39bcc0a49020f4e16baf4cc13e6c4c9da1b604;hpb=4c805f55d89919d6971d600102ab4d6d65d56dc3;p=libs%2Fgl.git diff --git a/builtin_data/_builtin.glsl b/builtin_data/_builtin.glsl index df39bcc0..124a117b 100644 --- a/builtin_data/_builtin.glsl +++ b/builtin_data/_builtin.glsl @@ -18,6 +18,10 @@ typedef vector(2) int ivec2; typedef vector(3) int ivec3; typedef vector(4) int ivec4; +typedef vector(2) bool bvec2; +typedef vector(3) bool bvec3; +typedef vector(4) bool bvec4; + typedef image(dimensions=1, sampled) float sampler1D; typedef image(dimensions=2, sampled) float sampler2D; typedef image(dimensions=3, sampled) float sampler3D; @@ -32,10 +36,404 @@ typedef image(dimensions=2[], shadow, sampled) float sampler2DArrayShadow; typedef image(dimensions=cube, shadow, sampled) float samplerCubeShadow; typedef image(dimensions=cube[], shadow, sampled) float samplerCubeArrayShadow; +// BEGIN BUILTIN FUNCTIONS +float radians(float degrees); +vec2 radians(vec2 degrees); +vec3 radians(vec3 degrees); +vec4 radians(vec4 degrees); +float degrees(float radians); +vec2 degrees(vec2 radians); +vec3 degrees(vec3 radians); +vec4 degrees(vec4 radians); +float sin(float angle); +vec2 sin(vec2 angle); +vec3 sin(vec3 angle); +vec4 sin(vec4 angle); +float cos(float angle); +vec2 cos(vec2 angle); +vec3 cos(vec3 angle); +vec4 cos(vec4 angle); +float tan(float angle); +vec2 tan(vec2 angle); +vec3 tan(vec3 angle); +vec4 tan(vec4 angle); +float asin(float x); +vec2 asin(vec2 x); +vec3 asin(vec3 x); +vec4 asin(vec4 x); +float acos(float x); +vec2 acos(vec2 x); +vec3 acos(vec3 x); +vec4 acos(vec4 x); +float atan(float y, float x); +vec2 atan(vec2 y, vec2 x); +vec3 atan(vec3 y, vec3 x); +vec4 atan(vec4 y, vec4 x); +float atan(float y_over_x); +vec2 atan(vec2 y_over_x); +vec3 atan(vec3 y_over_x); +vec4 atan(vec4 y_over_x); +float sinh(float angle); +vec2 sinh(vec2 angle); +vec3 sinh(vec3 angle); +vec4 sinh(vec4 angle); +float cosh(float angle); +vec2 cosh(vec2 angle); +vec3 cosh(vec3 angle); +vec4 cosh(vec4 angle); +float tanh(float angle); +vec2 tanh(vec2 angle); +vec3 tanh(vec3 angle); +vec4 tanh(vec4 angle); +float asinh(float x); +vec2 asinh(vec2 x); +vec3 asinh(vec3 x); +vec4 asinh(vec4 x); +float acosh(float x); +vec2 acosh(vec2 x); +vec3 acosh(vec3 x); +vec4 acosh(vec4 x); +float atanh(float x); +vec2 atanh(vec2 x); +vec3 atanh(vec3 x); +vec4 atanh(vec4 x); +float pow(float x, float y); +vec2 pow(vec2 x, vec2 y); +vec3 pow(vec3 x, vec3 y); +vec4 pow(vec4 x, vec4 y); +float exp(float x); +vec2 exp(vec2 x); +vec3 exp(vec3 x); +vec4 exp(vec4 x); +float log(float x); +vec2 log(vec2 x); +vec3 log(vec3 x); +vec4 log(vec4 x); +float exp2(float x); +vec2 exp2(vec2 x); +vec3 exp2(vec3 x); +vec4 exp2(vec4 x); +float log2(float x); +vec2 log2(vec2 x); +vec3 log2(vec3 x); +vec4 log2(vec4 x); +float sqrt(float x); +vec2 sqrt(vec2 x); +vec3 sqrt(vec3 x); +vec4 sqrt(vec4 x); +float inversesqrt(float x); +vec2 inversesqrt(vec2 x); +vec3 inversesqrt(vec3 x); +vec4 inversesqrt(vec4 x); +float abs(float x); +vec2 abs(vec2 x); +vec3 abs(vec3 x); +vec4 abs(vec4 x); +int abs(int x); +ivec2 abs(ivec2 x); +ivec3 abs(ivec3 x); +ivec4 abs(ivec4 x); +float sign(float x); +vec2 sign(vec2 x); +vec3 sign(vec3 x); +vec4 sign(vec4 x); +int sign(int x); +ivec2 sign(ivec2 x); +ivec3 sign(ivec3 x); +ivec4 sign(ivec4 x); +float floor(float x); +vec2 floor(vec2 x); +vec3 floor(vec3 x); +vec4 floor(vec4 x); +float trunc(float x); +vec2 trunc(vec2 x); +vec3 trunc(vec3 x); +vec4 trunc(vec4 x); +float round(float x); +vec2 round(vec2 x); +vec3 round(vec3 x); +vec4 round(vec4 x); +float roundEven(float x); +vec2 roundEven(vec2 x); +vec3 roundEven(vec3 x); +vec4 roundEven(vec4 x); +float ceil(float x); +vec2 ceil(vec2 x); +vec3 ceil(vec3 x); +vec4 ceil(vec4 x); +float fract(float x); +vec2 fract(vec2 x); +vec3 fract(vec3 x); +vec4 fract(vec4 x); +float mod(float x, float y); +vec2 mod(vec2 x, vec2 y); +vec3 mod(vec3 x, vec3 y); +vec4 mod(vec4 x, vec4 y); +vec2 mod(vec2 x, float y) { return mod(x, vec2(y)); } +vec3 mod(vec3 x, float y) { return mod(x, vec3(y)); } +vec4 mod(vec4 x, float y) { return mod(x, vec4(y)); } +float min(float x, float y); +vec2 min(vec2 x, vec2 y); +vec3 min(vec3 x, vec3 y); +vec4 min(vec4 x, vec4 y); +int min(int x, int y); +ivec2 min(ivec2 x, ivec2 y); +ivec3 min(ivec3 x, ivec3 y); +ivec4 min(ivec4 x, ivec4 y); +vec2 min(vec2 x, float y) { return min(x, vec2(y)); } +vec3 min(vec3 x, float y) { return min(x, vec3(y)); } +vec4 min(vec4 x, float y) { return min(x, vec4(y)); } +ivec2 min(ivec2 x, int y) { return min(x, ivec2(y)); } +ivec3 min(ivec3 x, int y) { return min(x, ivec3(y)); } +ivec4 min(ivec4 x, int y) { return min(x, ivec4(y)); } +float max(float x, float y); +vec2 max(vec2 x, vec2 y); +vec3 max(vec3 x, vec3 y); +vec4 max(vec4 x, vec4 y); +int max(int x, int y); +ivec2 max(ivec2 x, ivec2 y); +ivec3 max(ivec3 x, ivec3 y); +ivec4 max(ivec4 x, ivec4 y); +vec2 max(vec2 x, float y) { return max(x, vec2(y)); } +vec3 max(vec3 x, float y) { return max(x, vec3(y)); } +vec4 max(vec4 x, float y) { return max(x, vec4(y)); } +ivec2 max(ivec2 x, int y) { return max(x, ivec2(y)); } +ivec3 max(ivec3 x, int y) { return max(x, ivec3(y)); } +ivec4 max(ivec4 x, int y) { return max(x, ivec4(y)); } +float clamp(float x, float minVal, float maxVal); +vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal); +vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal); +vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal); +int clamp(int x, int minVal, int maxVal); +ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal); +ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal); +ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal); +vec2 clamp(vec2 x, float minVal, float maxVal) { return clamp(x, vec2(minVal), vec2(maxVal)); } +vec3 clamp(vec3 x, float minVal, float maxVal) { return clamp(x, vec3(minVal), vec3(maxVal)); } +vec4 clamp(vec4 x, float minVal, float maxVal) { return clamp(x, vec4(minVal), vec4(maxVal)); } +ivec2 clamp(ivec2 x, int minVal, int maxVal) { return clamp(x, ivec2(minVal), ivec2(maxVal)); } +ivec3 clamp(ivec3 x, int minVal, int maxVal) { return clamp(x, ivec3(minVal), ivec3(maxVal)); } +ivec4 clamp(ivec4 x, int minVal, int maxVal) { return clamp(x, ivec4(minVal), ivec4(maxVal)); } +float mix(float x, float y, float a); +vec2 mix(vec2 x, vec2 y, vec2 a); +vec3 mix(vec3 x, vec3 y, vec3 a); +vec4 mix(vec4 x, vec4 y, vec4 a); +float mix(float x, float y, float a) { return mix(x, y, float(a)); } +vec2 mix(vec2 x, vec2 y, float a) { return mix(x, y, vec2(a)); } +vec3 mix(vec3 x, vec3 y, float a) { return mix(x, y, vec3(a)); } +vec4 mix(vec4 x, vec4 y, float a) { return mix(x, y, vec4(a)); } +float mix(float x, float y, bool a); +vec2 mix(vec2 x, vec2 y, bvec2 a); +vec3 mix(vec3 x, vec3 y, bvec3 a); +vec4 mix(vec4 x, vec4 y, bvec4 a); +int mix(int x, int y, bool a); +ivec2 mix(ivec2 x, ivec2 y, bvec2 a); +ivec3 mix(ivec3 x, ivec3 y, bvec3 a); +ivec4 mix(ivec4 x, ivec4 y, bvec4 a); +float step(float edge, float x); +vec2 step(vec2 edge, vec2 x); +vec3 step(vec3 edge, vec3 x); +vec4 step(vec4 edge, vec4 x); +vec2 step(float edge, vec2 x) { return step(vec2(edge), x); } +vec3 step(float edge, vec3 x) { return step(vec3(edge), x); } +vec4 step(float edge, vec4 x) { return step(vec4(edge), x); } +float smoothstep(float edge0, float edge1, float x); +vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x); +vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x); +vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x); +vec2 smoothstep(float edge0, float edge1, vec2 x) { return smoothstep(vec2(edge0), vec2(edge1), x); } +vec3 smoothstep(float edge0, float edge1, vec3 x) { return smoothstep(vec3(edge0), vec3(edge1), x); } +vec4 smoothstep(float edge0, float edge1, vec4 x) { return smoothstep(vec4(edge0), vec4(edge1), x); } +bool isnan(float x); +bvec2 isnan(vec2 x); +bvec3 isnan(vec3 x); +bvec4 isnan(vec4 x); +bool isinf(float x); +bvec2 isinf(vec2 x); +bvec3 isinf(vec3 x); +bvec4 isinf(vec4 x); +float fma(float a, float b, float c); +vec2 fma(vec2 a, vec2 b, vec2 c); +vec3 fma(vec3 a, vec3 b, vec3 c); +vec4 fma(vec4 a, vec4 b, vec4 c); +float length(float x); +float length(vec2 x); +float length(vec3 x); +float length(vec4 x); +float distance(float p0, float p1); +float distance(vec2 p0, vec2 p1); +float distance(vec3 p0, vec3 p1); +float distance(vec4 p0, vec4 p1); +float dot(float x, float y); +float dot(vec2 x, vec2 y); +float dot(vec3 x, vec3 y); +float dot(vec4 x, vec4 y); +vec3 cross(vec3 x); +float normalize(float x); +vec2 normalize(vec2 x); +vec3 normalize(vec3 x); +vec4 normalize(vec4 x); +float faceforward(float N, float I, float Nref); +vec2 faceforward(vec2 N, vec2 I, vec2 Nref); +vec3 faceforward(vec3 N, vec3 I, vec3 Nref); +vec4 faceforward(vec4 N, vec4 I, vec4 Nref); +float reflect(float I, float N); +vec2 reflect(vec2 I, vec2 N); +vec3 reflect(vec3 I, vec3 N); +vec4 reflect(vec4 I, vec4 N); +float refract(float I, float N, float eta); +vec2 refract(vec2 I, vec2 N, float eta); +vec3 refract(vec3 I, vec3 N, float eta); +vec4 refract(vec4 I, vec4 N, float eta); +mat2 matrixCompMult(mat2 x, mat2 y); +mat3 matrixCompMult(mat3 x, mat3 y); +mat4 matrixCompMult(mat4 x, mat4 y); +mat2x3 matrixCompMult(mat2x3 x, mat2x3 y); +mat3x2 matrixCompMult(mat3x2 x, mat3x2 y); +mat2x4 matrixCompMult(mat2x4 x, mat2x4 y); +mat4x2 matrixCompMult(mat4x2 x, mat4x2 y); +mat3x4 matrixCompMult(mat3x4 x, mat3x4 y); +mat4x3 matrixCompMult(mat4x3 x, mat4x3 y); +mat2 outerProduct(vec2 c, vec2 r); +mat3 outerProduct(vec3 c, vec3 r); +mat4 outerProduct(vec4 c, vec4 r); +mat2x3 outerProduct(vec3 c, vec2 r); +mat3x2 outerProduct(vec2 c, vec3 r); +mat2x4 outerProduct(vec4 c, vec2 r); +mat4x2 outerProduct(vec2 c, vec4 r); +mat3x4 outerProduct(vec4 c, vec3 r); +mat4x3 outerProduct(vec3 c, vec4 r); +mat2 transpose(mat2 m); +mat3 transpose(mat3 m); +mat4 transpose(mat4 m); +mat3x2 transpose(mat2x3 m); +mat2x3 transpose(mat3x2 m); +mat4x2 transpose(mat2x4 m); +mat2x4 transpose(mat4x2 m); +mat4x3 transpose(mat3x4 m); +mat3x4 transpose(mat4x3 m); +mat2 determinant(mat2 m); +mat3 determinant(mat3 m); +mat4 determinant(mat4 m); +mat2 inverse(mat2 m); +mat3 inverse(mat3 m); +mat4 inverse(mat4 m); +bvec2 lessThan(vec2 x, vec2 y); +bvec3 lessThan(vec3 x, vec3 y); +bvec4 lessThan(vec4 x, vec4 y); +bvec2 lessThan(ivec2 x, ivec2 y); +bvec3 lessThan(ivec3 x, ivec3 y); +bvec4 lessThan(ivec4 x, ivec4 y); +bvec2 lessThanEqual(vec2 x, vec2 y); +bvec3 lessThanEqual(vec3 x, vec3 y); +bvec4 lessThanEqual(vec4 x, vec4 y); +bvec2 lessThanEqual(ivec2 x, ivec2 y); +bvec3 lessThanEqual(ivec3 x, ivec3 y); +bvec4 lessThanEqual(ivec4 x, ivec4 y); +bvec2 greaterThan(vec2 x, vec2 y); +bvec3 greaterThan(vec3 x, vec3 y); +bvec4 greaterThan(vec4 x, vec4 y); +bvec2 greaterThan(ivec2 x, ivec2 y); +bvec3 greaterThan(ivec3 x, ivec3 y); +bvec4 greaterThan(ivec4 x, ivec4 y); +bvec2 greaterThanEqual(vec2 x, vec2 y); +bvec3 greaterThanEqual(vec3 x, vec3 y); +bvec4 greaterThanEqual(vec4 x, vec4 y); +bvec2 greaterThanEqual(ivec2 x, ivec2 y); +bvec3 greaterThanEqual(ivec3 x, ivec3 y); +bvec4 greaterThanEqual(ivec4 x, ivec4 y); +bvec2 equal(vec2 x, vec2 y); +bvec3 equal(vec3 x, vec3 y); +bvec4 equal(vec4 x, vec4 y); +bvec2 equal(ivec2 x, ivec2 y); +bvec3 equal(ivec3 x, ivec3 y); +bvec4 equal(ivec4 x, ivec4 y); +bvec2 notEqual(vec2 x, vec2 y); +bvec3 notEqual(vec3 x, vec3 y); +bvec4 notEqual(vec4 x, vec4 y); +bvec2 notEqual(ivec2 x, ivec2 y); +bvec3 notEqual(ivec3 x, ivec3 y); +bvec4 notEqual(ivec4 x, ivec4 y); +bool any(bvec2 x); +bool any(bvec3 x); +bool any(bvec4 x); +bool all(bvec2 x); +bool all(bvec3 x); +bool all(bvec4 x); +bool not(bvec2 x); +bool not(bvec3 x); +bool not(bvec4 x); +int bitfieldExtract(int value, int offset, int bits); +ivec2 bitfieldExtract(ivec2 value, int offset, int bits); +ivec3 bitfieldExtract(ivec3 value, int offset, int bits); +ivec4 bitfieldExtract(ivec4 value, int offset, int bits); +int bitfieldInsert(int value, int insert, int offset, int bits); +ivec2 bitfieldInsert(ivec2 value, ivec2 insert, int offset, int bits); +ivec3 bitfieldInsert(ivec3 value, ivec3 insert, int offset, int bits); +ivec4 bitfieldInsert(ivec4 value, ivec4 insert, int offset, int bits); +int bitfieldReverse(int value); +ivec2 bitfieldReverse(ivec2 value); +ivec3 bitfieldReverse(ivec3 value); +ivec4 bitfieldReverse(ivec4 value); +int bitCount(int value); +ivec2 bitCount(ivec2 value); +ivec3 bitCount(ivec3 value); +ivec4 bitCount(ivec4 value); +int findLSB(int value); +ivec2 findLSB(ivec2 value); +ivec3 findLSB(ivec3 value); +ivec4 findLSB(ivec4 value); +int findMSB(int value); +ivec2 findMSB(ivec2 value); +ivec3 findMSB(ivec3 value); +ivec4 findMSB(ivec4 value); +int textureSize(sampler1D sampler, int lod); +ivec2 textureSize(sampler2D sampler, int lod); +ivec3 textureSize(sampler3D sampler, int lod); +ivec2 textureSize(sampler1DArray sampler, int lod); +ivec3 textureSize(sampler2DArray sampler, int lod); +ivec2 textureSize(samplerCube sampler, int lod); +ivec3 textureSize(samplerCubeArray sampler, int lod); +int textureSize(sampler1DShadow sampler, int lod); +ivec2 textureSize(sampler2DShadow sampler, int lod); +ivec2 textureSize(samplerCubeShadow sampler, int lod); +ivec2 textureSize(sampler1DArrayShadow sampler, int lod); +ivec3 textureSize(sampler2DArrayShadow sampler, int lod); +ivec3 textureSize(samplerCubeArrayShadow sampler, int lod); +vec4 texture(sampler1D sampler, float P); +vec4 texture(sampler2D sampler, vec2 P); +vec4 texture(sampler3D sampler, vec3 P); +vec4 texture(sampler1DArray sampler, vec2 P); +vec4 texture(sampler2DArray sampler, vec3 P); +vec4 texture(samplerCube sampler, vec3 P); +vec4 texture(samplerCubeArray sampler, vec4 P); +float texture(sampler1DShadow sampler, vec3 P); +float texture(sampler2DShadow sampler, vec3 P); +float texture(samplerCubeShadow sampler, vec4 P); +float texture(sampler1DArrayShadow sampler, vec3 P); +float texture(sampler2DArrayShadow sampler, vec4 P); +float texture(samplerCubeArrayShadow sampler, vec4 P, float compare); +vec4 textureLod(sampler1D sampler, float P, float lod); +vec4 textureLod(sampler2D sampler, vec2 P, float lod); +vec4 textureLod(sampler3D sampler, vec3 P, float lod); +vec4 textureLod(sampler1DArray sampler, vec2 P, float lod); +vec4 textureLod(sampler2DArray sampler, vec3 P, float lod); +vec4 textureLod(samplerCube sampler, vec3 P, float lod); +vec4 textureLod(samplerCubeArray sampler, vec4 P, float lod); +vec4 texelFetch(sampler1D sampler, int P, int lod); +vec4 texelFetch(sampler2D sampler, ivec2 P, int lod); +vec4 texelFetch(sampler3D sampler, ivec3 P, int lod); +vec4 texelFetch(sampler1DArray sampler, ivec2 P, int lod); +vec4 texelFetch(sampler2DArray sampler, ivec3 P, int lod); +// END BUILTIN FUNCTIONS + #pragma MSP stage(vertex) +in int gl_VertexID; +in int gl_InstanceID; out gl_PerVertex { vec4 gl_Position; + float gl_PointSize; float gl_ClipDistance[]; }; @@ -43,10 +441,81 @@ out gl_PerVertex in gl_PerVertex { vec4 gl_Position; + float gl_PointSize; float gl_ClipDistance[]; } gl_in[]; +in int gl_PrimitiveIDIn; +in int gl_InvocationID; out gl_PerVertex { vec4 gl_Position; + float gl_PointSize; float gl_ClipDistance[]; }; +out int gl_PrimitiveID; +out int gl_Layer; + +void EmitVertex(); +void EndPrimitive(); + +#pragma MSP stage(fragment) +// BEGIN BUILTIN FRAGMENT FUNCTIONS +float dFdx(float p); +vec2 dFdx(vec2 p); +vec3 dFdx(vec3 p); +vec4 dFdx(vec4 p); +float dFdy(float p); +vec2 dFdy(vec2 p); +vec3 dFdy(vec3 p); +vec4 dFdy(vec4 p); +float dFdxFine(float p); +vec2 dFdxFine(vec2 p); +vec3 dFdxFine(vec3 p); +vec4 dFdxFine(vec4 p); +float dFdyFine(float p); +vec2 dFdyFine(vec2 p); +vec3 dFdyFine(vec3 p); +vec4 dFdyFine(vec4 p); +float dFdxCoarse(float p); +vec2 dFdxCoarse(vec2 p); +vec3 dFdxCoarse(vec3 p); +vec4 dFdxCoarse(vec4 p); +float dFdyCoarse(float p); +vec2 dFdyCoarse(vec2 p); +vec3 dFdyCoarse(vec3 p); +vec4 dFdyCoarse(vec4 p); +float fwidth(float p); +vec2 fwidth(vec2 p); +vec3 fwidth(vec3 p); +vec4 fwidth(vec4 p); +float fwidthFine(float p); +vec2 fwidthFine(vec2 p); +vec3 fwidthFine(vec3 p); +vec4 fwidthFine(vec4 p); +float fwidthCoarse(float p); +vec2 fwidthCoarse(vec2 p); +vec3 fwidthCoarse(vec3 p); +vec4 fwidthCoarse(vec4 p); +float interpolateAtCentroid(float interpolant); +vec2 interpolateAtCentroid(vec2 interpolant); +vec3 interpolateAtCentroid(vec3 interpolant); +vec4 interpolateAtCentroid(vec4 interpolant); +float interpolateAtSample(float interpolant, int sample); +vec2 interpolateAtSample(vec2 interpolant, int sample); +vec3 interpolateAtSample(vec3 interpolant, int sample); +vec4 interpolateAtSample(vec4 interpolant, int sample); +float interpolateAtOffset(float interpolant, vec2 offset); +vec2 interpolateAtOffset(vec2 interpolant, vec2 offset); +vec3 interpolateAtOffset(vec3 interpolant, vec2 offset); +vec4 interpolateAtOffset(vec4 interpolant, vec2 offset); +// END BUILTIN FRAGMENT FUNCTIONS + +in vec4 gl_FragCoord; +in bool gl_FrontFacing; +in float gl_ClipDistance[]; +in vec2 gl_PointCoord; +in int gl_PrimitiveID; +in int gl_SampleID; +in vec2 gl_SamplePosition; +in int gl_Layer; +out float gl_FragDepth;