From f3ae5d62f9acfdf41b8434e8cc29ddbbe0ac8586 Mon Sep 17 00:00:00 2001 From: swinston Date: Mon, 5 Dec 2022 15:23:48 -0800 Subject: [PATCH 1/9] add ninja-build to the Dockerfile. --- .github/docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index adfb4815e..3bfc0ee0d 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -40,6 +40,7 @@ RUN apt-get update && apt-get install -y \ libglu1-mesa-dev \ xorg-dev \ adb \ + ninja-build \ software-properties-common RUN pip3 --no-cache-dir install \ From a1b60c82fb755fff8dd49f33bac9519f68279373 Mon Sep 17 00:00:00 2001 From: swinston Date: Sun, 12 Mar 2023 15:33:04 -0700 Subject: [PATCH 2/9] first checkin of vk_video --- samples/extensions/video/CMakeLists.txt | 30 ++++++ samples/extensions/video/VideoProcessor.cpp | 5 + samples/extensions/video/VideoProcessor.h | 12 +++ samples/extensions/video/video.cpp | 107 ++++++++++++++++++++ samples/extensions/video/video.h | 42 ++++++++ 5 files changed, 196 insertions(+) create mode 100644 samples/extensions/video/CMakeLists.txt create mode 100644 samples/extensions/video/VideoProcessor.cpp create mode 100644 samples/extensions/video/VideoProcessor.h create mode 100644 samples/extensions/video/video.cpp create mode 100644 samples/extensions/video/video.h diff --git a/samples/extensions/video/CMakeLists.txt b/samples/extensions/video/CMakeLists.txt new file mode 100644 index 000000000..44132e605 --- /dev/null +++ b/samples/extensions/video/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (c) 2023, Holochip Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# 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. +# + +get_filename_component(FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +get_filename_component(PARENT_DIR ${CMAKE_CURRENT_LIST_DIR} PATH) +get_filename_component(CATEGORY_NAME ${PARENT_DIR} NAME) + +add_sample( + ID ${FOLDER_NAME} + CATEGORY ${CATEGORY_NAME} + AUTHOR "Holochip" + NAME "video" + DESCRIPTION "Sample description" + FILES + VideoProcessor.cpp +) diff --git a/samples/extensions/video/VideoProcessor.cpp b/samples/extensions/video/VideoProcessor.cpp new file mode 100644 index 000000000..66102482a --- /dev/null +++ b/samples/extensions/video/VideoProcessor.cpp @@ -0,0 +1,5 @@ +// +// Created by swinston on 3/12/23. +// + +#include "VideoProcessor.h" diff --git a/samples/extensions/video/VideoProcessor.h b/samples/extensions/video/VideoProcessor.h new file mode 100644 index 000000000..4bd7c8212 --- /dev/null +++ b/samples/extensions/video/VideoProcessor.h @@ -0,0 +1,12 @@ +// +// Created by swinston on 3/12/23. +// + +#ifndef VULKAN_SAMPLES_VIDEOPROCESSOR_H +#define VULKAN_SAMPLES_VIDEOPROCESSOR_H + +class VideoProcessor +{ +}; + +#endif // VULKAN_SAMPLES_VIDEOPROCESSOR_H diff --git a/samples/extensions/video/video.cpp b/samples/extensions/video/video.cpp new file mode 100644 index 000000000..c23790c77 --- /dev/null +++ b/samples/extensions/video/video.cpp @@ -0,0 +1,107 @@ +/* Copyright (c) 2023, Holochip Inc. + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#include "video.h" + +#include "gltf_loader.h" +#include "rendering/subpasses/forward_subpass.h" + +video::video(): + pipeline(VK_NULL_HANDLE), pipeline_layout(VK_NULL_HANDLE), descriptor_set(VK_NULL_HANDLE), descriptor_set_layout(VK_NULL_HANDLE) +{ + title = "Compute shader N-body simulation using VK_KHR_synchronization2"; + camera.type = vkb::CameraType::LookAt; + + // Note: Using Reversed depth-buffer for increased precision, so Z-Near and Z-Far are flipped + camera.set_perspective(60.0f, static_cast(width) / static_cast(height), 512.0f, 0.1f); + camera.set_rotation(glm::vec3(0.0f, 0.0f, 0.0f)); + camera.set_translation(glm::vec3(0.0f, 0.0f, -14.0f)); + camera.translation_speed = 2.5f; + + // Vulkan Video required extensions + add_device_extension(VK_EXT_YCBCR_2PLANE_444_FORMATS_EXTENSION_NAME); + add_device_extension(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); + add_device_extension(VK_KHR_VIDEO_QUEUE_EXTENSION_NAME); + add_device_extension(VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME); +} + +video::~video() { + if (device) + { + vkDestroyPipeline(get_device().get_handle(), pipeline, nullptr); + vkDestroyPipelineLayout(get_device().get_handle(), pipeline_layout, nullptr); + vkDestroyDescriptorSetLayout(get_device().get_handle(), descriptor_set_layout, nullptr); + } +} + +void video::draw() +{ + ApiVulkanSample::prepare_frame(); + submit_info.commandBufferCount = 1; + submit_info.pCommandBuffers = &draw_cmd_buffers[current_buffer]; + + // Submit to queue + VK_CHECK(vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE)); + + ApiVulkanSample::submit_frame(); +} + +void video::build_command_buffers() +{ + +} + +bool video::prepare(vkb::Platform &platform) +{ + if (!ApiVulkanSample::prepare(platform)) + { + return false; + } + + // Load a scene from the assets folder + load_scene("scenes/sponza/Sponza01.gltf"); + + // Attach a move script to the camera component in the scene + auto &camera_node = vkb::add_free_camera(*scene, "main_camera", get_render_context().get_surface_extent()); + auto camera = &camera_node.get_component(); + + // Example Scene Render Pipeline + vkb::ShaderSource vert_shader("base.vert"); + vkb::ShaderSource frag_shader("base.frag"); + auto scene_sub_pass = std::make_unique(get_render_context(), std::move(vert_shader), std::move(frag_shader), *scene, *camera); + auto render_pipeline = vkb::RenderPipeline(); + render_pipeline.add_subpass(std::move(scene_sub_pass)); + set_render_pipeline(std::move(render_pipeline)); + + // Add a GUI with the stats you want to monitor + stats->request_stats({/*stats you require*/}); + gui = std::make_unique(*this, platform.get_window(), stats.get()); + + return true; +} + +void video::render(float delta_time) +{ + if (!prepared) + return; + draw(); +} + +std::unique_ptr create_video() +{ + return std::make_unique