| 72 | namespace wivrn |
| 73 | { |
| 74 | raw_decoder::raw_decoder( |
| 75 | vk::raii::Device & device, |
| 76 | vk::raii::PhysicalDevice & physical_device, |
| 77 | uint32_t vk_queue_family_index, |
| 78 | const wivrn::to_headset::video_stream_description & description, |
| 79 | uint8_t stream_index, |
| 80 | std::weak_ptr<scenes::stream> scene, |
| 81 | shard_accumulator * accumulator) : |
| 82 | device(device), |
| 83 | ycbcr_conversion(stream_index == 2 ? nullptr : vk::raii::SamplerYcbcrConversion(device, { |
| 84 | .format = vk::Format::eG8B8R82Plane420Unorm, |
| 85 | .ycbcrModel = vk::SamplerYcbcrModelConversion::eYcbcr709, |
| 86 | .ycbcrRange = vk::SamplerYcbcrRange::eItuFull, |
| 87 | .chromaFilter = vk::Filter::eNearest, |
| 88 | })), |
| 89 | sampler_(make_sampler(device, *ycbcr_conversion)), |
| 90 | command_pool(device, vk::CommandPoolCreateInfo{ |
| 91 | .flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer, |
| 92 | .queueFamilyIndex = vk_queue_family_index, |
| 93 | }), |
| 94 | cmd(device.allocateCommandBuffers(vk::CommandBufferAllocateInfo{ |
| 95 | .commandPool = *command_pool, |
| 96 | .commandBufferCount = 1, |
| 97 | })[0] |
| 98 | .release()), |
| 99 | fence(device, vk::FenceCreateInfo{.flags = vk::FenceCreateFlagBits::eSignaled}), |
| 100 | stream_index(stream_index), |
| 101 | extent{ |
| 102 | .width = description.width, |
| 103 | .height = description.height / (stream_index == 2 ? 2u : 1u), |
| 104 | }, |
| 105 | weak_scene(scene), |
| 106 | accumulator(accumulator) |
| 107 | { |
| 108 | vk::DeviceSize buffer_size = extent.width * extent.height; |
| 109 | vk::Format format{}; |
| 110 | switch (stream_index) |
| 111 | { |
| 112 | case 0: // colour left |
| 113 | case 1: // colour right |
| 114 | buffer_size += buffer_size / 2; |
| 115 | format = vk::Format::eG8B8R82Plane420Unorm; |
| 116 | break; |
| 117 | case 2: // alpha (monochrome) |
| 118 | format = vk::Format::eR8Unorm; |
| 119 | break; |
| 120 | } |
| 121 | for (auto & i: input) |
| 122 | { |
| 123 | i = buffer_allocation( |
| 124 | device, |
| 125 | { |
| 126 | .size = buffer_size, |
| 127 | .usage = vk::BufferUsageFlagBits::eTransferSrc, |
| 128 | }, |
| 129 | { |
| 130 | .flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT, |
| 131 | .usage = VMA_MEMORY_USAGE_AUTO, |
nothing calls this directly
no test coverage detected