Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ jobs:
- name: Generate layer_test
run: |
python3 ./generator/generate_vulkan_common.py
mkdir layer_example/build_rel
cd layer_example/build_rel
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
make -j4

build-ubuntu-x64-clang-new-project:
name: Ubuntu x64 generate new layer
Expand All @@ -94,6 +98,7 @@ jobs:

- name: Generate layer_test
run: |
python3 ./generator/generate_vulkan_common.py
python3 ./generator/generate_vulkan_layer.py --project-name Test --layer-name VkLayerTest --output layer_test
mkdir layer_test/build_rel
cd layer_test/build_rel
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ set(CMAKE_CXX_STANDARD 20)

project(libGPULayers_UnitTests VERSION 1.0.0)

# Standard CMake components
include(source_common/compiler_helper.cmake)

# Build steps
set(LGL_UNITTEST ON)

Expand Down
8 changes: 2 additions & 6 deletions generator/generate_vulkan_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,13 @@ def main():
print(f'ERROR: Layer name "{args.layer_name}" is invalid')
return 1

# If overwrite is set, remove output directory if it exists
if args.overwrite:
shutil.rmtree(args.output, ignore_errors=True)

# Check that output directory is either empty or non-existent
# Check that output directory is either empty or over-writable
outdir = args.output
if os.path.exists(outdir):
if not os.path.isdir(outdir):
print(f'ERROR: Output location "{outdir}" is not a directory')
return 1
if len(os.listdir(outdir)) != 0:
if len(os.listdir(outdir)) != 0 and not args.overwrite:
print(f'ERROR: Output directory "{outdir}" is not empty')
return 1

Expand Down
20 changes: 11 additions & 9 deletions generator/vk_codegen/device_dispatch_table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@

#include <vulkan/vulkan.h>

#include "device_functions.hpp"
#include "framework/device_functions.hpp"
#include "utils/misc.hpp"

#if __has_include ("layer_device_functions.hpp")
#include "layer_device_functions.hpp"
#endif

/**
* \brief Interception table lookup entry.
* @brief Interception table lookup entry.
*/
struct DeviceInterceptTableEntry
{
/**
* \brief The function entrypoint name.
* @brief The function entrypoint name.
*/
const char* name;

/**
* \brief The layer function pointer.
* @brief The layer function pointer.
*/
PFN_vkVoidFunction function;
};

#define ENTRY(fnc) { STR(fnc), reinterpret_cast<PFN_vkVoidFunction>(layer_##fnc<user_tag>) }

