From b56a50064caf2a590ba43699e0074690fcd431bf Mon Sep 17 00:00:00 2001 From: Jeff McGlynn Date: Wed, 20 Jun 2018 11:34:20 -0700 Subject: Initial version of astc-codec for open source release Contains an implementation of an ASTC decoder that is able to pass the dEQP ASTC LDR tests. astc-codec has no external dependencies for the main library, only for test code, and is licensed under the Apache license. Components: include/ - Public API that can decode ASTC LDR data into a RGBA UNORM8 buffer. src/base/ - Base library with common functionality not directly related to ASTC decoding. Contains a uint128 implementation, BitStream for reading/writing bits with a primitive (or uint128 type), Optional implementation (to not take a dependency on C++17), and more. src/decoder/ - Internal implementation of the ASTC decoder. src/base/test/, src/decoder/test/ - Unit tests (and a fuzzing test) for the astc decoder. src/decoder/testdata/ - Sample ASTC images and golden image results for testing. src/decoder/tools/ - A tool to inspect contents of an ASTC file. third_party/ - Third party libraries, only used for tests. Change-Id: Ia98e5a7dc847daa3d3a48c5e62d94b8fb1cb98bd --- src/decoder/BUILD.bazel | 238 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 src/decoder/BUILD.bazel (limited to 'src/decoder/BUILD.bazel') diff --git a/src/decoder/BUILD.bazel b/src/decoder/BUILD.bazel new file mode 100644 index 0000000..f2fded5 --- /dev/null +++ b/src/decoder/BUILD.bazel @@ -0,0 +1,238 @@ +# Copyright 2018 Google LLC +# +# 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 +# +# https://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. + +cc_library( + name = "footprint", + srcs = ["footprint.cc"], + hdrs = ["footprint.h"], + deps = [ + "//:api", + "//src/base", + ], +) + +cc_library( + name = "astc_utils", + srcs = [ + "astc_file.cc", + "endpoint_codec.cc", + "integer_sequence_codec.cc", + "intermediate_astc_block.cc", + "logical_astc_block.cc", + "partition.cc", + "physical_astc_block.cc", + "quantization.cc", + "weight_infill.cc", + ], + hdrs = [ + "astc_file.h", + "endpoint_codec.h", + "integer_sequence_codec.h", + "intermediate_astc_block.h", + "logical_astc_block.h", + "partition.h", + "physical_astc_block.h", + "quantization.h", + "types.h", + "weight_infill.h", + ], + deps = [ + ":footprint", + "//src/base", + ], +) + +cc_library( + name = "codec", + srcs = ["codec.cc"], + hdrs = ["codec.h"], + deps = [ + ":astc_utils", + ":footprint", + "//src/base", + ], + visibility = ["//:__pkg__"], +) + +cc_binary( + name = "astc_inspector_cli", + srcs = ["tools/astc_inspector_cli.cc"], + deps = [ + ":astc_utils", + "//src/base", + ], +) + +################################################################################ +## +## Testing +## +################################################################################ + +cc_library( + name = "test", + hdrs = ["test/image_utils.h"], + deps = [ + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "physical_astc_block_test", + size = "small", + srcs = ["test/physical_astc_block_test.cc"], + deps = [ + ":astc_utils", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "partition_test", + size = "small", + srcs = ["test/partition_test.cc"], + deps = [ + ":astc_utils", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "integer_sequence_codec_test", + size = "small", + srcs = ["test/integer_sequence_codec_test.cc"], + deps = [ + ":astc_utils", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "intermediate_astc_block_test", + size = "small", + srcs = ["test/intermediate_astc_block_test.cc"], + data = glob([ + "testdata/checkered_*.astc", + ]), + deps = [ + ":astc_utils", + ":test", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "quantization_test", + size = "medium", + srcs = ["test/quantization_test.cc"], + deps = [ + ":astc_utils", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "weight_infill_test", + size = "small", + srcs = ["test/weight_infill_test.cc"], + deps = [ + ":astc_utils", + ":footprint", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "endpoint_codec_test", + size = "small", + srcs = ["test/endpoint_codec_test.cc"], + data = [ + ":testdata/checkerboard.astc", + ], + deps = [ + ":astc_utils", + ":test", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "logical_astc_block_test", + size = "large", + srcs = ["test/logical_astc_block_test.cc"], + data = glob([ + "testdata/atlas_small_*.astc", + "testdata/atlas_small_*.bmp", + "testdata/footprint_*.astc", + "testdata/footprint_*.bmp", + "testdata/rgb_*.astc", + "testdata/rgb_*.bmp", + ]), + deps = [ + ":test", + ":astc_utils", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "codec_test", + size = "large", + srcs = ["test/codec_test.cc"], + data = glob([ + "testdata/atlas_small_*.astc", + "testdata/atlas_small_*.bmp", + ]), + deps = [ + ":test", + ":codec", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "footprint_test", + size = "small", + srcs = ["test/footprint_test.cc"], + deps = [ + ":footprint", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "astc_fuzzer", + srcs = ["test/astc_fuzzer.cc"], + copts = select({ + # Clang-only flags. TODO: Find a better way to detect GCC/clang. + "@bazel_tools//src/conditions:darwin_x86_64": [ + "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp", + "-fsanitize-coverage=bb", + ], + "@bazel_tools//src/conditions:darwin": [ + "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp", + "-fsanitize-coverage=bb", + ], + # GCC-only flags. + "//conditions:default": [ + "-finstrument-functions" + ], + }), + deps = [ + ":codec", + "@honggfuzz//:honggfuzz", + "@benchmark//:benchmark", + ], + linkstatic = 1, +) -- cgit v1.2.3