~sircmpwn/xrgears

a5d1b3bf0afa5994413fa5b940dbcfa85ecf4b4c — Lubosz Sarnecki 4 years ago e72fc8a
offscreenpass: fix validation warnings.
2 files changed, 12 insertions(+), 19 deletions(-)

M examples/xrgears/xrgears.cpp
M vitamin-k/render/vikOffscreenPass.hpp
M examples/xrgears/xrgears.cpp => examples/xrgears/xrgears.cpp +3 -4
@@ 49,9 49,9 @@ class XRGears : public vik::Application {

  vik::HMD* hmd;

  bool enableSky = false;
  bool enableHMDCam = false;
  bool enableDistortion = false;
  bool enableSky = true;
  bool enableHMDCam = true;
  bool enableDistortion = true;
  bool enableStereo = true;

  vik::SkyBox *skyBox = nullptr;


@@ 110,7 110,6 @@ class XRGears : public vik::Application {
    if (hmdDistortion)
      delete hmdDistortion;

    // uniformBuffers.camera.destroy();
    uniformBuffers.lights.destroy();

    for (auto& node : nodes)

M vitamin-k/render/vikOffscreenPass.hpp => vitamin-k/render/vikOffscreenPass.hpp +9 -15
@@ 72,22 72,9 @@ class OffscreenPass {
      VkFormat format,
      VkImageUsageFlagBits usage,
      FrameBufferAttachment *attachment) {
    VkImageAspectFlags aspectMask = 0;
    VkImageLayout imageLayout;

    attachment->format = format;

    if (usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
      aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
      imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
    }

    if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
      aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
      imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
    }

    assert(aspectMask > 0);
    attachment->format = format;

    VkImageCreateInfo image = initializers::imageCreateInfo();
    image.imageType = VK_IMAGE_TYPE_2D;


@@ 100,7 87,6 @@ class OffscreenPass {
    image.samples = VK_SAMPLE_COUNT_1_BIT;
    image.tiling = VK_IMAGE_TILING_OPTIMAL;
    image.usage = usage | VK_IMAGE_USAGE_SAMPLED_BIT;
    image.initialLayout = imageLayout;

    VkMemoryAllocateInfo memAlloc = initializers::memoryAllocateInfo();
    VkMemoryRequirements memReqs;


@@ 112,6 98,14 @@ class OffscreenPass {
    vik_log_check(vkAllocateMemory(device, &memAlloc, nullptr, &attachment->mem));
    vik_log_check(vkBindImageMemory(device, attachment->image, attachment->mem, 0));

    VkImageAspectFlags aspectMask = 0;
    if (usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
      aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
    } else if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
      aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
    }
    assert(aspectMask > 0);

    VkImageViewCreateInfo imageView = initializers::imageViewCreateInfo();
    imageView.viewType = VK_IMAGE_VIEW_TYPE_2D;
    imageView.format = format;