~sircmpwn/xrgears

517ca5490d022a28571db29676d8d88e6cd109a4 — Lubosz Sarnecki 4 years ago 799fd07
refactor swap chain inheritance.
M vitamin-k/vikSwapchain.hpp => vitamin-k/vikSwapchain.hpp +11 -0
@@ 4,9 4,20 @@

#include "../vks/vksLog.hpp"

#define MAX_NUM_IMAGES 4

namespace vik {

struct RenderBuffer {
  VkImage image;
  VkImageView view;
  VkFramebuffer framebuffer;
};

class SwapChain {
public:
  RenderBuffer buffers[MAX_NUM_IMAGES];

  SwapChain() {}
  ~SwapChain() {}


A vitamin-k/vikSwapchainVK.hpp => vitamin-k/vikSwapchainVK.hpp +13 -0
@@ 0,0 1,13 @@
#pragma once

#include <vulkan/vulkan.h>

#include "vikSwapchain.hpp"

namespace vik {
class SwapChainVK : public SwapChain {
public:
  SwapChainVK() {}
  ~SwapChainVK() {}
};
}

M vkc/vkcRenderer.cpp => vkc/vkcRenderer.cpp +1 -1
@@ 327,7 327,7 @@ void Renderer::build_command_buffer(VkFramebuffer frame_buffer) {
}

void Renderer::render(uint32_t index) {
  RenderBuffer *b = &swap_chain->buffers[index];
  vik::RenderBuffer *b = &swap_chain->buffers[index];
  build_command_buffer(b->framebuffer);
  submit_queue();
  wait_and_reset_fences();

M vkc/vkcRenderer.hpp => vkc/vkcRenderer.hpp +1 -1
@@ 11,7 11,7 @@ namespace vkc {

class Renderer : public vik::Renderer {
public:
  SwapChain *swap_chain;
  vik::SwapChain *swap_chain;

  VkInstance instance;
  VkPhysicalDevice physical_device;

D vkc/vkcSwapChain.hpp => vkc/vkcSwapChain.hpp +0 -32
@@ 1,32 0,0 @@
#pragma once

#include <vulkan/vulkan.h>

#include "vikSwapchain.hpp"

#define MAX_NUM_IMAGES 4

namespace vkc {

struct RenderBuffer {
  VkImage image;
  VkImageView view;
  VkFramebuffer framebuffer;
};

class SwapChain : public vik::SwapChain {
public:
  RenderBuffer buffers[MAX_NUM_IMAGES];

  SwapChain() {}
  ~SwapChain() {}

  /*
  void init_buffer(VkDevice device, VkFormat image_format, VkRenderPass render_pass,
                   uint32_t width, uint32_t height, RenderBuffer *b) {
    create_image_view(device, b->image, image_format, &b->view);
    create_frame_buffer(device, render_pass, &b->view, width, height, &b->framebuffer);
  }
  */
};
}

M vkc/vkcSwapChainDRM.hpp => vkc/vkcSwapChainDRM.hpp +3 -3
@@ 24,7 24,7 @@
#include <linux/vt.h>
#include <linux/major.h>

#include "vkcSwapChain.hpp"
#include "vikSwapchain.hpp"

namespace vkc {



@@ 35,7 35,7 @@ struct kms_buffer {
  uint32_t stride;
};

class SwapChainDRM : public SwapChain {
class SwapChainDRM : public vik::SwapChain {

public:
  kms_buffer kms_buffers[MAX_NUM_IMAGES];


@@ 53,7 53,7 @@ public:
        (PFN_vkCreateDmaBufImageINTEL)vkGetDeviceProcAddr(device, "vkCreateDmaBufImageINTEL");

    for (uint32_t i = 0; i < 2; i++) {
      struct RenderBuffer *b = &buffers[i];
      struct vik::RenderBuffer *b = &buffers[i];
      struct kms_buffer *kms_b = &kms_buffers[i];
      int buffer_fd, stride, ret;


M vkc/vkcSwapChainVK.hpp => vkc/vkcSwapChainVK.hpp +2 -2
@@ 2,12 2,12 @@

#include <vulkan/vulkan.h>

#include "vkcSwapChain.hpp"
#include "vikSwapchainVK.hpp"
#include "../vks/vksLog.hpp"

namespace vkc {

class SwapChainVK : public SwapChain {
class SwapChainVK : public vik::SwapChainVK {

public:
  VkSwapchainKHR swap_chain;

M vks/vksSwapChain.hpp => vks/vksSwapChain.hpp +1 -1
@@ 24,7 24,7 @@
#include "vksTools.hpp"

#include "vksLog.hpp"
#include "vikSwapchain.hpp"
#include "vikSwapchainVK.hpp"

namespace vks {


M vks/vksWindowKMS.hpp => vks/vksWindowKMS.hpp +0 -2
@@ 58,8 58,6 @@ class WindowKMS : public Window {
     //VkFramebuffer framebuffer;
  };

  #define MAX_NUM_IMAGES 3

  struct kms_buffer kms_buffers[MAX_NUM_IMAGES];
  struct render_buffer render_buffers[MAX_NUM_IMAGES];