Skip to content

Commit

Permalink
Disallow DMD compiler, Refactor GPU pass descriptor usages
Browse files Browse the repository at this point in the history
  • Loading branch information
chances committed Jun 29, 2024
1 parent 8c5deee commit fe66e8a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
matrix:
os: [ubuntu-latest, macos-12]
# TODO: os: [ubuntu-latest, macos-12, windows-latest]
compiler: [ldc-1.36.0, dmd-2.107.0]
# FIXME: ImportC doesn't emit `struct` constructors?
# Test against the last two LDC releases
compiler: [ldc-1.37.0, ldc-1.38.0]
# TODO: compiler: [ldc-1.36.0, dmd-2.107.0]
# FIXME: This is some linking issue in DMD that's not present in LDC. ImportC doesn't emit `struct` constructors?
exclude:
# Undefined symbols for architecture x86_64:
# "__C.WGPURenderPassDescriptor.__initwgpu_bindings", referenced from:
# @trusted wgpu.api.RenderPass wgpu.api.CommandEncoder.beginRenderPass(const(__C.WGPURenderPassDescriptor)) in wgpu-d-test-unittest.o
exclude:
- os: macos-12
compiler: dmd-2.107.0
- compiler: dmd-2.107.0
- compiler: dmd-2.108.0

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"targetPath": "bin",
"toolchainRequirements": {
"frontend": ">=2.105",
"dmd": ">=2.107.0",
"dmd": "no",
"gdc": "no",
"ldc": ">=1.35.0-beta1"
},
Expand Down
27 changes: 17 additions & 10 deletions source/wgpu/api.d
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,9 @@ struct ShaderModule {
/// When finished recording, call `CommandEncoder.finish` to obtain a `CommandBuffer` which may be submitted for execution.
/// See_Also: <a href="https://docs.rs/wgpu/0.10.2/wgpu/struct.CommandEncoder.html">wgpu::CommandEncoder</a>
struct CommandEncoder {
import std.conv : castFrom;
import std.traits : Unconst;

/// Handle identifier.
WGPUCommandEncoder id;
/// Describes a `CommandEncoder`.
Expand Down Expand Up @@ -1828,25 +1831,29 @@ struct CommandEncoder {
string label = null
) {
assert(colorAttachments.length);
auto descriptor = RenderPassDescriptor.init;
descriptor.label = label is null ? null : label.toStringz;
descriptor.colorAttachmentCount = colorAttachments.length.to!uint;
descriptor.colorAttachments = colorAttachments.ptr;
descriptor.depthStencilAttachment = depthStencilAttachment;
return beginRenderPass(descriptor);
auto renderPass = new RenderPassDescriptor();
renderPass.label = label is null ? null : label.toStringz;
renderPass.colorAttachmentCount = colorAttachments.length.to!uint;
renderPass.colorAttachments = colorAttachments.ptr;
renderPass.depthStencilAttachment = depthStencilAttachment;
return beginRenderPass(renderPass);
}
/// Begins recording of a render pass.
///
/// This function returns a `RenderPass` object which records a single render pass.
RenderPass beginRenderPass(const RenderPassDescriptor descriptor) @trusted {
return RenderPass(wgpuCommandEncoderBeginRenderPass(id, cast(RenderPassDescriptor*) &descriptor));
RenderPass beginRenderPass(Descriptor : RenderPassDescriptor*)(const Descriptor descriptor) @trusted {
return RenderPass(wgpuCommandEncoderBeginRenderPass(
id, castFrom!(const Descriptor).to!(Unconst!Descriptor)(descriptor))
);
}

/// Begins recording of a compute pass.
///
/// This function returns a `ComputePass` object which records a single compute pass.
ComputePass beginComputePass(const ComputePassDescriptor descriptor) @trusted {
return ComputePass(wgpuCommandEncoderBeginComputePass(id, cast(ComputePassDescriptor*) &descriptor));
ComputePass beginComputePass(Descriptor : ComputePassDescriptor*)(const Descriptor descriptor) @trusted {
return ComputePass(wgpuCommandEncoderBeginComputePass(
id, castFrom!(const Descriptor).to!(Unconst!Descriptor)(descriptor))
);
}

// TODO: void wgpuCommandEncoderCopyBufferToBuffer(WGPUCommandEncoder commandEncoder, WGPUBuffer source, uint64_t sourceOffset, WGPUBuffer destination, uint64_t destinationOffset, uint64_t size);
Expand Down

0 comments on commit fe66e8a

Please sign in to comment.