mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 08:44:08 +00:00
192 lines
8.7 KiB
Plaintext
192 lines
8.7 KiB
Plaintext
// language: metal1.2
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using metal::uint;
|
|
struct DefaultConstructible {
|
|
template<typename T>
|
|
operator T() && {
|
|
return T {};
|
|
}
|
|
};
|
|
|
|
|
|
metal::float4 test_textureLoad_1d(
|
|
int coords,
|
|
int level,
|
|
metal::texture1d<float, metal::access::sample> image_1d
|
|
) {
|
|
metal::float4 _e3 = (uint(level) < image_1d.get_num_mip_levels() && uint(coords) < image_1d.get_width() ? image_1d.read(uint(coords)): DefaultConstructible());
|
|
return _e3;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_2d(
|
|
metal::int2 coords_1,
|
|
int level_1,
|
|
metal::texture2d<float, metal::access::sample> image_2d
|
|
) {
|
|
metal::float4 _e3 = (uint(level_1) < image_2d.get_num_mip_levels() && metal::all(metal::uint2(coords_1) < metal::uint2(image_2d.get_width(level_1), image_2d.get_height(level_1))) ? image_2d.read(metal::uint2(coords_1), level_1): DefaultConstructible());
|
|
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
|
|
) {
|
|
metal::float4 _e4 = (uint(level_2) < image_2d_array.get_num_mip_levels() && uint(index) < image_2d_array.get_array_size() && metal::all(metal::uint2(coords_2) < metal::uint2(image_2d_array.get_width(level_2), image_2d_array.get_height(level_2))) ? image_2d_array.read(metal::uint2(coords_2), index, level_2): DefaultConstructible());
|
|
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
|
|
) {
|
|
metal::float4 _e4 = (uint(level_3) < image_2d_array.get_num_mip_levels() && uint(index_1) < image_2d_array.get_array_size() && metal::all(metal::uint2(coords_3) < metal::uint2(image_2d_array.get_width(level_3), image_2d_array.get_height(level_3))) ? image_2d_array.read(metal::uint2(coords_3), index_1, level_3): DefaultConstructible());
|
|
return _e4;
|
|
}
|
|
|
|
metal::float4 test_textureLoad_3d(
|
|
metal::int3 coords_4,
|
|
int level_4,
|
|
metal::texture3d<float, metal::access::sample> image_3d
|
|
) {
|
|
metal::float4 _e3 = (uint(level_4) < image_3d.get_num_mip_levels() && metal::all(metal::uint3(coords_4) < metal::uint3(image_3d.get_width(level_4), image_3d.get_height(level_4), image_3d.get_depth(level_4))) ? image_3d.read(metal::uint3(coords_4), level_4): DefaultConstructible());
|
|
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 = (uint(_sample) < image_multisampled_2d.get_num_samples() && metal::all(metal::uint2(coords_5) < metal::uint2(image_multisampled_2d.get_width(), image_multisampled_2d.get_height())) ? image_multisampled_2d.read(metal::uint2(coords_5), _sample): DefaultConstructible());
|
|
return _e3;
|
|
}
|
|
|
|
float test_textureLoad_depth_2d(
|
|
metal::int2 coords_6,
|
|
int level_5,
|
|
metal::depth2d<float, metal::access::sample> image_depth_2d
|
|
) {
|
|
float _e3 = (uint(level_5) < image_depth_2d.get_num_mip_levels() && metal::all(metal::uint2(coords_6) < metal::uint2(image_depth_2d.get_width(level_5), image_depth_2d.get_height(level_5))) ? image_depth_2d.read(metal::uint2(coords_6), level_5): DefaultConstructible());
|
|
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
|
|
) {
|
|
float _e4 = (uint(level_6) < image_depth_2d_array.get_num_mip_levels() && uint(index_2) < image_depth_2d_array.get_array_size() && metal::all(metal::uint2(coords_7) < metal::uint2(image_depth_2d_array.get_width(level_6), image_depth_2d_array.get_height(level_6))) ? image_depth_2d_array.read(metal::uint2(coords_7), index_2, level_6): DefaultConstructible());
|
|
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
|
|
) {
|
|
float _e4 = (uint(level_7) < image_depth_2d_array.get_num_mip_levels() && uint(index_3) < image_depth_2d_array.get_array_size() && metal::all(metal::uint2(coords_8) < metal::uint2(image_depth_2d_array.get_width(level_7), image_depth_2d_array.get_height(level_7))) ? image_depth_2d_array.read(metal::uint2(coords_8), index_3, level_7): DefaultConstructible());
|
|
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 = (uint(_sample_1) < image_depth_multisampled_2d.get_num_samples() && metal::all(metal::uint2(coords_9) < metal::uint2(image_depth_multisampled_2d.get_width(), image_depth_multisampled_2d.get_height())) ? image_depth_multisampled_2d.read(metal::uint2(coords_9), _sample_1): DefaultConstructible());
|
|
return _e3;
|
|
}
|
|
|
|
void test_textureStore_1d(
|
|
int coords_10,
|
|
metal::float4 value,
|
|
metal::texture1d<float, metal::access::write> image_storage_1d
|
|
) {
|
|
if (uint(coords_10) < image_storage_1d.get_width()) {
|
|
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
|
|
) {
|
|
if (metal::all(metal::uint2(coords_11) < metal::uint2(image_storage_2d.get_width(), image_storage_2d.get_height()))) {
|
|
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
|
|
) {
|
|
if (uint(array_index) < image_storage_2d_array.get_array_size() && metal::all(metal::uint2(coords_12) < metal::uint2(image_storage_2d_array.get_width(), image_storage_2d_array.get_height()))) {
|
|
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
|
|
) {
|
|
if (uint(array_index_1) < image_storage_2d_array.get_array_size() && metal::all(metal::uint2(coords_13) < metal::uint2(image_storage_2d_array.get_width(), image_storage_2d_array.get_height()))) {
|
|
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
|
|
) {
|
|
if (metal::all(metal::uint3(coords_14) < metal::uint3(image_storage_3d.get_width(), image_storage_3d.get_height(), image_storage_3d.get_depth()))) {
|
|
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) };
|
|
}
|