From 6cecb8f16f1863496884ca86790375dbb27138ba Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Sun, 11 Mar 2018 22:23:06 +0200 Subject: [PATCH] bind buf memory --- src/vulkan/mesh-vk.cc | 31 +++++++++++++++++++++++++++---- src/vulkan/vk.cc | 1 - 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/vulkan/mesh-vk.cc b/src/vulkan/mesh-vk.cc index 494389b..729e24c 100644 --- a/src/vulkan/mesh-vk.cc +++ b/src/vulkan/mesh-vk.cc @@ -91,20 +91,43 @@ bool MeshVK::update_vertex_data() /* write the buffers */ if(!vku_write_memory(vk_vertices->mem_pool, vsz, (void*)vertices.data())) { - fprintf(stderr, "Failed to write the vertices on GPU.\n"); + fprintf(stderr, "Failed to write the vertices to GPU.\n"); return false; } + if(vkBindBufferMemory(vk_device, vk_vertices->buf, vk_vertices->mem_pool, + 0) != VK_SUCCESS) { + fprintf(stderr, "Failed to bind the vertex buffer memory\n"); + return false; + } + if(!vku_write_memory(vk_normals->mem_pool, nsz, (void*)normals.data())) { - fprintf(stderr, "Failed to write the normalson GPU.\n"); + fprintf(stderr, "Failed to write the normals to GPU.\n"); return false; } + if(vkBindBufferMemory(vk_device, vk_normals->buf, vk_normals->mem_pool, 0) + != VK_SUCCESS) { + fprintf(stderr, "Failed to bind the normal buffer memory\n"); + return false; + } + if(!vku_write_memory(vk_tex_coords->mem_pool, tsz, (void*)tex_coords.data())) { - fprintf(stderr, "Failed to write the texture coordinates on GPU.\n"); + fprintf(stderr, "Failed to write the texture coordinates to GPU.\n"); return false; } + if(vkBindBufferMemory(vk_device, vk_tex_coords->buf, + vk_tex_coords->mem_pool, 0) != VK_SUCCESS) { + fprintf(stderr, "Failed to bind the tex coordinates buffer memory.\n"); + return false; + } + if(!vku_write_memory(vk_indices->mem_pool, isz, (void*)indices.data())) { - fprintf(stderr, "Failed to write the indices on GPU.\n"); + fprintf(stderr, "Failed to write the indices to GPU.\n"); + return false; + } + if(vkBindBufferMemory(vk_device, vk_indices->buf, vk_indices->mem_pool, 0) + != VK_SUCCESS) { + fprintf(stderr, "Failed to bind the index buffer memory.\n"); return false; } diff --git a/src/vulkan/vk.cc b/src/vulkan/vk.cc index 4a23211..261ba74 100644 --- a/src/vulkan/vk.cc +++ b/src/vulkan/vk.cc @@ -41,7 +41,6 @@ static VkSemaphore psema; /* static variables */ -static VkDeviceMemory gpu_mem; // to be replaced when I fix the allocator static Vec4 clear_color(1, 0.1, 0.1, 1.0); /* static functions */ -- 1.7.10.4