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

Commit 46cf072

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.
1 parent ce7a8f1 commit 46cf072

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

build-android/jni/Android.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ 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)/include/vk_safe_struct.cpp
4142
LOCAL_C_INCLUDES += $(SRC_DIR)/include \
4243
$(SRC_DIR)/layers \
4344
$(LAYER_DIR)/include \
@@ -100,6 +101,7 @@ include $(CLEAR_VARS)
100101
LOCAL_MODULE := VkLayer_unique_objects
101102
LOCAL_SRC_FILES += $(SRC_DIR)/layers/unique_objects.cpp
102103
LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
104+
LOCAL_SRC_FILES += $(LAYER_DIR)/include/vk_safe_struct.cpp
103105
LOCAL_C_INCLUDES += $(SRC_DIR)/include \
104106
$(SRC_DIR)/layers \
105107
$(LAYER_DIR)/include \

layers/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ run_vk_xml_generate(parameter_validation_generator.py parameter_validation.h)
156156
run_vk_xml_generate(unique_objects_generator.py unique_objects_wrappers.h)
157157
run_vk_xml_generate(dispatch_table_helper_generator.py vk_dispatch_table_helper.h)
158158

159+
run_vk_xml_generate(helper_file_generator.py vk_safe_struct.cpp)
160+
159161
# Layer Utils Library
160162
# For Windows, we use a static lib because the Windows loader has a fairly restrictive loader search
161163
# path that can't be easily modified to point it to the same directory that contains the layers.
@@ -167,11 +169,11 @@ else()
167169
endif()
168170
add_dependencies(VkLayer_utils generate_helper_files)
169171

170-
add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp descriptor_sets.cpp buffer_validation.cpp shader_validation.cpp)
172+
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)
171173
add_vk_layer(object_tracker object_tracker.cpp vk_layer_table.cpp)
172174
# generated
173175
add_vk_layer(threading threading.cpp thread_check.h vk_layer_table.cpp)
174-
add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp)
176+
add_vk_layer(unique_objects unique_objects.cpp unique_objects_wrappers.h vk_layer_table.cpp vk_safe_struct.cpp)
175177
add_vk_layer(parameter_validation parameter_validation.cpp parameter_validation.h vk_layer_table.cpp)
176178

177179
# 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)