~sircmpwn/xrgears

4d2c57c7eae28e5eab820a11a3ca1ea08fa40441 — Lubosz Sarnecki 4 years ago dcaf75b
rename functions
M vitamin-k/vikSwapChain.hpp => vitamin-k/vikSwapChain.hpp +4 -7
@@ 8,12 8,6 @@

namespace vik {

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

struct SwapChainBuffer {
  VkImage image;
  VkImageView view;


@@ 21,7 15,10 @@ struct SwapChainBuffer {

class SwapChain {
public:
  std::vector<RenderBuffer> buffers;
  std::vector<SwapChainBuffer> buffers;
  std::vector<VkFramebuffer> frame_buffers;

  uint32_t image_count = 0;

  SwapChain() {}
  ~SwapChain() {}

M vitamin-k/vikSwapChainVK.hpp => vitamin-k/vikSwapChainVK.hpp +1 -1
@@ 8,8 8,8 @@ namespace vik {
class SwapChainVK : public SwapChain {
public:

  /** @brief Handle to the current swap chain, required for recreation */
  VkSwapchainKHR swap_chain = VK_NULL_HANDLE;
  uint32_t image_count = 0;

  SwapChainVK() {}
  ~SwapChainVK() {}

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

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

M vkc/vkcSwapChainDRM.hpp => vkc/vkcSwapChainDRM.hpp +3 -2
@@ 47,6 47,7 @@ public:
    image_count = 4;
    buffers.resize(image_count);
    kms_buffers.resize(image_count);
    frame_buffers.resize(image_count);
  }

  ~SwapChainDRM() {


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

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



@@ 101,7 102,7 @@ public:
      create_image_view(device, b->image,
                        image_format, &b->view);
      create_frame_buffer(device, render_pass, &b->view,
                          width, height, &b->framebuffer);
                          width, height, &frame_buffers[i]);
    }
  }


M vkc/vkcSwapChainVK.hpp => vkc/vkcSwapChainVK.hpp +2 -1
@@ 92,9 92,10 @@ public:

  void update_frame_buffers(VkDevice device, uint32_t width,
                            uint32_t height, VkRenderPass render_pass) {
    frame_buffers.resize(image_count);
    for (uint32_t i = 0; i < image_count; i++) {
      create_frame_buffer(device, render_pass, &buffers[i].view,
                          width, height, &buffers[i].framebuffer);
                          width, height, &frame_buffers[i]);
    }
  }


M vks/vksRenderer.cpp => vks/vksRenderer.cpp +9 -12
@@ 11,18 11,15 @@ Renderer::~Renderer() {
    delete textOverlay;

  swapChain.cleanup();
  if (descriptorPool != VK_NULL_HANDLE) {
  if (descriptorPool != VK_NULL_HANDLE)
    vkDestroyDescriptorPool(device, descriptorPool, nullptr);
  }

  destroyCommandBuffers();
  vkDestroyRenderPass(device, renderPass, nullptr);
  for (uint32_t i = 0; i < frameBuffers.size(); i++) {
  for (uint32_t i = 0; i < frameBuffers.size(); i++)
    vkDestroyFramebuffer(device, frameBuffers[i], nullptr);
  }

  for (auto& shaderModule : shaderModules) {
    vkDestroyShaderModule(device, shaderModule, nullptr);
  }

  vkDestroyImageView(device, depthStencil.view, nullptr);
  vkDestroyImage(device, depthStencil.image, nullptr);
  vkFreeMemory(device, depthStencil.mem, nullptr);


@@ 52,9 49,9 @@ void Renderer::prepare() {

  createCommandBuffers();
  setupDepthStencil();
  setupRenderPass();
  create_render_pass();
  createPipelineCache();
  setupFrameBuffer();
  create_frame_buffers();
  if (enableTextOverlay)
    init_text_overlay();
}


@@ 422,7 419,7 @@ void Renderer::resize() {

  for (uint32_t i = 0; i < frameBuffers.size(); i++)
    vkDestroyFramebuffer(device, frameBuffers[i], nullptr);
  setupFrameBuffer();
  create_frame_buffers();

  // Command buffers need to be recreated as they may store
  // references to the recreated frame buffer


@@ 459,7 456,7 @@ void Renderer::submit_text_overlay() {
  submitInfo.pSignalSemaphores = &semaphores.renderComplete;
}

void Renderer::setupFrameBuffer() {
void Renderer::create_frame_buffers() {
  vik_log_d("setupFrameBuffer");




@@ 486,7 483,7 @@ void Renderer::setupFrameBuffer() {
  }
}

void Renderer::setupRenderPass() {
void Renderer::create_render_pass() {
  std::array<VkAttachmentDescription, 2> attachments = {};
  // Color attachment
  attachments[0].format = swapChain.surface_format.format;

M vks/vksRenderer.hpp => vks/vksRenderer.hpp +2 -3
@@ 59,7 59,6 @@ public:

  std::vector<VkCommandBuffer> drawCmdBuffers;
  std::vector<VkFramebuffer> frameBuffers;
  std::vector<VkShaderModule> shaderModules;

  std::vector<const char*> enabledExtensions;



@@ 88,8 87,8 @@ public:
  void prepareFrame();
  void submitFrame();
  void setupDepthStencil();
  void setupFrameBuffer();
  void setupRenderPass();
  void create_frame_buffers();
  void create_render_pass();

  void init_text_overlay();


M vks/vksSwapChain.hpp => vks/vksSwapChain.hpp +0 -3
@@ 40,9 40,6 @@ class SwapChain : public vik::SwapChainVK {
 public:
  VkSurfaceFormatKHR surface_format;

  /** @brief Handle to the current swap chain, required for recreation */

  std::vector<vik::SwapChainBuffer> buffers;
  // Index of the deteced graphics and presenting device queue
  /** @brief Queue family index of the detected graphics and presenting device queue */
  uint32_t queueNodeIndex = UINT32_MAX;