您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vkUnmapMemory函数代码示例

51自学网 2021-06-03 09:44:02
  C++
这篇教程C++ vkUnmapMemory函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vkUnmapMemory函数的典型用法代码示例。如果您正苦于以下问题:C++ vkUnmapMemory函数的具体用法?C++ vkUnmapMemory怎么用?C++ vkUnmapMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vkUnmapMemory函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: updateUniformBuffers

	void updateUniformBuffers()	{		// Vertex shader		glm::mat4 viewMatrix = glm::mat4();		uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);		viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));		float offset = 0.5f;		int uboIndex = 1;		uboVS.model = glm::mat4();		uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.VS.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.VS.memory);		// Geometry shader		uboGS.model = uboVS.model;		uboGS.projection = uboVS.projection;		err = vkMapMemory(device, uniformData.GS.memory, 0, sizeof(uboGS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboGS, sizeof(uboGS));		vkUnmapMemory(device, uniformData.GS.memory);	}
开发者ID:Ancou,项目名称:Vulkan,代码行数:29,


示例2: updateUniformBuffers

	void updateUniformBuffers()	{		// Vertex shader		glm::mat4 viewMatrix = glm::mat4();		ubos.vertexShader.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.001f, 256.0f);		viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));		ubos.vertexShader.model = glm::mat4();		ubos.vertexShader.model = viewMatrix * glm::translate(ubos.vertexShader.model, glm::vec3(0, 0, 0));		ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		ubos.vertexShader.model = glm::rotate(ubos.vertexShader.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		ubos.vertexShader.normal = glm::inverseTranspose(ubos.vertexShader.model);		if (!paused)		{			ubos.vertexShader.lightPos.x = sin(glm::radians(timer * 360.0f)) * 0.5;			ubos.vertexShader.lightPos.y = cos(glm::radians(timer * 360.0f)) * 0.5;		}		ubos.vertexShader.cameraPos = glm::vec4(0.0, 0.0, zoom, 0.0);		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.vertexShader.memory, 0, sizeof(ubos.vertexShader), 0, (void **)&pData);		assert(!err);		memcpy(pData, &ubos.vertexShader, sizeof(ubos.vertexShader));		vkUnmapMemory(device, uniformData.vertexShader.memory);		// Fragment shader		err = vkMapMemory(device, uniformData.fragmentShader.memory, 0, sizeof(ubos.fragmentShader), 0, (void **)&pData);		assert(!err);		memcpy(pData, &ubos.fragmentShader, sizeof(ubos.fragmentShader));		vkUnmapMemory(device, uniformData.fragmentShader.memory);	}
开发者ID:Ancou,项目名称:Vulkan,代码行数:35,


示例3: updateUniformBuffers

	void updateUniformBuffers()	{		// 3D object		glm::mat4 viewMatrix = glm::mat4();		uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);		viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));		uboVS.model = glm::mat4();		uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.objectVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.objectVS.memory);		// Skysphere		viewMatrix = glm::mat4();		uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.001f, 256.0f);		uboVS.model = glm::mat4();		uboVS.model = viewMatrix * glm::translate(uboVS.model, glm::vec3(0, 0, 0));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		err = vkMapMemory(device, uniformData.skyboxVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.skyboxVS.memory);	}
开发者ID:Ancou,项目名称:Vulkan,代码行数:34,


示例4: updateUniformBuffers

	void updateUniformBuffers()	{		// Tessellation eval		glm::mat4 viewMatrix = glm::mat4();		uboTE.projection = glm::perspective(glm::radians(45.0f), (float)(width* ((splitScreen) ? 0.5f : 1.0f)) / (float)height, 0.1f, 256.0f);		viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));		float offset = 0.5f;		int uboIndex = 1;		uboTE.model = glm::mat4();		uboTE.model = viewMatrix * glm::translate(uboTE.model, glm::vec3(0, 0, 0));		uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboTE.model = glm::rotate(uboTE.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformDataTE.memory, 0, sizeof(uboTE), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboTE, sizeof(uboTE));		vkUnmapMemory(device, uniformDataTE.memory);		// Tessellation control		err = vkMapMemory(device, uniformDataTC.memory, 0, sizeof(uboTC), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboTC, sizeof(uboTC));		vkUnmapMemory(device, uniformDataTC.memory);	}
开发者ID:2007750219,项目名称:Vulkan,代码行数:27,


示例5: createBuffer

		/**		* Create a buffer on the device		*		* @param usageFlags Usage flag bitmask for the buffer (i.e. index, vertex, uniform buffer)		* @param memoryPropertyFlags Memory properties for this buffer (i.e. device local, host visible, coherent)		* @param size Size of the buffer in byes		* @param buffer Pointer to the buffer handle acquired by the function		* @param memory Pointer to the memory handle acquired by the function		* @param data Pointer to the data that should be copied to the buffer after creation (optional, if not set, no data is copied over)		*		* @return VK_SUCCESS if buffer handle and memory have been created and (optionally passed) data has been copied		*/		VkResult createBuffer(VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, VkBuffer *buffer, VkDeviceMemory *memory, void *data = nullptr)		{			// Create the buffer handle			VkBufferCreateInfo bufferCreateInfo = vkTools::initializers::bufferCreateInfo(usageFlags, size);			bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;			VK_CHECK_RESULT(vkCreateBuffer(logicalDevice, &bufferCreateInfo, nullptr, buffer));			// Create the memory backing up the buffer handle			VkMemoryRequirements memReqs;			VkMemoryAllocateInfo memAlloc = vkTools::initializers::memoryAllocateInfo();			vkGetBufferMemoryRequirements(logicalDevice, *buffer, &memReqs);			memAlloc.allocationSize = memReqs.size;			// Find a memory type index that fits the properties of the buffer			memAlloc.memoryTypeIndex = getMemoryType(memReqs.memoryTypeBits, memoryPropertyFlags);			VK_CHECK_RESULT(vkAllocateMemory(logicalDevice, &memAlloc, nullptr, memory));						// If a pointer to the buffer data has been passed, map the buffer and copy over the data			if (data != nullptr)			{				void *mapped;				VK_CHECK_RESULT(vkMapMemory(logicalDevice, *memory, 0, size, 0, &mapped));				memcpy(mapped, data, size);				vkUnmapMemory(logicalDevice, *memory);			}			// Attach the memory to the buffer object			VK_CHECK_RESULT(vkBindBufferMemory(logicalDevice, *buffer, *memory, 0));			return VK_SUCCESS;		}
开发者ID:dreadwords,项目名称:Vulkan,代码行数:42,


示例6: vkCreateBuffer

VkBool32 VulkanExampleBase::createBuffer(	VkBufferUsageFlags usage,	VkDeviceSize size,	void * data,	VkBuffer *buffer,	VkDeviceMemory *memory){	VkMemoryRequirements memReqs;	VkMemoryAllocateInfo memAlloc = vkTools::initializers::memoryAllocateInfo();	VkBufferCreateInfo bufferCreateInfo = vkTools::initializers::bufferCreateInfo(usage, size);	VkResult err = vkCreateBuffer(device, &bufferCreateInfo, nullptr, buffer);	assert(!err);	vkGetBufferMemoryRequirements(device, *buffer, &memReqs);	memAlloc.allocationSize = memReqs.size;	getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &memAlloc.memoryTypeIndex);	err = vkAllocateMemory(device, &memAlloc, nullptr, memory);	assert(!err);	if (data != nullptr)	{		void *mapped;		err = vkMapMemory(device, *memory, 0, size, 0, &mapped);		assert(!err);		memcpy(mapped, data, size);		vkUnmapMemory(device, *memory);	}	err = vkBindBufferMemory(device, *buffer, *memory, 0);	assert(!err);	return true;}
开发者ID:AdamFlores,项目名称:Vulkan,代码行数:30,


示例7: VkcEntity

/** * Create the entity. */VkcEntity::VkcEntity(const VkcDevice *device) : VkcEntity(){    // Load the model.    vertices.append({-1.0f,  0.0f,  1.0f,    0.0f,  1.0f,    0.0f, -1.0f,  0.0f});    vertices.append({-1.0f,  0.0f, -1.0f,    0.0f,  0.0f,    0.0f, -1.0f,  0.0f});    vertices.append({ 1.0f,  0.0f,  1.0f,    1.0f,  1.0f,    0.0f, -1.0f,  0.0f});    vertices.append({ 1.0f,  0.0f, -1.0f,    1.0f,  0.0f,    0.0f, -1.0f,  0.0f});    indices = {0, 1, 2, 2, 1, 3};    // Load position, scale and rotation data.    // /@todo    // Create buffer.    buffer.create(vertices.size() * sizeof(VkVertex) + indices.size() * sizeof(uint32_t),                  VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, device);    // Map buffer memory to host.    uint8_t *data;    vkMapMemory(device->logical, buffer.memory, 0, VK_WHOLE_SIZE, 0,(void**) &data);    // Copy data to the buffer.    uint32_t offset = 0;    memcpy(data + offset, vertices.data(), vertices.size() * sizeof(VkVertex));    offset += vertices.size() * sizeof(VkVertex);    memcpy(data + offset, indices.data(), indices.size() * sizeof(uint32_t));    // Unmap memory.    vkUnmapMemory(device->logical, buffer.memory);}
开发者ID:vapopescu,项目名称:Vulkan-Engine,代码行数:34,


示例8: sin

void VulkanGear::updateUniformBuffer(glm::mat4 perspective, glm::vec3 rotation, float zoom, float timer){	ubo.projection = perspective;	ubo.view = glm::lookAt(		glm::vec3(0, 0, -zoom),		glm::vec3(-1.0, -1.5, 0),		glm::vec3(0, 1, 0)		);	ubo.view = glm::rotate(ubo.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));	ubo.view = glm::rotate(ubo.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));	ubo.model = glm::mat4();	ubo.model = glm::translate(ubo.model, pos);	rotation.z = (rotSpeed * timer) + rotOffset;	ubo.model = glm::rotate(ubo.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));	ubo.normal = glm::inverseTranspose(ubo.view * ubo.model);	ubo.lightPos = glm::vec3(0.0f, 0.0f, 2.5f);	ubo.lightPos.x = sin(glm::radians(timer)) * 8.0f;	ubo.lightPos.z = cos(glm::radians(timer)) * 8.0f;	uint8_t *pData;	VK_CHECK_RESULT(vkMapMemory(device, uniformData.memory, 0, sizeof(ubo), 0, (void **)&pData));	memcpy(pData, &ubo, sizeof(ubo));	vkUnmapMemory(device, uniformData.memory);}
开发者ID:AndrewGe,项目名称:Vulkan,代码行数:28,


示例9: sizeof

void op3d::Engine::createIndexBuffer(){    VkDeviceSize bufferSize = sizeof(indices[0]) * indices.size();    VDeleter<VkBuffer> stagingBuffer{device, vkDestroyBuffer};    VDeleter<VkDeviceMemory> stagingBufferMemory{device, vkFreeMemory};    createBuffer(bufferSize,                 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,                 stagingBuffer,                 stagingBufferMemory);    void* data;    vkMapMemory(device, stagingBufferMemory, 0, bufferSize, 0, &data);    memcpy(data, indices.data(), (std::size_t)bufferSize);    vkUnmapMemory(device, stagingBufferMemory);    createBuffer(bufferSize,                 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,                 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,                 indexBuffer,                 indexBufferMemory);    copyBuffer(stagingBuffer, indexBuffer, bufferSize);}
开发者ID:zgub4,项目名称:op3d,代码行数:25,


示例10: updateUniformBuffers

	void updateUniformBuffers()	{		uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);		uboVS.view = glm::lookAt(			glm::vec3(0, 0, -zoom),			glm::vec3(0, 0, 0),			glm::vec3(0, 1, 0)			);		uboVS.model = glm::mat4();		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboVS.model = glm::rotate(uboVS.model, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uboVS.normal = glm::inverseTranspose(uboVS.view * uboVS.model);		uboVS.lightPos = lightPos;		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.meshVS.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.meshVS.memory);	}
开发者ID:Delwin9999,项目名称:Vulkan,代码行数:25,


示例11: sizeof

void vkeGameRendererDynamic::setMaterialData(VkeMaterial::List *inData){	m_materials = inData;	if (m_materials != NULL){		uint32_t cnt = m_materials->count();		uint32_t sz = sizeof(VkeMaterialUniform) * cnt;		VkBufferUsageFlags usageFlags = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;		bufferCreate(&m_material_buffer_staging, sz, (VkBufferUsageFlagBits)usageFlags);		bufferAlloc(&m_material_buffer_staging, &m_material_staging, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT);		VkeMaterialUniform *uniforms = NULL;		VKA_CHECK_ERROR(vkMapMemory(getDefaultDevice(), m_material_staging, 0, sz, 0, (void **)&uniforms), "Could not map buffer memory./n");		for (uint32_t i = 0; i < cnt; ++i){			VkeMaterial *mat = m_materials->getMaterial(i);			mat->initVKBufferData(m_material_buffer_staging);			mat->updateVKBufferData(uniforms);		}		vkUnmapMemory(getDefaultDevice(), m_material_staging);	}}
开发者ID:brdf,项目名称:gl_vk_chopper,代码行数:27,


示例12: sizeof

void VertexBuffer::uploadData(std::vector<Vertex>& vertexData) {	//create the buffer	VkBufferCreateInfo createInfo = {};	createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;	createInfo.size = sizeof(Vertex) * vertexData.size();	createInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;	createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;	if (vkCreateBuffer(deviceHelper.getDevice(), &createInfo, nullptr, buffer.replace()) != VK_SUCCESS) {		throw std::runtime_error("Could not create buffer.");	}	VkMemoryRequirements memReqs = {};	vkGetBufferMemoryRequirements(deviceHelper.getDevice(), buffer, &memReqs);	//allocate the memory	VkMemoryAllocateInfo allocInfo = {};	allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;	allocInfo.allocationSize = memReqs.size;	allocInfo.memoryTypeIndex = deviceHelper.findMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);	if (vkAllocateMemory(deviceHelper.getDevice(), &allocInfo, nullptr, bufferMemory.replace()) != VK_SUCCESS) {		throw std::runtime_error("Could not allocate buffer memory.");	}	vkBindBufferMemory(deviceHelper.getDevice(), buffer, bufferMemory, 0);	//upload the data	void* dataPtr;	vkMapMemory(deviceHelper.getDevice(), bufferMemory, 0, createInfo.size, 0, &dataPtr);	memcpy(dataPtr, vertexData.data(), createInfo.size);	vkUnmapMemory(deviceHelper.getDevice(), bufferMemory);}
开发者ID:MadDoctor5813,项目名称:Vulkan-Demo,代码行数:28,


示例13: game_buffer_editor_record_vulkan_commands

bool game_buffer_editor_record_vulkan_commands(game_buffer *game_buffer, vulkan *vulkan) {  game_buffer_editor *editor = game_buffer->editor;  ImDrawData *draw_data = ImGui::GetDrawData();  VkResult vk_result = {};  {    uint64 vertices_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);    uint64 indices_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);    uint64 map_size = round_to_multi(vertices_size + indices_size, vulkan->physical_device_non_coherent_atom_size);    assert(map_size <= editor->imgui_vertex_index_vulkan_buffer.size);    uint8 *buf_ptr = nullptr;    if ((vk_result = vkMapMemory(vulkan->device, editor->imgui_vertex_index_vulkan_buffer.device_memory, 0, map_size, 0, (void **)&buf_ptr)) != VK_SUCCESS) {      return false;    }    assert((uintptr_t)buf_ptr % 16 == 0);    for (int i = 0; i < draw_data->CmdListsCount; i += 1) {      ImDrawList *dlist = draw_data->CmdLists[i];      memcpy(buf_ptr, dlist->VtxBuffer.Data, dlist->VtxBuffer.Size * sizeof(ImDrawVert));      buf_ptr += dlist->VtxBuffer.Size * sizeof(ImDrawVert);    }    for (int i = 0; i < draw_data->CmdListsCount; i += 1) {      ImDrawList *dlist = draw_data->CmdLists[i];      memcpy(buf_ptr, dlist->IdxBuffer.Data, dlist->IdxBuffer.Size * sizeof(ImDrawIdx));      buf_ptr += dlist->IdxBuffer.Size * sizeof(ImDrawIdx);    }    VkMappedMemoryRange memory_range = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE };    memory_range.memory = editor->imgui_vertex_index_vulkan_buffer.device_memory;    memory_range.offset = map_size;    if ((vk_result = vkFlushMappedMemoryRanges(vulkan->device, 1, &memory_range)) != VK_SUCCESS) {      return false;    }    vkUnmapMemory(vulkan->device, editor->imgui_vertex_index_vulkan_buffer.device_memory);  }  vkCmdBindPipeline(vulkan->swap_chain_cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, editor->imgui_vulkan_pipeline);  VkViewport viewport = { 0, 0, (float)game_buffer->vulkan_framebuffer_image_width, (float)game_buffer->vulkan_framebuffer_image_height, 0, 1 };  vkCmdSetViewport(vulkan->swap_chain_cmd_buffer, 0, 1, &viewport);  vec2 push_consts = { (float)game_buffer->vulkan_framebuffer_image_width, (float)game_buffer->vulkan_framebuffer_image_height };  vkCmdPushConstants(vulkan->swap_chain_cmd_buffer, editor->imgui_vulkan_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(push_consts), &push_consts);  VkDeviceSize vertex_offset = 0;  VkDeviceSize index_offset = draw_data->TotalVtxCount * sizeof(ImDrawVert);  for (int i = 0; i < draw_data->CmdListsCount; i += 1) {    ImDrawList *dlist = draw_data->CmdLists[i];    vkCmdBindVertexBuffers(vulkan->swap_chain_cmd_buffer, 0, 1, &editor->imgui_vertex_index_vulkan_buffer.buffer, &vertex_offset);    vertex_offset += dlist->VtxBuffer.Size * sizeof(ImDrawVert);    for (int i = 0; i < dlist->CmdBuffer.Size; i += 1) {      ImDrawCmd *dcmd = &dlist->CmdBuffer.Data[i];      VkRect2D scissor = { { (int)dcmd->ClipRect.x, (int)dcmd->ClipRect.y }, { (uint)dcmd->ClipRect.z, (uint)dcmd->ClipRect.w } };      vkCmdSetScissor(vulkan->swap_chain_cmd_buffer, 0, 1, &scissor);      if (dcmd->TextureId == editor->imgui_font_atlas_vulkan_image.image) {        vkCmdBindDescriptorSets(vulkan->swap_chain_cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, editor->imgui_vulkan_pipeline_layout, 0, 1, &editor->imgui_vulkan_descriptor_sets[0], 0, nullptr);      }      else {        vkCmdBindDescriptorSets(vulkan->swap_chain_cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, editor->imgui_vulkan_pipeline_layout, 0, 1, &editor->imgui_vulkan_descriptor_sets[1], 0, nullptr);      }      vkCmdBindIndexBuffer(vulkan->swap_chain_cmd_buffer, editor->imgui_vertex_index_vulkan_buffer.buffer, index_offset, VK_INDEX_TYPE_UINT16);      vkCmdDrawIndexed(vulkan->swap_chain_cmd_buffer, dcmd->ElemCount, 1, 0, 0, 0);      index_offset += dcmd->ElemCount * sizeof(ImDrawIdx);    }  }  return true;}
开发者ID:yngccc,项目名称:apby,代码行数:60,


