2021-11-16 15:15:36 +00:00
|
|
|
#version 310 es
|
|
|
|
|
2022-11-02 02:25:38 +00:00
|
|
|
struct Params {
|
2021-11-16 15:15:36 +00:00
|
|
|
uint filterDim;
|
|
|
|
uint blockDim;
|
2022-09-13 19:48:51 +00:00
|
|
|
uint pad;
|
|
|
|
uint pad_1;
|
2022-11-02 02:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
layout(binding = 1, std140) uniform params_block_ubo {
|
|
|
|
Params inner;
|
2021-11-16 15:15:36 +00:00
|
|
|
} params;
|
|
|
|
|
GLSL: fix textureLoad() and textureStore(), depth textures, and more.
The CombineSamplers transform was incorrectly flagging StorageTexture
(which in GLSL ends up as image2D) as needing to be combined with a
sampler, or at least renamed. This is incorrect: StorageTexture never
has an associated sampler, so don't try to pair it up and just output
it as image* in GLSL.
In GLSL, textureLoad (aka texelFetch) of depth textures is not allowed.
The fix is to bind the depth texture as the corresponding f32 texture
instead (e.g., texture_depth_2d -> texture_2d<f32>,
texture_depth_cube -> texture_cube<f32>, etc). This requires changing
both the uniform globals and function parameter types. We're now going
to receive a vec4 instead of a float from texelFetch, so add a ".x"
member accessor to retrieve the first component. (Note that we don't
do this inside a CallStatement since this gives the CloneContext
indigestion, and CallStatement is going to ignore the result of the
call anyway.)
We were failing to find the dummy samplers that Dawn creates for the
calls that actually do require a dummy sampler, since the old Inspector
implementation of GetSamplerTextureUses() does not find them. The fix
is to implement a new Inspector call to return the texture/sampler
pairs the Resolver found during resolution. This will include the
dummy sampler as a null variable pointer.
In order to identify the placeholder sampler, we pass in a BindingPair
to represent it. When we discover a null sampler in the variable pair,
we return the passed-in placeholder binding point to the caller (Dawn).
(Dawn will use a group of kMaxBindGroups, to ensure that it never
collides with an existing sampler.)
Bug: tint:1298
Change-Id: I82e142c2b4318608c27a9fa9521c27f15a6214cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78820
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-02-03 22:39:13 +00:00
|
|
|
layout(rgba8) uniform highp writeonly image2D outputTex;
|
2022-11-02 02:25:38 +00:00
|
|
|
struct Flip {
|
2021-11-16 15:15:36 +00:00
|
|
|
uint value;
|
2022-09-13 19:48:51 +00:00
|
|
|
uint pad_2;
|
|
|
|
uint pad_3;
|
|
|
|
uint pad_4;
|
2022-11-02 02:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
layout(binding = 3, std140) uniform flip_block_ubo {
|
|
|
|
Flip inner;
|
2021-11-16 15:15:36 +00:00
|
|
|
} flip;
|
|
|
|
|
2022-01-26 16:48:55 +00:00
|
|
|
shared vec3 tile[4][256];
|
2022-11-21 17:11:05 +00:00
|
|
|
uint tint_div(uint lhs, uint rhs) {
|
|
|
|
return (lhs / ((rhs == 0u) ? 1u : rhs));
|
|
|
|
}
|
|
|
|
|
2022-01-24 17:17:22 +00:00
|
|
|
uniform highp sampler2D inputTex_1;
|
|
|
|
uniform highp sampler2D inputTex_samp;
|
|
|
|
|
2022-01-28 22:36:58 +00:00
|
|
|
void tint_symbol(uvec3 WorkGroupID, uvec3 LocalInvocationID, uint local_invocation_index) {
|
2021-11-16 15:15:36 +00:00
|
|
|
{
|
|
|
|
for(uint idx = local_invocation_index; (idx < 1024u); idx = (idx + 64u)) {
|
|
|
|
uint i_1 = (idx / 256u);
|
|
|
|
uint i_2 = (idx % 256u);
|
2022-06-01 01:11:59 +00:00
|
|
|
tile[i_1][i_2] = vec3(0.0f);
|
2021-11-16 15:15:36 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-05 00:15:34 +00:00
|
|
|
barrier();
|
2022-11-09 22:04:11 +00:00
|
|
|
uint filterOffset = tint_div((params.inner.filterDim - 1u), 2u);
|
2022-10-26 18:36:44 +00:00
|
|
|
uvec2 dims = uvec2(textureSize(inputTex_1, 0));
|
2022-11-02 02:25:38 +00:00
|
|
|
uvec2 baseIndex = (((WorkGroupID.xy * uvec2(params.inner.blockDim, 4u)) + (LocalInvocationID.xy * uvec2(4u, 1u))) - uvec2(filterOffset, 0u));
|
2021-11-16 15:15:36 +00:00
|
|
|
{
|
|
|
|
for(uint r = 0u; (r < 4u); r = (r + 1u)) {
|
|
|
|
{
|
|
|
|
for(uint c = 0u; (c < 4u); c = (c + 1u)) {
|
2022-10-26 18:36:44 +00:00
|
|
|
uvec2 loadIndex = (baseIndex + uvec2(c, r));
|
2022-11-02 02:25:38 +00:00
|
|
|
if ((flip.inner.value != 0u)) {
|
2021-11-16 15:15:36 +00:00
|
|
|
loadIndex = loadIndex.yx;
|
|
|
|
}
|
2022-06-01 01:11:59 +00:00
|
|
|
tile[r][((4u * LocalInvocationID.x) + c)] = textureLod(inputTex_samp, ((vec2(loadIndex) + vec2(0.25f)) / vec2(dims)), 0.0f).rgb;
|
2021-11-16 15:15:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-05 00:15:34 +00:00
|
|
|
barrier();
|
2021-11-16 15:15:36 +00:00
|
|
|
{
|
|
|
|
for(uint r = 0u; (r < 4u); r = (r + 1u)) {
|
|
|
|
{
|
|
|
|
for(uint c = 0u; (c < 4u); c = (c + 1u)) {
|
2022-10-26 18:36:44 +00:00
|
|
|
uvec2 writeIndex = (baseIndex + uvec2(c, r));
|
2022-11-02 02:25:38 +00:00
|
|
|
if ((flip.inner.value != 0u)) {
|
2021-11-16 15:15:36 +00:00
|
|
|
writeIndex = writeIndex.yx;
|
|
|
|
}
|
|
|
|
uint center = ((4u * LocalInvocationID.x) + c);
|
|
|
|
bool tint_tmp_1 = (center >= filterOffset);
|
|
|
|
if (tint_tmp_1) {
|
|
|
|
tint_tmp_1 = (center < (256u - filterOffset));
|
|
|
|
}
|
|
|
|
bool tint_tmp = (tint_tmp_1);
|
|
|
|
if (tint_tmp) {
|
2021-11-16 16:16:56 +00:00
|
|
|
tint_tmp = all(lessThan(writeIndex, dims));
|
2021-11-16 15:15:36 +00:00
|
|
|
}
|
|
|
|
if ((tint_tmp)) {
|
2022-06-01 01:11:59 +00:00
|
|
|
vec3 acc = vec3(0.0f);
|
2021-11-16 15:15:36 +00:00
|
|
|
{
|
2022-11-02 02:25:38 +00:00
|
|
|
for(uint f = 0u; (f < params.inner.filterDim); f = (f + 1u)) {
|
2021-11-16 15:15:36 +00:00
|
|
|
uint i = ((center + f) - filterOffset);
|
2022-11-02 02:25:38 +00:00
|
|
|
acc = (acc + ((1.0f / float(params.inner.filterDim)) * tile[r][i]));
|
2021-11-16 15:15:36 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-26 18:36:44 +00:00
|
|
|
imageStore(outputTex, ivec2(writeIndex), vec4(acc, 1.0f));
|
2021-11-16 15:15:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
void main() {
|
2022-01-28 22:36:58 +00:00
|
|
|
tint_symbol(gl_WorkGroupID, gl_LocalInvocationID, gl_LocalInvocationIndex);
|
|
|
|
return;
|
2021-11-16 15:15:36 +00:00
|
|
|
}
|