MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / updateUniformBuffer

Function updateUniformBuffer

cpp/5_Domain_Specific/simpleVulkan/main.cpp:406–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404 VkDeviceSize getUniformSize() const { return sizeof(UniformBufferObject); }
405
406 void updateUniformBuffer(uint32_t imageIndex)
407 {
408 {
409 mat4x4 view, proj;
410 vec3 eye = {1.75f, 1.75f, 1.25f};
411 vec3 center = {0.0f, 0.0f, -0.25f};
412 vec3 up = {0.0f, 0.0f, 1.0f};
413
414 mat4x4_perspective(proj,
415 (float)degreesToRadians(45.0f),
416 m_swapChainExtent.width / (float)m_swapChainExtent.height,
417 0.1f,
418 10.0f);
419 proj[1][1] *= -1.0f; // Flip y axis
420
421 mat4x4_look_at(view, eye, center, up);
422 mat4x4_mul(m_ubo.modelViewProj, proj, view);
423 }
424
425 void *data;
426 vkMapMemory(m_device, m_uniformMemory[imageIndex], 0, getUniformSize(), 0, &data);
427 memcpy(data, &m_ubo, sizeof(m_ubo));
428 vkUnmapMemory(m_device, m_uniformMemory[imageIndex]);
429 }
430
431 std::vector<const char *> getRequiredExtensions() const
432 {

Callers 2

drawFrameMethod · 0.85
drawFrameMethod · 0.85

Calls 3

mat4x4_perspectiveFunction · 0.70
mat4x4_look_atFunction · 0.70
mat4x4_mulFunction · 0.70

Tested by

no test coverage detected