#include #include namespace psemek::wgpu { render_pass_encoder command_encoder::begin_render_pass(render_pass_encoder::descriptor const & desc) { std::vector color_attachments; for (auto const & src : desc.color_attachments) { auto & dst = color_attachments.emplace_back(); dst.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(src.chain); dst.view = (WGPUTextureView)src.view.get(); dst.resolveTarget = (WGPUTextureView)src.resolve_target.get(); dst.loadOp = (WGPULoadOp)src.load_op; dst.storeOp = (WGPUStoreOp)src.store_op; dst.clearValue = {src.clear_value[0], src.clear_value[1], src.clear_value[2], src.clear_value[3]}; } WGPURenderPassTimestampWrites timestamp_writes = {}; if (desc.timestamp_writes) { timestamp_writes.querySet = (WGPUQuerySet)desc.timestamp_writes->query_set.get(); timestamp_writes.beginningOfPassWriteIndex = desc.timestamp_writes->begin_index; timestamp_writes.endOfPassWriteIndex = desc.timestamp_writes->end_index; } WGPURenderPassDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); descriptor.label = desc.label.data(); descriptor.colorAttachmentCount = color_attachments.size(); descriptor.colorAttachments = color_attachments.data(); descriptor.occlusionQuerySet = (WGPUQuerySet)desc.occlusion_query_set.get(); descriptor.timestampWrites = desc.timestamp_writes ? ×tamp_writes : nullptr; return render_pass_encoder(wgpuCommandEncoderBeginRenderPass((WGPUCommandEncoder)get(), &descriptor)); } command_buffer command_encoder::finish(command_buffer::descriptor const & desc) { WGPUCommandBufferDescriptor descriptor = {}; descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain); descriptor.label = desc.label.data(); return command_buffer(wgpuCommandEncoderFinish((WGPUCommandEncoder)get(), &descriptor)); } void command_encoder::reference(void * ptr) { wgpuCommandEncoderReference((WGPUCommandEncoder)ptr); } void command_encoder::release(void * ptr) { wgpuCommandEncoderRelease((WGPUCommandEncoder)ptr); } }