dawn-cmake/test/benchmark/bloom-vertical-blur.wgsl.expected.msl
Ben Clayton 73ced33dfb test/benchmark: Add more shaders to the corpus
Kindly donated by Brandon Jones and Austin Eng.
Tint has been used to convert all the deprecated attributes to the new style. In doing so, comments have been stripped. These are not massively important for the benchmarking.

Bindings have also been adjusted to be sequential and unique so that the MSL backend doesn't have to deal with binding remapping.

Existing benchmark files that used an underscore '_' have been renamed to use a dash '-' instead, to match the new files.

Change-Id: If5fb507b981f107ed570f6eedb55b232448f67aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77443
Reviewed-by: Brandon Jones <bajones@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-01-21 22:38:16 +00:00

49 lines
2.6 KiB
Plaintext

#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
float arr[3];
};
struct BloomUniforms {
/* 0x0000 */ float radius;
/* 0x0004 */ float dim;
};
struct FragmentInput {
float2 texCoord;
};
struct tint_symbol_1 {
float2 texCoord [[user(locn0)]];
};
struct tint_symbol_2 {
float4 value [[color(0)]];
};
constant float2 bloomDir = float2(0.0f, 1.0f);
float4 getGaussianBlur(float2 texCoord, const constant BloomUniforms* const tint_symbol_4, texture2d<float, access::sample> tint_symbol_5, sampler tint_symbol_6, thread tint_array_wrapper* const tint_symbol_7) {
float2 const texelRadius = (float2((*(tint_symbol_4)).radius) / float2(int2(tint_symbol_5.get_width(), tint_symbol_5.get_height())));
float2 const step = (bloomDir * texelRadius);
float4 sum = float4(0.0f);
sum = (sum + (tint_symbol_5.sample(tint_symbol_6, texCoord) * (*(tint_symbol_7)).arr[0]));
sum = (sum + (tint_symbol_5.sample(tint_symbol_6, (texCoord + (step * 1.0f))) * (*(tint_symbol_7)).arr[1]));
sum = (sum + (tint_symbol_5.sample(tint_symbol_6, (texCoord - (step * 1.0f))) * (*(tint_symbol_7)).arr[1]));
sum = (sum + (tint_symbol_5.sample(tint_symbol_6, (texCoord + (step * 2.0f))) * (*(tint_symbol_7)).arr[2]));
sum = (sum + (tint_symbol_5.sample(tint_symbol_6, (texCoord - (step * 2.0f))) * (*(tint_symbol_7)).arr[2]));
return float4(float4(sum).rgb, 1.0f);
}
float4 fragmentMain_inner(FragmentInput input, const constant BloomUniforms* const tint_symbol_8, texture2d<float, access::sample> tint_symbol_9, sampler tint_symbol_10, thread tint_array_wrapper* const tint_symbol_11, texture2d<float, access::sample> tint_symbol_12) {
float4 const blurColor = getGaussianBlur(input.texCoord, tint_symbol_8, tint_symbol_9, tint_symbol_10, tint_symbol_11);
float4 const dimColor = (tint_symbol_12.sample(tint_symbol_10, input.texCoord) * (*(tint_symbol_8)).dim);
return (blurColor + dimColor);
}
fragment tint_symbol_2 fragmentMain(const constant BloomUniforms* tint_symbol_13 [[buffer(0)]], texture2d<float, access::sample> tint_symbol_14 [[texture(0)]], sampler tint_symbol_15 [[sampler(0)]], texture2d<float, access::sample> tint_symbol_17 [[texture(1)]], tint_symbol_1 tint_symbol [[stage_in]]) {
thread tint_array_wrapper tint_symbol_16 = {.arr={0.227027029f, 0.31621623f, 0.07027027f}};
FragmentInput const tint_symbol_3 = {.texCoord=tint_symbol.texCoord};
float4 const inner_result = fragmentMain_inner(tint_symbol_3, tint_symbol_13, tint_symbol_14, tint_symbol_15, &(tint_symbol_16), tint_symbol_17);
tint_symbol_2 wrapper_result = {};
wrapper_result.value = inner_result;
return wrapper_result;
}