Bug 1865830 - Implement CommandEncoder.clearBuffer. r=webgpu-reviewers,webidl,emilio,ErichDonGubler

Differential Revision: https://phabricator.services.mozilla.com/D194233
This commit is contained in:
Nicolas Silva 2023-12-04 22:11:21 +00:00
Родитель bbcb0c22f4
Коммит bc39e78852
4 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -162,6 +162,21 @@ void CommandEncoder::CopyTextureToTexture(
}
}
void CommandEncoder::ClearBuffer(const Buffer& aBuffer, const uint64_t aOffset,
const dom::Optional<uint64_t>& aSize) {
uint64_t sizeVal = 0xdeaddead;
uint64_t* size = nullptr;
if (aSize.WasPassed()) {
sizeVal = aSize.Value();
size = &sizeVal;
}
ipc::ByteBuf bb;
ffi::wgpu_command_encoder_clear_buffer(aBuffer.mId, aOffset, size,
ToFFI(&bb));
mBridge->SendCommandEncoderAction(mId, mParent->mId, std::move(bb));
}
void CommandEncoder::PushDebugGroup(const nsAString& aString) {
if (!mBridge->IsOpen()) {
return;

Просмотреть файл

@ -88,6 +88,8 @@ class CommandEncoder final : public ObjectBase, public ChildOf<Device> {
void CopyTextureToTexture(const dom::GPUImageCopyTexture& aSource,
const dom::GPUImageCopyTexture& aDestination,
const dom::GPUExtent3D& aCopySize);
void ClearBuffer(const Buffer& aBuffer, const uint64_t aOffset,
const dom::Optional<uint64_t>& aSize);
void PushDebugGroup(const nsAString& aString);
void PopDebugGroup();

Просмотреть файл

@ -893,6 +893,11 @@ interface GPUCommandEncoder {
GPUImageCopyTexture destination,
GPUExtent3D copySize);
undefined clearBuffer(
GPUBuffer buffer,
optional GPUSize64 offset = 0,
optional GPUSize64 size);
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
};
GPUCommandEncoder includes GPUObjectBase;

Просмотреть файл

@ -1270,6 +1270,21 @@ pub unsafe extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
*bb = make_byte_buf(&action);
}
#[no_mangle]
pub unsafe extern "C" fn wgpu_command_encoder_clear_buffer(
dst: wgc::id::BufferId,
offset: u64,
size: Option<&u64>,
bb: &mut ByteBuf,
) {
let action = CommandEncoderAction::ClearBuffer {
dst,
offset,
size: size.cloned(),
};
*bb = make_byte_buf(&action);
}
#[no_mangle]
pub extern "C" fn wgpu_command_encoder_push_debug_group(marker: &nsACString, bb: &mut ByteBuf) {
let string = marker.to_string();