Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
layers:Remove includes of vk_safe_struct.cpp
Browse files Browse the repository at this point in the history
After looking at these includes of vk_safe_struct.cpp I believe it was
just a hack that worked and has persisted in the code. This change
pulls the source into the layers that depend on it at build time and is
a better solution, in my opinion.

The one quirk is that the we now generate vk_struct.cpp in the base dir
and in the layers dir. Since the file is required by some layer shared
libs I had to generate in the layers dir, but there are also some
dependencies on the file in the top-level dir that I didn't care to
investigate further so I just genrate it in two places.
I'm sure this could be cleaned up if someone with more cmake knowledge
and/or patience than me cares to look into it further.

For the android build updated the codegen to put vk_safe_struct.cpp in
source dir so it could be added to libs from there.
  • Loading branch information
tobine committed Jun 13, 2017
1 parent 4d285de commit 0e0b433
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build-android/android-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd $dir

rm -rf generated
mkdir -p generated/include generated/common
mkdir -p generated/include generated/common generated/source

( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.h )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.cpp )
( cd generated/source; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.cpp )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_struct_size_helper.h )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_struct_size_helper.c )
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_enum_string_helper.h )
Expand Down
4 changes: 4 additions & 0 deletions build-android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ LOCAL_SRC_FILES += $(SRC_DIR)/layers/descriptor_sets.cpp
LOCAL_SRC_FILES += $(SRC_DIR)/layers/buffer_validation.cpp
LOCAL_SRC_FILES += $(SRC_DIR)/layers/shader_validation.cpp
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
LOCAL_SRC_FILES += $(LAYER_DIR)/source/vk_safe_struct.cpp
LOCAL_C_INCLUDES += $(SRC_DIR)/include \
$(SRC_DIR)/layers \
$(LAYER_DIR)/source \
$(LAYER_DIR)/include \
$(SRC_DIR)/loader \
$(ANDROID_DIR)/external/glslang \
Expand Down Expand Up @@ -100,9 +102,11 @@ include $(CLEAR_VARS)
LOCAL_MODULE := VkLayer_unique_objects
LOCAL_SRC_FILES += $(SRC_DIR)/layers/unique_objects.cpp
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
LOCAL_SRC_FILES += $(LAYER_DIR)/source/vk_safe_struct.cpp
LOCAL_C_INCLUDES += $(SRC_DIR)/include \
$(SRC_DIR)/layers \
$(LAYER_DIR)/include \
$(LAYER_DIR)/source \
$(SRC_DIR)/loader
LOCAL_STATIC_LIBRARIES += layer_utils
LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden
Expand Down
6 changes: 4 additions & 2 deletions layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ run_vk_xml_generate(parameter_validation_generator.py parameter_validation.h)
run_vk_xml_generate(unique_objects_generator.py unique_objects_wrappers.h)
run_vk_xml_generate(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)

run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp)

# Layer Utils Library
# For Windows, we use a static lib because the Windows loader has a fairly restrictive loader search
# path that can't be easily modified to point it to the same directory that contains the layers.
Expand All @@ -173,11 +175,11 @@ else()
endif()
add_dependencies(VkLayer_utils generate_helper_files)

add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp descriptor_sets.cpp buffer_validation.cpp shader_validation.cpp)
add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp descriptor_sets.cpp buffer_validation.cpp shader_validation.cpp vk_safe_struct.cpp)
add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp)
# generated
add_vk_layer(threading threading.cpp thread_check.h vk_layer_table.cpp)
add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp)
add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp vk_safe_struct.cpp)
add_vk_layer(parameter_validation parameter_validation.cpp parameter_validation.h vk_layer_table.cpp)

# Core validation has additional dependencies
Expand Down
3 changes: 0 additions & 3 deletions layers/core_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ std::string to_string(T var) {
}
#endif

// This intentionally includes a cpp file
#include "vk_safe_struct.cpp"

namespace core_validation {

using std::unordered_map;
Expand Down
3 changes: 0 additions & 3 deletions layers/unique_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
#include "vk_object_types.h"
#include "vulkan/vk_layer.h"

// This intentionally includes a cpp file
#include "vk_safe_struct.cpp"

#include "unique_objects_wrappers.h"

namespace unique_objects {
Expand Down

0 comments on commit 0e0b433

Please sign in to comment.