示例14: vkMapMemory

            bool VKMaterial::VUpdate()             {                //TODO: Figure out what data is going into what buffers                if (m_shaderVariables.size() == 0)                    return true;                VkDevice device = VKRenderer::RendererInstance->GetVKDevice();                uint8_t* pData;                                std::vector<Math::Matrix4> variableList;                std::map <std::string, ShaderVariable*>::iterator it;                for (it = m_shaderVariables.begin(); it != m_shaderVariables.end(); it++)                    variableList.push_back(*(Math::Matrix4*)(it->second->GetData()));                                VkResult err = vkMapMemory(device, m_uniformVSBuffer.memory, 0, sizeof(m_shaderVariables), 0, (void**)&pData);                assert(!err);                                memcpy(pData, variableList.data(), sizeof(Math::Matrix4));                vkUnmapMemory(device, m_uniformVSBuffer.memory);                return true;            }
开发者ID:JamesMarcil,项目名称:HatchitGraphics,代码行数:26,


示例15: assert

	xdl_int XdevLVertexBufferVulkan::unmap() {		assert(m_mapped && "XdevLVertexBufferVulkan::map: Was not mapped.");		vkUnmapMemory(m_device, m_deviceMemory);		m_mapped = xdl_false;		return RET_SUCCESS;	}
开发者ID:yaakuro,项目名称:XdevLSDK,代码行数:7,


示例16: unmap

		/**		* Unmap a mapped memory range		*		* @note Does not return a result as vkUnmapMemory can't fail		*/		void unmap()		{			if (mapped)			{				vkUnmapMemory(device, memory);				mapped = nullptr;			}		}
开发者ID:AlexanderVladimirov9090,项目名称:Vulkan,代码行数:13,


示例17: destroyUniformData

	void destroyUniformData(VkDevice device, vkTools::UniformData * uniformData)	{		if (uniformData->mapped != nullptr) {			vkUnmapMemory(device, uniformData->memory);		}		vkDestroyBuffer(device, uniformData->buffer, nullptr);		vkFreeMemory(device, uniformData->memory, nullptr);	}
开发者ID:GTOwlStudio,项目名称:BoardDesigner,代码行数:8,


示例18: vkUnmapMemory

	void VulkanImage::unmap()	{		VulkanDevice& device = mOwner->getDevice();		VkDeviceMemory memory;		VkDeviceSize memoryOffset;		device.getAllocationInfo(mAllocation, memory, memoryOffset);		vkUnmapMemory(device.getLogical(), memory);	}
开发者ID:lysannschlegel,项目名称:bsf,代码行数:10,


示例19: sin

		lightPos.y = -50.0f + sin(glm::radians(timer * 360.0f)) * 20.0f;		lightPos.z = 25.0f + sin(glm::radians(timer * 360.0f)) * 5.0f;	}	void updateUniformBuffers()	{		// Shadow map debug quad		float AR = (float)height / (float)width;		uboVSquad.projection = glm::ortho(0.0f, 2.5f / AR, 0.0f, 2.5f, -1.0f, 1.0f);		uboVSquad.model = glm::mat4();		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformDataVS.memory, 0, sizeof(uboVSquad), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVSquad, sizeof(uboVSquad));		vkUnmapMemory(device, uniformDataVS.memory);		// 3D scene		uboVSscene.projection = glm::perspective(glm::radians(45.0f), (float)width / (float)height, zNear, zFar);		uboVSscene.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));		uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboVSscene.view = glm::rotate(uboVSscene.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uboVSscene.model = glm::mat4();		uboVSscene.lightPos = lightPos;		// Render scene from light's point of view		if (lightPOV)		{			uboVSscene.projection = glm::perspective(glm::radians(lightFOV), (float)width / (float)height, zNear, zFar);			uboVSscene.view = glm::lookAt(lightPos, glm::vec3(0.0f), glm::vec3(0, 1, 0));		}			uboVSscene.depthBiasMVP = uboOffscreenVS.depthMVP;		pData;		err = vkMapMemory(device, uniformData.scene.memory, 0, sizeof(uboVSscene), 0, (void **)&pData);
开发者ID:prabindh,项目名称:Vulkan,代码行数:42,


示例20: updateUniformBuffers

	void updateUniformBuffers()	{		computeUbo.deltaT = frameTimer * 5.0f;		computeUbo.destX = sin(glm::radians(timer*360.0)) * 0.75f;		computeUbo.destY = 0;		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.computeShader.ubo.memory, 0, sizeof(computeUbo), 0, (void **)&pData);		assert(!err);		memcpy(pData, &computeUbo, sizeof(computeUbo));		vkUnmapMemory(device, uniformData.computeShader.ubo.memory);	}
