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
common dir so it could be added to libs from there.
  • Loading branch information
tobine committed Dec 15, 2017
1 parent 2f3e44a commit 59490a2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion build-android/android-generate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ if exist generated (
)
mkdir generated\include generated\common

cd generated/common
py -3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.cpp
cd generated/include
py -3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.h
py -3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.cpp
py -3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_struct_size_helper.h
py -3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_struct_size_helper.c
py -3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_enum_string_helper.h
Expand Down
2 changes: 1 addition & 1 deletion build-android/android-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rm -rf generated
mkdir -p generated/include generated/common

( 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/common; 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
2 changes: 2 additions & 0 deletions build-android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ 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)/common/vk_safe_struct.cpp
LOCAL_SRC_FILES += $(SRC_DIR)/layers/xxhash.c
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SRC_DIR)/include \
$(LOCAL_PATH)/$(SRC_DIR)/layers \
Expand Down Expand Up @@ -105,6 +106,7 @@ 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)/common/vk_safe_struct.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SRC_DIR)/include \
$(LOCAL_PATH)/$(SRC_DIR)/layers \
$(LOCAL_PATH)/$(LAYER_DIR)/include \
Expand Down
6 changes: 4 additions & 2 deletions layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ 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(object_tracker_generator.py object_tracker.cpp)

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 @@ -207,11 +209,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 xxhash.c)
add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp descriptor_sets.cpp buffer_validation.cpp shader_validation.cpp xxhash.c vk_safe_struct.cpp)
add_vk_layer(object_tracker object_tracker.cpp object_tracker_utils.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_utils.cpp parameter_validation.h vk_layer_table.cpp vk_validation_error_messages.h)

# 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 @@ -94,9 +94,6 @@ std::string to_string(T var) {
}
#endif

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

using mutex_t = std::mutex;
using lock_guard_t = std::lock_guard<mutex_t>;
using unique_lock_t = std::unique_lock<mutex_t>;
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 59490a2

Please sign in to comment.