Only blit useful part of the stream
With odd image size, encoders may add black borders. We need to properly ignore it on the headset side
This commit is contained in:
committed by
Guillaume Meunier
parent
21311baf8e
commit
b1cb28200d
@@ -63,7 +63,7 @@ struct wivrn::android::decoder::pipeline_context
|
|||||||
vkDestroySamplerYcbcrConversion(device, ycbcr_conversion, nullptr);
|
vkDestroySamplerYcbcrConversion(device, ycbcr_conversion, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline_context(VkDevice device, VkAndroidHardwareBufferFormatPropertiesANDROID & ahb_format, VkRenderPass renderpass, const to_headset::video_stream_description::item& description) :
|
pipeline_context(VkDevice device, const AHardwareBuffer_Desc& buffer_desc, VkAndroidHardwareBufferFormatPropertiesANDROID & ahb_format, VkRenderPass renderpass, const to_headset::video_stream_description::item& description) :
|
||||||
device(device), ahb_format(ahb_format)
|
device(device), ahb_format(ahb_format)
|
||||||
{
|
{
|
||||||
assert(ahb_format.externalFormat != 0);
|
assert(ahb_format.externalFormat != 0);
|
||||||
@@ -168,6 +168,22 @@ struct wivrn::android::decoder::pipeline_context
|
|||||||
poolInfo.maxSets = poolSize.descriptorCount;
|
poolInfo.maxSets = poolSize.descriptorCount;
|
||||||
CHECK_VK(vkCreateDescriptorPool(device, &poolInfo, nullptr, &descriptor_pool));
|
CHECK_VK(vkCreateDescriptorPool(device, &poolInfo, nullptr, &descriptor_pool));
|
||||||
|
|
||||||
|
float useful_size[] =
|
||||||
|
{
|
||||||
|
float(description.width) / buffer_desc.width,
|
||||||
|
float(description.height) / buffer_desc.height
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<VkSpecializationMapEntry> specialization_constants_desc{
|
||||||
|
{.constantID = 0, .offset = 0, .size = sizeof(float)},
|
||||||
|
{.constantID = 1, .offset = sizeof(float), .size = sizeof(float)}};
|
||||||
|
|
||||||
|
VkSpecializationInfo specialization_info{
|
||||||
|
.mapEntryCount = (uint32_t)specialization_constants_desc.size(),
|
||||||
|
.pMapEntries = specialization_constants_desc.data(),
|
||||||
|
.dataSize = sizeof(useful_size),
|
||||||
|
.pData = &useful_size};
|
||||||
|
|
||||||
// Create graphics pipeline
|
// Create graphics pipeline
|
||||||
vk::shader vertex_shader(device, "stream.vert");
|
vk::shader vertex_shader(device, "stream.vert");
|
||||||
vk::shader fragment_shader(device, "stream.frag");
|
vk::shader fragment_shader(device, "stream.frag");
|
||||||
@@ -180,7 +196,7 @@ struct wivrn::android::decoder::pipeline_context
|
|||||||
|
|
||||||
vk::pipeline::graphics_info pipeline_info{
|
vk::pipeline::graphics_info pipeline_info{
|
||||||
.shader_stages =
|
.shader_stages =
|
||||||
{{.stage = VK_SHADER_STAGE_VERTEX_BIT, .module = vertex_shader, .pName = "main"},
|
{{.stage = VK_SHADER_STAGE_VERTEX_BIT, .module = vertex_shader, .pName = "main", .pSpecializationInfo = &specialization_info},
|
||||||
{.stage = VK_SHADER_STAGE_FRAGMENT_BIT, .module = fragment_shader, .pName = "main"}},
|
{.stage = VK_SHADER_STAGE_FRAGMENT_BIT, .module = fragment_shader, .pName = "main"}},
|
||||||
.vertex_input_bindings = {},
|
.vertex_input_bindings = {},
|
||||||
.vertex_input_attributes = {},
|
.vertex_input_attributes = {},
|
||||||
@@ -629,7 +645,7 @@ std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AI
|
|||||||
if (!pipeline || memcmp(&pipeline->ahb_format, &format_properties, sizeof(format_properties)))
|
if (!pipeline || memcmp(&pipeline->ahb_format, &format_properties, sizeof(format_properties)))
|
||||||
{
|
{
|
||||||
pipeline.reset();
|
pipeline.reset();
|
||||||
pipeline = std::make_shared<pipeline_context>(device, format_properties, renderpass, description);
|
pipeline = std::make_shared<pipeline_context>(device, buffer_desc, format_properties, renderpass, description);
|
||||||
hardware_buffer_map.clear();
|
hardware_buffer_map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
#ifdef VERT_SHADER
|
#ifdef VERT_SHADER
|
||||||
|
|
||||||
|
layout (constant_id = 0) const float useful_size_x = 1.0;
|
||||||
|
layout (constant_id = 1) const float useful_size_y = 1.0;
|
||||||
|
|
||||||
vec2 positions[3] = vec2[](
|
vec2 positions[3] = vec2[](
|
||||||
vec2(-1.0, -1.0),
|
vec2(-1.0, -1.0),
|
||||||
vec2(3.0, -1.0),
|
vec2(3.0, -1.0),
|
||||||
@@ -27,8 +31,8 @@ vec2 positions[3] = vec2[](
|
|||||||
|
|
||||||
vec2 uvs[3] = vec2[](
|
vec2 uvs[3] = vec2[](
|
||||||
vec2(0.0, 0.0),
|
vec2(0.0, 0.0),
|
||||||
vec2(2.0, 0.0),
|
vec2(2.0 * useful_size_x, 0.0),
|
||||||
vec2(0.0, 2.0));
|
vec2(0.0, 2.0 * useful_size_y));
|
||||||
|
|
||||||
layout(location = 0) out vec2 outUV;
|
layout(location = 0) out vec2 outUV;
|
||||||
|
|
||||||
|
|||||||
@@ -150,10 +150,10 @@ static void create_encoders(wivrn_comp_target * cn, std::vector<encoder_settings
|
|||||||
|
|
||||||
for (auto & settings: _settings)
|
for (auto & settings: _settings)
|
||||||
{
|
{
|
||||||
|
desc.items.push_back(settings);
|
||||||
uint8_t stream_index = cn->encoders.size();
|
uint8_t stream_index = cn->encoders.size();
|
||||||
auto & encoder = cn->encoders.emplace_back(
|
auto & encoder = cn->encoders.emplace_back(
|
||||||
VideoEncoder::Create(vk, settings, stream_index, desc.width, desc.height, desc.fps));
|
VideoEncoder::Create(vk, settings, stream_index, desc.width, desc.height, desc.fps));
|
||||||
desc.items.push_back(settings);
|
|
||||||
|
|
||||||
std::vector<VkImage> images(cn->image_count);
|
std::vector<VkImage> images(cn->image_count);
|
||||||
std::vector<VkDeviceMemory> memory(cn->image_count);
|
std::vector<VkDeviceMemory> memory(cn->image_count);
|
||||||
|
|||||||
Reference in New Issue
Block a user