dont destroy buffers until not used

This commit is contained in:
Tyler Murphy 2022-09-28 10:51:15 -04:00
parent 9d0262e8a2
commit 50bd5c1a7e
5 changed files with 7 additions and 6 deletions

View file

@ -53,6 +53,7 @@ void Model::deleteModel(Model* model) {
void Model::submitDeleteQueue(bool purge) {
for(Model* model: DELETION_QUEUE) {
vkDeviceWaitIdle(model->xeDevice.device());
try { delete model; } catch(int err) {};
}
DELETION_QUEUE.clear();

View file

@ -59,7 +59,7 @@ void Renderer::freeCommandBuffers() {
}
VkCommandBuffer Renderer::beginFrame() {
assert(!isFrameStarted && "Can't acll beingFrame while already in progress");
assert(!isFrameStarted && "Can't call beingFrame while already in progress");
auto result = xeSwapChain->acquireNextImage(&currentImageIndex);

View file

@ -109,8 +109,6 @@ VkResult SwapChain::submitCommandBuffers(
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = signalSemaphores;
vkResetFences(device.device(), 1, &inFlightFences[currentFrame]);
if (vkQueueSubmit(device.graphicsQueue(), 1, &submitInfo, inFlightFences[currentFrame]) !=
VK_SUCCESS) {

View file

@ -19,6 +19,8 @@ Chunk::~Chunk() {
if(worker.joinable())
worker.join();
xe::Model::deleteModel(chunkMesh);
vertexData.data.clear();
cubes.clear();
}
//
@ -216,7 +218,7 @@ void Chunk::generate() {
for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) {
int height = perlin.octave2D_01((( x + gridX * 16) * 0.01), ((z + gridZ * 16) * 0.01), 4) * 10;
int height = perlin.octave2D_01((( x + gridX * 16) * 0.01), ((z + gridZ * 16) * 0.01), 4) * 20;
for(int y = 0; y < 256; y++) {
if(y == height){
setBlock(x, y, z, GRASS);

View file

@ -73,8 +73,8 @@ void FirstApp::reloadLoadedChunks(xe::GameObject& viewer) {
int gridZ = static_cast<int>(floor(gameObject.transform.translation.z / 16.f));
int newGridX = minX + x;
int newGridZ = minZ + z;
// if(gridX < minX || gridZ < minZ || gridX > maxX || gridZ > maxZ)
// Chunk::deleteChunk(gridX, gridZ);
if(gridX < minX || gridZ < minZ || gridX > maxX || gridZ > maxZ)
Chunk::deleteChunk(gridX, gridZ);
Chunk* chunk = Chunk::getChunk(newGridX, newGridZ);
if(chunk == nullptr) {
chunk = Chunk::newChunk(newGridX, newGridZ, 12345);