Diff
Modified: trunk/Source/WebGPU/ChangeLog (291686 => 291687)
--- trunk/Source/WebGPU/ChangeLog 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/ChangeLog 2022-03-22 19:04:20 UTC (rev 291687)
@@ -1,5 +1,140 @@
2022-03-22 Myles C. Maxfield <mmaxfi...@apple.com>
+ [WebGPU] Remove the double pointer indirection in front of all objects
+ https://bugs.webkit.org/show_bug.cgi?id=238001
+
+ Reviewed by Kimmo Kinnunen.
+
+ Instead of doing
+
+ class Buffer {
+ ...
+ };
+ struct WGPUBufferImpl {
+ Ref<Buffer> buffer;
+ }
+
+ we can instead do
+
+ struct WGPUBufferImpl {
+ };
+ struct Buffer : public WGPUBufferImpl {
+ ...
+ };
+
+ so we don't have to do pointer chasing to interact with objects.
+
+ * WebGPU/APIConversions.h:
+ (WebGPU::fromAPI):
+ (WebGPU::releaseToAPI):
+ * WebGPU/Adapter.h:
+ * WebGPU/Adapter.mm:
+ (wgpuAdapterRelease):
+ (wgpuAdapterRequestDevice):
+ (wgpuAdapterRequestDeviceWithBlock):
+ * WebGPU/BindGroup.h:
+ * WebGPU/BindGroup.mm:
+ (wgpuBindGroupRelease):
+ * WebGPU/BindGroupLayout.h:
+ * WebGPU/BindGroupLayout.mm:
+ (wgpuBindGroupLayoutRelease):
+ * WebGPU/Buffer.h:
+ * WebGPU/Buffer.mm:
+ (wgpuBufferRelease):
+ * WebGPU/CommandBuffer.h:
+ * WebGPU/CommandBuffer.mm:
+ (wgpuCommandBufferRelease):
+ * WebGPU/CommandEncoder.h:
+ * WebGPU/CommandEncoder.mm:
+ (wgpuCommandEncoderRelease):
+ (wgpuCommandEncoderBeginComputePass):
+ (wgpuCommandEncoderBeginRenderPass):
+ (wgpuCommandEncoderFinish):
+ * WebGPU/ComputePassEncoder.h:
+ * WebGPU/ComputePassEncoder.mm:
+ (wgpuComputePassEncoderRelease):
+ * WebGPU/ComputePipeline.h:
+ * WebGPU/ComputePipeline.mm:
+ (WebGPU::ComputePipeline::getBindGroupLayout):
+ (wgpuComputePipelineRelease):
+ (wgpuComputePipelineGetBindGroupLayout):
+ * WebGPU/Device.h:
+ * WebGPU/Device.mm:
+ (wgpuDeviceRelease):
+ (wgpuDeviceCreateBindGroup):
+ (wgpuDeviceCreateBindGroupLayout):
+ (wgpuDeviceCreateBuffer):
+ (wgpuDeviceCreateCommandEncoder):
+ (wgpuDeviceCreateComputePipeline):
+ (wgpuDeviceCreateComputePipelineAsync):
+ (wgpuDeviceCreateComputePipelineAsyncWithBlock):
+ (wgpuDeviceCreatePipelineLayout):
+ (wgpuDeviceCreateQuerySet):
+ (wgpuDeviceCreateRenderBundleEncoder):
+ (wgpuDeviceCreateRenderPipeline):
+ (wgpuDeviceCreateRenderPipelineAsync):
+ (wgpuDeviceCreateRenderPipelineAsyncWithBlock):
+ (wgpuDeviceCreateSampler):
+ (wgpuDeviceCreateShaderModule):
+ (wgpuDeviceCreateSwapChain):
+ (wgpuDeviceCreateTexture):
+ (wgpuDeviceGetQueue):
+ * WebGPU/Instance.h:
+ * WebGPU/Instance.mm:
+ (wgpuInstanceRelease):
+ (wgpuCreateInstance):
+ (wgpuInstanceCreateSurface):
+ (wgpuInstanceRequestAdapter):
+ (wgpuInstanceRequestAdapterWithBlock):
+ * WebGPU/PipelineLayout.h:
+ * WebGPU/PipelineLayout.mm:
+ (wgpuPipelineLayoutRelease):
+ * WebGPU/QuerySet.h:
+ * WebGPU/QuerySet.mm:
+ (wgpuQuerySetRelease):
+ * WebGPU/Queue.h:
+ * WebGPU/Queue.mm:
+ (wgpuQueueRelease):
+ * WebGPU/RenderBundle.h:
+ * WebGPU/RenderBundle.mm:
+ (wgpuRenderBundleRelease):
+ * WebGPU/RenderBundleEncoder.h:
+ * WebGPU/RenderBundleEncoder.mm:
+ (wgpuRenderBundleEncoderRelease):
+ (wgpuRenderBundleEncoderFinish):
+ * WebGPU/RenderPassEncoder.h:
+ * WebGPU/RenderPassEncoder.mm:
+ (wgpuRenderPassEncoderRelease):
+ * WebGPU/RenderPipeline.h:
+ * WebGPU/RenderPipeline.mm:
+ (WebGPU::RenderPipeline::getBindGroupLayout):
+ (wgpuRenderPipelineRelease):
+ (wgpuRenderPipelineGetBindGroupLayout):
+ * WebGPU/Sampler.h:
+ * WebGPU/Sampler.mm:
+ (wgpuSamplerRelease):
+ * WebGPU/ShaderModule.h:
+ * WebGPU/ShaderModule.mm:
+ (WebGPU::earlyCompileShaderModule):
+ (wgpuShaderModuleRelease):
+ * WebGPU/Surface.h:
+ * WebGPU/Surface.mm:
+ (wgpuSurfaceRelease):
+ * WebGPU/SwapChain.h:
+ * WebGPU/SwapChain.mm:
+ (WebGPU::SwapChain::getCurrentTextureView):
+ (wgpuSwapChainRelease):
+ (wgpuSwapChainGetCurrentTextureView):
+ * WebGPU/Texture.h:
+ * WebGPU/Texture.mm:
+ (wgpuTextureRelease):
+ (wgpuTextureCreateView):
+ * WebGPU/TextureView.h:
+ * WebGPU/TextureView.mm:
+ (wgpuTextureViewRelease):
+
+2022-03-22 Myles C. Maxfield <mmaxfi...@apple.com>
+
[WebGPU] Implement GPUBufferDescriptor.mappedAtCreation
https://bugs.webkit.org/show_bug.cgi?id=238190
Modified: trunk/Source/WebGPU/WebGPU/APIConversions.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/APIConversions.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/APIConversions.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -52,119 +52,121 @@
namespace WebGPU {
+// FIXME: It would be cool if we didn't have to list all these overloads, but instead could do something like bridge_cast() in WTF.
+
inline Adapter& fromAPI(WGPUAdapter adapter)
{
- return adapter->adapter;
+ return static_cast<Adapter&>(*adapter);
}
inline BindGroup& fromAPI(WGPUBindGroup bindGroup)
{
- return bindGroup->bindGroup;
+ return static_cast<BindGroup&>(*bindGroup);
}
inline BindGroupLayout& fromAPI(WGPUBindGroupLayout bindGroupLayout)
{
- return bindGroupLayout->bindGroupLayout;
+ return static_cast<BindGroupLayout&>(*bindGroupLayout);
}
inline Buffer& fromAPI(WGPUBuffer buffer)
{
- return buffer->buffer;
+ return static_cast<Buffer&>(*buffer);
}
inline CommandBuffer& fromAPI(WGPUCommandBuffer commandBuffer)
{
- return commandBuffer->commandBuffer;
+ return static_cast<CommandBuffer&>(*commandBuffer);
}
inline CommandEncoder& fromAPI(WGPUCommandEncoder commandEncoder)
{
- return commandEncoder->commandEncoder;
+ return static_cast<CommandEncoder&>(*commandEncoder);
}
inline ComputePassEncoder& fromAPI(WGPUComputePassEncoder computePassEncoder)
{
- return computePassEncoder->computePassEncoder;
+ return static_cast<ComputePassEncoder&>(*computePassEncoder);
}
inline ComputePipeline& fromAPI(WGPUComputePipeline computePipeline)
{
- return computePipeline->computePipeline;
+ return static_cast<ComputePipeline&>(*computePipeline);
}
inline Device& fromAPI(WGPUDevice device)
{
- return device->device;
+ return static_cast<Device&>(*device);
}
inline Instance& fromAPI(WGPUInstance instance)
{
- return instance->instance;
+ return static_cast<Instance&>(*instance);
}
inline PipelineLayout& fromAPI(WGPUPipelineLayout pipelineLayout)
{
- return pipelineLayout->pipelineLayout;
+ return static_cast<PipelineLayout&>(*pipelineLayout);
}
inline QuerySet& fromAPI(WGPUQuerySet querySet)
{
- return querySet->querySet;
+ return static_cast<QuerySet&>(*querySet);
}
inline Queue& fromAPI(WGPUQueue queue)
{
- return queue->queue;
+ return static_cast<Queue&>(*queue);
}
inline RenderBundle& fromAPI(WGPURenderBundle renderBundle)
{
- return renderBundle->renderBundle;
+ return static_cast<RenderBundle&>(*renderBundle);
}
inline RenderBundleEncoder& fromAPI(WGPURenderBundleEncoder renderBundleEncoder)
{
- return renderBundleEncoder->renderBundleEncoder;
+ return static_cast<RenderBundleEncoder&>(*renderBundleEncoder);
}
inline RenderPassEncoder& fromAPI(WGPURenderPassEncoder renderPassEncoder)
{
- return renderPassEncoder->renderPassEncoder;
+ return static_cast<RenderPassEncoder&>(*renderPassEncoder);
}
inline RenderPipeline& fromAPI(WGPURenderPipeline renderPipeline)
{
- return renderPipeline->renderPipeline;
+ return static_cast<RenderPipeline&>(*renderPipeline);
}
inline Sampler& fromAPI(WGPUSampler sampler)
{
- return sampler->sampler;
+ return static_cast<Sampler&>(*sampler);
}
inline ShaderModule& fromAPI(WGPUShaderModule shaderModule)
{
- return shaderModule->shaderModule;
+ return static_cast<ShaderModule&>(*shaderModule);
}
inline Surface& fromAPI(WGPUSurface surface)
{
- return surface->surface;
+ return static_cast<Surface&>(*surface);
}
inline SwapChain& fromAPI(WGPUSwapChain swapChain)
{
- return swapChain->swapChain;
+ return static_cast<SwapChain&>(*swapChain);
}
inline Texture& fromAPI(WGPUTexture texture)
{
- return texture->texture;
+ return static_cast<Texture&>(*texture);
}
inline TextureView& fromAPI(WGPUTextureView textureView)
{
- return textureView->textureView;
+ return static_cast<TextureView&>(*textureView);
}
inline String fromAPI(const char* string)
@@ -172,4 +174,10 @@
return String(string);
}
+template <typename T>
+inline T* releaseToAPI(RefPtr<T>&& pointer)
+{
+ return pointer.leakRef();
+}
+
} // namespace WebGPU
Modified: trunk/Source/WebGPU/WebGPU/Adapter.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Adapter.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Adapter.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -31,12 +31,15 @@
#import <wtf/RefCounted.h>
#import <wtf/RefPtr.h>
+struct WGPUAdapterImpl {
+};
+
namespace WebGPU {
class Device;
class Instance;
-class Adapter : public RefCounted<Adapter> {
+class Adapter : public WGPUAdapterImpl, public RefCounted<Adapter> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<Adapter> create(id<MTLDevice> device, Instance& instance)
@@ -60,9 +63,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUAdapterImpl {
- Ref<WebGPU::Adapter> adapter;
-};
Modified: trunk/Source/WebGPU/WebGPU/Adapter.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Adapter.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Adapter.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -132,7 +132,7 @@
void wgpuAdapterRelease(WGPUAdapter adapter)
{
- delete adapter;
+ WebGPU::fromAPI(adapter).deref();
}
size_t wgpuAdapterEnumerateFeatures(WGPUAdapter adapter, WGPUFeatureName* features)
@@ -158,11 +158,7 @@
void wgpuAdapterRequestDevice(WGPUAdapter adapter, const WGPUDeviceDescriptor* descriptor, WGPURequestDeviceCallback callback, void* userdata)
{
WebGPU::fromAPI(adapter).requestDevice(*descriptor, [callback, userdata](WGPURequestDeviceStatus status, RefPtr<WebGPU::Device>&& device, String&& message) {
- if (device) {
- auto& queue = device->getQueue();
- callback(status, new WGPUDeviceImpl { device.releaseNonNull(), { queue } }, message.utf8().data(), userdata);
- } else
- callback(status, nullptr, message.utf8().data(), userdata);
+ callback(status, WebGPU::releaseToAPI(WTFMove(device)), message.utf8().data(), userdata);
});
}
@@ -169,10 +165,6 @@
void wgpuAdapterRequestDeviceWithBlock(WGPUAdapter adapter, WGPUDeviceDescriptor const * descriptor, WGPURequestDeviceBlockCallback callback)
{
WebGPU::fromAPI(adapter).requestDevice(*descriptor, [callback = WTFMove(callback)](WGPURequestDeviceStatus status, RefPtr<WebGPU::Device>&& device, String&& message) {
- if (device) {
- auto& queue = device->getQueue();
- callback(status, new WGPUDeviceImpl { device.releaseNonNull(), { queue } }, message.utf8().data());
- } else
- callback(status, nullptr, message.utf8().data());
+ callback(status, WebGPU::releaseToAPI(WTFMove(device)), message.utf8().data());
});
}
Modified: trunk/Source/WebGPU/WebGPU/BindGroup.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/BindGroup.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/BindGroup.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,9 +29,12 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUBindGroupImpl {
+};
+
namespace WebGPU {
-class BindGroup : public RefCounted<BindGroup> {
+class BindGroup : public WGPUBindGroupImpl, public RefCounted<BindGroup> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<BindGroup> create(id<MTLBuffer> vertexArgumentBuffer, id<MTLBuffer> fragmentArgumentBuffer, id<MTLBuffer> computeArgumentBuffer)
@@ -56,9 +59,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUBindGroupImpl {
- Ref<WebGPU::BindGroup> bindGroup;
-};
Modified: trunk/Source/WebGPU/WebGPU/BindGroup.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/BindGroup.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/BindGroup.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -137,7 +137,7 @@
void wgpuBindGroupRelease(WGPUBindGroup bindGroup)
{
- delete bindGroup;
+ WebGPU::fromAPI(bindGroup).deref();
}
void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/BindGroupLayout.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/BindGroupLayout.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/BindGroupLayout.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,9 +29,12 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUBindGroupLayoutImpl {
+};
+
namespace WebGPU {
-class BindGroupLayout : public RefCounted<BindGroupLayout> {
+class BindGroupLayout : public WGPUBindGroupLayoutImpl, public RefCounted<BindGroupLayout> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<BindGroupLayout> create(id<MTLArgumentEncoder> vertexArgumentEncoder, id<MTLArgumentEncoder> fragmentArgumentEncoder, id<MTLArgumentEncoder> computeArgumentEncoder)
@@ -58,9 +61,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUBindGroupLayoutImpl {
- Ref<WebGPU::BindGroupLayout> bindGroupLayout;
-};
Modified: trunk/Source/WebGPU/WebGPU/BindGroupLayout.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/BindGroupLayout.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/BindGroupLayout.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -245,7 +245,7 @@
void wgpuBindGroupLayoutRelease(WGPUBindGroupLayout bindGroupLayout)
{
- delete bindGroupLayout;
+ WebGPU::fromAPI(bindGroupLayout).deref();
}
void wgpuBindGroupLayoutSetLabel(WGPUBindGroupLayout bindGroupLayout, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/Buffer.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Buffer.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Buffer.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -33,11 +33,14 @@
#import <wtf/Ref.h>
#import <wtf/ThreadSafeRefCounted.h>
+struct WGPUBufferImpl {
+};
+
namespace WebGPU {
class Device;
-class Buffer : public ThreadSafeRefCounted<Buffer> {
+class Buffer : public WGPUBufferImpl, public ThreadSafeRefCounted<Buffer> {
WTF_MAKE_FAST_ALLOCATED;
public:
enum class State : uint8_t;
@@ -98,9 +101,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUBufferImpl {
- Ref<WebGPU::Buffer> buffer;
-};
Modified: trunk/Source/WebGPU/WebGPU/Buffer.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Buffer.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Buffer.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -408,7 +408,7 @@
void wgpuBufferRelease(WGPUBuffer buffer)
{
- delete buffer;
+ WebGPU::fromAPI(buffer).deref();
}
void wgpuBufferDestroy(WGPUBuffer buffer)
Modified: trunk/Source/WebGPU/WebGPU/CommandBuffer.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/CommandBuffer.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/CommandBuffer.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,9 +29,12 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUCommandBufferImpl {
+};
+
namespace WebGPU {
-class CommandBuffer : public RefCounted<CommandBuffer> {
+class CommandBuffer : public WGPUCommandBufferImpl, public RefCounted<CommandBuffer> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<CommandBuffer> create(id<MTLCommandBuffer> commandBuffer)
@@ -52,9 +55,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUCommandBufferImpl {
- Ref<WebGPU::CommandBuffer> commandBuffer;
-};
Modified: trunk/Source/WebGPU/WebGPU/CommandBuffer.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/CommandBuffer.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/CommandBuffer.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -48,7 +48,7 @@
void wgpuCommandBufferRelease(WGPUCommandBuffer commandBuffer)
{
- delete commandBuffer;
+ WebGPU::fromAPI(commandBuffer).deref();
}
void wgpuCommandBufferSetLabel(WGPUCommandBuffer commandBuffer, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/CommandEncoder.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/CommandEncoder.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/CommandEncoder.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -30,6 +30,9 @@
#import <wtf/Ref.h>
#import <wtf/RefPtr.h>
+struct WGPUCommandEncoderImpl {
+};
+
namespace WebGPU {
class Buffer;
@@ -39,7 +42,7 @@
class QuerySet;
class RenderPassEncoder;
-class CommandEncoder : public RefCounted<CommandEncoder>, public CommandsMixin {
+class CommandEncoder : public WGPUCommandEncoderImpl, public RefCounted<CommandEncoder>, public CommandsMixin {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<CommandEncoder> create(id<MTLCommandBuffer> commandBuffer, Device& device)
@@ -82,9 +85,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUCommandEncoderImpl {
- Ref<WebGPU::CommandEncoder> commandEncoder;
-};
Modified: trunk/Source/WebGPU/WebGPU/CommandEncoder.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/CommandEncoder.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/CommandEncoder.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -365,19 +365,17 @@
void wgpuCommandEncoderRelease(WGPUCommandEncoder commandEncoder)
{
- delete commandEncoder;
+ WebGPU::fromAPI(commandEncoder).deref();
}
WGPUComputePassEncoder wgpuCommandEncoderBeginComputePass(WGPUCommandEncoder commandEncoder, const WGPUComputePassDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(commandEncoder).beginComputePass(*descriptor);
- return result ? new WGPUComputePassEncoderImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(commandEncoder).beginComputePass(*descriptor));
}
WGPURenderPassEncoder wgpuCommandEncoderBeginRenderPass(WGPUCommandEncoder commandEncoder, const WGPURenderPassDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(commandEncoder).beginRenderPass(*descriptor);
- return result ? new WGPURenderPassEncoderImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(commandEncoder).beginRenderPass(*descriptor));
}
void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size)
@@ -407,8 +405,7 @@
WGPUCommandBuffer wgpuCommandEncoderFinish(WGPUCommandEncoder commandEncoder, const WGPUCommandBufferDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(commandEncoder).finish(*descriptor);
- return result ? new WGPUCommandBufferImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(commandEncoder).finish(*descriptor));
}
void wgpuCommandEncoderInsertDebugMarker(WGPUCommandEncoder commandEncoder, const char* markerLabel)
Modified: trunk/Source/WebGPU/WebGPU/ComputePassEncoder.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/ComputePassEncoder.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/ComputePassEncoder.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -30,6 +30,9 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUComputePassEncoderImpl {
+};
+
namespace WebGPU {
class BindGroup;
@@ -37,7 +40,7 @@
class ComputePipeline;
class QuerySet;
-class ComputePassEncoder : public RefCounted<ComputePassEncoder>, public CommandsMixin {
+class ComputePassEncoder : public WGPUComputePassEncoderImpl, public RefCounted<ComputePassEncoder>, public CommandsMixin {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<ComputePassEncoder> create(id<MTLComputeCommandEncoder> computeCommandEncoder)
@@ -70,9 +73,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUComputePassEncoderImpl {
- Ref<WebGPU::ComputePassEncoder> computePassEncoder;
-};
Modified: trunk/Source/WebGPU/WebGPU/ComputePassEncoder.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/ComputePassEncoder.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/ComputePassEncoder.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -144,7 +144,7 @@
void wgpuComputePassEncoderRelease(WGPUComputePassEncoder computePassEncoder)
{
- delete computePassEncoder;
+ WebGPU::fromAPI(computePassEncoder).deref();
}
void wgpuComputePassEncoderBeginPipelineStatisticsQuery(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint32_t queryIndex)
Modified: trunk/Source/WebGPU/WebGPU/ComputePipeline.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/ComputePipeline.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/ComputePipeline.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,11 +29,14 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUComputePipelineImpl {
+};
+
namespace WebGPU {
class BindGroupLayout;
-class ComputePipeline : public RefCounted<ComputePipeline> {
+class ComputePipeline : public WGPUComputePipelineImpl, public RefCounted<ComputePipeline> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<ComputePipeline> create(id<MTLComputePipelineState> computePipelineState)
@@ -43,7 +46,7 @@
~ComputePipeline();
- Ref<BindGroupLayout> getBindGroupLayout(uint32_t groupIndex);
+ BindGroupLayout* getBindGroupLayout(uint32_t groupIndex);
void setLabel(String&&);
id<MTLComputePipelineState> computePipelineState() const { return m_computePipelineState; }
@@ -55,9 +58,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUComputePipelineImpl {
- Ref<WebGPU::ComputePipeline> computePipeline;
-};
Modified: trunk/Source/WebGPU/WebGPU/ComputePipeline.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/ComputePipeline.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/ComputePipeline.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -182,10 +182,10 @@
ComputePipeline::~ComputePipeline() = default;
-Ref<BindGroupLayout> ComputePipeline::getBindGroupLayout(uint32_t groupIndex)
+BindGroupLayout* ComputePipeline::getBindGroupLayout(uint32_t groupIndex)
{
UNUSED_PARAM(groupIndex);
- return BindGroupLayout::create(nil, nil, nil);
+ return nullptr;
}
void ComputePipeline::setLabel(String&&)
@@ -199,12 +199,12 @@
void wgpuComputePipelineRelease(WGPUComputePipeline computePipeline)
{
- delete computePipeline;
+ WebGPU::fromAPI(computePipeline).deref();
}
WGPUBindGroupLayout wgpuComputePipelineGetBindGroupLayout(WGPUComputePipeline computePipeline, uint32_t groupIndex)
{
- return new WGPUBindGroupLayoutImpl { WebGPU::fromAPI(computePipeline).getBindGroupLayout(groupIndex) };
+ return WebGPU::fromAPI(computePipeline).getBindGroupLayout(groupIndex);
}
void wgpuComputePipelineSetLabel(WGPUComputePipeline computePipeline, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/Device.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Device.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Device.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -35,6 +35,9 @@
#import <wtf/Vector.h>
#import <wtf/text/WTFString.h>
+struct WGPUDeviceImpl {
+};
+
namespace WebGPU {
class BindGroup;
@@ -53,7 +56,7 @@
class SwapChain;
class Texture;
-class Device : public RefCounted<Device> {
+class Device : public WGPUDeviceImpl, public RefCounted<Device> {
WTF_MAKE_FAST_ALLOCATED;
public:
static RefPtr<Device> create(id<MTLDevice>, String&& deviceLabel, Instance&);
@@ -116,10 +119,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUDeviceImpl {
- Ref<WebGPU::Device> device;
- WGPUQueueImpl defaultQueue;
-};
Modified: trunk/Source/WebGPU/WebGPU/Device.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Device.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Device.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -214,43 +214,38 @@
void wgpuDeviceRelease(WGPUDevice device)
{
- delete device;
+ WebGPU::fromAPI(device).deref();
}
WGPUBindGroup wgpuDeviceCreateBindGroup(WGPUDevice device, const WGPUBindGroupDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createBindGroup(*descriptor);
- return result ? new WGPUBindGroupImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createBindGroup(*descriptor));
}
WGPUBindGroupLayout wgpuDeviceCreateBindGroupLayout(WGPUDevice device, const WGPUBindGroupLayoutDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createBindGroupLayout(*descriptor);
- return result ? new WGPUBindGroupLayoutImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createBindGroupLayout(*descriptor));
}
WGPUBuffer wgpuDeviceCreateBuffer(WGPUDevice device, const WGPUBufferDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createBuffer(*descriptor);
- return result ? new WGPUBufferImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createBuffer(*descriptor));
}
WGPUCommandEncoder wgpuDeviceCreateCommandEncoder(WGPUDevice device, const WGPUCommandEncoderDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createCommandEncoder(*descriptor);
- return result ? new WGPUCommandEncoderImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createCommandEncoder(*descriptor));
}
WGPUComputePipeline wgpuDeviceCreateComputePipeline(WGPUDevice device, const WGPUComputePipelineDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createComputePipeline(*descriptor);
- return result ? new WGPUComputePipelineImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createComputePipeline(*descriptor));
}
void wgpuDeviceCreateComputePipelineAsync(WGPUDevice device, const WGPUComputePipelineDescriptor* descriptor, WGPUCreateComputePipelineAsyncCallback callback, void* userdata)
{
WebGPU::fromAPI(device).createComputePipelineAsync(*descriptor, [callback, userdata](WGPUCreatePipelineAsyncStatus status, RefPtr<WebGPU::ComputePipeline>&& pipeline, String&& message) {
- callback(status, pipeline ? new WGPUComputePipelineImpl { pipeline.releaseNonNull() } : nullptr, message.utf8().data(), userdata);
+ callback(status, WebGPU::releaseToAPI(WTFMove(pipeline)), message.utf8().data(), userdata);
});
}
@@ -257,38 +252,34 @@
void wgpuDeviceCreateComputePipelineAsyncWithBlock(WGPUDevice device, WGPUComputePipelineDescriptor const * descriptor, WGPUCreateComputePipelineAsyncBlockCallback callback)
{
WebGPU::fromAPI(device).createComputePipelineAsync(*descriptor, [callback = WTFMove(callback)](WGPUCreatePipelineAsyncStatus status, RefPtr<WebGPU::ComputePipeline>&& pipeline, String&& message) {
- callback(status, pipeline ? new WGPUComputePipelineImpl { pipeline.releaseNonNull() } : nullptr, message.utf8().data());
+ callback(status, WebGPU::releaseToAPI(WTFMove(pipeline)), message.utf8().data());
});
}
WGPUPipelineLayout wgpuDeviceCreatePipelineLayout(WGPUDevice device, const WGPUPipelineLayoutDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createPipelineLayout(*descriptor);
- return result ? new WGPUPipelineLayoutImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createPipelineLayout(*descriptor));
}
WGPUQuerySet wgpuDeviceCreateQuerySet(WGPUDevice device, const WGPUQuerySetDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createQuerySet(*descriptor);
- return result ? new WGPUQuerySetImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createQuerySet(*descriptor));
}
WGPURenderBundleEncoder wgpuDeviceCreateRenderBundleEncoder(WGPUDevice device, const WGPURenderBundleEncoderDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createRenderBundleEncoder(*descriptor);
- return result ? new WGPURenderBundleEncoderImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createRenderBundleEncoder(*descriptor));
}
WGPURenderPipeline wgpuDeviceCreateRenderPipeline(WGPUDevice device, const WGPURenderPipelineDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createRenderPipeline(*descriptor);
- return result ? new WGPURenderPipelineImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createRenderPipeline(*descriptor));
}
void wgpuDeviceCreateRenderPipelineAsync(WGPUDevice device, const WGPURenderPipelineDescriptor* descriptor, WGPUCreateRenderPipelineAsyncCallback callback, void* userdata)
{
WebGPU::fromAPI(device).createRenderPipelineAsync(*descriptor, [callback, userdata](WGPUCreatePipelineAsyncStatus status, RefPtr<WebGPU::RenderPipeline>&& pipeline, String&& message) {
- callback(status, pipeline ? new WGPURenderPipelineImpl { pipeline.releaseNonNull() } : nullptr, message.utf8().data(), userdata);
+ callback(status, WebGPU::releaseToAPI(WTFMove(pipeline)), message.utf8().data(), userdata);
});
}
@@ -295,32 +286,28 @@
void wgpuDeviceCreateRenderPipelineAsyncWithBlock(WGPUDevice device, WGPURenderPipelineDescriptor const * descriptor, WGPUCreateRenderPipelineAsyncBlockCallback callback)
{
WebGPU::fromAPI(device).createRenderPipelineAsync(*descriptor, [callback = WTFMove(callback)](WGPUCreatePipelineAsyncStatus status, RefPtr<WebGPU::RenderPipeline>&& pipeline, String&& message) {
- callback(status, pipeline ? new WGPURenderPipelineImpl { pipeline.releaseNonNull() } : nullptr, message.utf8().data());
+ callback(status, WebGPU::releaseToAPI(WTFMove(pipeline)), message.utf8().data());
});
}
WGPUSampler wgpuDeviceCreateSampler(WGPUDevice device, const WGPUSamplerDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createSampler(*descriptor);
- return result ? new WGPUSamplerImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createSampler(*descriptor));
}
WGPUShaderModule wgpuDeviceCreateShaderModule(WGPUDevice device, const WGPUShaderModuleDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createShaderModule(*descriptor);
- return result ? new WGPUShaderModuleImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createShaderModule(*descriptor));
}
WGPUSwapChain wgpuDeviceCreateSwapChain(WGPUDevice device, WGPUSurface surface, const WGPUSwapChainDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createSwapChain(WebGPU::fromAPI(surface), *descriptor);
- return result ? new WGPUSwapChainImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createSwapChain(WebGPU::fromAPI(surface), *descriptor));
}
WGPUTexture wgpuDeviceCreateTexture(WGPUDevice device, const WGPUTextureDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(device).createTexture(*descriptor);
- return result ? new WGPUTextureImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(device).createTexture(*descriptor));
}
void wgpuDeviceDestroy(WGPUDevice device)
@@ -340,7 +327,7 @@
WGPUQueue wgpuDeviceGetQueue(WGPUDevice device)
{
- return &device->defaultQueue;
+ return &WebGPU::fromAPI(device).getQueue();
}
bool wgpuDeviceHasFeature(WGPUDevice device, WGPUFeatureName feature)
Modified: trunk/Source/WebGPU/WebGPU/Instance.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Instance.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Instance.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -33,12 +33,15 @@
#import <wtf/RefPtr.h>
#import <wtf/ThreadSafeRefCounted.h>
+struct WGPUInstanceImpl {
+};
+
namespace WebGPU {
class Adapter;
class Surface;
-class Instance : public ThreadSafeRefCounted<Instance> {
+class Instance : public WGPUInstanceImpl, public ThreadSafeRefCounted<Instance> {
WTF_MAKE_FAST_ALLOCATED;
public:
static RefPtr<Instance> create(const WGPUInstanceDescriptor&);
@@ -66,9 +69,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUInstanceImpl {
- Ref<WebGPU::Instance> instance;
-};
Modified: trunk/Source/WebGPU/WebGPU/Instance.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Instance.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Instance.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -175,13 +175,12 @@
void wgpuInstanceRelease(WGPUInstance instance)
{
- delete instance;
+ WebGPU::fromAPI(instance).deref();
}
WGPUInstance wgpuCreateInstance(const WGPUInstanceDescriptor* descriptor)
{
- auto result = WebGPU::Instance::create(*descriptor);
- return result ? new WGPUInstanceImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::Instance::create(*descriptor));
}
WGPUProc wgpuGetProcAddress(WGPUDevice, const char* procName)
@@ -435,8 +434,7 @@
WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(instance).createSurface(*descriptor);
- return result ? new WGPUSurfaceImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(instance).createSurface(*descriptor));
}
void wgpuInstanceProcessEvents(WGPUInstance instance)
@@ -447,7 +445,7 @@
void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions* options, WGPURequestAdapterCallback callback, void* userdata)
{
WebGPU::fromAPI(instance).requestAdapter(*options, [callback, userdata](WGPURequestAdapterStatus status, RefPtr<WebGPU::Adapter>&& adapter, String&& message) {
- callback(status, adapter ? new WGPUAdapterImpl { adapter.releaseNonNull() } : nullptr, message.utf8().data(), userdata);
+ callback(status, WebGPU::releaseToAPI(WTFMove(adapter)), message.utf8().data(), userdata);
});
}
@@ -454,6 +452,6 @@
void wgpuInstanceRequestAdapterWithBlock(WGPUInstance instance, WGPURequestAdapterOptions const * options, WGPURequestAdapterBlockCallback callback)
{
WebGPU::fromAPI(instance).requestAdapter(*options, [callback = WTFMove(callback)](WGPURequestAdapterStatus status, RefPtr<WebGPU::Adapter>&& adapter, String&& message) {
- callback(status, adapter ? new WGPUAdapterImpl { adapter.releaseNonNull() } : nullptr, message.utf8().data());
+ callback(status, WebGPU::releaseToAPI(WTFMove(adapter)), message.utf8().data());
});
}
Modified: trunk/Source/WebGPU/WebGPU/PipelineLayout.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/PipelineLayout.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/PipelineLayout.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -30,11 +30,14 @@
#import <wtf/RefCounted.h>
#import <wtf/Vector.h>
+struct WGPUPipelineLayoutImpl {
+};
+
namespace WebGPU {
class BindGroupLayout;
-class PipelineLayout : public RefCounted<PipelineLayout> {
+class PipelineLayout : public WGPUPipelineLayoutImpl, public RefCounted<PipelineLayout> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<PipelineLayout> create(Vector<Ref<BindGroupLayout>>&& bindGroupLayouts)
@@ -59,9 +62,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUPipelineLayoutImpl {
- Ref<WebGPU::PipelineLayout> pipelineLayout;
-};
Modified: trunk/Source/WebGPU/WebGPU/PipelineLayout.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/PipelineLayout.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/PipelineLayout.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -76,7 +76,7 @@
void wgpuPipelineLayoutRelease(WGPUPipelineLayout pipelineLayout)
{
- delete pipelineLayout;
+ WebGPU::fromAPI(pipelineLayout).deref();
}
void wgpuPipelineLayoutSetLabel(WGPUPipelineLayout pipelineLayout, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/QuerySet.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/QuerySet.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/QuerySet.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,9 +29,12 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUQuerySetImpl {
+};
+
namespace WebGPU {
-class QuerySet : public RefCounted<QuerySet> {
+class QuerySet : public WGPUQuerySetImpl, public RefCounted<QuerySet> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<QuerySet> create(id<MTLCounterSampleBuffer> counterSampleBuffer)
@@ -53,9 +56,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUQuerySetImpl {
- Ref<WebGPU::QuerySet> querySet;
-};
Modified: trunk/Source/WebGPU/WebGPU/QuerySet.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/QuerySet.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/QuerySet.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -59,7 +59,7 @@
void wgpuQuerySetRelease(WGPUQuerySet querySet)
{
- delete querySet;
+ WebGPU::fromAPI(querySet).deref();
}
void wgpuQuerySetDestroy(WGPUQuerySet querySet)
Modified: trunk/Source/WebGPU/WebGPU/Queue.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Queue.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Queue.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -33,6 +33,9 @@
#import <wtf/ThreadSafeRefCounted.h>
#import <wtf/Vector.h>
+struct WGPUQueueImpl {
+};
+
namespace WebGPU {
class Buffer;
@@ -39,7 +42,7 @@
class CommandBuffer;
class Device;
-class Queue : public ThreadSafeRefCounted<Queue> {
+class Queue : public WGPUQueueImpl, public ThreadSafeRefCounted<Queue> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<Queue> create(id<MTLCommandQueue> commandQueue, Device& device)
@@ -75,9 +78,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUQueueImpl {
- Ref<WebGPU::Queue> queue;
-};
Modified: trunk/Source/WebGPU/WebGPU/Queue.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Queue.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Queue.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -134,7 +134,7 @@
void wgpuQueueRelease(WGPUQueue queue)
{
- delete queue;
+ WebGPU::fromAPI(queue).deref();
}
void wgpuQueueOnSubmittedWorkDone(WGPUQueue queue, uint64_t signalValue, WGPUQueueWorkDoneCallback callback, void* userdata)
Modified: trunk/Source/WebGPU/WebGPU/RenderBundle.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderBundle.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderBundle.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,9 +29,12 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPURenderBundleImpl {
+};
+
namespace WebGPU {
-class RenderBundle : public RefCounted<RenderBundle> {
+class RenderBundle : public WGPURenderBundleImpl, public RefCounted<RenderBundle> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<RenderBundle> create(id<MTLIndirectCommandBuffer> indirectCommandBuffer)
@@ -52,9 +55,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPURenderBundleImpl {
- Ref<WebGPU::RenderBundle> renderBundle;
-};
Modified: trunk/Source/WebGPU/WebGPU/RenderBundle.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderBundle.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderBundle.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -48,7 +48,7 @@
void wgpuRenderBundleRelease(WGPURenderBundle renderBundle)
{
- delete renderBundle;
+ WebGPU::fromAPI(renderBundle).deref();
}
void wgpuRenderBundleSetLabel(WGPURenderBundle renderBundle, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/RenderBundleEncoder.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderBundleEncoder.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderBundleEncoder.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -31,6 +31,9 @@
#import <wtf/RefCounted.h>
#import <wtf/RefPtr.h>
+struct WGPURenderBundleEncoderImpl {
+};
+
namespace WebGPU {
class BindGroup;
@@ -38,7 +41,7 @@
class RenderBundle;
class RenderPipeline;
-class RenderBundleEncoder : public RefCounted<RenderBundleEncoder>, public CommandsMixin {
+class RenderBundleEncoder : public WGPURenderBundleEncoderImpl, public RefCounted<RenderBundleEncoder>, public CommandsMixin {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<RenderBundleEncoder> create(id<MTLIndirectCommandBuffer> indirectCommandBuffer)
@@ -73,9 +76,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPURenderBundleEncoderImpl {
- Ref<WebGPU::RenderBundleEncoder> renderBundleEncoder;
-};
Modified: trunk/Source/WebGPU/WebGPU/RenderBundleEncoder.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderBundleEncoder.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderBundleEncoder.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -175,7 +175,7 @@
void wgpuRenderBundleEncoderRelease(WGPURenderBundleEncoder renderBundleEncoder)
{
- delete renderBundleEncoder;
+ WebGPU::fromAPI(renderBundleEncoder).deref();
}
void wgpuRenderBundleEncoderDraw(WGPURenderBundleEncoder renderBundleEncoder, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
@@ -200,8 +200,7 @@
WGPURenderBundle wgpuRenderBundleEncoderFinish(WGPURenderBundleEncoder renderBundleEncoder, const WGPURenderBundleDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(renderBundleEncoder).finish(*descriptor);
- return result ? new WGPURenderBundleImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(renderBundleEncoder).finish(*descriptor));
}
void wgpuRenderBundleEncoderInsertDebugMarker(WGPURenderBundleEncoder renderBundleEncoder, const char* markerLabel)
Modified: trunk/Source/WebGPU/WebGPU/RenderPassEncoder.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderPassEncoder.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderPassEncoder.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -31,6 +31,9 @@
#import <wtf/RefCounted.h>
#import <wtf/Vector.h>
+struct WGPURenderPassEncoderImpl {
+};
+
namespace WebGPU {
class BindGroup;
@@ -39,7 +42,7 @@
class RenderBundle;
class RenderPipeline;
-class RenderPassEncoder : public RefCounted<RenderPassEncoder>, public CommandsMixin {
+class RenderPassEncoder : public WGPURenderPassEncoderImpl, public RefCounted<RenderPassEncoder>, public CommandsMixin {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<RenderPassEncoder> create(id<MTLRenderCommandEncoder> renderCommandEncoder)
@@ -83,9 +86,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPURenderPassEncoderImpl {
- Ref<WebGPU::RenderPassEncoder> renderPassEncoder;
-};
Modified: trunk/Source/WebGPU/WebGPU/RenderPassEncoder.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderPassEncoder.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderPassEncoder.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -222,7 +222,7 @@
void wgpuRenderPassEncoderRelease(WGPURenderPassEncoder renderPassEncoder)
{
- delete renderPassEncoder;
+ WebGPU::fromAPI(renderPassEncoder).deref();
}
void wgpuRenderPassEncoderBeginOcclusionQuery(WGPURenderPassEncoder renderPassEncoder, uint32_t queryIndex)
Modified: trunk/Source/WebGPU/WebGPU/RenderPipeline.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderPipeline.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderPipeline.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,11 +29,14 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPURenderPipelineImpl {
+};
+
namespace WebGPU {
class BindGroupLayout;
-class RenderPipeline : public RefCounted<RenderPipeline> {
+class RenderPipeline : public WGPURenderPipelineImpl, public RefCounted<RenderPipeline> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<RenderPipeline> create(id<MTLRenderPipelineState> renderPipelineState)
@@ -43,7 +46,7 @@
~RenderPipeline();
- Ref<BindGroupLayout> getBindGroupLayout(uint32_t groupIndex);
+ BindGroupLayout* getBindGroupLayout(uint32_t groupIndex);
void setLabel(String&&);
id<MTLRenderPipelineState> renderPipelineState() const { return m_renderPipelineState; }
@@ -55,9 +58,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPURenderPipelineImpl {
- Ref<WebGPU::RenderPipeline> renderPipeline;
-};
Modified: trunk/Source/WebGPU/WebGPU/RenderPipeline.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/RenderPipeline.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/RenderPipeline.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -51,10 +51,10 @@
RenderPipeline::~RenderPipeline() = default;
-Ref<BindGroupLayout> RenderPipeline::getBindGroupLayout(uint32_t groupIndex)
+BindGroupLayout* RenderPipeline::getBindGroupLayout(uint32_t groupIndex)
{
UNUSED_PARAM(groupIndex);
- return BindGroupLayout::create(nil, nil, nil);
+ return nullptr;
}
void RenderPipeline::setLabel(String&&)
@@ -68,12 +68,12 @@
void wgpuRenderPipelineRelease(WGPURenderPipeline renderPipeline)
{
- delete renderPipeline;
+ WebGPU::fromAPI(renderPipeline).deref();
}
WGPUBindGroupLayout wgpuRenderPipelineGetBindGroupLayout(WGPURenderPipeline renderPipeline, uint32_t groupIndex)
{
- return new WGPUBindGroupLayoutImpl { WebGPU::fromAPI(renderPipeline).getBindGroupLayout(groupIndex) };
+ return WebGPU::fromAPI(renderPipeline).getBindGroupLayout(groupIndex);
}
void wgpuRenderPipelineSetLabel(WGPURenderPipeline renderPipeline, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/Sampler.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Sampler.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Sampler.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,11 +29,14 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUSamplerImpl {
+};
+
namespace WebGPU {
class Device;
-class Sampler : public RefCounted<Sampler> {
+class Sampler : public WGPUSamplerImpl, public RefCounted<Sampler> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<Sampler> create(id<MTLSamplerState> samplerState, const WGPUSamplerDescriptor& descriptor, Device& device)
@@ -65,9 +68,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUSamplerImpl {
- Ref<WebGPU::Sampler> sampler;
-};
Modified: trunk/Source/WebGPU/WebGPU/Sampler.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Sampler.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Sampler.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -224,7 +224,7 @@
void wgpuSamplerRelease(WGPUSampler sampler)
{
- delete sampler;
+ WebGPU::fromAPI(sampler).deref();
}
void wgpuSamplerSetLabel(WGPUSampler sampler, const char* label)
Modified: trunk/Source/WebGPU/WebGPU/ShaderModule.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/ShaderModule.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/ShaderModule.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -32,11 +32,14 @@
#import <wtf/text/StringHash.h>
#import <wtf/text/WTFString.h>
+struct WGPUShaderModuleImpl {
+};
+
namespace WebGPU {
class PipelineLayout;
-class ShaderModule : public RefCounted<ShaderModule> {
+class ShaderModule : public WGPUShaderModuleImpl, public RefCounted<ShaderModule> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<ShaderModule> create(std::variant<WGSL::SuccessfulCheck, WGSL::FailedCheck>&& checkResult, HashMap<String, Ref<PipelineLayout>>&& pipelineLayoutHints, HashMap<String, WGSL::Reflection::EntryPointInformation>&& entryPointInformation, id<MTLLibrary> library)
@@ -68,9 +71,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUShaderModuleImpl {
- Ref<WebGPU::ShaderModule> shaderModule;
-};
Modified: trunk/Source/WebGPU/WebGPU/ShaderModule.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/ShaderModule.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/ShaderModule.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -88,8 +88,8 @@
const auto& hint = suppliedHints.hints[i];
if (hint.nextInChain)
return nullptr;
- hints.add(hint.key, hint.hint.layout->pipelineLayout);
- auto convertedPipelineLayout = ShaderModule::convertPipelineLayout(hint.hint.layout->pipelineLayout);
+ hints.add(hint.key, WebGPU::fromAPI(hint.hint.layout));
+ auto convertedPipelineLayout = ShaderModule::convertPipelineLayout(WebGPU::fromAPI(hint.hint.layout));
wgslHints.add(hint.key, WTFMove(convertedPipelineLayout));
}
auto prepareResult = WGSL::prepare(std::get<WGSL::SuccessfulCheck>(checkResult).ast, wgslHints);
@@ -250,7 +250,7 @@
void wgpuShaderModuleRelease(WGPUShaderModule shaderModule)
{
- delete shaderModule;
+ WebGPU::fromAPI(shaderModule).deref();
}
void wgpuShaderModuleGetCompilationInfo(WGPUShaderModule shaderModule, WGPUCompilationInfoCallback callback, void * userdata)
Modified: trunk/Source/WebGPU/WebGPU/Surface.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Surface.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Surface.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,11 +29,14 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUSurfaceImpl {
+};
+
namespace WebGPU {
class Adapter;
-class Surface : public RefCounted<Surface> {
+class Surface : public WGPUSurfaceImpl, public RefCounted<Surface> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<Surface> create()
@@ -50,9 +53,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUSurfaceImpl {
- Ref<WebGPU::Surface> surface;
-};
Modified: trunk/Source/WebGPU/WebGPU/Surface.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Surface.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Surface.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -47,7 +47,7 @@
void wgpuSurfaceRelease(WGPUSurface surface)
{
- delete surface;
+ WebGPU::fromAPI(surface).deref();
}
WGPUTextureFormat wgpuSurfaceGetPreferredFormat(WGPUSurface surface, WGPUAdapter adapter)
Modified: trunk/Source/WebGPU/WebGPU/SwapChain.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/SwapChain.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/SwapChain.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,11 +29,14 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUSwapChainImpl {
+};
+
namespace WebGPU {
class TextureView;
-class SwapChain : public RefCounted<SwapChain> {
+class SwapChain : public WGPUSwapChainImpl, public RefCounted<SwapChain> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<SwapChain> create()
@@ -43,7 +46,7 @@
~SwapChain();
- Ref<TextureView> getCurrentTextureView();
+ TextureView* getCurrentTextureView();
void present();
private:
@@ -51,9 +54,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUSwapChainImpl {
- Ref<WebGPU::SwapChain> swapChain;
-};
Modified: trunk/Source/WebGPU/WebGPU/SwapChain.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/SwapChain.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/SwapChain.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -43,9 +43,9 @@
SwapChain::~SwapChain() = default;
-Ref<TextureView> SwapChain::getCurrentTextureView()
+TextureView* SwapChain::getCurrentTextureView()
{
- return TextureView::create(nil);
+ return nullptr;
}
void SwapChain::present()
@@ -58,12 +58,12 @@
void wgpuSwapChainRelease(WGPUSwapChain swapChain)
{
- delete swapChain;
+ WebGPU::fromAPI(swapChain).deref();
}
WGPUTextureView wgpuSwapChainGetCurrentTextureView(WGPUSwapChain swapChain)
{
- return new WGPUTextureViewImpl { WebGPU::fromAPI(swapChain).getCurrentTextureView() };
+ return WebGPU::fromAPI(swapChain).getCurrentTextureView();
}
void wgpuSwapChainPresent(WGPUSwapChain swapChain)
Modified: trunk/Source/WebGPU/WebGPU/Texture.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Texture.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Texture.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -30,11 +30,14 @@
#import <wtf/RefCounted.h>
#import <wtf/RefPtr.h>
+struct WGPUTextureImpl {
+};
+
namespace WebGPU {
class TextureView;
-class Texture : public RefCounted<Texture> {
+class Texture : public WGPUTextureImpl, public RefCounted<Texture> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<Texture> create(id<MTLTexture> texture)
@@ -57,9 +60,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUTextureImpl {
- Ref<WebGPU::Texture> texture;
-};
Modified: trunk/Source/WebGPU/WebGPU/Texture.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/Texture.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/Texture.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -66,13 +66,12 @@
void wgpuTextureRelease(WGPUTexture texture)
{
- delete texture;
+ WebGPU::fromAPI(texture).deref();
}
WGPUTextureView wgpuTextureCreateView(WGPUTexture texture, const WGPUTextureViewDescriptor* descriptor)
{
- auto result = WebGPU::fromAPI(texture).createView(*descriptor);
- return result ? new WGPUTextureViewImpl { result.releaseNonNull() } : nullptr;
+ return WebGPU::releaseToAPI(WebGPU::fromAPI(texture).createView(*descriptor));
}
void wgpuTextureDestroy(WGPUTexture texture)
Modified: trunk/Source/WebGPU/WebGPU/TextureView.h (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/TextureView.h 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/TextureView.h 2022-03-22 19:04:20 UTC (rev 291687)
@@ -29,9 +29,12 @@
#import <wtf/Ref.h>
#import <wtf/RefCounted.h>
+struct WGPUTextureViewImpl {
+};
+
namespace WebGPU {
-class TextureView : public RefCounted<TextureView> {
+class TextureView : public WGPUTextureViewImpl, public RefCounted<TextureView> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<TextureView> create(id<MTLTexture> texture)
@@ -52,9 +55,3 @@
};
} // namespace WebGPU
-
-#pragma mark WGPU Wrapper
-
-struct WGPUTextureViewImpl {
- Ref<WebGPU::TextureView> textureView;
-};
Modified: trunk/Source/WebGPU/WebGPU/TextureView.mm (291686 => 291687)
--- trunk/Source/WebGPU/WebGPU/TextureView.mm 2022-03-22 18:58:56 UTC (rev 291686)
+++ trunk/Source/WebGPU/WebGPU/TextureView.mm 2022-03-22 19:04:20 UTC (rev 291687)
@@ -48,7 +48,7 @@
void wgpuTextureViewRelease(WGPUTextureView textureView)
{
- UNUSED_PARAM(textureView);
+ WebGPU::fromAPI(textureView).deref();
}
void wgpuTextureViewSetLabel(WGPUTextureView textureView, const char* label)