Don't use extension for stream scale/bias
This commit is contained in:
+32
-31
@@ -977,10 +977,39 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(swapchain);
|
assert(swapchain);
|
||||||
// defoveate the image
|
// defoveate the image, apply scale/bias
|
||||||
int image_index = swapchain.acquire();
|
int image_index = swapchain.acquire();
|
||||||
swapchain.wait();
|
swapchain.wait();
|
||||||
defoveator->defoveate(command_buffer, foveation, images, image_index);
|
|
||||||
|
switch (gui_status)
|
||||||
|
{
|
||||||
|
case stream_tab::hidden:
|
||||||
|
case stream_tab::bitrate_settings:
|
||||||
|
case stream_tab::foveation_settings:
|
||||||
|
case stream_tab::compact:
|
||||||
|
case stream_tab::overlay_only:
|
||||||
|
dimming = dimming - frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||||
|
break;
|
||||||
|
case stream_tab::stats:
|
||||||
|
case stream_tab::settings:
|
||||||
|
case stream_tab::applications:
|
||||||
|
case stream_tab::application_launcher:
|
||||||
|
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dimming = std::clamp<float>(dimming, 0, 1);
|
||||||
|
float x = dimming * dimming * (3 - 2 * dimming); // Easing function
|
||||||
|
|
||||||
|
const float scale = std::lerp(1, constants::stream::dimming_scale, x);
|
||||||
|
const float bias = std::lerp(0, constants::stream::dimming_bias, x);
|
||||||
|
|
||||||
|
defoveator->defoveate(command_buffer,
|
||||||
|
foveation,
|
||||||
|
images,
|
||||||
|
{scale, scale, scale, 1.},
|
||||||
|
{bias, bias, bias, 0.},
|
||||||
|
image_index);
|
||||||
|
|
||||||
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
|
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
|
||||||
|
|
||||||
@@ -1043,38 +1072,10 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
add_projection_layer(
|
add_projection_layer(
|
||||||
XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
|
use_alpha ? XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT : 0,
|
||||||
application::space(xr::spaces::world),
|
application::space(xr::spaces::world),
|
||||||
layer_view);
|
layer_view);
|
||||||
|
|
||||||
if (composition_layer_color_scale_bias_supported)
|
|
||||||
{
|
|
||||||
switch (gui_status)
|
|
||||||
{
|
|
||||||
case stream_tab::hidden:
|
|
||||||
case stream_tab::bitrate_settings:
|
|
||||||
case stream_tab::foveation_settings:
|
|
||||||
case stream_tab::compact:
|
|
||||||
case stream_tab::overlay_only:
|
|
||||||
dimming = dimming - frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
|
||||||
break;
|
|
||||||
case stream_tab::stats:
|
|
||||||
case stream_tab::settings:
|
|
||||||
case stream_tab::applications:
|
|
||||||
case stream_tab::application_launcher:
|
|
||||||
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dimming = std::clamp<float>(dimming, 0, 1);
|
|
||||||
float x = dimming * dimming * (3 - 2 * dimming); // Easing function
|
|
||||||
|
|
||||||
float scale = std::lerp(1, constants::stream::dimming_scale, x);
|
|
||||||
float bias = std::lerp(0, constants::stream::dimming_bias, x);
|
|
||||||
|
|
||||||
set_color_scale_bias({scale, scale, scale, 1}, {bias, bias, bias, 0});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const configuration::openxr_post_processing_settings openxr_post_processing = application::get_config().openxr_post_processing;
|
if (const configuration::openxr_post_processing_settings openxr_post_processing = application::get_config().openxr_post_processing;
|
||||||
(openxr_post_processing.sharpening | openxr_post_processing.super_sampling) > 0)
|
(openxr_post_processing.sharpening | openxr_post_processing.super_sampling) > 0)
|
||||||
set_layer_settings(openxr_post_processing.sharpening | openxr_post_processing.super_sampling);
|
set_layer_settings(openxr_post_processing.sharpening | openxr_post_processing.super_sampling);
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ struct vert_pc
|
|||||||
{
|
{
|
||||||
glm::ivec4 rgb_rect;
|
glm::ivec4 rgb_rect;
|
||||||
glm::ivec4 a_rect;
|
glm::ivec4 a_rect;
|
||||||
|
std::array<float, 4> scale;
|
||||||
|
std::array<float, 4> bias;
|
||||||
};
|
};
|
||||||
|
|
||||||
void stream_defoveator::ensure_vertices(size_t num_vertices)
|
void stream_defoveator::ensure_vertices(size_t num_vertices)
|
||||||
@@ -304,6 +306,8 @@ static size_t required_vertices(const wivrn::to_headset::foveation_parameter & p
|
|||||||
void stream_defoveator::defoveate(vk::raii::CommandBuffer & command_buffer,
|
void stream_defoveator::defoveate(vk::raii::CommandBuffer & command_buffer,
|
||||||
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
|
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
|
||||||
const std::array<input, 2> & inputs,
|
const std::array<input, 2> & inputs,
|
||||||
|
std::array<float, 4> scale,
|
||||||
|
std::array<float, 4> bias,
|
||||||
int destination)
|
int destination)
|
||||||
{
|
{
|
||||||
if (destination < 0 || destination >= (int)output_images.size())
|
if (destination < 0 || destination >= (int)output_images.size())
|
||||||
@@ -424,6 +428,8 @@ void stream_defoveator::defoveate(vk::raii::CommandBuffer & command_buffer,
|
|||||||
input.rect_a.offset.y,
|
input.rect_a.offset.y,
|
||||||
input.rect_a.extent.width,
|
input.rect_a.extent.width,
|
||||||
input.rect_a.extent.height),
|
input.rect_a.extent.height),
|
||||||
|
.scale = scale,
|
||||||
|
.bias = bias,
|
||||||
};
|
};
|
||||||
|
|
||||||
device.updateDescriptorSets(descriptor_writes, {});
|
device.updateDescriptorSets(descriptor_writes, {});
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ public:
|
|||||||
vk::raii::CommandBuffer & command_buffer,
|
vk::raii::CommandBuffer & command_buffer,
|
||||||
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
|
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
|
||||||
const std::array<input, 2> & inputs,
|
const std::array<input, 2> & inputs,
|
||||||
|
std::array<float, 4> scale,
|
||||||
|
std::array<float, 4> bias,
|
||||||
int destination);
|
int destination);
|
||||||
|
|
||||||
static XrExtent2Di defoveated_size(const wivrn::to_headset::foveation_parameter &);
|
static XrExtent2Di defoveated_size(const wivrn::to_headset::foveation_parameter &);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ layout(push_constant) uniform pc
|
|||||||
{
|
{
|
||||||
ivec4 rgb_rect;
|
ivec4 rgb_rect;
|
||||||
ivec4 a_rect;
|
ivec4 a_rect;
|
||||||
|
vec4 scale;
|
||||||
|
vec4 bias;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef VERT_SHADER
|
#ifdef VERT_SHADER
|
||||||
@@ -85,6 +87,21 @@ void main()
|
|||||||
{
|
{
|
||||||
outColor = sRGB_to_linear_rgba(outColor);
|
outColor = sRGB_to_linear_rgba(outColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alpha == 0)
|
||||||
|
{
|
||||||
|
outColor = outColor * scale + bias;
|
||||||
|
}
|
||||||
|
else if (outColor.a < 0.02)
|
||||||
|
{
|
||||||
|
outColor = vec4(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outColor.rgb /= outColor.a;
|
||||||
|
outColor = outColor * scale + bias;
|
||||||
|
outColor.rgb *= outColor.a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user