boolvectypes = ("bvec2", "bvec3", "bvec4")
squarematrixtypes = ("mat2", "mat3", "mat4")
matrixtypes = squarematrixtypes+("mat2x3", "mat3x2", "mat2x4", "mat4x2", "mat3x4", "mat4x3")
-flatsamplertypes = ("sampler1D", "sampler2D", "sampler3D", "sampler1DArray", "sampler2DArray")
-colorsamplertypes = flatsamplertypes+("samplerCube", "samplerCubeArray")
-shadowsamplertypes = ("sampler1DShadow", "sampler2DShadow", "samplerCubeShadow", "sampler1DArrayShadow", "sampler2DArrayShadow", "samplerCubeArrayShadow")
-mssamplertypes = ("sampler2DMS", "sampler2DMSArray")
-samplertypes = colorsamplertypes+shadowsamplertypes
+flatdimensions = ("1D", "2D", "3D", "1DArray", "2DArray")
+colordimensions = flatdimensions+("Cube", "CubeArray")
+shadowdimensions = ("1DShadow", "2DShadow", "CubeShadow", "1DArrayShadow", "2DArrayShadow", "CubeArrayShadow")
+msdimensions = ("2DMS", "2DMSArray")
+dimensions = colordimensions+shadowdimensions
+samplertypes = lambda d: tuple("sampler"+i for i in d)
+imagetypes = lambda d: tuple("image"+i for i in d)
+for i in colordimensions+msdimensions:
+ traits["image"+i] = traits["sampler"+i]
shared_funcs = [
# Trigonometric
("T radians(T degrees)", float32types),
("int[T::Dim] findMSB(T value)", int32types),
# Texture
- ("int[T::IDim] textureSize(T sampler, int lod)", samplertypes+mssamplertypes),
- ("vec2 textureQueryLod(T sampler, float[T::LDim] P)", samplertypes),
- ("int textureQueryLevels(T sampler)", samplertypes),
- ("int textureSamples(T sampler)", mssamplertypes),
- ("vec4 texture(T sampler, float[T::CDim] P)", colorsamplertypes),
- ("float texture(T sampler, float[T::CDim] P)", tuple(s for s in shadowsamplertypes if "CubeArray" not in s)),
+ ("int[T::IDim] textureSize(T sampler, int lod)", samplertypes(dimensions+msdimensions)),
+ ("vec2 textureQueryLod(T sampler, float[T::LDim] P)", samplertypes(dimensions)),
+ ("int textureQueryLevels(T sampler)", samplertypes(dimensions)),
+ ("int textureSamples(T sampler)", samplertypes(msdimensions)),
+ ("vec4 texture(T sampler, float[T::CDim] P)", samplertypes(colordimensions)),
+ ("float texture(T sampler, float[T::CDim] P)", tuple(s for s in samplertypes(shadowdimensions) if "CubeArray" not in s)),
"float texture(samplerCubeArrayShadow sampler, vec4 P, float compare)",
- ("vec4 textureLod(T sampler, float[T::CDim] P, float lod)", colorsamplertypes),
- ("vec4 texelFetch(T sampler, int[T::CDim] P, int lod)", flatsamplertypes),
- ("vec4 texelFetch(T sampler, int[T::CDim] P, int sample)", mssamplertypes)
+ ("vec4 textureLod(T sampler, float[T::CDim] P, float lod)", samplertypes(colordimensions)),
+ ("vec4 texelFetch(T sampler, int[T::CDim] P, int lod)", samplertypes(flatdimensions)),
+ ("vec4 texelFetch(T sampler, int[T::CDim] P, int sample)", samplertypes(msdimensions)),
+
+ # Image
+ ("int[T::IDim] imageSize(T image)", imagetypes(colordimensions+msdimensions)),
+ ("int imageSamples(T image)", imagetypes(msdimensions)),
+ ("vec4 imageLoad(T image, int[T::CDim] P)", imagetypes(colordimensions)),
+ ("vec4 imageLoad(T image, int[T::CDim] P, int sample)", imagetypes(msdimensions)),
+ ("void imageStore(T image, int[T::CDim] P, vec4 data)", imagetypes(colordimensions)),
+ ("void imageStore(T image, int[T::CDim] P, int sample, vec4 data)", imagetypes(msdimensions))
]
fragment_funcs = [