<commit_before>/*
* Vulkan Demo Scene 
*
* Don't take this a an example, it's more of a personal playground
*
* Copyright (C) 2016 by <NAME> - www.saschawillems.de
*
* Note : Different license than the other examples!
*
* This code is licensed under the Mozilla Public License Version 2.0 (http://opensource.org/licenses/MPL-2.0)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <vector>

#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_inverse.hpp>

#include <vulkan/vulkan.h>
#include "vulkanexamplebase.h"

#define VERTEX_BUFFER_BIND_ID 0
#define ENABLE_VALIDATION false

class VulkanExample : public VulkanExampleBase
{
public:

	struct DemoMeshes
	{
		std::vector<std::string> names{ "logos", "background", "models", "skybox" };
		VkPipelineVertexInputStateCreateInfo inputState;
		std::vector<VkVertexInputBindingDescription> bindingDescriptions;
		std::vector<VkVertexInputAttributeDescription> attributeDescriptions;
		VkPipeline pipeline;
		VulkanMeshLoader* logos;
		VulkanMeshLoader* background;
		VulkanMeshLoader* models;
		VulkanMeshLoader* skybox;
	} demoMeshes;
	std::vector<VulkanMeshLoader*> meshes;

	struct {
		vkTools::UniformData meshVS;
	} uniformData;

	struct {
		glm::mat4 projection;
		glm::mat4 model;
		glm::mat4 normal;
		glm::mat4 view;
		glm::vec4 lightPos;
	} uboVS;

	struct
	{
		vkTools::VulkanTexture skybox;
	} textures;

	struct {
		VkPipeline logos;
		VkPipeline models;
		VkPipeline skybox;
	} pipelines;

	VkPipelineLayout pipelineLayout;
	VkDescriptorSet descriptorSet;
	VkDescriptorSetLayout descriptorSetLayout;

	glm::vec4 lightPos = glm::vec4(1.0f, 2.0f, 0.0f, 0.0f);

	VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
	{
		width = 1280;
		height = 720;
		zoom = -3.75f;
		rotationSpeed = 0.5f;
		rotation = glm::vec3(15.0f, 0.f, 0.0f);
		title = "Vulkan Demo Scene -  2016 by <NAME>";
	}

	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class
		vkDestroyPipeline(device, pipelines.logos, nullptr);
		vkDestroyPipeline(device, pipelines.models, nullptr);
		vkDestroyPipeline(device, pipelines.skybox, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);

		vkTools::destroyUniformData(device, &uniformData.meshVS);

		for (auto& mesh : meshes)
		{
			vkDestroyBuffer(device, mesh->vertexBuffer.buf, nullptr);
			vkFreeMemory(device, mesh->vertexBuffer.mem, nullptr);

			vkDestroyBuffer(device, mesh->indexBuffer.buf, nullptr);
			vkFreeMemory(device, mesh->indexBuffer.mem, nullptr);
		}

		textureLoader->destroyTexture(textures.skybox);
	}

	void loadTextures()
	{
		textureLoader->loadCubemap(
			getAssetPath() + "textures/cubemap_vulkan.ktx", 
			VK_FORMAT_R8G8B8A8_UNORM, 
			&textures.skybox);
	}

	void buildCommandBuffers()
	{<commit_msg>* Added delete() for meshes which were left to leak at vulkanScene example.<commit_after>/*
* Vulkan Demo Scene 
*
* Don't take this a an example, it's more of a personal playground
*
* Copyright (C) 2016 by <NAME> - www.saschawillems.de
*
* Note : Different license than the other examples!
*
* This code is licensed under the Mozilla Public License Version 2.0 (http://opensource.org/licenses/MPL-2.0)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <vector>

#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/matrix_inverse.hpp>

#include <vulkan/vulkan.h>
#include "vulkanexamplebase.h"

#define VERTEX_BUFFER_BIND_ID 0
#define ENABLE_VALIDATION false

class VulkanExample : public VulkanExampleBase
{
public:

	struct DemoMeshes
	{
		std::vector<std::string> names{ "logos", "background", "models", "skybox" };
		VkPipelineVertexInputStateCreateInfo inputState;
		std::vector<VkVertexInputBindingDescription> bindingDescriptions;
		std::vector<VkVertexInputAttributeDescription> attributeDescriptions;
		VkPipeline pipeline;
		VulkanMeshLoader* logos;
		VulkanMeshLoader* background;
		VulkanMeshLoader* models;
		VulkanMeshLoader* skybox;
	} demoMeshes;
	std::vector<VulkanMeshLoader*> meshes;

	struct {
		vkTools::UniformData meshVS;
	} uniformData;

	struct {
		glm::mat4 projection;
		glm::mat4 model;
		glm::mat4 normal;
		glm::mat4 view;
		glm::vec4 lightPos;
	} uboVS;

	struct
	{
		vkTools::VulkanTexture skybox;
	} textures;

	struct {
		VkPipeline logos;
		VkPipeline models;
		VkPipeline skybox;
	} pipelines;

	VkPipelineLayout pipelineLayout;
	VkDescriptorSet descriptorSet;
	VkDescriptorSetLayout descriptorSetLayout;

	glm::vec4 lightPos = glm::vec4(1.0f, 2.0f, 0.0f, 0.0f);

	VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
	{
		width = 1280;
		height = 720;
		zoom = -3.75f;
		rotationSpeed = 0.5f;
		rotation = glm::vec3(15.0f, 0.f, 0.0f);
		title = "Vulkan Demo Scene -  2016 by <NAME>";
	}

	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class
		vkDestroyPipeline(device, pipelines.logos, nullptr);
		vkDestroyPipeline(device, pipelines.models, nullptr);
		vkDestroyPipeline(device, pipelines.skybox, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);

		vkTools::destroyUniformData(device, &uniformData.meshVS);

		for (auto& mesh : meshes)
		{
			vkDestroyBuffer(device, mesh->vertexBuffer.buf, nullptr);
			vkFreeMemory(device, mesh->vertexBuffer.mem, nullptr);

			vkDestroyBuffer(device, mesh->indexBuffer.buf, nullptr);
			vkFreeMemory(device, mesh->indexBuffer.mem, nullptr);
		}

		textureLoader->destroyTexture(textures.skybox);

		delete(demoMeshes.logos		);
		delete(demoMeshes.background);
		delete(demoMeshes.models	);
		delete(demoMeshes.skybox	);
	}

	void loadTextures()
	{
		textureLoader->loadCubemap(
			getAssetPath() + "textures/cubemap_vulkan.ktx", 
			VK_FORMAT_R8G8B8A8_UNORM, 
			&textures.skybox);
	}

	void buildCommandBuffers()
	{
{'fraction_non_alphanumeric': 0.11372422680412371, 'fraction_numerical': 0.01643041237113402, 'mean_word_length': 5.215215215215215, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '93962', 'n_tokens_mistral': 2451, 'n_tokens_neox': 2188, 'n_words': 462}