Only write alpha if useful

This commit is contained in:
Patrick Nicolas
2026-04-11 16:55:02 +02:00
parent 9bb39c4809
commit 1f6e237f21
4 changed files with 18 additions and 8 deletions
+2 -1
View File
@@ -427,7 +427,8 @@ xrt_result_t compositor::layer_commit(xrt_graphics_sync_handle_t sync_handle)
flip_y,
src,
src_rect,
src_fov);
src_fov,
view_info.alpha);
for (auto & encoder: encoders)
{
+6 -2
View File
@@ -42,6 +42,7 @@ struct ubo_data
uint32_t x[XRT_MAX_VIEWS * RENDER_FOVEATION_BUFFER_DIMENSIONS];
uint32_t y[XRT_MAX_VIEWS * RENDER_FOVEATION_BUFFER_DIMENSIONS];
uint32_t alpha_width;
VkBool32 alpha;
};
vk::raii::Sampler make_sampler(wivrn::vk_bundle & vk)
@@ -512,7 +513,6 @@ void foveation::update_ubo(
compute_params();
auto ubo = gpu_buffer.data<ubo_data>();
ubo->alpha_width = foveated_size.width / 2;
for (size_t view = 0; view < 2; ++view)
{
bool flip = false;
@@ -565,9 +565,13 @@ std::array<to_headset::foveation_parameter, 2> foveation::foveate(
bool flip_y,
std::array<vk::ImageView, 2> src,
std::array<xrt_rect, 2> src_rect,
std::array<xrt_fov, 2> src_fov)
std::array<xrt_fov, 2> src_fov,
bool alpha)
{
update_ubo(cmd, flip_y, src_rect, src_fov);
auto ubo = gpu_buffer.data<ubo_data>();
ubo->alpha_width = foveated_size.width / 2;
ubo->alpha = alpha;
std::array src_image_info{
vk::DescriptorImageInfo{
+2 -1
View File
@@ -96,6 +96,7 @@ public:
bool flip_y,
std::array<vk::ImageView, 2> src,
std::array<xrt_rect, 2> src_rect,
std::array<xrt_fov, 2> src_fov);
std::array<xrt_fov, 2> src_fov,
bool alpha);
};
} // namespace wivrn
+8 -4
View File
@@ -37,6 +37,7 @@ layout(set = 0, binding = 1, std430) buffer restrict Config
uint y[2*MAX_DIM];
// output parameters
uint alpha_width;
bool alpha;
} ubo;
layout(set = 0, binding = 2) uniform writeonly restrict image2DArray luma;
@@ -125,9 +126,12 @@ void main()
// actual chroma
imageStore(chroma, ivec3(ix/2, iy/2, iz), vec4(sum.y, sum.z, 0, 0) / 4);
// alpha in luma
int offset = int(ubo.alpha_width * iz);
imageStore(luma, ivec3(offset + ix/2, iy/2, 2), vec4(sum.w, 0, 0, 0) / 4);
imageStore(chroma, ivec3(offset + ix/2, iy/2, 2), vec4(0.5, 0.5, 0, 0));
if (ubo.alpha)
{
// alpha in luma
int offset = int(ubo.alpha_width * iz);
imageStore(luma, ivec3(offset + ix/2, iy/2, 2), vec4(sum.w, 0, 0, 0) / 4);
imageStore(chroma, ivec3(offset + ix/2, iy/2, 2), vec4(0.5, 0.5, 0, 0));
}
}
}