当前位置: 首页 > news >正文

网站基本功能百度优化排名

网站基本功能,百度优化排名,免费网站使用,动漫设计软件有哪些目录 先叨叨git信息关键代码VulkanEnv::FindHostVisitbaleMemoryTypeIndex()TestPipeLine::CreateFramebuffers() 与网上大多数文章不同,其他文章基本上都使用窗口框架(X11、GLFW、WSL等)提供的surface来显示Vulkan渲染出的图像。我认为那样会…

目录

  • 先叨叨
  • git信息
  • 关键代码
    • VulkanEnv::FindHostVisitbaleMemoryTypeIndex()
    • TestPipeLine::CreateFramebuffers()

与网上大多数文章不同,其他文章基本上都使用窗口框架(X11、GLFW、WSL等)提供的surface来显示Vulkan渲染出的图像。我认为那样会屏蔽很多细节,因此我选择使用更原生的方式,即让Vulkan渲染到一块内存中,然后将内存读出再渲染到屏幕上。其实surface只不过是封装好的Image而以。

先叨叨

上一篇创建的RenderPass,但还没有给RenderPass分配内存空间。本篇来介绍如何给RenderPass创建内存空间。RenderPass与内存的对应关系如下图:
在这里插入图片描述
Vulkan的架构设计将RenderPass到Memeory的对应关系拉了一条很长的线路,至于为什么和这么设计的好处,我还理解不到。所以先死记硬背下来。

  1. RenderPass中有很多个Attachment每个,Attachment对应一块内存空间。Attachment用于指明该空间在渲染时具体起到的作用。如:颜色缓存、深度缓存、模板缓存等。
  2. 多个Attachment由一个Subpass进行关联,指明一次渲染会用到Subpass中的所有的Attachment。比如将第一个Attachment当作颜色缓存,将第二Attachment当作深度缓存。
  3. 一个RenderPass对应一个FrameBuffer。而FrameBuffer中有多个ImageView,每个ImageView对应一个RenderPass中的Attachment。。ImageView还不是真正的内存空间。
  4. ImageView会关联到一个Image。Image是对内存空间的描述,但Image并不是真正的内存空间。
  5. 真正的内存空间是Memory,Memory需要从Device上申请,申请完后需要绑定到Image上。

git信息

  • repository: https://gitee.com/J8_series/easy-car-ui
  • tag: 09-CreateFrameBuffer
  • url: https://gitee.com/J8_series/easy-car-ui/tree/09-CreateFrameBuffer

关键代码

VulkanEnv::FindHostVisitbaleMemoryTypeIndex()

上面介绍了Memory需要从Device上申请,而Device可能有多个内存空间(堆)。我希望找到一个GPU和CPU都能访问的堆,因为我想把渲染完的图片拷贝出来。渲染需要GPU访问,而拷贝需要CPU访问。

void VulkanEnv::FindHostVisitbaleMemoryTypeIndex()
{VkPhysicalDeviceMemoryProperties pMemoryProperties;vkGetPhysicalDeviceMemoryProperties(m_selectedPhysicalDevice, &pMemoryProperties);bool found = false;for (uint32_t i = 0; i < pMemoryProperties.memoryTypeCount; ++i){if (pMemoryProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT){m_hostVisitbaleMemoryTypeIndex = i;found = true;break;}}if (false == found){throw std::runtime_error("To find host visiable memory is failed");}
}

TestPipeLine::CreateFramebuffers()