开发者ID:ron-devel,项目名称:Vulkan,代码行数:11,


示例21: updateUniformBuffers

	void updateUniformBuffers()	{		// Vertex shader		glm::mat4 viewMatrix = glm::mat4();		uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f);		viewMatrix = glm::translate(viewMatrix, glm::vec3(0.0f, 0.0f, zoom));		glm::mat4 rotMatrix = glm::mat4();		rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		rotMatrix = glm::rotate(rotMatrix, deg_to_rad(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uboVS.model = glm::mat4();		uboVS.model = viewMatrix * rotMatrix;;		uboVS.visible = 1.0f;		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.vsScene.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.vsScene.memory);		// teapot		// Toggle color depending on visibility		uboVS.visible = (passedSamples[0] > 0) ? 1.0f : 0.0f;		uboVS.model = viewMatrix * rotMatrix * glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, -10.0f));		err = vkMapMemory(device, uniformData.teapot.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.teapot.memory);		// sphere		// Toggle color depending on visibility		uboVS.visible = (passedSamples[1] > 0) ? 1.0f : 0.0f;		uboVS.model = viewMatrix * rotMatrix * glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, 10.0f));		err = vkMapMemory(device, uniformData.sphere.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.sphere.memory);	}
开发者ID:jshiraef,项目名称:VulkanTester,代码行数:41,


示例22: WError

WError WMaterial::SaveToStream(WFile* file, std::ostream& outputStream) {	if (!Valid())		return WError(W_NOTVALID);	VkDevice device = m_app->GetVulkanDevice();	// write the UBO data	uint tmp = m_uniformBuffers.size();	outputStream.write((char*)&tmp, sizeof(tmp));	for (uint i = 0; i < m_uniformBuffers.size(); i++) {		UNIFORM_BUFFER_INFO* UBO = &m_uniformBuffers[i];		outputStream.write((char*)&UBO->descriptor.range, sizeof(UBO->descriptor.range));		void* data;		VkResult vkRes = vkMapMemory(device, m_uniformBuffers[i].memory, 0, UBO->descriptor.range, 0, (void **)&data);		if (vkRes)			return WError(W_UNABLETOMAPBUFFER);		outputStream.write((char*)data, UBO->descriptor.range);		vkUnmapMemory(device, m_uniformBuffers[0].memory);	}	// write the texture data	tmp = m_sampler_info.size();	outputStream.write((char*)&tmp, sizeof(tmp));	std::streampos texturesOffset = outputStream.tellp();	for (uint i = 0; i < m_sampler_info.size(); i++) {		SAMPLER_INFO* SI = &m_sampler_info[i];		tmp = 0;		outputStream.write((char*)&tmp, sizeof(tmp));		outputStream.write((char*)&SI->sampler_info->binding_index, sizeof(SI->sampler_info->binding_index));	}	outputStream.write((char*)&tmp, sizeof(tmp)); // effect id	_MarkFileEnd(file, outputStream.tellp());	// save dependencies	for (uint i = 0; i < m_sampler_info.size(); i++) {		SAMPLER_INFO* SI = &m_sampler_info[i];		if (SI->img) {			WError err = file->SaveAsset(SI->img, &tmp);			if (!err)				return err;			outputStream.seekp(texturesOffset + std::streamoff(i * (2 * sizeof(uint))));			outputStream.write((char*)&tmp, sizeof(tmp));		}	}	WError err = file->SaveAsset(m_effect, &tmp);	if (!err)		return err;	outputStream.seekp(texturesOffset + std::streamoff(m_sampler_info.size() * (2 * sizeof(uint))));	outputStream.write((char*)&tmp, sizeof(tmp));	return WError(W_SUCCEEDED);}
开发者ID:Hasan-Jawaheri,项目名称:Wasabi,代码行数:52,


示例23: _dbg_assert_

void VulkanPushBuffer::Unmap() {	_dbg_assert_(G3D, writePtr_ != 0);	/*	// Should not need this since we use coherent memory.	VkMappedMemoryRange range{ VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE };	range.offset = 0;	range.size = offset_;	range.memory = buffers_[buf_].deviceMemory;	vkFlushMappedMemoryRanges(device_, 1, &range);	*/	vkUnmapMemory(device_, buffers_[buf_].deviceMemory);	writePtr_ = nullptr;}
开发者ID:AmesianX,项目名称:ppsspp,代码行数:13,


示例24: if

 void Buffer::unmap() {     if (mpStagingResource)     {         mpStagingResource->unmap();         mpStagingResource = nullptr;     }     // We only unmap staging buffers     else if (mDynamicData.pData == nullptr && mBindFlags == BindFlags::None)     {         assert(mCpuAccess == CpuAccess::Read);         vkUnmapMemory(gpDevice->getApiHandle(), mApiHandle);     } }
开发者ID:Junios,项目名称:Falcor,代码行数:14,


示例25: vkUnmapMemory

void WImage::UnmapPixels() {	VkDevice device = m_app->GetVulkanDevice();	vkUnmapMemory(device, m_stagingMemory);	if (!m_readOnlyMap) {		VkResult err = m_app->BeginCommandBuffer();		if (err)			return;		VkBufferImageCopy bufferCopyRegion = {};		// Setup buffer copy regions for each mip level		bufferCopyRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;		bufferCopyRegion.imageSubresource.mipLevel = 0;		bufferCopyRegion.imageSubresource.baseArrayLayer = 0;		bufferCopyRegion.imageSubresource.layerCount = 1;		bufferCopyRegion.imageExtent.width = m_width;		bufferCopyRegion.imageExtent.height = m_height;		bufferCopyRegion.imageExtent.depth = 1;		bufferCopyRegion.bufferOffset = 0;		// Image barrier for optimal image (target)		// Optimal image will be used as destination for the copy		vkTools::setImageLayout(			m_app->GetCommandBuffer(),			m_image,			VK_IMAGE_ASPECT_COLOR_BIT,			VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,			VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);		// Copy mip levels from staging buffer		vkCmdCopyBufferToImage(			m_app->GetCommandBuffer(),			m_stagingBuffer,			m_image,			VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,			1,			&bufferCopyRegion		);		// Change texture image layout to shader read after all mip levels have been copied		vkTools::setImageLayout(			m_app->GetCommandBuffer(),			m_image,			VK_IMAGE_ASPECT_COLOR_BIT,			VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,			VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);		err = m_app->EndCommandBuffer();	}}
开发者ID:Hasan-Jawaheri,项目名称:Wasabi,代码行数:50,


示例26: updateUniformBuffers

	void updateUniformBuffers()	{		uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f);		uboVS.view = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, zoom));		uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));		uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));		uboVS.view = glm::rotate(uboVS.view, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformData.vsScene.memory, 0, sizeof(uboVS), 0, (void **)&pData);		assert(!err);		memcpy(pData, &uboVS, sizeof(uboVS));		vkUnmapMemory(device, uniformData.vsScene.memory);	}
