HoviTron Video Pipeline
Public Member Functions | Static Public Attributes
BufferControllerBlending Class Reference

Class that manages ressources for the blending pipeline. More...

#include <BuffersControllerBlending.h>

Inheritance diagram for BufferControllerBlending:
BuffersController

Public Member Functions

 BufferControllerBlending (VulkanContext *context, VulkanRenderPass *renderpass, VulkanPipelineBlending *pipeline, VulkanWrapper *wraps, int inputView)
 
void init () override
 
void bindBuffers (vk::CommandBuffer &commandBuffer, int index, InputProvider::StreamFrameInfo &frameInfo, int view) override
 
void updateAllUniformBuffer (uint32_t currentImage, int view) override
 
void updateUniformBuffer (uint32_t currentImage, int view) override
 
void cleanUp () override
 
vk::VertexInputBindingDescription getBindingDescription () override
 
std::vector< vk::VertexInputAttributeDescription > getAttributeDescription () override
 
void update (std::span< InputProvider::StreamFrameInfo > infos, int view) override
 
uint32_t getIndiceCount () override
 
virtual void init ()=0
 
virtual void cleanUp ()=0
 
virtual void bindBuffers (vk::CommandBuffer &commandBuffer, int index, InputProvider::StreamFrameInfo &frameInfos, int view)=0
 
virtual void updateAllUniformBuffer (uint32_t currentImage, int view)=0
 
virtual void updateUniformBuffer (uint32_t currentImage, int view)=0
 
virtual void update (std::span< InputProvider::StreamFrameInfo > infos, int inputView)=0
 
virtual vk::VertexInputBindingDescription getBindingDescription ()=0
 
virtual std::vector< vk::VertexInputAttributeDescription > getAttributeDescription ()=0
 
virtual uint32_t getIndiceCount ()=0
 

Static Public Attributes

static std::vector< uint32_t > indices
 

Additional Inherited Members

- Protected Member Functions inherited from BuffersController
virtual void createVertexBuffer ()=0
 
virtual void createIndexBuffer ()=0
 
virtual void createUniformBuffer (int size)=0
 
virtual void createDescriptorPool ()=0
 
virtual void createDescriptorSets ()=0
 
void copyBuffer (vk::Buffer srcBuffer, vk::Buffer dstBuffer, vk::DeviceSize size)
 
- Protected Attributes inherited from BuffersController
int inputView = 0
 
VulkanContextcontext = nullptr
 
VulkanRenderPassrenderpass = nullptr
 

Detailed Description

Class that manages ressources for the blending pipeline.

Class that manages ressources for the blending pipeline. From vertex+indices buffers to samplers and uniforms buffers. It is also in charge of the descriptor set.

Definition at line 51 of file BuffersControllerBlending.h.

Constructor & Destructor Documentation

◆ BufferControllerBlending()

BufferControllerBlending::BufferControllerBlending ( VulkanContext context,
VulkanRenderPass renderpass,
VulkanPipelineBlending pipeline,
VulkanWrapper wraps,
int  inputView 
)

Constructor

Definition at line 25 of file BuffersControllerBlending.cpp.

26{
27 this->context = context;
28 this->renderpass = renderpass;
29 this->pipeline = pipeline;
30 this->inputView = inputView;
31 this->wrapper = wraps;
32
33 attachmentCount = wrapper->multiviewSetup ? wrapper->getViewNumber() : wrapper->getAttachmentSize();
34}
VulkanRenderPass * renderpass
const bool multiviewSetup

Member Function Documentation

◆ bindBuffers()

void BufferControllerBlending::bindBuffers ( vk::CommandBuffer &  commandBuffer,
int  index,
InputProvider::StreamFrameInfo frameInfo,
int  view 
)
overridevirtual

Bind buffers for the uniform

Implements BuffersController.

Definition at line 259 of file BuffersControllerBlending.cpp.

260{
261 int index = wrapper->multiviewSetup ? view : currentSwapIndex ;
262 vk::Buffer vertexBuffers[] = { vertexBuffer };
263 vk::DeviceSize offsets[] = { 0 };
264 commandBuffer.bindVertexBuffers(0, 1, vertexBuffers, offsets);
265 commandBuffer.bindIndexBuffer(indexBuffer, 0, vk::IndexType::eUint32);
266
267 commandBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipeline->pipelineLayout, 0, 1, &descriptorSets[index], 0, nullptr);
268}
vk::PipelineLayout pipelineLayout

◆ cleanUp()

void BufferControllerBlending::cleanUp ( )
overridevirtual

CleanUp ressources

Implements BuffersController.

Definition at line 292 of file BuffersControllerBlending.cpp.

293{
294 for (size_t i = 0; i < uniformBuffers.size(); i++) {
295 context->device.destroyBuffer(uniformBuffers[i], nullptr);
296 context->device.freeMemory(uniformBuffersMemory[i], nullptr);
297 }
298
299 if (inputView == 0) {
300 context->device.destroyBuffer(vertexBuffer);
301 context->device.freeMemory(vertexBufferMemory, nullptr);
302
303 context->device.destroyBuffer(indexBuffer);
304 context->device.freeMemory(indexBufferMemory, nullptr);
305 }
306
307 context->device.destroyDescriptorPool(descriptorPool);
308}
vk::Device device
Definition: VulkanContext.h:87

◆ getAttributeDescription()

std::vector< vk::VertexInputAttributeDescription > BufferControllerBlending::getAttributeDescription ( )
overridevirtual

Return the attribute description (vk::VertexInputAttributeDescription) for the blending pipeline

