From 2e8e8f5a5e86f005d6aa42dda810ef0d06696ec4 Mon Sep 17 00:00:00 2001 From: Allan MacKinnon <allanmac@google.com> Date: Mon, 13 May 2019 21:15:50 +0000 Subject: [PATCH] [graphics][compute] Add Spinel libs to compute build. Tracked by SPN-22 and SPN-19. Blocks tests SPN-17, SPN-18. Change-Id: I4bd95681b26b81e3521c518b4d0894730e5c23ce --- src/graphics/lib/compute/BUILD.gn | 1 + src/graphics/lib/compute/spinel/BUILD.gn | 49 +++++++++++++++ .../lib/compute/spinel/platforms/vk/BUILD.gn | 61 +++++++++++++++++++ .../spinel/platforms/vk/composition_impl.c | 8 +++ .../lib/compute/spinel/platforms/vk/device.c | 2 +- .../lib/compute/spinel/platforms/vk/device.h | 15 +---- .../compute/spinel/platforms/vk/handle_pool.c | 4 -- .../compute/spinel/platforms/vk/render_impl.c | 10 ++- .../spinel/{ => platforms/vk}/spinel_vk.h | 20 +++++- .../vk/spinel_vk_types.h} | 11 +++- .../spinel/platforms/vk/styling_impl.c | 4 ++ .../lib/compute/spinel/platforms/vk/target.c | 2 +- src/graphics/lib/compute/spinel/spinel.h | 19 ++++-- .../lib/compute/spinel/spinel_assert.h | 16 +++++ .../lib/compute/spinel/spinel_result.h | 13 +++- .../lib/compute/spinel/spinel_types.h | 17 +++++- .../spinel_vk_path_builder}/main.c | 2 +- .../meta/spinel_vk_path_builder.cmx | 15 +++++ 18 files changed, 232 insertions(+), 37 deletions(-) create mode 100644 src/graphics/lib/compute/spinel/BUILD.gn create mode 100644 src/graphics/lib/compute/spinel/platforms/vk/BUILD.gn rename src/graphics/lib/compute/spinel/{ => platforms/vk}/spinel_vk.h (64%) rename src/graphics/lib/compute/spinel/{spinel_types_vk.h => platforms/vk/spinel_vk_types.h} (93%) rename src/graphics/lib/compute/spinel/{demo => tests/spinel_vk_path_builder}/main.c (99%) create mode 100644 src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/meta/spinel_vk_path_builder.cmx diff --git a/src/graphics/lib/compute/BUILD.gn b/src/graphics/lib/compute/BUILD.gn index a32869f644d..c7adb06899a 100644 --- a/src/graphics/lib/compute/BUILD.gn +++ b/src/graphics/lib/compute/BUILD.gn @@ -7,5 +7,6 @@ group("compute") { "common", "common/vk", "hotsort", + "spinel/platforms/vk", ] } diff --git a/src/graphics/lib/compute/spinel/BUILD.gn b/src/graphics/lib/compute/spinel/BUILD.gn new file mode 100644 index 00000000000..3abee6ff08a --- /dev/null +++ b/src/graphics/lib/compute/spinel/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright 2019 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. + +source_set("spinel") { + public = [ + "spinel.h", + "spinel_types.h", + "spinel_result.h", + "spinel_assert.h", + ] + friend = [ + "platforms/vk" + ] + sources = [ + "allocator_host.c", + "allocator_host.h", + "composition.c", + "composition.h", + "context.c", + "context.h", + "core.h", + "core_c.h", + "handle.h", + "path_builder.c", + "path_builder.h", + "platforms", + "raster_builder.c", + "raster_builder.h", + "spinel.h", + "spinel_assert.c", + "spinel_assert.h", + "spinel_result.h", + "spinel_types.h", + "state_assert.h", + "styling.c", + "styling.h", + "suballocator.c", + "suballocator.h", + "weakref.c", + "weakref.h", + ] + include_dirs = [ + "//src/graphics/lib/compute", + ] + deps = [ + "//src/graphics/lib/compute/common", + ] +} diff --git a/src/graphics/lib/compute/spinel/platforms/vk/BUILD.gn b/src/graphics/lib/compute/spinel/platforms/vk/BUILD.gn new file mode 100644 index 00000000000..2b2d6e5096a --- /dev/null +++ b/src/graphics/lib/compute/spinel/platforms/vk/BUILD.gn @@ -0,0 +1,61 @@ +# Copyright 2019 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. + +source_set("vk") { + public = [ + "spinel_vk.h", + "spinel_vk_types.h", + ] + sources = [ + "allocator_device.c", + "allocator_device.h", + "block_pool.c", + "block_pool.h", + "cb_pool.c", + "cb_pool.h", + "composition_impl.c", + "composition_impl.h", + "device.c", + "device.h", + "expand_x.h", + "extent.c", + "extent.h", + "fence_pool.c", + "fence_pool.h", + "handle_pool.c", + "handle_pool.h", + "path_builder_impl.c", + "path_builder_impl.h", + "queue_pool.c", + "queue_pool.h", + "raster_builder_impl.c", + "raster_builder_impl.h", + "render_impl.c", + "render_impl.h", + "ring.c", + "ring.h", + "semaphore_pool.c", + "semaphore_pool.h", + "spinel_vk.h", + "spinel_vk_types.h", + "styling_impl.c", + "styling_impl.h", + "target.c", + "target_config.h", + "target_config_name.h", + "target_context_remove.h", + "target.h", + "target_layouts.h", + ] + include_dirs = [ + "//src/graphics/lib/compute", + "//src/graphics/lib/compute/spinel", + ] + deps = [ + "//src/graphics/lib/compute/spinel", + "//src/graphics/lib/compute/common", + "//src/graphics/lib/compute/common/vk", + "//third_party/vulkan_loader_and_validation_layers:vulkan", + ] +} diff --git a/src/graphics/lib/compute/spinel/platforms/vk/composition_impl.c b/src/graphics/lib/compute/spinel/platforms/vk/composition_impl.c index a10104c56e5..58c86aca96c 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/composition_impl.c +++ b/src/graphics/lib/compute/spinel/platforms/vk/composition_impl.c @@ -607,6 +607,8 @@ spn_ci_block_until_unsealed_and_reseal(struct spn_composition_impl * const impl) // // +#ifdef SPN_DISABLE_UNTIL_INTEGRATED + static void spn_ci_complete_p_3(void * pfn_payload) @@ -635,6 +637,8 @@ spn_ci_complete_p_3(void * pfn_payload) impl->state = SPN_CI_STATE_SEALED; } +#endif + // // // @@ -1187,6 +1191,8 @@ spn_ci_release(struct spn_composition_impl * const impl) // // +#ifdef SPN_DISABLE_UNTIL_INTEGRATED + static void spn_ci_retain_and_lock(struct spn_composition_impl * const impl) @@ -1205,6 +1211,8 @@ spn_composition_unlock_and_release(struct spn_composition_impl * const impl) spn_ci_release(impl); } +#endif + // // // diff --git a/src/graphics/lib/compute/spinel/platforms/vk/device.c b/src/graphics/lib/compute/spinel/platforms/vk/device.c index 6a60fe2f0e3..caa29d061d9 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/device.c +++ b/src/graphics/lib/compute/spinel/platforms/vk/device.c @@ -225,7 +225,7 @@ spn_device_lost(struct spn_device * const device) // spn_result -spn_context_create_vk(struct spn_context * * const context_p, +spn_context_create_vk(spn_context_t * const context_p, struct spn_device_vk * const device_vk, struct spn_target_image const * const target_image, uint64_t const block_pool_size, diff --git a/src/graphics/lib/compute/spinel/platforms/vk/device.h b/src/graphics/lib/compute/spinel/platforms/vk/device.h index 6c310a860cd..9af61e0d6d3 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/device.h +++ b/src/graphics/lib/compute/spinel/platforms/vk/device.h @@ -92,21 +92,10 @@ struct spn_device // // -// Creation and disposal intitializes context and may rely on other -// context resources like the scheduler +// Creation and disposal intitializes the context and may rely on +// other context resources like the scheduler // -// -// this is exposed here temporarily -// - -spn_result -spn_context_create_vk(struct spn_context * * const context_p, - struct spn_device_vk * const device_vk, - struct spn_target_image const * const target_image, - uint64_t const block_pool_size, - uint32_t const handle_count); - // // Disable device because of a fatal error // diff --git a/src/graphics/lib/compute/spinel/platforms/vk/handle_pool.c b/src/graphics/lib/compute/spinel/platforms/vk/handle_pool.c index 9dfe22011b2..9257aba4ae6 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/handle_pool.c +++ b/src/graphics/lib/compute/spinel/platforms/vk/handle_pool.c @@ -867,10 +867,6 @@ spn_device_handle_pool_release_d(struct spn_device * const device, refcnt.d -= 1; *refcnt_ptr = refcnt; -#if 0 - printf("%8u = { %u, %u }\n",handle,refcnt.h,refcnt.d); -#endif - if (refcnt.hd == 0) { spn_device_handle_pool_reclaim(device,handle_pool,reclaim_type,handle); } diff --git a/src/graphics/lib/compute/spinel/platforms/vk/render_impl.c b/src/graphics/lib/compute/spinel/platforms/vk/render_impl.c index e9b958dd4d7..5f0a4caa87d 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/render_impl.c +++ b/src/graphics/lib/compute/spinel/platforms/vk/render_impl.c @@ -6,11 +6,9 @@ // // -#include <string.h> - #include "render_impl.h" #include "spinel.h" -#include "spinel_types_vk.h" +#include "spinel_vk_types.h" #include "device.h" #include "target.h" #include "block_pool.h" @@ -24,6 +22,12 @@ // // +#include <string.h> + +// +// +// + struct spn_render_submit_ext_base { void * ext; diff --git a/src/graphics/lib/compute/spinel/spinel_vk.h b/src/graphics/lib/compute/spinel/platforms/vk/spinel_vk.h similarity index 64% rename from src/graphics/lib/compute/spinel/spinel_vk.h rename to src/graphics/lib/compute/spinel/platforms/vk/spinel_vk.h index ee99379b8ba..44af860aabb 100644 --- a/src/graphics/lib/compute/spinel/spinel_vk.h +++ b/src/graphics/lib/compute/spinel/platforms/vk/spinel_vk.h @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SPN_ONCE_SPINEL_VK -#define SPN_ONCE_SPINEL_VK +#pragma once // // @@ -13,11 +12,24 @@ #include "spinel.h" +// +// +// + +#ifdef __cplusplus +extern "C" { +#endif + // // CONTEXT CREATION: VULKAN // -// create the vulkan context +spn_result +spn_context_create_vk(spn_context_t * const context_p, + struct spn_device_vk * const device_vk, + struct spn_target_image const * const target_image, + uint64_t const block_pool_size, + uint32_t const handle_count); // // RENDER EXTENSION: VULKAN BUFFER @@ -40,6 +52,8 @@ struct spn_render_submit_ext_vk_buffer // // +#ifdef __cplusplus +} #endif // diff --git a/src/graphics/lib/compute/spinel/spinel_types_vk.h b/src/graphics/lib/compute/spinel/platforms/vk/spinel_vk_types.h similarity index 93% rename from src/graphics/lib/compute/spinel/spinel_types_vk.h rename to src/graphics/lib/compute/spinel/platforms/vk/spinel_vk_types.h index c3f7a9c89ef..817a695d710 100644 --- a/src/graphics/lib/compute/spinel/spinel_types_vk.h +++ b/src/graphics/lib/compute/spinel/platforms/vk/spinel_vk_types.h @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SPN_ONCE_SPINEL_TYPES_VK -#define SPN_ONCE_SPINEL_TYPES_VK +#pragma once // // @@ -13,6 +12,8 @@ #include "spinel_types.h" + + // // VK RENDER EXTENSIONS // @@ -52,4 +53,10 @@ struct spn_render_submit_ext_vk_image // // +#ifdef __cplusplus +} #endif + +// +// +// diff --git a/src/graphics/lib/compute/spinel/platforms/vk/styling_impl.c b/src/graphics/lib/compute/spinel/platforms/vk/styling_impl.c index a6e282f6453..abcf6204ba1 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/styling_impl.c +++ b/src/graphics/lib/compute/spinel/platforms/vk/styling_impl.c @@ -288,6 +288,8 @@ spn_si_release(struct spn_styling_impl * const impl) // // +#ifdef SPN_DISABLED_UNTIL_INTEGRATED + static void spn_si_retain_and_lock(struct spn_styling_impl * const impl) @@ -306,6 +308,8 @@ spn_styling_unlock_and_release(struct spn_styling_impl * const impl) spn_si_release(impl); } +#endif + // // // diff --git a/src/graphics/lib/compute/spinel/platforms/vk/target.c b/src/graphics/lib/compute/spinel/platforms/vk/target.c index fbe8e9432ed..971bc165ea0 100644 --- a/src/graphics/lib/compute/spinel/platforms/vk/target.c +++ b/src/graphics/lib/compute/spinel/platforms/vk/target.c @@ -730,7 +730,7 @@ spn_target_create(struct spn_device_vk * const vk, #define SPN_TARGET_PL_CREATE(_p_idx,_p_id,...) \ { \ - const uint32_t pps = target->config.p.push_sizes.array[_p_idx]; \ + uint32_t const pps = target->config.p.push_sizes.array[_p_idx]; \ \ if (pps == 0) { \ plci.pushConstantRangeCount = 0; \ diff --git a/src/graphics/lib/compute/spinel/spinel.h b/src/graphics/lib/compute/spinel/spinel.h index 1118dd79ead..fd4cc5bf09d 100644 --- a/src/graphics/lib/compute/spinel/spinel.h +++ b/src/graphics/lib/compute/spinel/spinel.h @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SPN_ONCE_SPINEL -#define SPN_ONCE_SPINEL +#pragma once // // @@ -12,6 +11,14 @@ #include "spinel_result.h" #include "spinel_types.h" +// +// +// + +#ifdef __cplusplus +extern "C" { +#endif + // // CONTEXT // @@ -222,7 +229,7 @@ spn_composition_reset(spn_composition_t composition); spn_result spn_composition_get_bounds(spn_composition_t composition, int32_t bounds[4]); -#if 0 +#ifdef SPN_TODO // let's switch to a per place bounds using weakrefs -- clip 0 will be largest clip spn_result spn_composition_set_clip(spn_composition_t composition, int32_t const clip[4]); @@ -326,12 +333,12 @@ spn_styling_group_layer(spn_styling_t styling, uint32_t const n, spn_styling_cmd_t * * const cmds); -#if 0 - // // FIXME -- styling command encoders will be opaque // +#ifdef SPN_DISABLE_UNTIL_INTEGRATED + void spn_styling_layer_fill_rgba_encoder(spn_styling_cmd_t * cmds, float const rgba[4]); @@ -376,6 +383,8 @@ spn_render(spn_context_t context, spn_render_submit_t const * const submit); // // +#ifdef __cplusplus +} #endif // diff --git a/src/graphics/lib/compute/spinel/spinel_assert.h b/src/graphics/lib/compute/spinel/spinel_assert.h index 950abbc47d3..876f38cfd43 100644 --- a/src/graphics/lib/compute/spinel/spinel_assert.h +++ b/src/graphics/lib/compute/spinel/spinel_assert.h @@ -14,6 +14,14 @@ // // +#ifdef __cplusplus +extern "C" { +#endif + +// +// +// + char const * spn_result_to_string(spn_result const result); @@ -50,3 +58,11 @@ spn_assert_n(char const * const file, // // // + +#ifdef __cplusplus +} +#endif + +// +// +// diff --git a/src/graphics/lib/compute/spinel/spinel_result.h b/src/graphics/lib/compute/spinel/spinel_result.h index 7c9590746da..5950ef6985e 100644 --- a/src/graphics/lib/compute/spinel/spinel_result.h +++ b/src/graphics/lib/compute/spinel/spinel_result.h @@ -2,8 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SPN_ONCE_SPINEL_RESULT -#define SPN_ONCE_SPINEL_RESULT +#pragma once + +// +// +// + +#ifdef __cplusplus +extern "C" { +#endif // // FIXME -- harvest error codes that are no longer used @@ -52,6 +59,8 @@ typedef enum spn_result { // // +#ifdef __cplusplus +} #endif // diff --git a/src/graphics/lib/compute/spinel/spinel_types.h b/src/graphics/lib/compute/spinel/spinel_types.h index 310134a1b3e..58342185442 100644 --- a/src/graphics/lib/compute/spinel/spinel_types.h +++ b/src/graphics/lib/compute/spinel/spinel_types.h @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SPN_ONCE_SPINEL_TYPES -#define SPN_ONCE_SPINEL_TYPES +#pragma once // // @@ -16,6 +15,14 @@ // // +#ifdef __cplusplus +extern "C" { +#endif + +// +// +// + typedef struct spn_context * spn_context_t; typedef struct spn_path_builder * spn_path_builder_t; typedef struct spn_raster_builder * spn_raster_builder_t; @@ -75,4 +82,10 @@ typedef struct spn_render_submit // // +#ifdef __cplusplus +} #endif + +// +// +// diff --git a/src/graphics/lib/compute/spinel/demo/main.c b/src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/main.c similarity index 99% rename from src/graphics/lib/compute/spinel/demo/main.c rename to src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/main.c index cf8a92a2ae4..462eb960de8 100644 --- a/src/graphics/lib/compute/spinel/demo/main.c +++ b/src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/main.c @@ -29,7 +29,7 @@ // // -#include "spinel.h" +#include "spinel_vk.h" #include "spinel_assert.h" // diff --git a/src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/meta/spinel_vk_path_builder.cmx b/src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/meta/spinel_vk_path_builder.cmx new file mode 100644 index 00000000000..1c51dfe9310 --- /dev/null +++ b/src/graphics/lib/compute/spinel/tests/spinel_vk_path_builder/meta/spinel_vk_path_builder.cmx @@ -0,0 +1,15 @@ +{ + "program": { + "binary": "bin/app" + }, + "sandbox": { + "features": [ + "vulkan" + ], + "services": [ + "fuchsia.sysmem.Allocator", + "fuchsia.vulkan.loader.Loader", + "fuchsia.tracelink.Registry" + ] + } +} -- GitLab