From 836459dce3f50767d41978be4a2f7ac788e6a9ba Mon Sep 17 00:00:00 2001 From: grothedev Date: Thu, 2 Oct 2025 10:25:04 -0400 Subject: added metrics for rust impl. having trouble with c++ atm --- cpp-timeplot/CMakeLists.txt | 1 - cpp-timeplot/src/main.cpp | 105 ++++++++++++++++++----- cpp-timeplot/src/renderer.cpp | 185 ++++++++++++++++++++++++++++------------- cpp-timeplot/src/renderer.h | 14 ++-- cpp-timeplot/src/waterfall.cpp | 44 +++++----- cpp-timeplot/src/waterfall.h | 14 ++-- 6 files changed, 252 insertions(+), 111 deletions(-) (limited to 'cpp-timeplot') diff --git a/cpp-timeplot/CMakeLists.txt b/cpp-timeplot/CMakeLists.txt index 58993dd..5ae12be 100644 --- a/cpp-timeplot/CMakeLists.txt +++ b/cpp-timeplot/CMakeLists.txt @@ -66,7 +66,6 @@ set(SOURCES src/main.cpp src/renderer.cpp src/waterfall.cpp - src/webgpu_impl.cpp ) add_executable(timeplot ${SOURCES}) diff --git a/cpp-timeplot/src/main.cpp b/cpp-timeplot/src/main.cpp index 7afd3e8..35ae051 100644 --- a/cpp-timeplot/src/main.cpp +++ b/cpp-timeplot/src/main.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -12,7 +12,8 @@ constexpr int WINDOW_HEIGHT = 720; class Application { public: - Application() : window_(nullptr) {} + Application() : window_(nullptr), instance_(nullptr), device_(nullptr), + surface_(nullptr), adapter_(nullptr) {} ~Application() { cleanup(); @@ -61,9 +62,30 @@ public: } private: + static void onAdapterRequestEnded(WGPURequestAdapterStatus status, WGPUAdapter adapter, + WGPUStringView message, void* userdata1, void* userdata2) { + if (status == WGPURequestAdapterStatus_Success) { + *static_cast(userdata1) = adapter; + } else { + std::cerr << "Failed to get adapter: " << std::string(message.data, message.length) << std::endl; + } + } + + static void onDeviceRequestEnded(WGPURequestDeviceStatus status, WGPUDevice device, + WGPUStringView message, void* userdata1, void* userdata2) { + if (status == WGPURequestDeviceStatus_Success) { + *static_cast(userdata1) = device; + } else { + std::cerr << "Failed to get device: " << std::string(message.data, message.length) << std::endl; + } + } + bool initWebGPU() { // Create instance - instance_ = wgpu::createInstance(wgpu::InstanceDescriptor{}); + WGPUInstanceDescriptor instanceDesc = {}; + instanceDesc.nextInChain = nullptr; + + instance_ = wgpuCreateInstance(&instanceDesc); if (!instance_) { std::cerr << "Failed to create WebGPU instance" << std::endl; return false; @@ -76,23 +98,50 @@ private: return false; } - // Request adapter (synchronous version) - wgpu::RequestAdapterOptions adapterOpts{}; + // Request adapter with callback + WGPURequestAdapterOptions adapterOpts = {}; + adapterOpts.nextInChain = nullptr; adapterOpts.compatibleSurface = surface_; + adapterOpts.powerPreference = WGPUPowerPreference_HighPerformance; - wgpu::Adapter adapter = instance_.requestAdapter(adapterOpts); - if (!adapter) { - std::cerr << "Failed to get adapter" << std::endl; - return false; - } + WGPURequestAdapterCallbackInfo adapterCallbackInfo = {}; + adapterCallbackInfo.mode = WGPUCallbackMode_AllowSpontaneous; + adapterCallbackInfo.callback = onAdapterRequestEnded; + adapterCallbackInfo.userdata1 = &adapter_; + adapterCallbackInfo.userdata2 = nullptr; - // Request device (synchronous version) - wgpu::DeviceDescriptor deviceDesc{}; - device_ = adapter.requestDevice(deviceDesc); + wgpuInstanceRequestAdapter(instance_, &adapterOpts, adapterCallbackInfo); - if (!device_) { - std::cerr << "Failed to get device" << std::endl; - return false; + // Process events until adapter is ready + while (!adapter_) { + wgpuInstanceProcessEvents(instance_); + } + + // Request device with callback + WGPUDeviceDescriptor deviceDesc = {}; + deviceDesc.nextInChain = nullptr; + deviceDesc.label = {nullptr, WGPU_STRLEN}; + deviceDesc.requiredFeatureCount = 0; + deviceDesc.requiredLimits = nullptr; + deviceDesc.defaultQueue.nextInChain = nullptr; + deviceDesc.defaultQueue.label = {nullptr, WGPU_STRLEN}; + deviceDesc.deviceLostCallbackInfo.nextInChain = nullptr; + deviceDesc.deviceLostCallbackInfo.mode = WGPUCallbackMode_AllowSpontaneous; + deviceDesc.deviceLostCallbackInfo.callback = nullptr; + deviceDesc.uncapturedErrorCallbackInfo.nextInChain = nullptr; + deviceDesc.uncapturedErrorCallbackInfo.callback = nullptr; + + WGPURequestDeviceCallbackInfo deviceCallbackInfo = {}; + deviceCallbackInfo.mode = WGPUCallbackMode_AllowSpontaneous; + deviceCallbackInfo.callback = onDeviceRequestEnded; + deviceCallbackInfo.userdata1 = &device_; + deviceCallbackInfo.userdata2 = nullptr; + + wgpuAdapterRequestDevice(adapter_, &deviceDesc, deviceCallbackInfo); + + // Process events until device is ready + while (!device_) { + wgpuInstanceProcessEvents(instance_); } return true; @@ -101,6 +150,23 @@ private: void cleanup() { renderer_.reset(); + if (device_) { + wgpuDeviceRelease(device_); + device_ = nullptr; + } + if (adapter_) { + wgpuAdapterRelease(adapter_); + adapter_ = nullptr; + } + if (surface_) { + wgpuSurfaceRelease(surface_); + surface_ = nullptr; + } + if (instance_) { + wgpuInstanceRelease(instance_); + instance_ = nullptr; + } + if (window_) { glfwDestroyWindow(window_); window_ = nullptr; @@ -125,9 +191,10 @@ private: } GLFWwindow* window_; - wgpu::Instance instance_; - wgpu::Device device_; - wgpu::Surface surface_; + WGPUInstance instance_; + WGPUAdapter adapter_; + WGPUDevice device_; + WGPUSurface surface_; std::unique_ptr renderer_; }; diff --git a/cpp-timeplot/src/renderer.cpp b/cpp-timeplot/src/renderer.cpp index 1c61698..b65ed46 100644 --- a/cpp-timeplot/src/renderer.cpp +++ b/cpp-timeplot/src/renderer.cpp @@ -4,11 +4,14 @@ #include #include -Renderer::Renderer(wgpu::Device device, wgpu::Surface surface, int width, int height) +Renderer::Renderer(WGPUDevice device, WGPUSurface surface, int width, int height) : device_(device), surface_(surface), width_(width), height_(height), time_(0.0f), - surfaceFormat_(wgpu::TextureFormat::BGRA8Unorm) {} + surfaceFormat_(WGPUTextureFormat_BGRA8Unorm), linePipeline_(nullptr), lineListPipeline_(nullptr) {} -Renderer::~Renderer() = default; +Renderer::~Renderer() { + if (linePipeline_) wgpuRenderPipelineRelease(linePipeline_); + if (lineListPipeline_) wgpuRenderPipelineRelease(lineListPipeline_); +} bool Renderer::initialize() { configureSurface(); @@ -30,16 +33,19 @@ bool Renderer::initialize() { } void Renderer::configureSurface() { - wgpu::SurfaceConfiguration config{}; + WGPUSurfaceConfiguration config = {}; + config.nextInChain = nullptr; config.device = device_; config.format = surfaceFormat_; - config.usage = wgpu::TextureUsage::RenderAttachment; + config.usage = WGPUTextureUsage_RenderAttachment; config.width = width_; config.height = height_; - config.presentMode = wgpu::PresentMode::Fifo; - config.alphaMode = wgpu::CompositeAlphaMode::Auto; + config.presentMode = WGPUPresentMode_Fifo; + config.alphaMode = WGPUCompositeAlphaMode_Auto; + config.viewFormatCount = 0; + config.viewFormats = nullptr; - surface_.configure(config); + wgpuSurfaceConfigure(surface_, &config); } void Renderer::createPipelines() { @@ -49,74 +55,103 @@ void Renderer::createPipelines() { buffer << shaderFile.rdbuf(); std::string shaderCode = buffer.str(); - wgpu::ShaderSourceWGSL wgslSource{}; - wgslSource.chain.sType = wgpu::SType::ShaderSourceWGSL; - wgslSource.code.data = shaderCode.c_str(); - wgslSource.code.length = shaderCode.length(); + WGPUShaderSourceWGSL wgslSource = {}; + wgslSource.chain.sType = WGPUSType_ShaderSourceWGSL; + wgslSource.chain.next = nullptr; + wgslSource.code = {shaderCode.c_str(), shaderCode.length()}; - wgpu::ShaderModuleDescriptor shaderDesc{}; + WGPUShaderModuleDescriptor shaderDesc = {}; shaderDesc.nextInChain = &wgslSource.chain; - wgpu::ShaderModule shader = device_.createShaderModule(shaderDesc); + shaderDesc.label = {nullptr, WGPU_STRLEN}; + + WGPUShaderModule shader = wgpuDeviceCreateShaderModule(device_, &shaderDesc); // Vertex buffer layout - wgpu::VertexAttribute attributes[2]; - attributes[0].format = wgpu::VertexFormat::Float32x2; + WGPUVertexAttribute attributes[2] = {}; + attributes[0].format = WGPUVertexFormat_Float32x2; attributes[0].offset = 0; attributes[0].shaderLocation = 0; - attributes[1].format = wgpu::VertexFormat::Float32x3; + attributes[1].format = WGPUVertexFormat_Float32x3; attributes[1].offset = 2 * sizeof(float); attributes[1].shaderLocation = 1; - wgpu::VertexBufferLayout vertexBufferLayout{}; + WGPUVertexBufferLayout vertexBufferLayout = {}; vertexBufferLayout.arrayStride = 5 * sizeof(float); - vertexBufferLayout.stepMode = wgpu::VertexStepMode::Vertex; + vertexBufferLayout.stepMode = WGPUVertexStepMode_Vertex; vertexBufferLayout.attributeCount = 2; vertexBufferLayout.attributes = attributes; // Pipeline layout - wgpu::PipelineLayoutDescriptor layoutDesc{}; - wgpu::PipelineLayout pipelineLayout = device_.createPipelineLayout(layoutDesc); + WGPUPipelineLayoutDescriptor layoutDesc = {}; + layoutDesc.nextInChain = nullptr; + layoutDesc.label = {nullptr, WGPU_STRLEN}; + layoutDesc.bindGroupLayoutCount = 0; + layoutDesc.bindGroupLayouts = nullptr; + + WGPUPipelineLayout pipelineLayout = wgpuDeviceCreatePipelineLayout(device_, &layoutDesc); // Color target - wgpu::BlendState blend{}; - blend.color.operation = wgpu::BlendOperation::Add; - blend.color.srcFactor = wgpu::BlendFactor::One; - blend.color.dstFactor = wgpu::BlendFactor::Zero; - blend.alpha.operation = wgpu::BlendOperation::Add; - blend.alpha.srcFactor = wgpu::BlendFactor::One; - blend.alpha.dstFactor = wgpu::BlendFactor::Zero; - - wgpu::ColorTargetState colorTarget{}; + WGPUBlendState blend = {}; + blend.color.operation = WGPUBlendOperation_Add; + blend.color.srcFactor = WGPUBlendFactor_One; + blend.color.dstFactor = WGPUBlendFactor_Zero; + blend.alpha.operation = WGPUBlendOperation_Add; + blend.alpha.srcFactor = WGPUBlendFactor_One; + blend.alpha.dstFactor = WGPUBlendFactor_Zero; + + WGPUColorTargetState colorTarget = {}; + colorTarget.nextInChain = nullptr; colorTarget.format = surfaceFormat_; colorTarget.blend = &blend; - colorTarget.writeMask = wgpu::ColorWriteMask::All; + colorTarget.writeMask = WGPUColorWriteMask_All; - wgpu::FragmentState fragmentState{}; + WGPUFragmentState fragmentState = {}; + fragmentState.nextInChain = nullptr; fragmentState.module = shader; - fragmentState.entryPoint.data = "fs_main"; - fragmentState.entryPoint.length = 7; + fragmentState.entryPoint = {"fs_main", 7}; + fragmentState.constantCount = 0; + fragmentState.constants = nullptr; fragmentState.targetCount = 1; fragmentState.targets = &colorTarget; // Line strip pipeline - wgpu::RenderPipelineDescriptor pipelineDesc{}; + WGPURenderPipelineDescriptor pipelineDesc = {}; + pipelineDesc.nextInChain = nullptr; + pipelineDesc.label = {nullptr, WGPU_STRLEN}; pipelineDesc.layout = pipelineLayout; + + pipelineDesc.vertex.nextInChain = nullptr; pipelineDesc.vertex.module = shader; - pipelineDesc.vertex.entryPoint.data = "vs_main"; - pipelineDesc.vertex.entryPoint.length = 7; + pipelineDesc.vertex.entryPoint = {"vs_main", 7}; + pipelineDesc.vertex.constantCount = 0; + pipelineDesc.vertex.constants = nullptr; pipelineDesc.vertex.bufferCount = 1; pipelineDesc.vertex.buffers = &vertexBufferLayout; - pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::LineStrip; - pipelineDesc.fragment = &fragmentState; + + pipelineDesc.primitive.nextInChain = nullptr; + pipelineDesc.primitive.topology = WGPUPrimitiveTopology_LineStrip; + pipelineDesc.primitive.stripIndexFormat = WGPUIndexFormat_Undefined; + pipelineDesc.primitive.frontFace = WGPUFrontFace_CCW; + pipelineDesc.primitive.cullMode = WGPUCullMode_None; + + pipelineDesc.depthStencil = nullptr; + pipelineDesc.multisample.nextInChain = nullptr; pipelineDesc.multisample.count = 1; pipelineDesc.multisample.mask = ~0u; + pipelineDesc.multisample.alphaToCoverageEnabled = false; - linePipeline_ = device_.createRenderPipeline(pipelineDesc); + pipelineDesc.fragment = &fragmentState; + + linePipeline_ = wgpuDeviceCreateRenderPipeline(device_, &pipelineDesc); // Line list pipeline for grid - pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::LineList; - lineListPipeline_ = device_.createRenderPipeline(pipelineDesc); + pipelineDesc.primitive.topology = WGPUPrimitiveTopology_LineList; + lineListPipeline_ = wgpuDeviceCreateRenderPipeline(device_, &pipelineDesc); + + // Cleanup + wgpuPipelineLayoutRelease(pipelineLayout); + wgpuShaderModuleRelease(shader); } void Renderer::update() { @@ -128,41 +163,75 @@ void Renderer::update() { } void Renderer::render() { - wgpu::SurfaceTexture surfaceTexture; - surface_.getCurrentTexture(&surfaceTexture); + WGPUSurfaceTexture surfaceTexture; + wgpuSurfaceGetCurrentTexture(surface_, &surfaceTexture); - if (surfaceTexture.status != wgpu::SurfaceGetCurrentTextureStatus::SuccessOptimal && - surfaceTexture.status != wgpu::SurfaceGetCurrentTextureStatus::SuccessSuboptimal) { + if (surfaceTexture.status != WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal && + surfaceTexture.status != WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal) { std::cerr << "Failed to get surface texture" << std::endl; return; } - wgpu::Texture texture(surfaceTexture.texture); - wgpu::TextureView textureView = texture.createView(); + WGPUTextureViewDescriptor viewDesc = {}; + viewDesc.nextInChain = nullptr; + viewDesc.label = {nullptr, WGPU_STRLEN}; + viewDesc.format = surfaceFormat_; + viewDesc.dimension = WGPUTextureViewDimension_2D; + viewDesc.baseMipLevel = 0; + viewDesc.mipLevelCount = 1; + viewDesc.baseArrayLayer = 0; + viewDesc.arrayLayerCount = 1; + viewDesc.aspect = WGPUTextureAspect_All; + + WGPUTextureView textureView = wgpuTextureCreateView(surfaceTexture.texture, &viewDesc); + + WGPUCommandEncoderDescriptor encoderDesc = {}; + encoderDesc.nextInChain = nullptr; + encoderDesc.label = {nullptr, WGPU_STRLEN}; - wgpu::CommandEncoder encoder = device_.createCommandEncoder(); + WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device_, &encoderDesc); - wgpu::RenderPassColorAttachment colorAttachment{}; + WGPURenderPassColorAttachment colorAttachment = {}; + colorAttachment.nextInChain = nullptr; colorAttachment.view = textureView; - colorAttachment.loadOp = wgpu::LoadOp::Clear; - colorAttachment.storeOp = wgpu::StoreOp::Store; + colorAttachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; + colorAttachment.resolveTarget = nullptr; + colorAttachment.loadOp = WGPULoadOp_Clear; + colorAttachment.storeOp = WGPUStoreOp_Store; colorAttachment.clearValue = {0.1, 0.1, 0.15, 1.0}; - wgpu::RenderPassDescriptor renderPassDesc{}; + WGPURenderPassDescriptor renderPassDesc = {}; + renderPassDesc.nextInChain = nullptr; + renderPassDesc.label = {nullptr, WGPU_STRLEN}; renderPassDesc.colorAttachmentCount = 1; renderPassDesc.colorAttachments = &colorAttachment; + renderPassDesc.depthStencilAttachment = nullptr; + renderPassDesc.occlusionQuerySet = nullptr; + renderPassDesc.timestampWrites = nullptr; - wgpu::RenderPassEncoder pass = encoder.beginRenderPass(renderPassDesc); + WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &renderPassDesc); for (auto& waterfall : waterfalls_) { waterfall->render(pass, linePipeline_, lineListPipeline_, width_, height_); } - pass.end(); + wgpuRenderPassEncoderEnd(pass); + + WGPUCommandBufferDescriptor cmdBufferDesc = {}; + cmdBufferDesc.nextInChain = nullptr; + cmdBufferDesc.label = {nullptr, WGPU_STRLEN}; + + WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, &cmdBufferDesc); + + WGPUQueue queue = wgpuDeviceGetQueue(device_); + wgpuQueueSubmit(queue, 1, &commands); + wgpuSurfacePresent(surface_); - wgpu::CommandBuffer commands = encoder.finish(); - device_.getQueue().submit(1, &commands); - surface_.present(); + // Cleanup + wgpuCommandBufferRelease(commands); + wgpuCommandEncoderRelease(encoder); + wgpuRenderPassEncoderRelease(pass); + wgpuTextureViewRelease(textureView); } void Renderer::resize(int width, int height) { diff --git a/cpp-timeplot/src/renderer.h b/cpp-timeplot/src/renderer.h index 3bb2e21..0656cdc 100644 --- a/cpp-timeplot/src/renderer.h +++ b/cpp-timeplot/src/renderer.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -8,7 +8,7 @@ class Waterfall; class Renderer { public: - Renderer(wgpu::Device device, wgpu::Surface surface, int width, int height); + Renderer(WGPUDevice device, WGPUSurface surface, int width, int height); ~Renderer(); bool initialize(); @@ -21,11 +21,11 @@ private: void configureSurface(); void createPipelines(); - wgpu::Device device_; - wgpu::Surface surface_; - wgpu::TextureFormat surfaceFormat_; - wgpu::RenderPipeline linePipeline_; - wgpu::RenderPipeline lineListPipeline_; + WGPUDevice device_; + WGPUSurface surface_; + WGPUTextureFormat surfaceFormat_; + WGPURenderPipeline linePipeline_; + WGPURenderPipeline lineListPipeline_; int width_; int height_; diff --git a/cpp-timeplot/src/waterfall.cpp b/cpp-timeplot/src/waterfall.cpp index 9baeba6..7fa0bee 100644 --- a/cpp-timeplot/src/waterfall.cpp +++ b/cpp-timeplot/src/waterfall.cpp @@ -2,19 +2,24 @@ #include #include -Waterfall::Waterfall(wgpu::Device device, float x, float y, float width, float height, const std::string& title) - : device_(device), x_(x), y_(y), width_(width), height_(height), title_(title), showGrid_(true) {} +Waterfall::Waterfall(WGPUDevice device, float x, float y, float width, float height, const std::string& title) + : device_(device), vertexBuffer_(nullptr), x_(x), y_(y), width_(width), height_(height), + title_(title), showGrid_(true) {} -Waterfall::~Waterfall() = default; +Waterfall::~Waterfall() { + if (vertexBuffer_) wgpuBufferRelease(vertexBuffer_); +} bool Waterfall::initialize() { // Create vertex buffer (large enough for grid, border, and waterfall lines) - wgpu::BufferDescriptor bufferDesc{}; + WGPUBufferDescriptor bufferDesc = {}; + bufferDesc.nextInChain = nullptr; + bufferDesc.label = {nullptr, WGPU_STRLEN}; bufferDesc.size = sizeof(Vertex) * POINTS_PER_LINE * 100; - bufferDesc.usage = wgpu::BufferUsage::Vertex | wgpu::BufferUsage::CopyDst; + bufferDesc.usage = WGPUBufferUsage_Vertex | WGPUBufferUsage_CopyDst; bufferDesc.mappedAtCreation = false; - vertexBuffer_ = device_.createBuffer(bufferDesc); + vertexBuffer_ = wgpuDeviceCreateBuffer(device_, &bufferDesc); return vertexBuffer_ != nullptr; } @@ -60,12 +65,12 @@ void Waterfall::update(float time) { ); } -void Waterfall::render(wgpu::RenderPassEncoder& pass, - wgpu::RenderPipeline linePipeline, - wgpu::RenderPipeline lineListPipeline, +void Waterfall::render(WGPURenderPassEncoder pass, + WGPURenderPipeline linePipeline, + WGPURenderPipeline lineListPipeline, int windowWidth, int windowHeight) { // Set viewport - pass.setViewport( + wgpuRenderPassEncoderSetViewport(pass, x_ * windowWidth, y_ * windowHeight, width_ * windowWidth, @@ -98,27 +103,28 @@ void Waterfall::render(wgpu::RenderPassEncoder& pass, // Upload vertices if (!allVertices.empty()) { - device_.getQueue().writeBuffer(vertexBuffer_, 0, allVertices.data(), - allVertices.size() * sizeof(Vertex)); + WGPUQueue queue = wgpuDeviceGetQueue(device_); + wgpuQueueWriteBuffer(queue, vertexBuffer_, 0, allVertices.data(), + allVertices.size() * sizeof(Vertex)); } // Draw border - pass.setPipeline(lineListPipeline); - pass.setVertexBuffer(0, vertexBuffer_, 0, allVertices.size() * sizeof(Vertex)); - pass.draw(borderVertices.size(), 1, borderOffset, 0); + wgpuRenderPassEncoderSetPipeline(pass, lineListPipeline); + wgpuRenderPassEncoderSetVertexBuffer(pass, 0, vertexBuffer_, 0, allVertices.size() * sizeof(Vertex)); + wgpuRenderPassEncoderDraw(pass, borderVertices.size(), 1, borderOffset, 0); // Draw grid if (showGrid_ && gridCount > 0) { - pass.setPipeline(lineListPipeline); - pass.draw(gridCount, 1, gridOffset, 0); + wgpuRenderPassEncoderSetPipeline(pass, lineListPipeline); + wgpuRenderPassEncoderDraw(pass, gridCount, 1, gridOffset, 0); } // Draw waterfall lines if (!lines_.empty()) { - pass.setPipeline(linePipeline); + wgpuRenderPassEncoderSetPipeline(pass, linePipeline); for (size_t i = 0; i < lines_.size(); ++i) { uint32_t start = linesOffset + i * POINTS_PER_LINE; - pass.draw(POINTS_PER_LINE, 1, start, 0); + wgpuRenderPassEncoderDraw(pass, POINTS_PER_LINE, 1, start, 0); } } } diff --git a/cpp-timeplot/src/waterfall.h b/cpp-timeplot/src/waterfall.h index 4c5d813..454caf8 100644 --- a/cpp-timeplot/src/waterfall.h +++ b/cpp-timeplot/src/waterfall.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -11,14 +11,14 @@ struct Vertex { class Waterfall { public: - Waterfall(wgpu::Device device, float x, float y, float width, float height, const std::string& title); + Waterfall(WGPUDevice device, float x, float y, float width, float height, const std::string& title); ~Waterfall(); bool initialize(); void update(float time); - void render(wgpu::RenderPassEncoder& pass, - wgpu::RenderPipeline linePipeline, - wgpu::RenderPipeline lineListPipeline, + void render(WGPURenderPassEncoder pass, + WGPURenderPipeline linePipeline, + WGPURenderPipeline lineListPipeline, int windowWidth, int windowHeight); void toggleGrid(); @@ -26,8 +26,8 @@ private: std::vector generateGridLines(); std::vector generateBorder(); - wgpu::Device device_; - wgpu::Buffer vertexBuffer_; + WGPUDevice device_; + WGPUBuffer vertexBuffer_; float x_, y_, width_, height_; std::string title_; -- cgit v1.2.3