Implements BuffersController.

Definition at line 320 of file BuffersControllerBlending.cpp.

321{
322 std::vector<vk::VertexInputAttributeDescription> attributeDescriptions{
323 vk::VertexInputAttributeDescription(
324 0, //location
325 0, //binding
326 vk::Format::eR32G32B32A32Sfloat, //format
327 0 //offset
328 ) };
329 return attributeDescriptions;
330}

◆ getBindingDescription()

vk::VertexInputBindingDescription BufferControllerBlending::getBindingDescription ( )
overridevirtual

Return the vk::VertexInputBindingDescription for the blending pipeline

Implements BuffersController.

Definition at line 310 of file BuffersControllerBlending.cpp.

311{
312 vk::VertexInputBindingDescription bindingDescription{
313 0, //binding
314 sizeof(glm::vec4), // stride
315 vk::VertexInputRate::eVertex //inputRate
316 };
317 return bindingDescription;
318}

◆ getIndiceCount()

uint32_t BufferControllerBlending::getIndiceCount ( )
overridevirtual

Return the number of indices in the indices buffer

Implements BuffersController.

Definition at line 358 of file BuffersControllerBlending.cpp.

359{
360 return indiceCount;
361}

◆ init()

void BufferControllerBlending::init ( )
overridevirtual

Initialize ressources

Implements BuffersController.

Definition at line 36 of file BuffersControllerBlending.cpp.

37{
38 if (inputView == 0) {
39 createVertexBuffer();
40 createIndexBuffer();
41 }
42 createUniformBuffer(attachmentCount);
43 createDescriptorPool();
44 createDescriptorSets();
45}

◆ update()

void BufferControllerBlending::update ( std::span< InputProvider::StreamFrameInfo infos,
int  view 
)
overridevirtual

Update the struct using the information given by the input provider

Implements BuffersController.

Definition at line 332 of file BuffersControllerBlending.cpp.

333{
334 //Does nothing for blending
335
336 //in OMAF rotation vector is rotation against z axis, y axis, and x axis
337 auto R_from = glmEulerAnglesDegreeToRotationMatrix(frameInfo[view].extrinsics.rotation);
338 //------------ Virtual camera parameter may not be in OMAF but can be converted to it using the conversion at wrapper->params.conversionToOMAF
339 // (in general it would be openxr coordinate system)
340 // and the rotation is defined as rotation against x axis, y axis, z axis
341 auto R_start = glmEulerAnglesDegreeToRotationMatrixNotOMAF(wrapper->params.getStartingRotation());
342 auto R_to = glmEulerAnglesDegreeToRotationMatrixNotOMAF(wrapper->params.getVirtualExtrinsics(view).rotation);
343 R_to = (R_start * R_to * glm::transpose(R_start)) * R_start;
344 R_to = wrapper->params.conversionToOMAF * R_to * glm::transpose(wrapper->params.conversionToOMAF);
345
346 auto R = glm::transpose(R_to) * R_from;
347
348 auto t_from = frameInfo[view].extrinsics.position;
349 auto t_start = wrapper->params.getStartingPosition();
350 auto t_to = wrapper->params.getVirtualExtrinsics(view).position;
351 t_to = t_start + R_start * t_to;// *glm::transpose(R_start); //
352
353 t_to = wrapper->params.conversionToOMAF * t_to;
354 glm::vec3 T = -glm::transpose(R_to) * (t_to - t_from);
355 this->blendingParam.inputDistance = std::max(0.01f, glm::length(T));
356}
const InputProvider::Extrinsics getVirtualExtrinsics(int view)
const glm::mat3x3 conversionToOMAF
const glm::vec3 getStartingPosition()
const glm::vec3 getStartingRotation()
RenderingParameters params

◆ updateAllUniformBuffer()

void BufferControllerBlending::updateAllUniformBuffer ( uint32_t  currentImage,
int  view 
)
overridevirtual

Send all the uniform to GPU

Implements BuffersController.

Definition at line 274 of file BuffersControllerBlending.cpp.

275{
276 int index = wrapper->multiviewSetup ? view : currentImage;
277
278 this->blendingParam.blendingFactor = wrapper->params.blendingFactor;
279 this->blendingParam.ZNearHeadset = wrapper->params.nearPlaneHeadset;
280 this->blendingParam.ZFarHeadset = wrapper->params.farPlaneHeadset;
281 this->blendingParam.ZFar = wrapper->params.max_depth;
282 this->blendingParam.maxMul = wrapper->params.maxMult;
283 this->blendingParam.scaleFactor = wrapper->params.scaleFactor;
284
285 //float alphaBlend = blendingFactor;
286 void* data;
287 context->device.mapMemory(uniformBuffersMemory[index], 0, sizeof(BlendingParameters), {}, &data);
288 memcpy(data, &this->blendingParam, sizeof(BlendingParameters));
289 context->device.unmapMemory(uniformBuffersMemory[index]);
290}
Struct that contains value to be sent to the fragment shader of the blending pipeline.

◆ updateUniformBuffer()

void BufferControllerBlending::updateUniformBuffer ( uint32_t  currentImage,
int  view 
)
overridevirtual

Does nothing here since this values are not changing from one frame to another

Implements BuffersController.

Definition at line 270 of file BuffersControllerBlending.cpp.

271{
272 //nothing to update for the moment
273};

Field Documentation

◆ indices

std::vector<uint32_t> BufferControllerBlending::indices
inlinestatic

List of indices

Definition at line 74 of file BuffersControllerBlending.h.


The documentation for this class was generated from the following files: