aboutsummaryrefslogtreecommitdiff
path: root/src/gfxstream/host/vulkan/emulated_textures/shaders/EacRG11Snorm.comp
blob: bd516c110a93ccb4c0e6f18cee65e8bd0a2e28f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2019 The Android Open Source Project
//
// 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.

#version 450
#include "Etc2ShaderLib.comp"

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout(push_constant) uniform ImageFormatBlock {
    uint compFormat;
    uint baseLayer;
}
u_pushConstant;

layout(binding = 0, rgba32ui) readonly uniform WITH_TYPE(uimage) u_image0;
layout(binding = 1, rg16_snorm) writeonly uniform WITH_TYPE(image) u_image1;

void main(void) {
    ivec3 pos = ivec3(gl_GlobalInvocationID.xyz);
    pos.z += int(u_pushConstant.baseLayer);
    uvec4 srcBlock = imageLoad(u_image0, WITH_TYPE(getPos)(pos));

    float[16] decompressedR =
        eac_decode_single_channel_block_float(flip32(srcBlock[0]), flip32(srcBlock[1]), true);
    float[16] decompressedG =
        eac_decode_single_channel_block_float(flip32(srcBlock[2]), flip32(srcBlock[3]), true);

    for (int y = 0; y < WITH_TYPE(BLOCK_Y_SIZE_); y++) {
        for (int x = 0; x < 4; x++) {
            imageStore(u_image1, WITH_TYPE(getPos)(ivec3(pos.xy * 4 + ivec2(x, y), pos.z)),
                       vec4(decompressedR[y * 4 + x], decompressedG[y * 4 + x], 0, 1));
        }
    }
}