Changeset 87c8f1a in opengl-game for vulkan-ref.cpp


Ignore:
Timestamp:
Nov 1, 2019, 5:11:45 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
d2d9286
Parents:
34bdf3a
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (11/01/19 17:09:16)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (11/01/19 17:11:45)
Message:

In vaulkangame, define vertex buffer and index buffer data and transfer it to the gpu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-ref.cpp

    r34bdf3a r87c8f1a  
    7272   glm::vec2 texCoord;
    7373};
    74 /*** END OF REFACTORED CODE ***/
    7574
    7675struct UniformBufferObject {
     
    8079};
    8180
    82 /*** START OF REFACTORED CODE ***/
    8381struct DescriptorInfo {
    8482   VkDescriptorType type;
     
    8886   VkDescriptorImageInfo* imageData;
    8987};
    90 /*** END OF REFACTORED CODE ***/
    9188
    9289struct GraphicsPipelineInfo {
    93 /*** START OF REFACTORED CODE ***/
    9490   VkPipelineLayout pipelineLayout;
    9591   VkPipeline pipeline;
     
    10399   VkDescriptorSetLayout descriptorSetLayout;
    104100   vector<VkDescriptorSet> descriptorSets;
    105 /*** END OF REFACTORED CODE ***/
    106 
    107    size_t numVertices; // Currently unused
     101
     102   size_t numVertices;
    108103   size_t vertexCapacity;
    109104   VkBuffer vertexBuffer;
     
    116111};
    117112
    118 /*** START OF REFACTORED CODE ***/
    119113VkResult CreateDebugUtilsMessengerEXT(VkInstance instance,
    120114      const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
     
    223217      vector<VkSemaphore> renderFinishedSemaphores;
    224218      vector<VkFence> inFlightFences;
     219
     220      size_t currentFrame = 0;
    225221/*** END OF REFACTORED CODE ***/
    226 
    227       size_t currentFrame = 0;
    228222
    229223      size_t numPlanes = 0; // temp
     
    340334         overlayImageInfo.imageView = sdlOverlayImageView;
    341335         overlayImageInfo.sampler = textureSampler;
    342 /*** END OF REFACTORED CODE ***/
    343336
    344337         // SHADER-SPECIFIC STUFF STARTS HERE
     
    364357            sceneIndices.data(), sizeof(uint16_t), sceneIndices.size());
    365358
    366 /*** START OF REFACTORED CODE ***/
    367359         addAttributeDescription(scenePipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&Vertex::pos));
    368360         addAttributeDescription(scenePipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&Vertex::color));
     
    373365
    374366         createDescriptorSetLayout(scenePipeline);
    375 /*** END OF REFACTORED CODE ***/
    376367
    377368         numPlanes = 2;
     
    391382            overlayIndices.data(), sizeof(uint16_t), overlayIndices.size());
    392383
    393 /*** START OF REFACTORED CODE ***/
    394384         addAttributeDescription(overlayPipeline, VK_FORMAT_R32G32B32_SFLOAT, offset_of(&OverlayVertex::pos));
    395385         addAttributeDescription(overlayPipeline, VK_FORMAT_R32G32_SFLOAT, offset_of(&OverlayVertex::texCoord));
     
    812802         info.bindingDescription.stride = vertexSize;
    813803         info.bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
    814 /*** END OF REFACTORED CODE ***/
    815804
    816805         info.numVertices = numVertices;
     
    13931382         }
    13941383      }
    1395 /*** END OF REFACTORED CODE ***/
    13961384
    13971385      void createVertexBuffer(GraphicsPipelineInfo& info, const void* vertexData, int vertexSize) {
     
    14431431      }
    14441432
    1445 /*** START OF REFACTORED CODE ***/
    14461433      void createUniformBuffers() {
    14471434         VkDeviceSize bufferSize = sizeof(UniformBufferObject);
     
    15071494      }
    15081495
     1496/*** START OF REFACTORED CODE ***/
    15091497      void copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize srcOffset, VkDeviceSize dstOffset,
    15101498            VkDeviceSize size) {
     
    15501538      }
    15511539
    1552 /*** START OF REFACTORED CODE ***/
    15531540      uint32_t findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) {
    15541541         VkPhysicalDeviceMemoryProperties memProperties;
     
    18011788
    18021789      void drawFrame() {
     1790         vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, numeric_limits<uint64_t>::max());
     1791
     1792         uint32_t imageIndex;
    18031793/*** END OF REFACTORED CODE ***/
    1804          vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, numeric_limits<uint64_t>::max());
    1805 
    1806          uint32_t imageIndex;
    18071794
    18081795         VkResult result = vkAcquireNextImageKHR(device, swapChain, numeric_limits<uint64_t>::max(),
     
    18611848         }
    18621849
     1850/*** START OF REFACTORED CODE ***/
    18631851         currentFrame = (currentFrame + 1) % MAX_FRAMES_IN_FLIGHT;
    18641852         currentFrame = (currentFrame + 1) % MAX_FRAMES_IN_FLIGHT;
    1865 /*** START OF REFACTORED CODE ***/
    18661853      }
    18671854
     
    20522039      void cleanupPipelineBuffers(GraphicsPipelineInfo& pipeline) {
    20532040         vkDestroyDescriptorSetLayout(device, pipeline.descriptorSetLayout, nullptr);
    2054 /*** END OF REFACTORED CODE ***/
    20552041
    20562042         vkDestroyBuffer(device, pipeline.vertexBuffer, nullptr);
     
    20592045         vkFreeMemory(device, pipeline.indexBufferMemory, nullptr);
    20602046      }
     2047/*** END OF REFACTORED CODE ***/
    20612048
    20622049      static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
Note: See TracChangeset for help on using the changeset viewer.