Move reusable Vulkan code from VulkanBenchmarks to new VulkanWrapper library

This will allow us to reuse this code across unit tests and benchmarks. Bug: b/176981107 Change-Id: Ie5ea3708cb959dbd0189658b42f01bad998ae94a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51869Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent e27e7488
...@@ -984,6 +984,11 @@ if(SWIFTSHADER_BUILD_TESTS) ...@@ -984,6 +984,11 @@ if(SWIFTSHADER_BUILD_TESTS)
endif() endif()
if(SWIFTSHADER_BUILD_BENCHMARKS) if(SWIFTSHADER_BUILD_BENCHMARKS)
if (NOT TARGET glslang)
add_subdirectory(${THIRD_PARTY_DIR}/glslang)
endif()
add_subdirectory(${TESTS_DIR}/VulkanWrapper) # Add VulkanWrapper target
if (NOT TARGET benchmark::benchmark) if (NOT TARGET benchmark::benchmark)
set(BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL FALSE FORCE) set(BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL FALSE FORCE)
add_subdirectory(${THIRD_PARTY_DIR}/benchmark) add_subdirectory(${THIRD_PARTY_DIR}/benchmark)
...@@ -991,10 +996,6 @@ if(SWIFTSHADER_BUILD_BENCHMARKS) ...@@ -991,10 +996,6 @@ if(SWIFTSHADER_BUILD_BENCHMARKS)
set_target_properties(benchmark_main PROPERTIES FOLDER "third_party") set_target_properties(benchmark_main PROPERTIES FOLDER "third_party")
endif() endif()
if (NOT TARGET glslang)
add_subdirectory(${THIRD_PARTY_DIR}/glslang)
endif()
add_subdirectory(${TESTS_DIR}/ReactorBenchmarks) # Add ReactorBenchmarks target add_subdirectory(${TESTS_DIR}/ReactorBenchmarks) # Add ReactorBenchmarks target
add_subdirectory(${TESTS_DIR}/SystemBenchmarks) # Add system-benchmarks target add_subdirectory(${TESTS_DIR}/SystemBenchmarks) # Add system-benchmarks target
add_subdirectory(${TESTS_DIR}/VulkanBenchmarks) # Add VulkanBenchmarks target add_subdirectory(${TESTS_DIR}/VulkanBenchmarks) # Add VulkanBenchmarks target
......
...@@ -22,22 +22,8 @@ set(ROOT_PROJECT_LINK_LIBRARIES ...@@ -22,22 +22,8 @@ set(ROOT_PROJECT_LINK_LIBRARIES
) )
set(VULKAN_BENCHMARKS_SRC_FILES set(VULKAN_BENCHMARKS_SRC_FILES
Buffer.cpp
Buffer.hpp
Framebuffer.cpp
Framebuffer.hpp
Image.cpp
Image.hpp
main.cpp main.cpp
Swapchain.cpp
Swapchain.hpp
Util.cpp
Util.hpp
VulkanBenchmarks.cpp VulkanBenchmarks.cpp
VulkanHeaders.cpp
VulkanHeaders.hpp
Window.cpp
Window.hpp
) )
add_executable(VulkanBenchmarks add_executable(VulkanBenchmarks
...@@ -48,16 +34,8 @@ if (NOT TARGET benchmark::benchmark) ...@@ -48,16 +34,8 @@ if (NOT TARGET benchmark::benchmark)
message(FATAL_ERROR "Missing required target: benchmark::benchmark") message(FATAL_ERROR "Missing required target: benchmark::benchmark")
endif() endif()
if (NOT TARGET glslang) if (NOT TARGET VulkanWrapper)
message(FATAL_ERROR "Missing required target: glslang") message(FATAL_ERROR "Missing required target: VulkanWrapper")
endif()
if (NOT TARGET glslang-default-resource-limits)
message(FATAL_ERROR "Missing required target: glslang-default-resource-limits")
endif()
if (NOT TARGET SPIRV)
message(FATAL_ERROR "Missing required target: SPIRV")
endif() endif()
add_dependencies(VulkanBenchmarks add_dependencies(VulkanBenchmarks
...@@ -87,8 +65,6 @@ target_link_options(VulkanBenchmarks ...@@ -87,8 +65,6 @@ target_link_options(VulkanBenchmarks
target_link_libraries(VulkanBenchmarks target_link_libraries(VulkanBenchmarks
PRIVATE PRIVATE
benchmark::benchmark benchmark::benchmark
glslang VulkanWrapper
glslang-default-resource-limits
SPIRV
${ROOT_PROJECT_LINK_LIBRARIES} ${ROOT_PROJECT_LINK_LIBRARIES}
) )
# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(ROOT_PROJECT_COMPILE_OPTIONS
${WARNINGS_AS_ERRORS}
)
set(VULKAN_WRAPPER_SRC_FILES
Buffer.hpp
Framebuffer.hpp
Image.hpp
Swapchain.hpp
Util.hpp
VulkanHeaders.hpp
Window.hpp
Buffer.cpp
Framebuffer.cpp
Image.cpp
Swapchain.cpp
Util.cpp
VulkanHeaders.cpp
Window.cpp
)
add_library(VulkanWrapper STATIC
${VULKAN_WRAPPER_SRC_FILES}
)
if (NOT TARGET glslang)
message(FATAL_ERROR "Missing required target: glslang")
endif()
if (NOT TARGET glslang-default-resource-limits)
message(FATAL_ERROR "Missing required target: glslang-default-resource-limits")
endif()
if (NOT TARGET SPIRV)
message(FATAL_ERROR "Missing required target: SPIRV")
endif()
set_target_properties(VulkanWrapper PROPERTIES
FOLDER "Benchmarks"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
target_include_directories(VulkanWrapper
PUBLIC
"."
"${SWIFTSHADER_DIR}/include"
)
target_compile_options(VulkanWrapper
PRIVATE
${ROOT_PROJECT_COMPILE_OPTIONS}
)
target_link_options(VulkanWrapper
PRIVATE
${SWIFTSHADER_LINK_FLAGS}
)
target_link_libraries(VulkanWrapper
PUBLIC
glslang
glslang-default-resource-limits
SPIRV
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment