Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.06k stars 511 forks source link

uniforms not working (MacOS) #303

Closed sauron65 closed 1 year ago

sauron65 commented 1 year ago

I don't know what the problem is, I checked my code multiple times, but the square isn't showing. It might be because I'm not using glm (I made my own matrix class), but I did a test and the matrix is working the same as glm. I don't see any errors or warnings in the validation layers. My code is at https://github.com/sauron65/cpp-vulkan-uniforms

(I only got to the part in Descriptor pool and sets where it shows an image with a 3D square)

nvanderploeg commented 1 year ago

Not sure this is your issue I am seeing you maping/unmaping your uniform buffer memory in your UpdateUniformBuffer method

      void * data;
      vkMapMemory(device, uniformBuffersMemory[currentImage], 0, sizeof(ubo), 0, &data);
      memcpy(data, &ubo, sizeof(ubo));
      vkUnmapMemory(device, uniformBuffersMemory[currentImage]);

but the tutorial merely memcopies to the mapped buffer

      memcpy(uniformBuffersMapped[currentImage], &ubo, sizeof(ubo));
SaschaWillems commented 1 year ago

Both ways should work fine. The tutorial did map and unmap for each update too, but I removed that with a PR recently as it's not really necessary to constantly map and unmap.

sauron65 commented 1 year ago

I fixed the issue a while ago actually, and forgot to close this. It was something with glm::lookAt creating a view matrix instead of a world matrix.