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 e188c5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
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 e188c5f

Please sign in to comment.