X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fvulkan%2Fmesh-vk.cc;h=540501eb18118a016f564bc010bf2bb0972ae7f9;hb=05d269a194496bcef85da78652b947f5bf1c9bcf;hp=494389b00daa4f2c6ea9ab29529aca6f8cac30d4;hpb=c3d7c1b7f8a7f4bcfc7661b6baf166ce0648083a;p=demo diff --git a/src/vulkan/mesh-vk.cc b/src/vulkan/mesh-vk.cc index 494389b..540501e 100644 --- a/src/vulkan/mesh-vk.cc +++ b/src/vulkan/mesh-vk.cc @@ -52,14 +52,14 @@ bool MeshVK::update_vertex_data() int vsz = vertices.size() * sizeof(Vec3); if(!(vk_vertices = vku_create_buffer(vsz, - VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { + VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { fprintf(stderr, "Failed to create the buffer for the vertices.\n"); return false; } int nsz = normals.size() * sizeof(Vec3); if(!(vk_normals = vku_create_buffer(nsz, - VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { + VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { vku_destroy_buffer(vk_vertices); fprintf(stderr, "Failed to create the buffer for the normals.\n"); @@ -68,18 +68,18 @@ bool MeshVK::update_vertex_data() int tsz = tex_coords.size() * sizeof(Vec2); if(!(vk_tex_coords = vku_create_buffer(tsz, - VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { + VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { vku_destroy_buffer(vk_vertices); vku_destroy_buffer(vk_normals); fprintf(stderr, - "Failed to create the buffer for the texture coordinates.\n"); + "Failed to create the buffer for the texture coordinates.\n"); return false; } int isz = indices.size() * 2; if(!(vk_indices = vku_create_buffer(isz, - VK_BUFFER_USAGE_INDEX_BUFFER_BIT))) { + VK_BUFFER_USAGE_INDEX_BUFFER_BIT))) { vku_destroy_buffer(vk_vertices); vku_destroy_buffer(vk_normals); vku_destroy_buffer(vk_tex_coords); @@ -90,21 +90,44 @@ 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"); + if(!vku_write_memory(vk_vertices->mem_pool, vsz, (void *)vertices.data())) { + fprintf(stderr, "Failed to write the vertices to GPU.\n"); return false; } - if(!vku_write_memory(vk_normals->mem_pool, nsz, (void*)normals.data())) { - fprintf(stderr, "Failed to write the normalson GPU.\n"); + 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 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"); + (void *)tex_coords.data())) { + 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 to GPU.\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"); + 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; }