| # Copyright 2016 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/package.gni") |
| import("//build/testing/environments.gni") |
| import("//third_party/vulkan_loader_and_validation_layers/layers/layers.gni") |
| |
| declare_args() { |
| # Using Vulkan on host (i.e. Linux) is an involved affair that involves |
| # downloading the Vulkan SDK, setting environment variables, and so forth... |
| # all things that are difficult to achieve in a CQ environment. Therefore, |
| # by default we use a stub implementation of Vulkan which fails to create a |
| # VkInstance. This allows everything to build, and also allows running Escher |
| # unit tests which don't require Vulkan. |
| escher_use_null_vulkan_config_on_host = true |
| } |
| |
| package("escher_tests") { |
| testonly = true |
| |
| deps = [ |
| "test:escher_unittests", |
| ] |
| |
| tests = [ |
| { |
| name = "escher_unittests" |
| environments = basic_envs |
| }, |
| ] |
| |
| meta = [ |
| { |
| path = rebase_path("meta/escher_unittests.cmx") |
| dest = "escher_unittests.cmx" |
| }, |
| ] |
| |
| public_deps = vulkan_validation_layers.public_deps |
| loadable_modules = vulkan_validation_layers.loadable_modules |
| resources = vulkan_validation_layers.resources |
| resources += [ |
| { |
| path = rebase_path("shaders/model_renderer/default_position.vert") |
| dest = "shaders/model_renderer/default_position.vert" |
| }, |
| { |
| path = rebase_path("shaders/model_renderer/main.frag") |
| dest = "shaders/model_renderer/main.frag" |
| }, |
| { |
| path = rebase_path("shaders/model_renderer/main.vert") |
| dest = "shaders/model_renderer/main.vert" |
| }, |
| { |
| path = rebase_path("shaders/model_renderer/shadow_map_generation.frag") |
| dest = "shaders/model_renderer/shadow_map_generation.frag" |
| }, |
| { |
| path = rebase_path("shaders/model_renderer/shadow_map_lighting.frag") |
| dest = "shaders/model_renderer/shadow_map_lighting.frag" |
| }, |
| { |
| path = rebase_path("shaders/model_renderer/wobble_position.vert") |
| dest = "shaders/model_renderer/wobble_position.vert" |
| }, |
| { |
| path = rebase_path("shaders/paper/common/use.glsl") |
| dest = "shaders/paper/common/use.glsl" |
| }, |
| { |
| path = rebase_path("shaders/paper/frag/main_ambient_light.frag") |
| dest = "shaders/paper/frag/main_ambient_light.frag" |
| }, |
| { |
| path = rebase_path("shaders/paper/frag/main_point_light.frag") |
| dest = "shaders/paper/frag/main_point_light.frag" |
| }, |
| { |
| path = rebase_path("shaders/paper/vert/compute_model_space_position.vert") |
| dest = "shaders/paper/vert/compute_model_space_position.vert" |
| }, |
| { |
| path = rebase_path("shaders/paper/vert/compute_world_space_position.vert") |
| dest = "shaders/paper/vert/compute_world_space_position.vert" |
| }, |
| { |
| path = rebase_path("shaders/paper/vert/main_shadow_volume_extrude.vert") |
| dest = "shaders/paper/vert/main_shadow_volume_extrude.vert" |
| }, |
| { |
| path = rebase_path("shaders/paper/vert/vertex_attributes.vert") |
| dest = "shaders/paper/vert/vertex_attributes.vert" |
| }, |
| ] |
| } |
| |
| # Used by 'source_set("vulkan")' for host builds (e.g. Escher-on-Linux) for |
| # build environments where Vulkan is not available. |
| config("null_vulkan_config") { |
| defines = [ |
| "VULKAN_HPP_NO_EXCEPTIONS", |
| "VULKAN_HPP_NO_SMART_HANDLE", |
| ] |
| |
| # Only include the Vulkan headers: since this is used for host builds, we |
| # don't want to depend on e.g. //garnet/public/lib/vulkan, which brings in |
| # Zircon dependencies which cannot be compiled. |
| include_dirs = [ "//third_party/vulkan_loader_and_validation_layers/include" ] |
| } |
| |
| # Used by 'source_set("vulkan")' target builds (i.e. Escher-on-Fuchsia), and |
| # also for host builds (e.g. Escher-on-Linux) where Vulkan is made available via |
| # the 'download-vulkan-sdk' script, which downloads the LunarG Vulkan SDK from |
| # Google storage. |
| config("vulkan_config") { |
| defines = [ |
| "VULKAN_HPP_NO_EXCEPTIONS", |
| "VULKAN_HPP_NO_SMART_HANDLE", |
| ] |
| |
| # Specify the include/lib dirs and linked libraries for use with the |
| # downloaded LunarG Vulkan SDK. |
| if (is_linux) { |
| vulkan_sdk = "//garnet/public/lib/escher/third_party/vulkansdk/x86_64" |
| include_dirs = [ "$vulkan_sdk/include" ] |
| lib_dirs = [ "$vulkan_sdk/lib" ] |
| libs = [ "vulkan" ] |
| } |
| } |
| |
| # Cross-platform Vulkan setup; supports both host and target builds. |
| source_set("vulkan") { |
| if (is_fuchsia) { |
| public_configs = [ ":vulkan_config" ] |
| public_deps = [ |
| "//garnet/public/lib/vulkan", |
| ] |
| } else if (!escher_use_null_vulkan_config_on_host) { |
| # Host build using downloaded LunarG SDK. |
| public_configs = [ ":vulkan_config" ] |
| } else { |
| # Host build using stub Vulkan implementation. |
| public_configs = [ ":null_vulkan_config" ] |
| |
| sources = [ |
| "//garnet/public/lib/escher/third_party/null_vulkan/escher_null_vulkan.cc", |
| ] |
| } |
| } |
| |
| config("glm_config") { |
| include_dirs = [ "//third_party/glm" ] |
| |
| defines = [ |
| "GLM_ENABLE_EXPERIMENTAL", |
| |
| # Use Vulkan NDC (normalized depth coordinates): [0..1] instead of [-1..1] |
| "GLM_FORCE_DEPTH_ZERO_TO_ONE", |
| |
| # Disable SIMD code paths that seem unstable on Fuchsia. |
| "GLM_FORCE_PURE", |
| ] |
| } |
| |
| config("thread_safety_warning") { |
| cflags = [ |
| "-Wthread-safety", |
| "-fcolor-diagnostics", |
| ] |
| } |
| |
| config("vk_mem_alloc_error_suppression") { |
| cflags = [ |
| "-Wno-unused-variable", |
| "-Wno-missing-field-initializers", |
| ] |
| } |
| |
| source_set("vk_mem_alloc") { |
| public_deps = [ |
| ":vulkan", |
| "//garnet/public/lib/fxl", |
| ] |
| |
| sources = [ |
| "third_party/VulkanMemoryAllocator/vk_mem_alloc.h", |
| "vk/vk_mem_alloc.cc", |
| ] |
| |
| public_configs = [ ":vk_mem_alloc_error_suppression" ] |
| } |
| |
| source_set("escher") { |
| defines = [ |
| # Currently necessary on Fuchsia, but not Linux. |
| "ESCHER_DISABLE_BACKGROUND_COMPILATION", |
| ] |
| |
| deps = [ |
| "//third_party/shaderc/libshaderc", |
| "//third_party/shaderc/third_party/glslang", |
| "//third_party/shaderc/third_party/glslang:SPIRV", |
| "//third_party/shaderc/third_party/glslang:glslang-default-resource-limits", |
| "//third_party/shaderc/third_party/spirv-tools:spirv-tools-opt", |
| "//third_party/spirv-cross", |
| ] |
| |
| public_deps = [ |
| ":vk_mem_alloc", |
| ":vulkan", |
| "//garnet/public/lib/escher/base:escher_base", |
| "//garnet/public/lib/fxl", |
| ] |
| |
| sources = [ |
| "defaults/default_shader_program_factory.cc", |
| "defaults/default_shader_program_factory.h", |
| "escher.cc", |
| "escher.h", |
| "escher_process_init.cc", |
| "escher_process_init.h", |
| "forward_declarations.h", |
| "fs/hack_filesystem.cc", |
| "fs/hack_filesystem.h", |
| "geometry/bounding_box.cc", |
| "geometry/bounding_box.h", |
| "geometry/clip_planes.cc", |
| "geometry/clip_planes.h", |
| "geometry/indexed_triangle_mesh.h", |
| "geometry/indexed_triangle_mesh_clip.h", |
| "geometry/indexed_triangle_mesh_upload.h", |
| "geometry/intersection.cc", |
| "geometry/intersection.h", |
| "geometry/plane_ops.h", |
| "geometry/quad.cc", |
| "geometry/quad.h", |
| "geometry/tessellation.cc", |
| "geometry/tessellation.h", |
| "geometry/transform.cc", |
| "geometry/transform.h", |
| "geometry/type_utils.h", |
| "geometry/types.h", |
| "hmd/pose_buffer_latching_shader.cc", |
| "hmd/pose_buffer_latching_shader.h", |
| "impl/command_buffer.cc", |
| "impl/command_buffer.h", |
| "impl/command_buffer_pool.cc", |
| "impl/command_buffer_pool.h", |
| "impl/command_buffer_sequencer.cc", |
| "impl/command_buffer_sequencer.h", |
| "impl/compute_shader.cc", |
| "impl/compute_shader.h", |
| "impl/debug_print.cc", |
| "impl/descriptor_set_pool.cc", |
| "impl/descriptor_set_pool.h", |
| "impl/frame_manager.cc", |
| "impl/frame_manager.h", |
| "impl/gaussian_3x3f16.cc", |
| "impl/gaussian_3x3f16.h", |
| "impl/glsl_compiler.cc", |
| "impl/glsl_compiler.h", |
| "impl/gpu_mem_slab.cc", |
| "impl/gpu_mem_slab.h", |
| "impl/gpu_mem_suballocation.cc", |
| "impl/gpu_mem_suballocation.h", |
| "impl/gpu_uploader.cc", |
| "impl/gpu_uploader.h", |
| "impl/image_cache.cc", |
| "impl/image_cache.h", |
| "impl/mesh_manager.cc", |
| "impl/mesh_manager.h", |
| "impl/mesh_shader_binding.cc", |
| "impl/mesh_shader_binding.h", |
| "impl/model_data.cc", |
| "impl/model_data.h", |
| "impl/model_depth_pass.cc", |
| "impl/model_depth_pass.h", |
| "impl/model_display_list.cc", |
| "impl/model_display_list.h", |
| "impl/model_display_list_builder.cc", |
| "impl/model_display_list_builder.h", |
| "impl/model_display_list_flags.h", |
| "impl/model_lighting_pass.cc", |
| "impl/model_lighting_pass.h", |
| "impl/model_moment_shadow_map_lighting_pass.cc", |
| "impl/model_moment_shadow_map_lighting_pass.h", |
| "impl/model_moment_shadow_map_pass.cc", |
| "impl/model_moment_shadow_map_pass.h", |
| "impl/model_pipeline.cc", |
| "impl/model_pipeline.h", |
| "impl/model_pipeline_cache.cc", |
| "impl/model_pipeline_cache.h", |
| "impl/model_pipeline_spec.h", |
| "impl/model_render_pass.cc", |
| "impl/model_render_pass.h", |
| "impl/model_renderer.cc", |
| "impl/model_renderer.h", |
| "impl/model_shadow_map_lighting_pass.cc", |
| "impl/model_shadow_map_lighting_pass.h", |
| "impl/model_shadow_map_pass.cc", |
| "impl/model_shadow_map_pass.h", |
| "impl/naive_buffer.cc", |
| "impl/naive_buffer.h", |
| "impl/naive_image.cc", |
| "impl/naive_image.h", |
| "impl/ssdo_accelerator.cc", |
| "impl/ssdo_accelerator.h", |
| "impl/ssdo_sampler.cc", |
| "impl/ssdo_sampler.h", |
| "impl/uniform_buffer_pool.cc", |
| "impl/uniform_buffer_pool.h", |
| "impl/vk/pipeline.cc", |
| "impl/vk/pipeline.h", |
| "impl/vk/pipeline_cache.cc", |
| "impl/vk/pipeline_cache.h", |
| "impl/vk/pipeline_factory.h", |
| "impl/vk/pipeline_layout.cc", |
| "impl/vk/pipeline_layout.h", |
| "impl/vk/pipeline_spec.cc", |
| "impl/vk/pipeline_spec.h", |
| "impl/vulkan_utils.cc", |
| "impl/vulkan_utils.h", |
| "impl/wobble_modifier_absorber.cc", |
| "impl/wobble_modifier_absorber.h", |
| "impl/z_sort.cc", |
| "impl/z_sort.h", |
| "material/color_utils.cc", |
| "material/color_utils.h", |
| "material/material.cc", |
| "material/material.h", |
| "math/lerp.h", |
| "math/rotations.cc", |
| "math/rotations.h", |
| "paper/paper_draw_call.h", |
| "paper/paper_draw_call_factory.cc", |
| "paper/paper_draw_call_factory.h", |
| "paper/paper_drawable.h", |
| "paper/paper_drawable_flags.h", |
| "paper/paper_legacy_drawable.cc", |
| "paper/paper_legacy_drawable.h", |
| "paper/paper_light.h", |
| "paper/paper_material.h", |
| "paper/paper_readme.h", |
| "paper/paper_render_funcs.cc", |
| "paper/paper_render_funcs.h", |
| "paper/paper_render_queue.cc", |
| "paper/paper_render_queue.h", |
| "paper/paper_render_queue_context.cc", |
| "paper/paper_render_queue_context.h", |
| "paper/paper_render_queue_flags.h", |
| "paper/paper_renderer2.cc", |
| "paper/paper_renderer2.h", |
| "paper/paper_renderer_config.h", |
| "paper/paper_scene.h", |
| "paper/paper_shader_structs.h", |
| "paper/paper_shape_cache.cc", |
| "paper/paper_shape_cache.h", |
| "paper/paper_transform_stack.cc", |
| "paper/paper_transform_stack.h", |
| "profiling/timestamp_profiler.cc", |
| "profiling/timestamp_profiler.h", |
| "renderer/batch_gpu_uploader.cc", |
| "renderer/batch_gpu_uploader.h", |
| "renderer/buffer_cache.cc", |
| "renderer/buffer_cache.h", |
| "renderer/frame.cc", |
| "renderer/frame.h", |
| "renderer/moment_shadow_map.cc", |
| "renderer/moment_shadow_map.h", |
| "renderer/moment_shadow_map_renderer.cc", |
| "renderer/moment_shadow_map_renderer.h", |
| "renderer/paper_renderer.cc", |
| "renderer/paper_renderer.h", |
| "renderer/render_queue.cc", |
| "renderer/render_queue.h", |
| "renderer/render_queue_context.h", |
| "renderer/render_queue_item.h", |
| "renderer/renderer.cc", |
| "renderer/renderer.h", |
| "renderer/semaphore.cc", |
| "renderer/semaphore.h", |
| "renderer/shadow_map.cc", |
| "renderer/shadow_map.h", |
| "renderer/shadow_map_renderer.cc", |
| "renderer/shadow_map_renderer.h", |
| "renderer/shadow_map_type_info.h", |
| "renderer/uniform_allocation.h", |
| "renderer/uniform_binding.h", |
| "renderer/uniform_block_allocator.cc", |
| "renderer/uniform_block_allocator.h", |
| "resources/resource.cc", |
| "resources/resource.h", |
| "resources/resource_manager.cc", |
| "resources/resource_manager.h", |
| "resources/resource_recycler.cc", |
| "resources/resource_recycler.h", |
| "resources/resource_type_info.h", |
| "resources/waitable_resource.cc", |
| "resources/waitable_resource.h", |
| "scene/ambient_light.cc", |
| "scene/ambient_light.h", |
| "scene/binding.h", |
| "scene/camera.cc", |
| "scene/camera.h", |
| "scene/directional_light.cc", |
| "scene/directional_light.h", |
| "scene/displacement.cc", |
| "scene/displacement.h", |
| "scene/model.cc", |
| "scene/model.h", |
| "scene/object.cc", |
| "scene/object.h", |
| "scene/shape.cc", |
| "scene/shape.h", |
| "scene/shape_modifier.h", |
| "scene/stage.cc", |
| "scene/stage.h", |
| "scene/viewing_volume.cc", |
| "scene/viewing_volume.h", |
| "shape/mesh.cc", |
| "shape/mesh.h", |
| "shape/mesh_builder.cc", |
| "shape/mesh_builder.h", |
| "shape/mesh_builder_factory.h", |
| "shape/mesh_spec.cc", |
| "shape/mesh_spec.h", |
| "shape/modifier_wobble.cc", |
| "shape/modifier_wobble.h", |
| "shape/rounded_rect.cc", |
| "shape/rounded_rect.h", |
| "shape/rounded_rect_factory.cc", |
| "shape/rounded_rect_factory.h", |
| "status.h", |
| "third_party/granite/vk/command_buffer.cc", |
| "third_party/granite/vk/command_buffer.h", |
| "third_party/granite/vk/command_buffer_pipeline_state.cc", |
| "third_party/granite/vk/command_buffer_pipeline_state.h", |
| "third_party/granite/vk/descriptor_set_layout.cc", |
| "third_party/granite/vk/descriptor_set_layout.h", |
| "third_party/granite/vk/pipeline_layout.cc", |
| "third_party/granite/vk/pipeline_layout.h", |
| "third_party/granite/vk/render_pass.cc", |
| "third_party/granite/vk/render_pass.h", |
| "third_party/granite/vk/render_pass_info.cc", |
| "third_party/granite/vk/render_pass_info.h", |
| "third_party/granite/vk/shader_utils.cc", |
| "third_party/granite/vk/shader_utils.h", |
| "util/align.h", |
| "util/alloca.h", |
| "util/bit_ops.h", |
| "util/bitmap.h", |
| "util/block_allocator.cc", |
| "util/block_allocator.h", |
| "util/debug_print.h", |
| "util/depth_to_color.cc", |
| "util/depth_to_color.h", |
| "util/enum_cast.h", |
| "util/enum_count.h", |
| "util/enum_flags.h", |
| "util/enum_utils.h", |
| "util/epsilon_compare.h", |
| "util/hash.h", |
| "util/hash_cache.h", |
| "util/hash_fnv_1a.h", |
| "util/hash_map.h", |
| "util/hashable.h", |
| "util/hasher.h", |
| "util/image_utils.cc", |
| "util/image_utils.h", |
| "util/intrusive_list.h", |
| "util/object_pool.h", |
| "util/pair_hasher.h", |
| "util/stack_allocator.h", |
| "util/stopwatch.h", |
| "util/string_utils.h", |
| "util/trace_macros.h", |
| "util/tracer.cc", |
| "util/tracer.h", |
| "vk/buffer.cc", |
| "vk/buffer.h", |
| "vk/buffer_factory.h", |
| "vk/command_buffer.h", |
| "vk/framebuffer.cc", |
| "vk/framebuffer.h", |
| "vk/gpu_allocator.h", |
| "vk/gpu_mem.cc", |
| "vk/gpu_mem.h", |
| "vk/image.cc", |
| "vk/image.h", |
| "vk/image_view.cc", |
| "vk/image_view.h", |
| "vk/impl/descriptor_set_allocator.cc", |
| "vk/impl/descriptor_set_allocator.h", |
| "vk/impl/framebuffer.cc", |
| "vk/impl/framebuffer.h", |
| "vk/impl/framebuffer_allocator.cc", |
| "vk/impl/framebuffer_allocator.h", |
| "vk/impl/pipeline_layout_cache.cc", |
| "vk/impl/pipeline_layout_cache.h", |
| "vk/impl/render_pass_cache.cc", |
| "vk/impl/render_pass_cache.h", |
| "vk/naive_gpu_allocator.cc", |
| "vk/naive_gpu_allocator.h", |
| "vk/render_pass.cc", |
| "vk/render_pass.h", |
| "vk/render_pass_info.h", |
| "vk/shader_module.cc", |
| "vk/shader_module.h", |
| "vk/shader_module_template.cc", |
| "vk/shader_module_template.h", |
| "vk/shader_program.cc", |
| "vk/shader_program.h", |
| "vk/shader_program_factory.cc", |
| "vk/shader_program_factory.h", |
| "vk/shader_variant_args.cc", |
| "vk/shader_variant_args.h", |
| "vk/texture.cc", |
| "vk/texture.h", |
| "vk/vma_gpu_allocator.cc", |
| "vk/vma_gpu_allocator.h", |
| "vk/vulkan_context.h", |
| "vk/vulkan_device_queues.cc", |
| "vk/vulkan_device_queues.h", |
| "vk/vulkan_instance.cc", |
| "vk/vulkan_instance.h", |
| "vk/vulkan_limits.h", |
| "vk/vulkan_swapchain.cc", |
| "vk/vulkan_swapchain.h", |
| "vk/vulkan_swapchain_helper.cc", |
| "vk/vulkan_swapchain_helper.h", |
| ] |
| |
| if (is_fuchsia) { |
| sources += [ |
| "flib/fence.h", |
| "flib/fence_listener.cc", |
| "flib/fence_listener.h", |
| "flib/fence_set_listener.cc", |
| "flib/fence_set_listener.h", |
| "flib/release_fence_signaller.cc", |
| "flib/release_fence_signaller.h", |
| "fs/fuchsia_data_source.cc", |
| "fs/fuchsia_data_source.h", |
| "util/fuchsia_utils.cc", |
| "util/fuchsia_utils.h", |
| ] |
| public_deps += [ |
| "//sdk/fidl/fuchsia.images", |
| "//zircon/public/lib/async-loop-cpp", |
| "//zircon/public/lib/fit", |
| "//zircon/public/lib/fs", |
| "//zircon/public/lib/trace-vthread", |
| ] |
| deps += [ "//zircon/public/lib/trace" ] |
| } |
| |
| if (is_linux) { |
| sources += [ |
| "fs/linux_data_source.cc", |
| "fs/linux_data_source.h", |
| "util/impl/trace_macros_impl.cc", |
| "util/impl/trace_macros_impl.h", |
| ] |
| } |
| |
| include_dirs = [ |
| "//third_party/shaderc/third_party/glslang", |
| "//third_party/shaderc/third_party/spirv-tools/include", |
| ] |
| |
| public_configs = [ |
| ":glm_config", |
| ":thread_safety_warning", |
| ] |
| } |
| |
| group("unittests") { |
| testonly = true |
| deps = [ |
| "//garnet/public/lib/escher/test:escher_unittests", |
| ] |
| } |