开发者ID:AnastasiaBorisova,项目名称:Vulkan,代码行数:15,


示例27: memcpy

		memcpy(pData, &uboVSscene, sizeof(uboVSscene));		vkUnmapMemory(device, uniformData.scene.memory);	}	void updateUniformBufferOffscreen()	{		// Matrix from light's point of view		glm::mat4 depthProjectionMatrix = glm::perspective(glm::radians(lightFOV), 1.0f, zNear, zFar);		glm::mat4 depthViewMatrix = glm::lookAt(lightPos, glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));		glm::mat4 depthModelMatrix = glm::mat4();		uboOffscreenVS.depthMVP = depthProjectionMatrix * depthViewMatrix * depthModelMatrix;		uint8_t *pData;		VkResult err = vkMapMemory(device, uniformDataOffscreenVS.memory, 0, sizeof(uboOffscreenVS), 0, (void **)&pData);
开发者ID:prabindh,项目名称:Vulkan,代码行数:15,


示例28: vkMapMemory

	xdl_int XdevLVertexBufferVulkan::upload(xdl_uint8* src, xdl_uint size) {		if(m_memReqs.size > size) {			return RET_FAILED;		}		xdl_uint8* pData;		VkResult result = vkMapMemory(m_device, m_deviceMemory, 0, m_memReqs.size, 0, (void **)&pData);		if(VK_SUCCESS != result) {			return RET_FAILED;		}		memcpy(pData, src, size);		vkUnmapMemory(m_device, m_deviceMemory);		return RET_FAILED;	}
开发者ID:yaakuro,项目名称:XdevLSDK,代码行数:16,



注:本文中的vkUnmapMemory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ vkUpdateDescriptorSets函数代码示例
C++ vkQueueSubmit函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。