Fix colorspace on headset
This commit is contained in:
@@ -63,7 +63,7 @@ struct wivrn::android::decoder::pipeline_context
|
||||
vkDestroySamplerYcbcrConversion(device, ycbcr_conversion, nullptr);
|
||||
}
|
||||
|
||||
pipeline_context(VkDevice device, VkAndroidHardwareBufferFormatPropertiesANDROID & ahb_format, VkRenderPass renderpass) :
|
||||
pipeline_context(VkDevice device, VkAndroidHardwareBufferFormatPropertiesANDROID & ahb_format, VkRenderPass renderpass, const to_headset::video_stream_description::item& description) :
|
||||
device(device), ahb_format(ahb_format)
|
||||
{
|
||||
assert(ahb_format.externalFormat != 0);
|
||||
@@ -102,6 +102,11 @@ struct wivrn::android::decoder::pipeline_context
|
||||
.yChromaOffset = ahb_format.suggestedYChromaOffset,
|
||||
.chromaFilter = yuv_filter,
|
||||
};
|
||||
// suggested values from decoder don't actually read the metadata, so it's garbage
|
||||
if (description.range)
|
||||
ycbcr_create_info.ycbcrRange = VkSamplerYcbcrRange(*description.range);
|
||||
if (description.color_model)
|
||||
ycbcr_create_info.ycbcrModel = VkSamplerYcbcrModelConversion(*description.color_model);
|
||||
|
||||
CHECK_VK(vkCreateSamplerYcbcrConversion(device, &ycbcr_create_info, nullptr, &ycbcr_conversion));
|
||||
|
||||
@@ -615,7 +620,7 @@ std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AI
|
||||
if (!pipeline || memcmp(&pipeline->ahb_format, &format_properties, sizeof(format_properties)))
|
||||
{
|
||||
pipeline.reset();
|
||||
pipeline = std::make_shared<pipeline_context>(device, format_properties, renderpass);
|
||||
pipeline = std::make_shared<pipeline_context>(device, format_properties, renderpass, description);
|
||||
hardware_buffer_map.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,25 @@ layout(location = 0) in vec2 inUV;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
float sRGB_to_linear(float x)
|
||||
{
|
||||
if (x <= 0.04045)
|
||||
return x / 12.92;
|
||||
return pow((x + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
|
||||
vec4 sRGB_to_linear_rgba(vec4 x)
|
||||
{
|
||||
return vec4(
|
||||
sRGB_to_linear(x.r),
|
||||
sRGB_to_linear(x.g),
|
||||
sRGB_to_linear(x.b),
|
||||
x.a
|
||||
);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
outColor = texture(texSampler, inUV);
|
||||
outColor = sRGB_to_linear_rgba(texture(texSampler, inUV));
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user