1// Copyright 2019 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#version 450 16#include "Etc2ShaderLib.comp" 17 18layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; 19 20layout(push_constant) uniform ImageFormatBlock { 21 uint compFormat; 22 uint baseLayer; 23} 24u_pushConstant; 25 26layout(binding = 0, rgba32ui) readonly uniform WITH_TYPE(uimage) u_image0; 27layout(binding = 1, rgba8ui) writeonly uniform WITH_TYPE(uimage) u_image1; 28 29void main(void) { 30 ivec3 pos = ivec3(gl_GlobalInvocationID.xyz); 31 pos.z += int(u_pushConstant.baseLayer); 32 uvec4 srcBlock = uvec4(imageLoad(u_image0, WITH_TYPE(getPos)(pos))); 33 34 uint[16] decompressedAlpha = 35 eac_decode_single_channel_block(flip32(srcBlock[0]), flip32(srcBlock[1]), false); 36 37 ivec4[16] decompressed = 38 etc2_decode_rgb_block(int(flip32(srcBlock[2])), int(flip32(srcBlock[3])), false); 39 40 for (int y = 0; y < WITH_TYPE(BLOCK_Y_SIZE_); y++) { 41 for (int x = 0; x < 4; x++) { 42 imageStore(u_image1, WITH_TYPE(getPos)(ivec3(pos.xy * 4 + ivec2(x, y), pos.z)), 43 ivec4(decompressed[y * 4 + x].rgb, decompressedAlpha[y * 4 + x])); 44 } 45 } 46} 47