blob: 814352cee9025a45e7c2015184e306ff7ad362b9 [file] [log] [blame]
// Copyright 2023 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// Spirv builtin definition file //
////////////////////////////////////////////////////////////////////////////////
// TODO(crbug.com/2036): add an include facility and move these duplicate match and type lines
// into a common file.
type bool
type f32
type f16
type i32
type u32
type vec2<T>
type vec3<T>
type vec4<T>
type mat2x2<T>
type mat2x3<T>
type mat2x4<T>
type mat3x2<T>
type mat3x3<T>
type mat3x4<T>
type mat4x2<T>
type mat4x3<T>
type mat4x4<T>
@display("vec{N}<{T}>") type vec<N: num, T>
@display("mat{N}x{M}<{T}>") type mat<N: num, M: num, T>
type atomic<T>
type sampler
type sampler_comparison
type texture_1d<T>
type texture_2d<T>
type texture_2d_array<T>
type texture_3d<T>
type texture_cube<T>
type texture_cube_array<T>
type texture_multisampled_2d<T>
type texture_depth_2d
type texture_depth_2d_array
type texture_depth_cube
type texture_depth_cube_array
type texture_depth_multisampled_2d
type texture_storage_1d<F: texel_format, A: access>
type texture_storage_2d<F: texel_format, A: access>
type texture_storage_2d_array<F: texel_format, A: access>
type texture_storage_3d<F: texel_format, A: access>
type ptr<S: address_space, T, A: access>
type struct_with_runtime_array
type sampled_image<T>
enum address_space {
function
private
workgroup
uniform
storage
push_constant
pixel_local
}
enum access {
read
write
read_write
}
enum texel_format {
bgra8unorm
rgba8unorm
rgba8snorm
rgba8uint
rgba8sint
rgba16uint
rgba16sint
rgba16float
r32uint
r32sint
r32float
rg32uint
rg32sint
rg32float
rgba32uint
rgba32sint
rgba32float
}
match f32_f16: f32 | f16
match iu32: i32 | u32
match fiu32: f32 | i32 | u32
match scalar: f32 | f16 | i32 | u32 | bool
match read_write: access.read_write
match storage
: address_space.storage
match workgroup_or_storage
: address_space.workgroup
| address_space.storage
match samplers
: sampler
| sampler_comparison
match f32_texel_format
: texel_format.bgra8unorm
| texel_format.rgba8unorm
| texel_format.rgba8snorm
| texel_format.rgba16float
| texel_format.r32float
| texel_format.rg32float
| texel_format.rgba32float
match i32_texel_format
: texel_format.rgba8sint
| texel_format.rgba16sint
| texel_format.r32sint
| texel_format.rg32sint
| texel_format.rgba32sint
match u32_texel_format
: texel_format.rgba8uint
| texel_format.rgba16uint
| texel_format.r32uint
| texel_format.rg32uint
| texel_format.rgba32uint
match readable
: access.read
| access.read_write
////////////////////////////////////////////////////////////////////////////////
// Enumerators //
////////////////////////////////////////////////////////////////////////////////
enum intrinsic {
image_sample_implicit_lod
image_sample_explicit_lod
image_sample_dref_implicit_lod
image_sample_dref_explicit_lod
image_write
}
////////////////////////////////////////////////////////////////////////////////
// Builtin Functions //
////////////////////////////////////////////////////////////////////////////////
fn array_length<I: u32, A: access>(ptr<storage, struct_with_runtime_array, A>, I) -> u32
@stage("fragment", "compute") fn atomic_and<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_compare_exchange<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, U, T, T) -> T
@stage("fragment", "compute") fn atomic_exchange<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_iadd<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_isub<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_load<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U) -> T
@stage("fragment", "compute") fn atomic_or<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_smax<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_smin<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_store<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T)
@stage("fragment", "compute") fn atomic_umax<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_umin<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
@stage("fragment", "compute") fn atomic_xor<T: iu32, U: u32, S: workgroup_or_storage>(ptr<S, atomic<T>, read_write>, U, U, T) -> T
fn dot<N: num, T: f32_f16>(vec<N, T>, vec<N, T>) -> T
fn image_dref_gather<A: f32, B: iu32>(sampled_image<texture_depth_2d>, vec2<f32>, A, B) -> vec4<f32>
fn image_dref_gather<A: f32, B: iu32, C: iu32>(sampled_image<texture_depth_2d>, vec2<f32>, A, B, vec2<C>) -> vec4<f32>
fn image_dref_gather<A: f32, B: iu32>(sampled_image<texture_depth_2d_array>, vec3<f32>, A, B) -> vec4<f32>
fn image_dref_gather<A: f32, B: iu32, C: iu32>(sampled_image<texture_depth_2d_array>, vec3<f32>, A, B, vec2<C>) -> vec4<f32>
fn image_dref_gather<A: f32, B: iu32>(sampled_image<texture_depth_cube>, vec3<f32>, A, B) -> vec4<f32>
fn image_dref_gather<A: f32, B: iu32>(sampled_image<texture_depth_cube_array>, vec4<f32>, A, B) -> vec4<f32>
fn image_fetch<T: fiu32, C: iu32, I: iu32, S: iu32>(texture_1d<T>, C, I, S) -> vec4<T>
fn image_fetch<T: fiu32, C: iu32, I: iu32, S: iu32>(texture_2d<T>, vec2<C>, I, S) -> vec4<T>
fn image_fetch<T: fiu32, C: iu32, I: iu32, S: iu32>(texture_2d_array<T>, vec3<C>, I, S) -> vec4<T>
fn image_fetch<T: fiu32, C: iu32, I: iu32, S: iu32>(texture_3d<T>, vec3<C>, I, S) -> vec4<T>
fn image_fetch<T: fiu32, C: iu32, I: iu32, S: iu32>(texture_multisampled_2d<T>, vec2<C>, I, S) -> vec4<T>
fn image_fetch<I: iu32, C: iu32, S: iu32>(texture_depth_2d, vec2<C>, I, S) -> vec4<f32>
fn image_fetch<I: iu32, C: iu32, S: iu32>(texture_depth_2d_array, vec3<C>, I, S) -> vec4<f32>
fn image_fetch<I: iu32, C: iu32, S: iu32>(texture_depth_multisampled_2d, vec2<C>, I, S) -> vec4<f32>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_1d<T> >, vec2<f32>, A, B) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_2d<T> >, vec2<f32>, A, B) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_2d<T> >, vec2<f32>, A, B, vec2<i32>) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_2d_array<T> >, vec3<f32>, A, B) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32, C: iu32>(sampled_image<texture_2d_array<T> >, vec3<f32>, A, B, vec2<C>) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_3d<T> >, vec2<f32>, A, B) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_cube<T> >, vec3<f32>, A, B) -> vec4<T>
fn image_gather<T: fiu32, A: iu32, B: iu32>(sampled_image<texture_cube_array<T> >, vec4<f32>, A, B) -> vec4<T>
fn image_gather<A: iu32, B: iu32>(sampled_image<texture_depth_2d>, vec2<f32>, A, B) -> vec4<f32>
fn image_gather<A: iu32, B: iu32, C: iu32>(sampled_image<texture_depth_2d>, vec2<f32>, A, B, vec2<C>) -> vec4<f32>
fn image_gather<A: iu32, B: iu32>(sampled_image<texture_depth_2d_array>, vec3<f32>, A, B) -> vec4<f32>
fn image_gather<A: iu32, B: iu32, C: iu32>(sampled_image<texture_depth_2d_array>, vec3<f32>, A, B, vec2<C>) -> vec4<f32>
fn image_gather<A: iu32, B: iu32>(sampled_image<texture_depth_cube>, vec3<f32>, A, B) -> vec4<f32>
fn image_gather<A: iu32, B: iu32>(sampled_image<texture_depth_cube_array>, vec4<f32>, A, B) -> vec4<f32>
fn image_query_size<T: fiu32>(texture_1d<T>) -> u32
fn image_query_size<T: fiu32>(texture_2d<T>) -> vec2<u32>
fn image_query_size<T: fiu32>(texture_2d_array<T>) -> vec3<u32>
fn image_query_size<T: fiu32>(texture_3d<T>) -> vec3<u32>
fn image_query_size<T: fiu32>(texture_cube<T>) -> vec2<u32>
fn image_query_size<T: fiu32>(texture_cube_array<T>) -> vec3<u32>
fn image_query_size<T: fiu32>(texture_multisampled_2d<T>) -> vec2<u32>
fn image_query_size(texture_depth_2d) -> vec2<u32>
fn image_query_size(texture_depth_2d_array) -> vec3<u32>
fn image_query_size(texture_depth_cube) -> vec2<u32>
fn image_query_size(texture_depth_cube_array) -> vec3<u32>
fn image_query_size(texture_depth_multisampled_2d) -> vec2<u32>
fn image_query_size<F: texel_format, A: access>(texture_storage_1d<F, A>) -> u32
fn image_query_size<F: texel_format, A: access>(texture_storage_2d<F, A>) -> vec2<u32>
fn image_query_size<F: texel_format, A: access>(texture_storage_2d_array<F, A>) -> vec3<u32>
fn image_query_size<F: texel_format, A: access>(texture_storage_3d<F, A>) -> vec3<u32>
fn image_query_size_lod<T: fiu32, A: iu32>(texture_1d<T>, A) -> u32
fn image_query_size_lod<T: fiu32, A: iu32>(texture_2d<T>, A) -> vec2<u32>
fn image_query_size_lod<T: fiu32, A: iu32>(texture_2d_array<T>, A) -> vec3<u32>
fn image_query_size_lod<T: fiu32, A: iu32>(texture_3d<T>, A) -> vec3<u32>
fn image_query_size_lod<T: fiu32, A: iu32>(texture_cube<T>, A) -> vec2<u32>
fn image_query_size_lod<T: fiu32, A: iu32>(texture_cube_array<T>, A) -> vec3<u32>
fn image_query_size_lod<A: iu32>(texture_depth_2d, A) -> vec2<u32>
fn image_query_size_lod<A: iu32>(texture_depth_2d_array, A) -> vec3<u32>
fn image_query_size_lod<A: iu32>(texture_depth_cube, A) -> vec2<u32>
fn image_query_size_lod<A: iu32>(texture_depth_cube_array, A) -> vec3<u32>
fn image_read<F: f32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_1d<F, A>, C, S) -> vec4<f32>
fn image_read<F: i32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_1d<F, A>, C, S) -> vec4<i32>
fn image_read<F: u32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_1d<F, A>, C, S) -> vec4<u32>
fn image_read<F: f32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_2d<F, A>, vec2<C>, S) -> vec4<f32>
fn image_read<F: i32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_2d<F, A>, vec2<C>, S) -> vec4<i32>
fn image_read<F: u32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_2d<F, A>, vec2<C>, S) -> vec4<u32>
fn image_read<F: f32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_2d_array<F, A>, vec3<C>, S) -> vec4<f32>
fn image_read<F: i32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_2d_array<F, A>, vec3<C>, S) -> vec4<i32>
fn image_read<F: u32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_2d_array<F, A>, vec3<C>, S) -> vec4<u32>
fn image_read<F: f32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_3d<F, A>, vec3<C>, S) -> vec4<f32>
fn image_read<F: i32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_3d<F, A>, vec3<C>, S) -> vec4<i32>
fn image_read<F: u32_texel_format, A: readable, C: iu32, S: iu32>(texture_storage_3d<F, A>, vec3<C>, S) -> vec4<u32>
fn matrix_times_matrix<T: f32_f16, K: num, C: num, R: num>(mat<K, R, T>, mat<C, K, T>) -> mat<C, R, T>
fn matrix_times_scalar<T: f32_f16, N: num, M: num>(mat<N, M, T>, T) -> mat<N, M, T>
fn matrix_times_vector<T: f32_f16, N: num, M: num>(mat<N, M, T>, vec<N, T>) -> vec<M, T>
fn sampled_image<T: fiu32, S: samplers>(texture_1d<T>, S) -> sampled_image<texture_1d<T> >
fn sampled_image<T: fiu32, S: samplers>(texture_2d<T>, S) -> sampled_image<texture_2d<T> >
fn sampled_image<T: fiu32, S: samplers>(texture_2d_array<T>, S) -> sampled_image<texture_2d_array<T> >
fn sampled_image<T: fiu32, S: samplers>(texture_3d<T>, S) -> sampled_image<texture_3d<T> >
fn sampled_image<T: fiu32, S: samplers>(texture_cube<T>, S) -> sampled_image<texture_cube<T> >
fn sampled_image<T: fiu32, S: samplers>(texture_cube_array<T>, S) -> sampled_image<texture_cube_array<T> >
fn sampled_image<S: samplers>(texture_depth_2d, S) -> sampled_image<texture_depth_2d>
fn sampled_image<S: samplers>(texture_depth_2d_array, S) -> sampled_image<texture_depth_2d_array>
fn sampled_image<S: samplers>(texture_depth_cube, S) -> sampled_image<texture_depth_cube>
fn sampled_image<S: samplers>(texture_depth_cube_array, S) -> sampled_image<texture_depth_cube_array>
fn select<T: scalar>(bool, T, T) -> T
fn select<N: num, T: scalar>(vec<N, bool>, vec<N, T>, vec<N, T>) -> vec<N, T>
fn vector_times_matrix<T: f32_f16, N: num, M: num>(vec<N, T>, mat<M, N, T>) -> vec<M, T>
fn vector_times_scalar<T: f32_f16, N: num>(vec<N, T>, T) -> vec<N, T>