Skip to content

Commit

Permalink
Update dfdutils-included vulkan_core.h. (#783)
Browse files Browse the repository at this point in the history
ASTC HDR and A4B4G4R4_UNORM formats are now core. Update all code and
tests to use the non _EXT names. Make `ktx create --format` accept both
variants of the format name.

Fix mkvkformatfiles to add format aliases to `stringToVkFormat`.

Fix dfdutils scripts to not create duplicate cases for _{EXT,KHR} and
non-_{EXT,KHR} names.

Fix long standing bug in the dfdutils scripts where they were reading as input both
files given on the command line.

Add instructions and a script for regenerating vulkan_core.h from vk.xml.

Do not look for the VulkanSDK for mkvk target as it does not use the SDK's
vulkan_core.h and hasn't for some time.
  • Loading branch information
MarkCallow authored Oct 27, 2023
1 parent 7b6eab5 commit 9c223d9
Show file tree
Hide file tree
Showing 24 changed files with 12,403 additions and 4,603 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ script:
if [ "$CHECK_REUSE" = "YES" -o "$CHECK_REUSE" = "ONLY" ]; then
echo "Calling reuse lint."
set -e # because the if below swallows a bad exit status.
reuse lint
reuse --suppress-deprecation lint
set +e
fi
if [ "$CHECK_REUSE" != "ONLY" ]; then
Expand Down
18 changes: 10 additions & 8 deletions cmake/mkvk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

# Code generation scripts that require a Vulkan SDK installation

set(skip_mkvk_message "-> skipping mkvk target (this is harmless; only needed when re-generating of vulkan headers and dfdutils is required)")
#set(skip_mkvk_message "-> skipping mkvk target (this is harmless; only needed when re-generating of vulkan headers and dfdutils is required)")

if (NOT IOS)
# find_package doesn't find the Vulkan SDK when building for IOS.
# I haven't investigated why.
find_package(Vulkan)
if(NOT Vulkan_FOUND)
message(STATUS "Vulkan SDK not found ${skip_mkvk_message}")
return()
endif()
# Not needed as local custom vulkan_core.h is used. Keeping
# in case we go back to the standard one.
# # find_package doesn't find the Vulkan SDK when building for IOS.
# # I haven't investigated why.
# find_package(Vulkan)
# if(NOT Vulkan_FOUND)
# message(STATUS "Vulkan SDK not found ${skip_mkvk_message}")
# return()
# endif()
else()
# Skip mkvk. We don't need to run it when building for iOS.
return()
Expand Down
16 changes: 16 additions & 0 deletions interface/java_binding/src/main/java/org/khronos/ktx/VkFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ public class VkFormat {
public static final int VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005;
public static final int VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006;
public static final int VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007;
public static final int VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK = 1000066000;
public static final int VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK = 1000066001;
public static final int VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK = 1000066002;
public static final int VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK = 1000066003;
public static final int VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK = 1000066004;
public static final int VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK = 1000066005;
public static final int VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK = 1000066006;
public static final int VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK = 1000066007;
public static final int VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK = 1000066008;
public static final int VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK = 1000066009;
public static final int VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK = 1000066010;
public static final int VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK = 1000066011;
public static final int VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK = 1000066012;
public static final int VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK = 1000066013;
public static final int VK_FORMAT_A4R4G4B4_UNORM_PACK16 = 1000340000;
public static final int VK_FORMAT_A4B4G4R4_UNORM_PACK16 = 1000340001;
public static final int VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = 1000066000;
public static final int VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = 1000066001;
public static final int VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = 1000066002;
Expand Down
18 changes: 14 additions & 4 deletions lib/dfdutils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ targets := testcreatedfd testinterpretdfd testbidirectionalmapping doc

all: $(addprefix out/,${targets})

CFLAGS=-I.

# Note. Currently we use an unreleased version of vulkan_core.h with enums
# for ASTC 3D. Since this is temporary, the sources still use <angled>
# includes. The -I. causes our local copy to be found while the VULKAN_SDK
# part keeps compilers from warning that the file was not found with
# <angled> include.
$(out)/testcreatedfd: createdfd.c createdfdtest.c printdfd.c vk2dfd.c vk2dfd.inl KHR/khr_df.h dfd.h | out
gcc createdfdtest.c createdfd.c printdfd.c -I. $(if VULKAN_SDK,-I${VULKAN_SDK}/include) -o $@ -std=c99 -W -Wall -pedantic -O2 -Wno-strict-aliasing
gcc createdfdtest.c createdfd.c printdfd.c -I. $(if $(VULKAN_SDK),-I$(VULKAN_SDK)/include) -o $@ -std=c99 -W -Wall -pedantic -O2 -Wno-strict-aliasing -Wno-unused-parameter

$(out)/testinterpretdfd: createdfd.c interpretdfd.c interpretdfdtest.c printdfd.c KHR/khr_df.h dfd.h | out
gcc interpretdfd.c createdfd.c interpretdfdtest.c printdfd.c -o $@ -I. $(if VULKAN_SDK,-I${VULKAN_SDK}/include) -O -W -Wall -std=c99 -pedantic
gcc interpretdfd.c createdfd.c interpretdfdtest.c printdfd.c -o $@ -I. $(if $(VULKAN_SDK),-I$(VULKAN_SDK)/include) -O -W -Wall -std=c99 -pedantic -Wno-unused-parameter

$(out)/testbidirectionalmapping: testbidirectionalmapping.c interpretdfd.c createdfd.c dfd2vk.c dfd2vk.inl vk2dfd.c vk2dfd.inl KHR/khr_df.h dfd.h | out
gcc testbidirectionalmapping.c interpretdfd.c createdfd.c -o $@ -I. $(if VULKAN_SDK,-I${VULKAN_SDK}/include) -g -W -Wall -std=c99 -pedantic
gcc testbidirectionalmapping.c interpretdfd.c createdfd.c -o $@ -I. $(if $(VULKAN_SDK),-I$(VULKAN_SDK)/include) -g -W -Wall -std=c99 -pedantic -Wno-unused-parameter

$(out)/doc: colourspaces.c createdfd.c createdfdtest.c printdfd.c queries.c KHR/khr_df.h dfd.h | out
doxygen dfdutils.doxy
Expand All @@ -28,20 +30,28 @@ build out:
mkdir -p $@

clean:
rm -rf $(out)/dfd2vk.o $(out)/vk2dfd.o

clobber: clean
rm -rf $(addprefix out/,${targets})

doc: $(out)/doc

switches: dfd2vk.inl vk2dfd.inl
# Generate the switch bodies and test build the including code.
switches: dfd2vk.inl $(out)/dfd2vk.o vk2dfd.inl $(out)/vk2dfd.o

dfd2vk.inl: vulkan/vulkan_core.h makedfd2vk.pl
./makedfd2vk.pl $< $@

vk2dfd.inl: vulkan/vulkan_core.h makevk2dfd.pl
./makevk2dfd.pl $< $@

$(out)/vk2dfd.o: vk2dfd.c | $(out)
cc -c -o $@ -I . $<

$(out)/dfd2vk.o: dfd2vk.c | $(out)
cc -c -o $@ -I . $<

# For those who wish to generate a project from the gyp file so
# as to use xcode for debugging.
xcodeproj: build/project.pbxproj
Expand Down
2 changes: 1 addition & 1 deletion lib/dfdutils/createdfdtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define TESTRGB565 1

int main()
int main(int argc, char** argv)
{
#ifdef TESTRGBA8888
uint32_t *DFD = createDFDUnpacked(0, 4, 1, 1, s_UNORM);
Expand Down
Loading

0 comments on commit 9c223d9

Please sign in to comment.