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

有个网站专做品牌 而且价格便宜淘宝数据分析工具

有个网站专做品牌 而且价格便宜,淘宝数据分析工具,郑州网站高端设计,网站名字大全WebGPU(七):C头部封装 在前面的学习中,我们使用的都是原生态的WebGPU API,那是基于C语言的API,但是为了更高效的开发,我们可以使用一个基于C的库。 根据参考的教程,这个github库提供更加纤细的描述。它提…

WebGPU(七):C++头部封装

在前面的学习中,我们使用的都是原生态的WebGPU API,那是基于C语言的API,但是为了更高效的开发,我们可以使用一个基于C++的库。

根据参考的教程,这个github库提供更加纤细的描述。它提供了一个webgpu.hpp的C++封装头文件,但是在Dawn的代码实现中,本身包含一个C++头封装文件,本例程主要使用Dawn自带的C++封装头文件。

#define WEBGPU_CPP_IMPLEMENTATION
#include <webgpu/webgpu.hpp>#include <glfw3webgpu.h>
#include <GLFW/glfw3.h>#include <iostream>
#include <cassert>#define UNUSED(x) (void)x;using namespace wgpu;int main (int, char**) {Instance instance = createInstance(InstanceDescriptor{});if (!instance) {std::cerr << "Could not initialize WebGPU!" << std::endl;return 1;}if (!glfwInit()) {std::cerr << "Could not initialize GLFW!" << std::endl;return 1;}glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);GLFWwindow* window = glfwCreateWindow(640, 480, "Learn WebGPU", NULL, NULL);if (!window) {std::cerr << "Could not open window!" << std::endl;return 1;}std::cout << "Requesting adapter..." << std::endl;Surface surface = glfwGetWGPUSurface(instance, window);RequestAdapterOptions adapterOpts{};adapterOpts.compatibleSurface = surface;Adapter adapter = instance.requestAdapter(adapterOpts);std::cout << "Got adapter: " << adapter << std::endl;std::cout << "Requesting device..." << std::endl;DeviceDescriptor deviceDesc{};deviceDesc.label = "My Device";deviceDesc.requiredFeaturesCount = 0;deviceDesc.requiredLimits = nullptr;deviceDesc.defaultQueue.label = "The default queue";Device device = adapter.requestDevice(deviceDesc);std::cout << "Got device: " << device << std::endl;Queue queue = device.getQueue();auto onDeviceError = [](WGPUErrorType type, char const* message, void* /* pUserData */) {std::cout << "Uncaptured device error: type " << type;if (message) std::cout << " (" << message << ")";std::cout << std::endl;};wgpuDeviceSetUncapturedErrorCallback(device, onDeviceError, nullptr /* pUserData */);std::cout << "Creating swapchain device..." << std::endl;
#ifdef WEBGPU_BACKEND_WGPUTextureFormat swapChainFormat = surface.getPreferredFormat(adapter);
#elseTextureFormat swapChainFormat = TextureFormat::BGRA8Unorm;
#endifSwapChainDescriptor swapChainDesc = {};swapChainDesc.width = 640;swapChainDesc.height = 480;swapChainDesc.usage = TextureUsage::RenderAttachment;swapChainDesc.format = swapChainFormat;swapChainDesc.presentMode = PresentMode::Fifo;SwapChain swapChain = device.createSwapChain(surface, swapChainDesc);std::cout << "Swapchain: " << swapChain << std::endl;while (!glfwWindowShouldClose(window)) {glfwPollEvents();TextureView nextTexture = swapChain.getCurrentTextureView();if (!nextTexture) {std::cerr << "Cannot acquire next swap chain texture" << std::endl;return 1;}CommandEncoderDescriptor commandEncoderDesc{};commandEncoderDesc.label = "Command Encoder";CommandEncoder encoder = device.createCommandEncoder(commandEncoderDesc);RenderPassDescriptor renderPassDesc{};WGPURenderPassColorAttachment renderPassColorAttachment = {};renderPassColorAttachment.view = nextTexture;renderPassColorAttachment.resolveTarget = nullptr;renderPassColorAttachment.loadOp = LoadOp::Clear;renderPassColorAttachment.storeOp = StoreOp::Store;renderPassColorAttachment.clearValue = Color{ 0.9, 0.1, 0.2, 1.0 };renderPassDesc.colorAttachmentCount = 1;renderPassDesc.colorAttachments = &renderPassColorAttachment;renderPassDesc.depthStencilAttachment = nullptr;renderPassDesc.timestampWriteCount = 0;renderPassDesc.timestampWrites = nullptr;RenderPassEncoder renderPass = encoder.beginRenderPass(renderPassDesc);renderPass.end();nextTexture.release();CommandBufferDescriptor cmdBufferDescriptor{};cmdBufferDescriptor.label = "Command buffer";CommandBuffer command = encoder.finish(cmdBufferDescriptor);queue.submit(command);swapChain.present();}glfwDestroyWindow(window);glfwTerminate();return 0;
}

因为在测试的时候发现,有很多函数都没有相对应的封装,所以这一步的代码修改的内容相对而言很少。

http://www.jinmujx.cn/news/111732.html

相关文章:

  • 怎么做淘宝客网站页面宁波seo网络推广咨询热线
  • 深圳品牌做网站公司有哪些网络服务器有哪些
  • 更换wordpress登录界面深圳英文站seo
  • 湖北营销型网站建设seo数据优化
  • 怎么修改WordPress文件結構seo 资料包怎么获得
  • 做网站一定要实名认证吗流量精灵
  • 网络游戏端游郑州优化网站公司
  • 齐河网站建设公司网络营销的优势与不足
  • 自适应网站wordpress推广app用什么平台比较好
  • 融媒体中心 党政网站的建设广州seo网站优化培训
  • 阿里巴巴网站开发seo关键词排名软件流量词
  • 网站风格分类百度云登录首页
  • 微网站自己怎么做品牌营销策划公司哪家好
  • 建设一个网站的支出杭州seo按天计费
  • 软件开发培训机构价格上海seo优化外包公司
  • 高端品牌全屋定制成都自动seo
  • 做钓鱼网站会被抓吗百度竞价排名平台
  • 吴江城乡建设局网站产品软文代写
  • 一个网站能放多少关键词周口网络推广哪家好
  • 福州家园网新河seo怎么做整站排名
  • 锦州网站建设哪家好sem是什么方法
  • 怎么免费做一个网站做淘宝客市场推广外包团队
  • 网站的mysql数据库放到服务器上服务器需要安装mysql吗?推广团队在哪里找
  • 福州市疫情最新情况曹操论坛seo
  • 平度做网站公司晚上免费b站软件
  • 河南省建设监理协会网站人才十seo公司推广宣传
  • 360网站咋做东莞关键词优化软件
  • mysql python开发网站开发永久免费自助建站平台
  • 金坛网站建设百度后台登录
  • 阿里云怎样做商城式网站南宁优化网站收费