1 | /* |
2 | * Copyright (C) 2018 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "GPUDevice.h" |
28 | |
29 | #if ENABLE(WEBGPU) |
30 | |
31 | #include "GPUBindGroupLayout.h" |
32 | #include "GPUBindGroupLayoutDescriptor.h" |
33 | #include "GPUBuffer.h" |
34 | #include "GPUBufferDescriptor.h" |
35 | #include "GPUCommandBuffer.h" |
36 | #include "GPUComputePipeline.h" |
37 | #include "GPUComputePipelineDescriptor.h" |
38 | #include "GPUPipelineLayout.h" |
39 | #include "GPUPipelineLayoutDescriptor.h" |
40 | #include "GPURenderPipeline.h" |
41 | #include "GPURenderPipelineDescriptor.h" |
42 | #include "GPUSampler.h" |
43 | #include "GPUSamplerDescriptor.h" |
44 | #include "GPUShaderModule.h" |
45 | #include "GPUShaderModuleDescriptor.h" |
46 | #include "GPUSwapChainDescriptor.h" |
47 | #include "GPUTexture.h" |
48 | #include "GPUTextureDescriptor.h" |
49 | #include <wtf/Optional.h> |
50 | |
51 | namespace WebCore { |
52 | |
53 | RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(const GPUBufferDescriptor& descriptor) |
54 | { |
55 | return GPUBuffer::tryCreate(makeRef(*this), descriptor); |
56 | } |
57 | |
58 | RefPtr<GPUTexture> GPUDevice::tryCreateTexture(const GPUTextureDescriptor& descriptor) const |
59 | { |
60 | return GPUTexture::tryCreate(*this, descriptor); |
61 | } |
62 | |
63 | RefPtr<GPUSampler> GPUDevice::tryCreateSampler(const GPUSamplerDescriptor& descriptor) const |
64 | { |
65 | return GPUSampler::tryCreate(*this, descriptor); |
66 | } |
67 | |
68 | RefPtr<GPUBindGroupLayout> GPUDevice::tryCreateBindGroupLayout(const GPUBindGroupLayoutDescriptor& descriptor) const |
69 | { |
70 | return GPUBindGroupLayout::tryCreate(*this, descriptor); |
71 | } |
72 | |
73 | Ref<GPUPipelineLayout> GPUDevice::createPipelineLayout(GPUPipelineLayoutDescriptor&& descriptor) const |
74 | { |
75 | return GPUPipelineLayout::create(WTFMove(descriptor)); |
76 | } |
77 | |
78 | RefPtr<GPUShaderModule> GPUDevice::tryCreateShaderModule(const GPUShaderModuleDescriptor& descriptor) const |
79 | { |
80 | return GPUShaderModule::tryCreate(*this, descriptor); |
81 | } |
82 | |
83 | RefPtr<GPURenderPipeline> GPUDevice::tryCreateRenderPipeline(const GPURenderPipelineDescriptor& descriptor) const |
84 | { |
85 | return GPURenderPipeline::tryCreate(*this, descriptor); |
86 | } |
87 | |
88 | RefPtr<GPUComputePipeline> GPUDevice::tryCreateComputePipeline(const GPUComputePipelineDescriptor& descriptor) const |
89 | { |
90 | return GPUComputePipeline::tryCreate(*this, descriptor); |
91 | } |
92 | |
93 | RefPtr<GPUCommandBuffer> GPUDevice::tryCreateCommandBuffer() const |
94 | { |
95 | return GPUCommandBuffer::tryCreate(*this); |
96 | } |
97 | |
98 | RefPtr<GPUQueue> GPUDevice::tryGetQueue() const |
99 | { |
100 | if (!m_queue) |
101 | m_queue = GPUQueue::tryCreate(*this); |
102 | |
103 | return m_queue; |
104 | } |
105 | |
106 | void GPUDevice::setSwapChain(RefPtr<GPUSwapChain>&& swapChain) |
107 | { |
108 | m_swapChain = WTFMove(swapChain); |
109 | } |
110 | |
111 | } // namespace WebCore |
112 | |
113 | #endif // ENABLE(WEBGPU) |
114 | |