|
1 | 1 | ## Load WGPU |
2 | | -using WGPU |
| 2 | +using WGPUCore |
3 | 3 |
|
4 | 4 | using WGPUNative |
5 | 5 |
|
6 | | -WGPU.SetLogLevel(WGPULogLevel_Debug) |
| 6 | +WGPUCore.SetLogLevel(WGPULogLevel_Debug) |
7 | 7 |
|
8 | 8 | shaderSource = Vector{UInt8}( |
9 | 9 | """ |
@@ -57,47 +57,47 @@ for i = 1:n |
57 | 57 | data[i] = i |
58 | 58 | end |
59 | 59 |
|
60 | | -# canvas = WGPU.defaultCanvas(WGPU.WGPUCanvas); |
61 | | -gpuDevice = WGPU.getDefaultDevice() |
| 60 | +# canvas = WGPUCore.defaultCanvas(WGPUCore.WGPUCanvas); |
| 61 | +gpuDevice = WGPUCore.getDefaultDevice() |
62 | 62 |
|
63 | | -shadercode = WGPU.loadWGSL(shaderSource) |> first |
| 63 | +shadercode = WGPUCore.loadWGSL(shaderSource) |> first |
64 | 64 |
|
65 | 65 | cshader = |
66 | | - WGPU.createShaderModule(gpuDevice, "shadercode", shadercode, nothing, nothing) |> Ref |
| 66 | + WGPUCore.createShaderModule(gpuDevice, "shadercode", shadercode, nothing, nothing) |> Ref |
67 | 67 |
|
68 | | -(buffer1, _) = WGPU.createBufferWithData(gpuDevice, "buffer1", data, "Storage") |
| 68 | +(buffer1, _) = WGPUCore.createBufferWithData(gpuDevice, "buffer1", data, "Storage") |
69 | 69 |
|
70 | 70 | buffer2 = |
71 | | - WGPU.createBuffer("buffer2", gpuDevice, sizeof(data), ["Storage", "CopySrc"], false) |
| 71 | + WGPUCore.createBuffer("buffer2", gpuDevice, sizeof(data), ["Storage", "CopySrc"], false) |
72 | 72 |
|
73 | 73 | bindingLayouts = [ |
74 | | - WGPU.WGPUBufferEntry => |
| 74 | + WGPUCore.WGPUBufferEntry => |
75 | 75 | [:binding => 0, :visibility => "Compute", :type => "ReadOnlyStorage"], |
76 | | - WGPU.WGPUBufferEntry => |
| 76 | + WGPUCore.WGPUBufferEntry => |
77 | 77 | [:binding => 1, :visibility => "Compute", :type => "Storage"], |
78 | 78 | ] |
79 | 79 |
|
80 | 80 | bindings = [ |
81 | | - WGPU.GPUBuffer => |
| 81 | + WGPUCore.GPUBuffer => |
82 | 82 | [:binding => 0, :buffer => buffer1, :offset => 0, :size => buffer1.size], |
83 | | - WGPU.GPUBuffer => |
| 83 | + WGPUCore.GPUBuffer => |
84 | 84 | [:binding => 1, :buffer => buffer2, :offset => 0, :size => buffer2.size], |
85 | 85 | ] |
86 | 86 |
|
87 | 87 |
|
88 | 88 | (bindGroupLayouts, bindGroup) = |
89 | | - WGPU.makeBindGroupAndLayout(gpuDevice, bindingLayouts, bindings) |
90 | | -pipelineLayout = WGPU.createPipelineLayout(gpuDevice, "PipeLineLayout", bindGroupLayouts) |
91 | | -computeStage = WGPU.createComputeStage(cshader[], "main") |
| 89 | + WGPUCore.makeBindGroupAndLayout(gpuDevice, bindingLayouts, bindings) |
| 90 | +pipelineLayout = WGPUCore.createPipelineLayout(gpuDevice, "PipeLineLayout", bindGroupLayouts) |
| 91 | +computeStage = WGPUCore.createComputeStage(cshader[], "main") |
92 | 92 | computePipeline = |
93 | | - WGPU.createComputePipeline(gpuDevice, "computePipeline", pipelineLayout, computeStage) |
| 93 | + WGPUCore.createComputePipeline(gpuDevice, "computePipeline", pipelineLayout, computeStage) |
94 | 94 |
|
95 | | -commandEncoder = WGPU.createCommandEncoder(gpuDevice, "Command Encoder") |
96 | | -computePass = WGPU.beginComputePass(commandEncoder) |
| 95 | +commandEncoder = WGPUCore.createCommandEncoder(gpuDevice, "Command Encoder") |
| 96 | +computePass = WGPUCore.beginComputePass(commandEncoder) |
97 | 97 |
|
98 | | -WGPU.setPipeline(computePass, computePipeline) |
99 | | -WGPU.setBindGroup(computePass, 0, bindGroup, UInt32[], 0, 999999) |
100 | | -WGPU.dispatchWorkGroups(computePass, n, 1, 1) |
101 | | -WGPU.endComputePass(computePass) |
102 | | -WGPU.submit(gpuDevice.queue, [WGPU.finish(commandEncoder)]) |
103 | | -WGPU.readBuffer(gpuDevice, buffer2, 0, sizeof(data)) |
| 98 | +WGPUCore.setPipeline(computePass, computePipeline) |
| 99 | +WGPUCore.setBindGroup(computePass, 0, bindGroup, UInt32[], 0, 999999) |
| 100 | +WGPUCore.dispatchWorkGroups(computePass, n, 1, 1) |
| 101 | +WGPUCore.endComputePass(computePass) |
| 102 | +WGPUCore.submit(gpuDevice.queue, [WGPUCore.finish(commandEncoder)]) |
| 103 | +WGPUCore.readBuffer(gpuDevice, buffer2, 0, sizeof(data)) |
0 commit comments