This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void EnvMapLoader::create_specular_map(ftl::TaskScheduler* scheduler, ph::VulkanContext& vulkan, EnvMapProcessData& process_data) { | |
| const uint32_t mip_count = std::log2(process_data.specular_map_base_size) + 1; | |
| process_data.specular_map = ph::create_image(vulkan, process_data.specular_map_base_size, process_data.specular_map_base_size, | |
| ph::ImageType::EnvMap, vk::Format::eR32G32B32A32Sfloat, 6, mip_count); | |
| process_data.specular_map_view = ph::create_image_view(vulkan.device, process_data.specular_map); | |
| process_data.specular_map_mips.resize(mip_count); | |
| for (uint32_t level = 0; level < mip_count; ++level) { | |
| process_data.specular_map_mips[level] = ph::create_image_view_level(vulkan.device, process_data.specular_map, level); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #version 450 | |
| #extension GL_EXT_nonuniform_qualifier : enable | |
| #define MAX_LIGHT_COUNT 32 | |
| layout(location = 0) in vec2 TexCoords; | |
| layout(location = 1) in vec3 FragPos; | |
| layout(location = 2) in vec3 ViewPos; | |
| layout(location = 3) in mat3 TBN; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Mesh::create_index_buffer(CreateInfo const& info) { | |
| index_count = info.index_count; | |
| vk::DeviceSize byte_size = info.index_count * sizeof(uint32_t); | |
| vk::Buffer staging_buffer; | |
| VmaAllocation staging_buffer_memory; | |
| create_buffer(*ctx, byte_size, BufferType::TransferBuffer, staging_buffer, staging_buffer_memory); | |
| // Fill staging buffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() { | |
| DefaultLogger logger; | |
| logger.set_timestamp(true); | |
| // Create window context | |
| ph::WindowContext* window_context = ph::create_window_context("Phobos Test App", 1280, 720); | |
| // Create Vulkan context | |
| ph::AppSettings settings; | |
| settings.enable_validation_layers = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vk::CommandBuffer cmd_buffer = info.command_buffer; | |
| // Record command buffer | |
| vk::CommandBufferBeginInfo begin_info; | |
| begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit; | |
| cmd_buffer.begin(begin_info); | |
| update_camera_data(info, info.render_graph); | |
| update_materials(info, info.render_graph); | |
| update_lights(info, info.render_graph); | |
| update_model_matrices(info, info.render_graph); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create RenderGraph | |
| ph::RenderGraph* render_graph = new ph::RenderGraph(vulkan_context); | |
| // Setup render target for the main renderpass | |
| auto& offscreen_attachment = present_manager.get_attachment("color1"); | |
| auto& depth_attachment = present_manager.get_attachment("depth1"); | |
| stl::vector<ph::RenderAttachment> offscreen_attachments; | |
| offscreen_attachments.push_back(offscreen_attachment); | |
| offscreen_attachments.push_back(depth_attachment); | |
| frame_info.offscreen_target = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ph::RenderPass main_pass; | |
| main_pass.sampled_attachments = {}; | |
| main_pass.outputs.push_back(offscreen_attachment); | |
| main_pass.outputs.push_back(depth_attachment); | |
| // Set materials | |
| main_pass.materials.push_back(default_material); | |
| // Add lights | |
| scene.light.position.x = std::sin(time) * 2.0f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static vk::ImageLayout get_final_layout(stl::span<RenderPass> passes, stl::span<RenderPass>::iterator pass, | |
| stl::vector<RenderAttachment>::iterator attachment) { | |
| // For the final layout, there are 3 (4?) options: | |
| // 1. The attachment is used later as an input attachment. | |
| // In this case, finalLayout becomes eShaderReadOnlyOptimal | |
| // 2. The attachement is used later to present | |
| // In this case, finalLayout becomes ePresentSrcKHR | |
| // 3. The attachment is not used later | |
| // In this case, finalLayout becomes the corresponding format's output attachemnt layout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <win/platform.h> | |
| #include <internal.h> | |
| #include <utils.h> | |
| #include <mimas/mimas.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <windows.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef STL_MEMORY_HPP_ | |
| #define STL_MEMORY_HPP_ | |
| #include <stl/types.hpp> | |
| #include <stl/traits.hpp> | |
| namespace stl { | |
| template<typename T> | |
| T&& forward(typename identity<T>::type&& param) { |