You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
// 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.
|
|
|
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
layout(push_constant) uniform ImageFormatBlock {
|
|
uint compFormat;
|
|
uint baseLayer;
|
|
}
|
|
u_pushConstant;
|
|
|
|
layout(binding = 0, rgba16ui) readonly uniform uimage${type} u_image0;
|
|
layout(binding = 1, rgba8ui) writeonly uniform uimage${type} u_image1;
|
|
|
|
void main(void) {
|
|
ivec3 pos = ivec3(gl_GlobalInvocationID.xyz);
|
|
pos.z += int(u_pushConstant.baseLayer);
|
|
ivec4 srcBlock = ivec4(imageLoad(u_image0, getPos${type}(pos)));
|
|
|
|
bool isPunchthroughAlpha =
|
|
(u_pushConstant.compFormat == VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK ||
|
|
u_pushConstant.compFormat == VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK);
|
|
|
|
ivec4[16] decompressed = etc2_decode_rgb_block(
|
|
constructUint32(srcBlock[0], srcBlock[1]),
|
|
constructUint32(srcBlock[2], srcBlock[3]), isPunchthroughAlpha);
|
|
|
|
for (int y = 0; y < BLOCK_Y_SIZE_${type}; y++) {
|
|
for (int x = 0; x < 4; x++) {
|
|
imageStore(u_image1,
|
|
getPos${type}(ivec3(pos.xy * 4 + ivec2(x, y), pos.z)),
|
|
decompressed[y * 4 + x]);
|
|
}
|
|
}
|
|
}
|