From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- dom/webgpu/Device.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'dom/webgpu/Device.cpp') diff --git a/dom/webgpu/Device.cpp b/dom/webgpu/Device.cpp index a9fd5ee44c..62d302c4d8 100644 --- a/dom/webgpu/Device.cpp +++ b/dom/webgpu/Device.cpp @@ -667,6 +667,8 @@ RawId CreateComputePipelineImpl(PipelineCreationContext* const aContext, ipc::ByteBuf* const aByteBuf) { ffi::WGPUComputePipelineDescriptor desc = {}; nsCString entryPoint; + nsTArray constantKeys; + nsTArray constants; webgpu::StringHelper label(aDesc.mLabel); desc.label = label.Get(); @@ -685,6 +687,21 @@ RawId CreateComputePipelineImpl(PipelineCreationContext* const aContext, } else { desc.stage.entry_point = nullptr; } + if (aDesc.mCompute.mConstants.WasPassed()) { + const auto& descConstants = aDesc.mCompute.mConstants.Value().Entries(); + constantKeys.SetCapacity(descConstants.Length()); + constants.SetCapacity(descConstants.Length()); + for (const auto& entry : descConstants) { + ffi::WGPUConstantEntry constantEntry = {}; + nsCString key = NS_ConvertUTF16toUTF8(entry.mKey); + constantKeys.AppendElement(key); + constantEntry.key = key.get(); + constantEntry.value = entry.mValue; + constants.AppendElement(constantEntry); + } + desc.stage.constants = constants.Elements(); + desc.stage.constants_length = constants.Length(); + } RawId implicit_bgl_ids[WGPUMAX_BIND_GROUPS] = {}; RawId id = ffi::wgpu_client_create_compute_pipeline( @@ -708,6 +725,8 @@ RawId CreateRenderPipelineImpl(PipelineCreationContext* const aContext, nsTArray vertexAttributes; ffi::WGPURenderPipelineDescriptor desc = {}; nsCString vsEntry, fsEntry; + nsTArray vsConstantKeys, fsConstantKeys; + nsTArray vsConstants, fsConstants; ffi::WGPUIndexFormat stripIndexFormat = ffi::WGPUIndexFormat_Uint16; ffi::WGPUFace cullFace = ffi::WGPUFace_Front; ffi::WGPUVertexState vertexState = {}; @@ -735,6 +754,21 @@ RawId CreateRenderPipelineImpl(PipelineCreationContext* const aContext, } else { vertexState.stage.entry_point = nullptr; } + if (stage.mConstants.WasPassed()) { + const auto& descConstants = stage.mConstants.Value().Entries(); + vsConstantKeys.SetCapacity(descConstants.Length()); + vsConstants.SetCapacity(descConstants.Length()); + for (const auto& entry : descConstants) { + ffi::WGPUConstantEntry constantEntry = {}; + nsCString key = NS_ConvertUTF16toUTF8(entry.mKey); + vsConstantKeys.AppendElement(key); + constantEntry.key = key.get(); + constantEntry.value = entry.mValue; + vsConstants.AppendElement(constantEntry); + } + vertexState.stage.constants = vsConstants.Elements(); + vertexState.stage.constants_length = vsConstants.Length(); + } for (const auto& vertex_desc : stage.mBuffers) { ffi::WGPUVertexBufferLayout vb_desc = {}; @@ -775,6 +809,21 @@ RawId CreateRenderPipelineImpl(PipelineCreationContext* const aContext, } else { fragmentState.stage.entry_point = nullptr; } + if (stage.mConstants.WasPassed()) { + const auto& descConstants = stage.mConstants.Value().Entries(); + fsConstantKeys.SetCapacity(descConstants.Length()); + fsConstants.SetCapacity(descConstants.Length()); + for (const auto& entry : descConstants) { + ffi::WGPUConstantEntry constantEntry = {}; + nsCString key = NS_ConvertUTF16toUTF8(entry.mKey); + fsConstantKeys.AppendElement(key); + constantEntry.key = key.get(); + constantEntry.value = entry.mValue; + fsConstants.AppendElement(constantEntry); + } + fragmentState.stage.constants = fsConstants.Elements(); + fragmentState.stage.constants_length = fsConstants.Length(); + } // Note: we pre-collect the blend states into a different array // so that we can have non-stale pointers into it. -- cgit v1.2.3