diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/webgpu/Device.cpp | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/webgpu/Device.cpp')
-rw-r--r-- | dom/webgpu/Device.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
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<nsCString> constantKeys; + nsTArray<ffi::WGPUConstantEntry> 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<ffi::WGPUVertexAttribute> vertexAttributes; ffi::WGPURenderPipelineDescriptor desc = {}; nsCString vsEntry, fsEntry; + nsTArray<nsCString> vsConstantKeys, fsConstantKeys; + nsTArray<ffi::WGPUConstantEntry> 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. |