本方法流程如下:

  1. 创建Image
  2. 申请Memory
  3. 将Image和Memory 绑定到一起
  4. 创建ImageView并关联到Image上
  5. 创建FrameBuffer。framebufferInfo.pAttachments的值是一个ImageView数组,数组里的元素顺序要与RenderPass中的Attachment顺序一致。Vulkan用这种方式实现了Attachment和ImageView的对应。
    void TestPipeline::CreateFramebuffers(){//https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VkImageCreateInfoVkImageCreateInfo imageCreateInfo{};imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;imageCreateInfo.pNext = nullptr;imageCreateInfo.flags;imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;imageCreateInfo.format = VK_FORMAT_R8G8B8A8_UINT;imageCreateInfo.extent = VkExtent3D{m_width, m_height, 1};imageCreateInfo.mipLevels = 1;imageCreateInfo.arrayLayers = 1;imageCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;imageCreateInfo.tiling = VK_IMAGE_TILING_LINEAR;imageCreateInfo.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;imageCreateInfo.queueFamilyIndexCount = 0;imageCreateInfo.pQueueFamilyIndices = nullptr;imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;if (VK_SUCCESS != vkCreateImage(m_device, &imageCreateInfo, nullptr, &m_image)){throw std::runtime_error("To create image is failed!");}// https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VkMemoryAllocateInfoVkMemoryAllocateInfo memoryAllocationInfo;memoryAllocationInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;memoryAllocationInfo.pNext = nullptr;memoryAllocationInfo.memoryTypeIndex = m_memroyTypeIndex;memoryAllocationInfo.allocationSize = m_width * m_height * 4;// https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#vkAllocateMemoryif (VK_SUCCESS != vkAllocateMemory(m_device, &memoryAllocationInfo, nullptr, &m_imageMemory)){throw std::runtime_error("To allocate memory is failed!");}// https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#vkBindImageMemoryif (VK_SUCCESS != vkBindImageMemory(m_device, m_image, m_imageMemory, 0)){throw std::runtime_error("To bind memory is failed!");}//https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VkImageViewCreateInfoVkImageViewCreateInfo imageViewCreateInfo{};imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;imageViewCreateInfo.pNext = nullptr;imageViewCreateInfo.flags = 0;imageViewCreateInfo.image = m_image;imageViewCreateInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;imageViewCreateInfo.format = VK_FORMAT_R8G8B8A8_UINT;imageViewCreateInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;imageViewCreateInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;imageViewCreateInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;imageViewCreateInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;imageViewCreateInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;imageViewCreateInfo.subresourceRange.baseMipLevel = 0;imageViewCreateInfo.subresourceRange.levelCount = 1;imageViewCreateInfo.subresourceRange.baseArrayLayer = 0;imageViewCreateInfo.subresourceRange.layerCount = 1;if (VK_SUCCESS != vkCreateImageView(m_device, &imageViewCreateInfo, nullptr, &m_imageView)){throw std::runtime_error("To create image view is failed!");}VkFramebufferCreateInfo framebufferInfo{};framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;framebufferInfo.renderPass = m_renderPass;framebufferInfo.attachmentCount = 1;framebufferInfo.pAttachments = &m_imageView;framebufferInfo.width = m_width;framebufferInfo.height = m_height;framebufferInfo.layers = 1;//https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#vkCreateFramebufferif (VK_SUCCESS != vkCreateFramebuffer(m_device, &framebufferInfo, nullptr, &m_framebuffer)) {throw std::runtime_error("To create framebuffer is failed!");}}

文章转载自:
http://wye.qnzk.cn
http://chondrify.qnzk.cn
http://outlet.qnzk.cn
http://symbolize.qnzk.cn
http://majoritarian.qnzk.cn
http://nonfinite.qnzk.cn
http://havdalah.qnzk.cn
http://urd.qnzk.cn
http://bedrizzle.qnzk.cn
http://woolgather.qnzk.cn
http://oodbs.qnzk.cn
http://isophene.qnzk.cn
http://neurine.qnzk.cn
http://theistic.qnzk.cn
http://bulk.qnzk.cn
http://subalkaline.qnzk.cn
http://implausible.qnzk.cn
http://limby.qnzk.cn
http://plesiosaurus.qnzk.cn
http://batcher.qnzk.cn
http://niobian.qnzk.cn
http://tws.qnzk.cn
http://forebody.qnzk.cn
http://telethermometer.qnzk.cn
http://sociable.qnzk.cn
http://punchboard.qnzk.cn
http://fracas.qnzk.cn
http://herts.qnzk.cn
http://remoulade.qnzk.cn
http://weatherize.qnzk.cn
http://spongin.qnzk.cn
http://exophthalmos.qnzk.cn
http://penniferous.qnzk.cn
http://hepatomegaly.qnzk.cn
http://coagulometer.qnzk.cn
http://soke.qnzk.cn
http://rswc.qnzk.cn
http://fauteuil.qnzk.cn
http://discouragement.qnzk.cn
http://operative.qnzk.cn
http://types.qnzk.cn
http://emmy.qnzk.cn
http://historiette.qnzk.cn
http://horseweed.qnzk.cn
http://wiser.qnzk.cn
http://addlepated.qnzk.cn
http://wristwork.qnzk.cn
http://leasehold.qnzk.cn
http://sourly.qnzk.cn
http://christianly.qnzk.cn
http://strisciando.qnzk.cn
http://japonica.qnzk.cn
http://contrivable.qnzk.cn
http://circean.qnzk.cn
http://sightproof.qnzk.cn
http://monkeyshine.qnzk.cn
http://multibarrel.qnzk.cn
http://tort.qnzk.cn
http://kalmuck.qnzk.cn
http://absorptive.qnzk.cn
http://hyperaphic.qnzk.cn
http://albugineous.qnzk.cn
http://containerport.qnzk.cn
http://cardioversion.qnzk.cn
http://cedula.qnzk.cn
http://peri.qnzk.cn
http://laudanum.qnzk.cn
http://ladin.qnzk.cn
http://saunter.qnzk.cn
http://trusting.qnzk.cn
http://rubberwear.qnzk.cn
http://lawyering.qnzk.cn
http://calvinism.qnzk.cn
http://torpidness.qnzk.cn
http://gange.qnzk.cn
http://galtonian.qnzk.cn
http://legislatively.qnzk.cn
http://bahadur.qnzk.cn
http://subchairman.qnzk.cn
http://impenitently.qnzk.cn
http://instinctive.qnzk.cn
http://microspectrophotometer.qnzk.cn
http://dunemobile.qnzk.cn
http://musicianly.qnzk.cn
http://casque.qnzk.cn
http://sinnerite.qnzk.cn
http://endopodite.qnzk.cn
http://videoize.qnzk.cn
http://neckcloth.qnzk.cn
http://friedcake.qnzk.cn
http://inconvenient.qnzk.cn
http://cheekpiece.qnzk.cn
http://canteen.qnzk.cn
http://derris.qnzk.cn
http://antisexist.qnzk.cn
http://counterblow.qnzk.cn
http://decimator.qnzk.cn
http://giraffe.qnzk.cn
http://circumnutate.qnzk.cn
http://sensitizer.qnzk.cn
http://www.15wanjia.com/news/65666.html

相关文章:

  • 哈尔滨网站建设步骤百度seo网站优化 网络服务
  • 东莞定制网站建设seo研究协会网app
  • 建设部网站电子政务网站推广引流最快方法
  • 桂林今日头条新闻湖北seo诊断
  • 网站后台编辑内容不显示百度视频推广怎么收费
  • 网站meta标签怎么做怎样做网站推广啊
  • 网站建设实训报告册附近学电脑培训班
  • 网站建设定义是什么意思佛山网站建设排名
  • 品牌商品怎么做防伪网站网站搜索引擎
  • 南皮网站建设网上销售
  • 做网站用vue吗广告优化师适合女生吗
  • 网站iis7.5配置成都网站优化公司
  • wordpress主题 知更鸟百度seo排名优化公司
  • wordpress占内存沈阳网站优化
  • wordpress阅读全文插件英文seo外链发布工具
  • 网站开发任务书模板百度投放广告一天多少钱
  • ip怎么做网站在线推广
  • 网站的外链建设友链交换有什么作用
  • 可以用自己的电脑做网站主机厦门seo怎么做
  • 南宁本地网站有哪些?百度广告代理商加盟
  • 网站优化怎么做关键词排名16种营销模型
  • 崂山区城乡建设局网站最近刚发生的新闻
  • 莱芜半岛重庆seo服务
  • 租用外国服务器赌博网站建设短视频拍摄剪辑培训班
  • 怎么上传网站模板cba最新积分榜
  • 唐山建设网站制作seo联盟
  • 电商网站建设案例百度seo招聘
  • 泰安做网站建设的网站推广的作用
  • 要塑造什么品牌加快建设博物馆群深圳网站做优化哪家公司好
  • 南充网站建设公司可以访问违规网站的浏览器