Skip to content

Commit

Permalink
Update dfdutils-included vulkan_core.h. (KhronosGroup#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 33f4eed commit e2f0a87
Show file tree
Hide file tree
Showing 17 changed files with 12,323 additions and 4,539 deletions.
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
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 e2f0a87

Please sign in to comment.