Select Git revision
rubocop-base.yml
-
Darius Schneider authoredDarius Schneider authored
dual_layer_reprojection.hpp 4.26 KiB
#pragma once
#include <memory>
#include "stereo_strategy.hpp"
namespace glsl
{
#include "res/dpr/strategy/dual_layer_reprojection/dual_layer_reprojection_defines.inc"
}
enum DualLayerReprojectionOverlay : uint32_t
{
DUAL_LAYER_REPROJECTION_OVERLAY_COLOR,
DUAL_LAYER_REPROJECTION_OVERLAY_ENCODED_DEPTH
};
enum DualLayerReprojectionDepthEncoding : uint32_t
{
DUAL_LAYER_REPROJECTION_DEPTH_ENCODING_NONE,
DUAL_LAYER_REPROJECTION_DEPTH_ENCODING_LOW_HIGH_FREQUENCY,
DUAL_LAYER_REPROJECTION_DEPTH_ENCODING_LOW_HIGH_FREQUENCY_LINEAR,
DUAL_LAYER_REPROJECTION_DEPTH_ENCODING_BIT_PACKING
};
enum DualLayerReprojectionReprojectThreshold : uint32_t
{
DUAL_LAYER_REPROJECTION_REPROJECT_THRESHOLD_TEXTURE_COORDINATES,
DUAL_LAYER_REPROJECTION_REPROJECT_THRESHOLD_DEPTH_GRADIENT,
DUAL_LAYER_REPROJECTION_REPROJECT_THRESHOLD_DEPTH_GRADIENT_LINEAR,
DUAL_LAYER_REPROJECTION_REPROJECT_THRESHOLD_GEOMETRY
};
struct DualLayerReprojectionMetadata
{
DualLayerReprojectionDepthEncoding depth_encoding;
DualLayerReprojectionReprojectThreshold reproject_threshold;
glm::mat4 projection_matrix;
glm::mat4 head_eye_projection_matrix;
glm::uvec2 layer_resolution;
float layer_separation;
float slope_threshold;
float subdivision_threshold;
float depth_low_high_frequency_factor;
float debug_value;
bool wireframe;
bool performance_view;
uint32_t subdivision_resolution;
};
class DualLayerReprojection : public StereoStrategy
{
public:
typedef std::shared_ptr<DualLayerReprojection> Ptr;
public:
DualLayerReprojection();
bool on_setup_remote() override;
bool on_create() override;
void on_destroy() override;
bool on_interface() override;
bool on_update(lava::delta delta_time) override;
bool on_render(VkCommandBuffer command_buffer, lava::index frame) override;
uint32_t get_remote_frame_id_count() const override;
EncoderFormat get_remote_frame_format(FrameId frame_id) const override;
glm::uvec2 get_remote_framebuffer_resolution() const override;
const char* get_name() const override;
private:
bool create_buffers();
bool create_samplers();
bool create_descriptors();
bool create_layer_pass();
bool create_layer_pipeline();
bool create_layer_subdivide_pipeline();
bool build_projection();
bool write_transform(lava::index frame);
void process_layer_pass(VkCommandBuffer command_buffer);
void process_layer_subdivide_pass(VkCommandBuffer command_buffer);
private:
bool setup_layout = true;
uint32_t layer = 0;
uint32_t overlay = DUAL_LAYER_REPROJECTION_OVERLAY_COLOR;
uint32_t depth_encoding = DUAL_LAYER_REPROJECTION_DEPTH_ENCODING_NONE;
uint32_t reproject_threshold = DUAL_LAYER_REPROJECTION_REPROJECT_THRESHOLD_DEPTH_GRADIENT;
float depth_low_high_frequency_factor = 1024.0f;
float layer_constant_threshold = 0.5f;
float layer_slope_threshold = 0.0f;
float reproject_slope_threshold = 0.05f;
float subdivision_threshold = 0.01f;
uint32_t subdivide_cell_border = 2;
float debug_value = 0.0f;
bool wireframe = false;
bool performance_view = false;
uint32_t subdivision_resolution = DUAL_LAYER_REPROJECTION_SUBDIVIDE_GROUP_SIZE;
glm::uvec2 layer_resolution = glm::uvec2(0);
glm::mat4 layer_projection_matrix = glm::mat4(1.0f);
glm::mat4 layer_head_to_eye_matrix = glm::mat4(1.0f);
std::vector<lava::buffer::ptr> transform_buffers;
std::array<lava::image::ptr, 2> layer_depth_buffers;
std::array<lava::image::ptr, 2> encoded_depth_buffers;
lava::descriptor::pool::ptr descriptor_pool;
lava::descriptor::ptr layer_descriptor;
lava::descriptor::ptr transform_descriptor;
lava::descriptor::ptr layer_encoded_depth_descriptor;
std::array<VkDescriptorSet, 2> layer_descriptor_sets;
std::array<VkDescriptorSet, 2> layer_encoded_depth_descriptor_sets;
std::vector<VkDescriptorSet> transform_descriptor_sets;
VkSampler layer_sampler = VK_NULL_HANDLE;
lava::render_pass::ptr layer_pass;
lava::pipeline_layout::ptr layer_pipeline_layout;
lava::graphics_pipeline::ptr layer_pipeline;
lava::pipeline_layout::ptr layer_subdivide_pipeline_layout;
lava::compute_pipeline::ptr layer_subdivide_pipeline;
};
DualLayerReprojection::Ptr make_dual_layer_reprojection();