/**
* \brief The device dispatch table used to call the driver.
* @brief The device dispatch table used to call the driver.
*/
static const struct DeviceInterceptTableEntry deviceIntercepts[] = {
{ITABLE_MEMBERS}
Expand All @@ -44,11 +46,11 @@ struct DeviceDispatchTable {
#define ENTRY(fnc) table.fnc = (PFN_##fnc)getProcAddr(device, STR(fnc))

/**
* \brief Initialize the device dispatch table with driver function pointers.
* @brief Initialize the device dispatch table with driver function pointers.
*
* \param device The device handle.
* \param getProcAddr The function getter for the driver/next layer down.
* \param table The table to populate.
* @param device The device handle.
* @param getProcAddr The function getter for the driver/next layer down.
* @param table The table to populate.
*/
static inline void initDriverDeviceDispatchTable(
VkDevice device,
Expand Down
22 changes: 12 additions & 10 deletions generator/vk_codegen/instance_dispatch_table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@

#include <vulkan/vulkan.h>

#include "instance_functions.hpp"
#include "framework/instance_functions.hpp"
#include "utils/misc.hpp"

#if __has_include ("layer_instance_functions.hpp")
#include "layer_instance_functions.hpp"
#endif

/**
* \brief Interception table lookup entry.
* @brief Interception table lookup entry.
*/
struct InstanceInterceptTableEntry
{
/**
* \brief The function entrypoint name.
* @brief The function entrypoint name.
*/
const char* name;

/**
* \brief The layer function pointer.
* @brief The layer function pointer.
*/
PFN_vkVoidFunction function;
};

#define ENTRY(fnc) { STR(fnc), reinterpret_cast<PFN_vkVoidFunction>(layer_##fnc<user_tag>) }

/**
* \brief The instance dispatch table used to call the driver.
* @brief The instance dispatch table used to call the driver.
*/
static const struct InstanceInterceptTableEntry instanceIntercepts[] = {
{ITABLE_MEMBERS}
Expand All @@ -35,7 +37,7 @@ static const struct InstanceInterceptTableEntry instanceIntercepts[] = {
#undef ENTRY

/**
* \brief The instance dispatch table used to call the driver.
* @brief The instance dispatch table used to call the driver.
*/
struct InstanceDispatchTable {
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
Expand All @@ -46,11 +48,11 @@ struct InstanceDispatchTable {
#define ENTRY(fnc) table.fnc = (PFN_##fnc)getProcAddr(instance, STR(fnc))

/**
* \brief Initialize the instance dispatch table with driver function pointers.
* @brief Initialize the instance dispatch table with driver function pointers.
*
* \param instance The instance handle.
* \param getProcAddr The function getter for the driver/next layer down.
* \param table The table to populate.
* @param instance The instance handle.
* @param getProcAddr The function getter for the driver/next layer down.
* @param table The table to populate.
*/
static inline void initDriverInstanceDispatchTable(
VkInstance instance,
Expand Down
1 change: 1 addition & 0 deletions generator/vk_codegen/root_CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ project({PROJECT_NAME} VERSION 1.0.0)

# Common configuration
set(LGL_LOG_TAG, "{LAYER_NAME}")
include(../source_common/compiler_helper.cmake)

# Build steps
add_subdirectory(source)
Expand Down
27 changes: 3 additions & 24 deletions generator/vk_codegen/source_CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
# SOFTWARE.
# -----------------------------------------------------------------------------

# Compiler accepts GNU-style command line options
set(is_gnu_fe1 "$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},GNU>")

# Compiler accepts AppleClang-style command line options, which is also GNU-style
set(is_gnu_fe2 "$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},AppleClang>")

# Compiler accepts GNU-style command line options
set(is_gnu_fe "$<OR:${is_gnu_fe1},${is_gnu_fe2}>")

# Compiler is upstream clang with the standard frontend
set(is_clang "$<AND:${is_gnu_fe},$<CXX_COMPILER_ID:Clang,AppleClang>>")

# Set output file names
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(VK_LAYER {LAYER_NAME}_sym)
Expand All @@ -59,24 +47,15 @@ add_library(

target_include_directories(
${VK_LAYER} PRIVATE
${PROJECT_SOURCE_DIR}/../source_common/framework
${PROJECT_SOURCE_DIR}/../source_common
${CMAKE_CURRENT_BINARY_DIR}
.)

target_include_directories(
${VK_LAYER} SYSTEM PRIVATE
../../khronos/vulkan/include)

target_compile_options(
${VK_LAYER} PRIVATE
-fvisibility=hidden
-fvisibility-inlines-hidden
-fno-exceptions
-fno-rtti
-Wall
-Wextra
-Wno-missing-field-initializers
$<${is_clang}:-Wdocumentation>)
lgl_set_build_options(${VK_LAYER})

target_compile_definitions(
${VK_LAYER} PRIVATE
Expand All @@ -85,7 +64,7 @@ target_compile_definitions(

target_link_libraries(
${VK_LAYER}
layer_common
lib_layer_framework
$<$<PLATFORM_ID:Android>:log>)

if (CMAKE_BUILD_TYPE STREQUAL "Release")
Expand Down
38 changes: 8 additions & 30 deletions generator/vk_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,32 @@
# SOFTWARE.
# -----------------------------------------------------------------------------

# Compiler accepts GNU-style command line options
set(is_gnu_fe1 "$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},GNU>")

# Compiler accepts AppleClang-style command line options, which is also GNU-style
set(is_gnu_fe2 "$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},AppleClang>")

# Compiler accepts GNU-style command line options
set(is_gnu_fe "$<OR:${is_gnu_fe1},${is_gnu_fe2}>")

# Compiler is upstream clang with the standard frontend
set(is_clang "$<AND:${is_gnu_fe},$<CXX_COMPILER_ID:Clang,AppleClang>>")

set(DIR_TARGET layer_common)
set(BUILD_TARGET lib_layer_framework)

add_library(
${DIR_TARGET} STATIC
${BUILD_TARGET} STATIC
device_functions.cpp
instance_functions.cpp)

target_include_directories(
${DIR_TARGET} PRIVATE
${BUILD_TARGET} PRIVATE
# Note, this includes from the layer-specific tree
${PROJECT_SOURCE_DIR}/source
.)
../)

target_include_directories(
${DIR_TARGET} SYSTEM PRIVATE
${BUILD_TARGET} SYSTEM PRIVATE
../../khronos/vulkan/include)

target_compile_options(
${DIR_TARGET} PRIVATE
-fvisibility=hidden
-fvisibility-inlines-hidden
-fno-exceptions
-fno-rtti
-fpic
-Wall
-Wextra
-Wno-missing-field-initializers
$<${is_clang}:-Wdocumentation>)
lgl_set_build_options(${BUILD_TARGET})

# TODO: Log tag needs to come from child project
target_compile_definitions(
${DIR_TARGET} PRIVATE
${BUILD_TARGET} PRIVATE
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR=1>
$<$<PLATFORM_ID:Android>:LGL_LOG_TAG="${LGL_LOG_TAG}">)

# TODO: Remove this?
target_link_libraries(
${DIR_TARGET}
${BUILD_TARGET}
$<$<PLATFORM_ID:Android>:log>)
21 changes: 11 additions & 10 deletions generator/vk_common/entry_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "device_dispatch_table.hpp"
#include "device_functions.hpp"

extern std::mutex g_vulkanLock;

#define VK_LAYER_EXPORT __attribute__((visibility("default")))

Expand All @@ -53,7 +54,7 @@
#endif

/**
* \brief The layer configuration.
* @brief The layer configuration.
*/
#define LGL_VERSION VK_MAKE_VERSION(LGL_VER_MAJOR, LGL_VER_MINOR, LGL_VER_PATCH)

Expand All @@ -62,37 +63,37 @@ static const std::array<VkLayerProperties, 1> layerProps = {
};

/**
* \brief Dispatch table lookup entry.
* @brief Dispatch table lookup entry.
*/
struct DispatchTableEntry
{
/**
* \brief The function entrypoint name.
* @brief The function entrypoint name.
*/
const char* name;

/**
* \brief The function pointer.
* @brief The function pointer.
*/
PFN_vkVoidFunction function;
};

/**
* \brief Utility macro to define a lookup for a core function.
* @brief Utility macro to define a lookup for a core function.
*/
#define VK_TABLE_ENTRY(func) \
{ STR(func), reinterpret_cast<PFN_vkVoidFunction>(func) }

/**
* \brief Utility macro to define a lookup for a layer-dispatch-only function.
* @brief Utility macro to define a lookup for a layer-dispatch-only function.
*/
#define VK_TABLE_ENTRYL(func) \
{ STR(func), reinterpret_cast<PFN_vkVoidFunction>(layer_##func) }

/**
* \brief Fetch the layer function for a given instance entrypoint name.
* @brief Fetch the layer function for a given instance entrypoint name.
*
* \param name The layer entry point name.
* @param name The layer entry point name.
*
* \return The layer function pointer, or \c nullptr if the layer doesn't
* intercept the function.
Expand Down Expand Up @@ -126,9 +127,9 @@ static PFN_vkVoidFunction get_instance_layer_function(
}

/**
* \brief Fetch the layer function for a given device entrypoint name.
* @brief Fetch the layer function for a given device entrypoint name.
*
* \param name The layer entry point name.
* @param name The layer entry point name.
*
* \return The layer function pointer, or \c nullptr if the layer doesn't intercept the function.
*/
Expand Down
Loading