mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 00:33:51 +00:00
183 lines
7.7 KiB
Plaintext
183 lines
7.7 KiB
Plaintext
// language: metal1.2
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using metal::uint;
|
|
|
|
|
|
metal::float4 test_textureLoad_1d(
|
|
int coords,
|
|
int level,
|
|
metal::texture1d<float, metal::access::sample> image_1d
|
|
) {
|
|
metal::float4 _e3 = image_1d.read(metal::min(uint(coords), image_1d.get_width() - 1));
|
|
return _e3;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_2d(
|
|
metal::int2 coords_1,
|
|
int level_1,
|
|
metal::texture2d<float, metal::access::sample> image_2d
|
|
) {
|
|
uint clamped_lod_e3 = metal::min(uint(level_1), image_2d.get_num_mip_levels() - 1);
|
|
metal::float4 _e3 = image_2d.read(metal::min(metal::uint2(coords_1), metal::uint2(image_2d.get_width(clamped_lod_e3), image_2d.get_height(clamped_lod_e3)) - 1), clamped_lod_e3);
|
|
return _e3;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_2d_array_u(
|
|
metal::int2 coords_2,
|
|
uint index,
|
|
int level_2,
|
|
metal::texture2d_array<float, metal::access::sample> image_2d_array
|
|
) {
|
|
uint clamped_lod_e4 = metal::min(uint(level_2), image_2d_array.get_num_mip_levels() - 1);
|
|
metal::float4 _e4 = image_2d_array.read(metal::min(metal::uint2(coords_2), metal::uint2(image_2d_array.get_width(clamped_lod_e4), image_2d_array.get_height(clamped_lod_e4)) - 1), metal::min(uint(index), image_2d_array.get_array_size() - 1), clamped_lod_e4);
|
|
return _e4;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_2d_array_s(
|
|
metal::int2 coords_3,
|
|
int index_1,
|
|
int level_3,
|
|
metal::texture2d_array<float, metal::access::sample> image_2d_array
|
|
) {
|
|
uint clamped_lod_e4 = metal::min(uint(level_3), image_2d_array.get_num_mip_levels() - 1);
|
|
metal::float4 _e4 = image_2d_array.read(metal::min(metal::uint2(coords_3), metal::uint2(image_2d_array.get_width(clamped_lod_e4), image_2d_array.get_height(clamped_lod_e4)) - 1), metal::min(uint(index_1), image_2d_array.get_array_size() - 1), clamped_lod_e4);
|
|
return _e4;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_3d(
|
|
metal::int3 coords_4,
|
|
int level_4,
|
|
metal::texture3d<float, metal::access::sample> image_3d
|
|
) {
|
|
uint clamped_lod_e3 = metal::min(uint(level_4), image_3d.get_num_mip_levels() - 1);
|
|
metal::float4 _e3 = image_3d.read(metal::min(metal::uint3(coords_4), metal::uint3(image_3d.get_width(clamped_lod_e3), image_3d.get_height(clamped_lod_e3), image_3d.get_depth(clamped_lod_e3)) - 1), clamped_lod_e3);
|
|
return _e3;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_multisampled_2d(
|
|
metal::int2 coords_5,
|
|
int _sample,
|
|
metal::texture2d_ms<float, metal::access::read> image_multisampled_2d
|
|
) {
|
|
metal::float4 _e3 = image_multisampled_2d.read(metal::min(metal::uint2(coords_5), metal::uint2(image_multisampled_2d.get_width(), image_multisampled_2d.get_height()) - 1), metal::min(uint(_sample), image_multisampled_2d.get_num_samples() - 1));
|
|
return _e3;
|
|
}
|
|
|
|
float test_textureLoad_depth_2d(
|
|
metal::int2 coords_6,
|
|
int level_5,
|
|
metal::depth2d<float, metal::access::sample> image_depth_2d
|
|
) {
|
|
uint clamped_lod_e3 = metal::min(uint(level_5), image_depth_2d.get_num_mip_levels() - 1);
|
|
float _e3 = image_depth_2d.read(metal::min(metal::uint2(coords_6), metal::uint2(image_depth_2d.get_width(clamped_lod_e3), image_depth_2d.get_height(clamped_lod_e3)) - 1), clamped_lod_e3);
|
|
return _e3;
|
|
}
|
|
|
|
float test_textureLoad_depth_2d_array_u(
|
|
metal::int2 coords_7,
|
|
uint index_2,
|
|
int level_6,
|
|
metal::depth2d_array<float, metal::access::sample> image_depth_2d_array
|
|
) {
|
|
uint clamped_lod_e4 = metal::min(uint(level_6), image_depth_2d_array.get_num_mip_levels() - 1);
|
|
float _e4 = image_depth_2d_array.read(metal::min(metal::uint2(coords_7), metal::uint2(image_depth_2d_array.get_width(clamped_lod_e4), image_depth_2d_array.get_height(clamped_lod_e4)) - 1), metal::min(uint(index_2), image_depth_2d_array.get_array_size() - 1), clamped_lod_e4);
|
|
return _e4;
|
|
}
|
|
|
|
float test_textureLoad_depth_2d_array_s(
|
|
metal::int2 coords_8,
|
|
int index_3,
|
|
int level_7,
|
|
metal::depth2d_array<float, metal::access::sample> image_depth_2d_array
|
|
) {
|
|
uint clamped_lod_e4 = metal::min(uint(level_7), image_depth_2d_array.get_num_mip_levels() - 1);
|
|
float _e4 = image_depth_2d_array.read(metal::min(metal::uint2(coords_8), metal::uint2(image_depth_2d_array.get_width(clamped_lod_e4), image_depth_2d_array.get_height(clamped_lod_e4)) - 1), metal::min(uint(index_3), image_depth_2d_array.get_array_size() - 1), clamped_lod_e4);
|
|
return _e4;
|
|
}
|
|
|
|
float test_textureLoad_depth_multisampled_2d(
|
|
metal::int2 coords_9,
|
|
int _sample_1,
|
|
metal::depth2d_ms<float, metal::access::read> image_depth_multisampled_2d
|
|
) {
|
|
float _e3 = image_depth_multisampled_2d.read(metal::min(metal::uint2(coords_9), metal::uint2(image_depth_multisampled_2d.get_width(), image_depth_multisampled_2d.get_height()) - 1), metal::min(uint(_sample_1), image_depth_multisampled_2d.get_num_samples() - 1));
|
|
return _e3;
|
|
}
|
|
|
|
void test_textureStore_1d(
|
|
int coords_10,
|
|
metal::float4 value,
|
|
metal::texture1d<float, metal::access::write> image_storage_1d
|
|
) {
|
|
image_storage_1d.write(value, uint(coords_10));
|
|
return;
|
|
}
|
|
|
|
void test_textureStore_2d(
|
|
metal::int2 coords_11,
|
|
metal::float4 value_1,
|
|
metal::texture2d<float, metal::access::write> image_storage_2d
|
|
) {
|
|
image_storage_2d.write(value_1, metal::uint2(coords_11));
|
|
return;
|
|
}
|
|
|
|
void test_textureStore_2d_array_u(
|
|
metal::int2 coords_12,
|
|
uint array_index,
|
|
metal::float4 value_2,
|
|
metal::texture2d_array<float, metal::access::write> image_storage_2d_array
|
|
) {
|
|
image_storage_2d_array.write(value_2, metal::uint2(coords_12), array_index);
|
|
return;
|
|
}
|
|
|
|
void test_textureStore_2d_array_s(
|
|
metal::int2 coords_13,
|
|
int array_index_1,
|
|
metal::float4 value_3,
|
|
metal::texture2d_array<float, metal::access::write> image_storage_2d_array
|
|
) {
|
|
image_storage_2d_array.write(value_3, metal::uint2(coords_13), array_index_1);
|
|
return;
|
|
}
|
|
|
|
void test_textureStore_3d(
|
|
metal::int3 coords_14,
|
|
metal::float4 value_4,
|
|
metal::texture3d<float, metal::access::write> image_storage_3d
|
|
) {
|
|
image_storage_3d.write(value_4, metal::uint3(coords_14));
|
|
return;
|
|
}
|
|
|
|
struct fragment_shaderOutput {
|
|
metal::float4 member [[color(0)]];
|
|
};
|
|
fragment fragment_shaderOutput fragment_shader(
|
|
metal::texture1d<float, metal::access::sample> image_1d [[user(fake0)]]
|
|
, metal::texture2d<float, metal::access::sample> image_2d [[user(fake0)]]
|
|
, metal::texture2d_array<float, metal::access::sample> image_2d_array [[user(fake0)]]
|
|
, metal::texture3d<float, metal::access::sample> image_3d [[user(fake0)]]
|
|
, metal::texture2d_ms<float, metal::access::read> image_multisampled_2d [[user(fake0)]]
|
|
, metal::texture1d<float, metal::access::write> image_storage_1d [[user(fake0)]]
|
|
, metal::texture2d<float, metal::access::write> image_storage_2d [[user(fake0)]]
|
|
, metal::texture2d_array<float, metal::access::write> image_storage_2d_array [[user(fake0)]]
|
|
, metal::texture3d<float, metal::access::write> image_storage_3d [[user(fake0)]]
|
|
) {
|
|
metal::float4 _e2 = test_textureLoad_1d(0, 0, image_1d);
|
|
metal::float4 _e5 = test_textureLoad_2d(metal::int2 {}, 0, image_2d);
|
|
metal::float4 _e9 = test_textureLoad_2d_array_u(metal::int2 {}, 0u, 0, image_2d_array);
|
|
metal::float4 _e13 = test_textureLoad_2d_array_s(metal::int2 {}, 0, 0, image_2d_array);
|
|
metal::float4 _e16 = test_textureLoad_3d(metal::int3 {}, 0, image_3d);
|
|
metal::float4 _e19 = test_textureLoad_multisampled_2d(metal::int2 {}, 0, image_multisampled_2d);
|
|
test_textureStore_1d(0, metal::float4 {}, image_storage_1d);
|
|
test_textureStore_2d(metal::int2 {}, metal::float4 {}, image_storage_2d);
|
|
test_textureStore_2d_array_u(metal::int2 {}, 0u, metal::float4 {}, image_storage_2d_array);
|
|
test_textureStore_2d_array_s(metal::int2 {}, 0, metal::float4 {}, image_storage_2d_array);
|
|
test_textureStore_3d(metal::int3 {}, metal::float4 {}, image_storage_3d);
|
|
return fragment_shaderOutput { metal::float4(0.0, 0.0, 0.0, 0.0) };
|
|
}
|