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

Commit 0e0b433

Browse files
committed
layers:Remove includes of vk_safe_struct.cpp
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.
1 parent 4d285de commit 0e0b433

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

build-android/android-generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
1919
cd $dir
2020

2121
rm -rf generated
22-
mkdir -p generated/include generated/common
22+
mkdir -p generated/include generated/common generated/source
2323

2424
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.h )
25-
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.cpp )
25+
( cd generated/source; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_safe_struct.cpp )
2626
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_struct_size_helper.h )
2727
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_struct_size_helper.c )
2828
( cd generated/include; python3 ../../../scripts/lvl_genvk.py -registry ../../../scripts/vk.xml vk_enum_string_helper.h )

build-android/jni/Android.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ LOCAL_SRC_FILES += $(SRC_DIR)/layers/descriptor_sets.cpp
3838
LOCAL_SRC_FILES += $(SRC_DIR)/layers/buffer_validation.cpp
3939
LOCAL_SRC_FILES += $(SRC_DIR)/layers/shader_validation.cpp
4040
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
41+
LOCAL_SRC_FILES += $(LAYER_DIR)/source/vk_safe_struct.cpp
4142
LOCAL_C_INCLUDES += $(SRC_DIR)/include \
4243
$(SRC_DIR)/layers \
44+
$(LAYER_DIR)/source \
4345
$(LAYER_DIR)/include \
4446
$(SRC_DIR)/loader \
4547
$(ANDROID_DIR)/external/glslang \
@@ -100,9 +102,11 @@ include $(CLEAR_VARS)
100102
LOCAL_MODULE := VkLayer_unique_objects
101103
LOCAL_SRC_FILES += $(SRC_DIR)/layers/unique_objects.cpp
102104
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
105+
LOCAL_SRC_FILES += $(LAYER_DIR)/source/vk_safe_struct.cpp
103106
LOCAL_C_INCLUDES += $(SRC_DIR)/include \
104107
$(SRC_DIR)/layers \
105108
$(LAYER_DIR)/include \
109+
$(LAYER_DIR)/source \
106110
$(SRC_DIR)/loader
107111
LOCAL_STATIC_LIBRARIES += layer_utils
108112
LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden

layers/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ run_vk_xml_generate(parameter_validation_generator.py parameter_validation.h)
160160
run_vk_xml_generate(unique_objects_generator.py unique_objects_wrappers.h)
161161
run_vk_xml_generate(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)
162162

163+
run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp)
164+
163165
# Layer Utils Library
164166
# For Windows, we use a static lib because the Windows loader has a fairly restrictive loader search
165167
# path that can't be easily modified to point it to the same directory that contains the layers.
@@ -173,11 +175,11 @@ else()
173175
endif()
174176
add_dependencies(VkLayer_utils generate_helper_files)
175177

176-
add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp descriptor_sets.cpp buffer_validation.cpp shader_validation.cpp)
178+
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)
177179
add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp)
178180
# generated
179181
add_vk_layer(threading threading.cpp thread_check.h vk_layer_table.cpp)
180-
add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp)
182+
add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp vk_safe_struct.cpp)
181183
add_vk_layer(parameter_validation parameter_validation.cpp parameter_validation.h vk_layer_table.cpp)
182184

183185
# Core validation has additional dependencies

layers/core_validation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ std::string to_string(T var) {
9292
}
9393
#endif
9494

95-
// This intentionally includes a cpp file
96-
#include "vk_safe_struct.cpp"
97-
9895
namespace core_validation {
9996

10097
using std::unordered_map;

layers/unique_objects.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
#include "vk_object_types.h"
4949
#include "vulkan/vk_layer.h"
5050

51-
// This intentionally includes a cpp file
52-
#include "vk_safe_struct.cpp"
53-
5451
#include "unique_objects_wrappers.h"
5552

5653
namespace unique_objects {

0 commit comments

Comments
 (0)