зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1614703 - WebGPU render pipeline creation r=jgilbert,webidl,baku
Differential Revision: https://phabricator.services.mozilla.com/D64833 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7017ded493
Коммит
53a10a49a5
|
@ -12,10 +12,12 @@
|
|||
|
||||
#include "Adapter.h"
|
||||
#include "Buffer.h"
|
||||
#include "ComputePipeline.h"
|
||||
#include "Queue.h"
|
||||
#include "RenderPipeline.h"
|
||||
#include "Sampler.h"
|
||||
#include "Texture.h"
|
||||
#include "TextureView.h"
|
||||
#include "Queue.h"
|
||||
#include "ipc/WebGPUChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -185,5 +187,12 @@ already_AddRefed<ComputePipeline> Device::CreateComputePipeline(
|
|||
return object.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<RenderPipeline> Device::CreateRenderPipeline(
|
||||
const dom::GPURenderPipelineDescriptor& aDesc) {
|
||||
RawId id = mBridge->DeviceCreateRenderPipeline(mId, aDesc);
|
||||
RefPtr<RenderPipeline> object = new RenderPipeline(this, id);
|
||||
return object.forget();
|
||||
}
|
||||
|
||||
} // namespace webgpu
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -120,6 +120,8 @@ class Device final : public DOMEventTargetHelper {
|
|||
const dom::GPUShaderModuleDescriptor& aDesc);
|
||||
already_AddRefed<ComputePipeline> CreateComputePipeline(
|
||||
const dom::GPUComputePipelineDescriptor& aDesc);
|
||||
already_AddRefed<RenderPipeline> CreateRenderPipeline(
|
||||
const dom::GPURenderPipelineDescriptor& aDesc);
|
||||
|
||||
// IMPL_EVENT_HANDLER(uncapturederror)
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@ using SerialBindGroupLayoutDescriptor from "mozilla/webgpu/WebGPUTypes.h";
|
|||
using SerialPipelineLayoutDescriptor from "mozilla/webgpu/WebGPUTypes.h";
|
||||
using SerialBindGroupDescriptor from "mozilla/webgpu/WebGPUTypes.h";
|
||||
using SerialComputePipelineDescriptor from "mozilla/webgpu/WebGPUTypes.h";
|
||||
using SerialRenderPipelineDescriptor from "mozilla/webgpu/WebGPUTypes.h";
|
||||
using dom::GPURequestAdapterOptions from "mozilla/dom/WebGPUBinding.h";
|
||||
using dom::GPUDeviceDescriptor from "mozilla/dom/WebGPUBinding.h";
|
||||
using dom::GPUBufferDescriptor from "mozilla/dom/WebGPUBinding.h";
|
||||
|
@ -69,6 +70,7 @@ parent:
|
|||
async ShaderModuleDestroy(RawId selfId);
|
||||
async DeviceCreateComputePipeline(RawId selfId, SerialComputePipelineDescriptor desc, RawId newId);
|
||||
async ComputePipelineDestroy(RawId selfId);
|
||||
async DeviceCreateRenderPipeline(RawId selfId, SerialRenderPipelineDescriptor desc, RawId newId);
|
||||
async RenderPipelineDestroy(RawId selfId);
|
||||
async Shutdown();
|
||||
|
||||
|
|
|
@ -348,13 +348,21 @@ void WebGPUChild::DestroyShaderModule(RawId aId) {
|
|||
ffi::wgpu_client_kill_shader_module_id(mClient, aId);
|
||||
}
|
||||
|
||||
static SerialProgrammableStageDescriptor ConvertProgrammableStageDescriptor(
|
||||
const dom::GPUProgrammableStageDescriptor& aDesc) {
|
||||
SerialProgrammableStageDescriptor stage = {};
|
||||
stage.mModule = aDesc.mModule->mId;
|
||||
stage.mEntryPoint = aDesc.mEntryPoint;
|
||||
return stage;
|
||||
}
|
||||
|
||||
RawId WebGPUChild::DeviceCreateComputePipeline(
|
||||
RawId aSelfId, const dom::GPUComputePipelineDescriptor& aDesc) {
|
||||
RawId id = ffi::wgpu_client_make_compute_pipeline_id(mClient, aSelfId);
|
||||
SerialProgrammableStageDescriptor stage = {};
|
||||
stage.mModule = aDesc.mComputeStage.mModule->mId;
|
||||
stage.mEntryPoint = aDesc.mComputeStage.mEntryPoint;
|
||||
SerialComputePipelineDescriptor desc = {aDesc.mLayout->mId, stage};
|
||||
const SerialComputePipelineDescriptor desc = {
|
||||
aDesc.mLayout->mId,
|
||||
ConvertProgrammableStageDescriptor(aDesc.mComputeStage),
|
||||
};
|
||||
if (!SendDeviceCreateComputePipeline(aSelfId, desc, id)) {
|
||||
MOZ_CRASH("IPC failure");
|
||||
}
|
||||
|
@ -366,6 +374,134 @@ void WebGPUChild::DestroyComputePipeline(RawId aId) {
|
|||
ffi::wgpu_client_kill_compute_pipeline_id(mClient, aId);
|
||||
}
|
||||
|
||||
static ffi::WGPURasterizationStateDescriptor ConvertRasterizationDescriptor(
|
||||
const dom::GPURasterizationStateDescriptor& aDesc) {
|
||||
ffi::WGPURasterizationStateDescriptor desc = {};
|
||||
desc.front_face = ffi::WGPUFrontFace(aDesc.mFrontFace);
|
||||
desc.cull_mode = ffi::WGPUCullMode(aDesc.mCullMode);
|
||||
desc.depth_bias = aDesc.mDepthBias;
|
||||
desc.depth_bias_slope_scale = aDesc.mDepthBiasSlopeScale;
|
||||
desc.depth_bias_clamp = aDesc.mDepthBiasClamp;
|
||||
return desc;
|
||||
}
|
||||
|
||||
static ffi::WGPUBlendDescriptor ConvertBlendDescriptor(
|
||||
const dom::GPUBlendDescriptor& aDesc) {
|
||||
ffi::WGPUBlendDescriptor desc = {};
|
||||
desc.src_factor = ffi::WGPUBlendFactor(aDesc.mSrcFactor);
|
||||
desc.dst_factor = ffi::WGPUBlendFactor(aDesc.mDstFactor);
|
||||
desc.operation = ffi::WGPUBlendOperation(aDesc.mOperation);
|
||||
return desc;
|
||||
}
|
||||
|
||||
static ffi::WGPUColorStateDescriptor ConvertColorDescriptor(
|
||||
const dom::GPUColorStateDescriptor& aDesc) {
|
||||
ffi::WGPUColorStateDescriptor desc = {};
|
||||
desc.format = ffi::WGPUTextureFormat(aDesc.mFormat);
|
||||
const ffi::WGPUBlendDescriptor no_blend = {
|
||||
ffi::WGPUBlendFactor_One,
|
||||
ffi::WGPUBlendFactor_Zero,
|
||||
ffi::WGPUBlendOperation_Add,
|
||||
};
|
||||
desc.alpha_blend = aDesc.mAlpha.WasPassed()
|
||||
? ConvertBlendDescriptor(aDesc.mAlpha.Value())
|
||||
: no_blend;
|
||||
desc.color_blend = aDesc.mColor.WasPassed()
|
||||
? ConvertBlendDescriptor(aDesc.mColor.Value())
|
||||
: no_blend;
|
||||
desc.write_mask = aDesc.mWriteMask;
|
||||
return desc;
|
||||
}
|
||||
|
||||
static ffi::WGPUStencilStateFaceDescriptor ConvertStencilFaceDescriptor(
|
||||
const dom::GPUStencilStateFaceDescriptor& aDesc) {
|
||||
ffi::WGPUStencilStateFaceDescriptor desc = {};
|
||||
desc.compare = ffi::WGPUCompareFunction(aDesc.mCompare);
|
||||
desc.fail_op = ffi::WGPUStencilOperation(aDesc.mFailOp);
|
||||
desc.depth_fail_op = ffi::WGPUStencilOperation(aDesc.mDepthFailOp);
|
||||
desc.pass_op = ffi::WGPUStencilOperation(aDesc.mPassOp);
|
||||
return desc;
|
||||
}
|
||||
|
||||
static ffi::WGPUDepthStencilStateDescriptor ConvertDepthStencilDescriptor(
|
||||
const dom::GPUDepthStencilStateDescriptor& aDesc) {
|
||||
ffi::WGPUDepthStencilStateDescriptor desc = {};
|
||||
desc.format = ffi::WGPUTextureFormat(aDesc.mFormat);
|
||||
desc.depth_write_enabled = aDesc.mDepthWriteEnabled;
|
||||
desc.depth_compare = ffi::WGPUCompareFunction(aDesc.mDepthCompare);
|
||||
desc.stencil_front = ConvertStencilFaceDescriptor(aDesc.mStencilFront);
|
||||
desc.stencil_back = ConvertStencilFaceDescriptor(aDesc.mStencilBack);
|
||||
desc.stencil_read_mask = aDesc.mStencilReadMask;
|
||||
desc.stencil_write_mask = aDesc.mStencilWriteMask;
|
||||
return desc;
|
||||
}
|
||||
|
||||
static ffi::WGPUVertexAttributeDescriptor ConvertVertexAttributeDescriptor(
|
||||
const dom::GPUVertexAttributeDescriptor& aDesc) {
|
||||
ffi::WGPUVertexAttributeDescriptor desc = {};
|
||||
desc.offset = aDesc.mOffset;
|
||||
desc.format = ffi::WGPUVertexFormat(aDesc.mFormat);
|
||||
desc.shader_location = aDesc.mShaderLocation;
|
||||
return desc;
|
||||
}
|
||||
|
||||
static SerialVertexBufferDescriptor ConvertVertexBufferDescriptor(
|
||||
const dom::GPUVertexBufferDescriptor& aDesc) {
|
||||
SerialVertexBufferDescriptor desc = {};
|
||||
desc.mStride = aDesc.mStride;
|
||||
desc.mStepMode = ffi::WGPUInputStepMode(aDesc.mStepMode);
|
||||
for (const auto& vat : aDesc.mAttributeSet) {
|
||||
desc.mAttributes.AppendElement(ConvertVertexAttributeDescriptor(vat));
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
RawId WebGPUChild::DeviceCreateRenderPipeline(
|
||||
RawId aSelfId, const dom::GPURenderPipelineDescriptor& aDesc) {
|
||||
RawId id = ffi::wgpu_client_make_render_pipeline_id(mClient, aSelfId);
|
||||
SerialRenderPipelineDescriptor desc = {};
|
||||
desc.mLayout = aDesc.mLayout->mId;
|
||||
desc.mVertexStage = ConvertProgrammableStageDescriptor(aDesc.mVertexStage);
|
||||
if (aDesc.mFragmentStage.WasPassed()) {
|
||||
desc.mFragmentStage =
|
||||
ConvertProgrammableStageDescriptor(aDesc.mFragmentStage.Value());
|
||||
}
|
||||
desc.mPrimitiveTopology =
|
||||
ffi::WGPUPrimitiveTopology(aDesc.mPrimitiveTopology);
|
||||
if (aDesc.mRasterizationState.WasPassed()) {
|
||||
desc.mRasterizationState =
|
||||
Some(ConvertRasterizationDescriptor(aDesc.mRasterizationState.Value()));
|
||||
}
|
||||
for (const auto& color_state : aDesc.mColorStates) {
|
||||
desc.mColorStates.AppendElement(ConvertColorDescriptor(color_state));
|
||||
}
|
||||
if (aDesc.mDepthStencilState.WasPassed()) {
|
||||
desc.mDepthStencilState =
|
||||
Some(ConvertDepthStencilDescriptor(aDesc.mDepthStencilState.Value()));
|
||||
}
|
||||
desc.mVertexInput.mIndexFormat =
|
||||
ffi::WGPUIndexFormat(aDesc.mVertexInput.mIndexFormat);
|
||||
for (const auto& vertex_desc : aDesc.mVertexInput.mVertexBuffers) {
|
||||
SerialVertexBufferDescriptor vb_desc = {};
|
||||
if (!vertex_desc.IsNull()) {
|
||||
vb_desc = ConvertVertexBufferDescriptor(vertex_desc.Value());
|
||||
}
|
||||
desc.mVertexInput.mVertexBuffers.AppendElement(vb_desc);
|
||||
}
|
||||
desc.mSampleCount = aDesc.mSampleCount;
|
||||
desc.mSampleMask = aDesc.mSampleMask;
|
||||
desc.mAlphaToCoverageEnabled = aDesc.mAlphaToCoverageEnabled;
|
||||
if (!SendDeviceCreateRenderPipeline(aSelfId, desc, id)) {
|
||||
MOZ_CRASH("IPC failure");
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
void WebGPUChild::DestroyRenderPipeline(RawId aId) {
|
||||
SendRenderPipelineDestroy(aId);
|
||||
ffi::wgpu_client_kill_render_pipeline_id(mClient, aId);
|
||||
}
|
||||
|
||||
void WebGPUChild::QueueSubmit(RawId aSelfId,
|
||||
const nsTArray<RawId>& aCommandBufferIds) {
|
||||
SendQueueSubmit(aSelfId, aCommandBufferIds);
|
||||
|
@ -374,10 +510,5 @@ void WebGPUChild::QueueSubmit(RawId aSelfId,
|
|||
}
|
||||
}
|
||||
|
||||
void WebGPUChild::DestroyRenderPipeline(RawId aId) {
|
||||
SendRenderPipelineDestroy(aId);
|
||||
ffi::wgpu_client_kill_render_pipeline_id(mClient, aId);
|
||||
}
|
||||
|
||||
} // namespace webgpu
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -79,10 +79,12 @@ class WebGPUChild final : public PWebGPUChild {
|
|||
RawId aSelfId, const dom::GPUComputePipelineDescriptor& aDesc);
|
||||
void DestroyComputePipeline(RawId aId);
|
||||
|
||||
void QueueSubmit(RawId aSelfId, const nsTArray<RawId>& aCommandBufferIds);
|
||||
|
||||
RawId DeviceCreateRenderPipeline(
|
||||
RawId aSelfId, const dom::GPURenderPipelineDescriptor& aDesc);
|
||||
void DestroyRenderPipeline(RawId aId);
|
||||
|
||||
void QueueSubmit(RawId aSelfId, const nsTArray<RawId>& aCommandBufferIds);
|
||||
|
||||
private:
|
||||
virtual ~WebGPUChild();
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ ipc::IPCResult WebGPUParent::RecvShaderModuleDestroy(RawId aSelfId) {
|
|||
|
||||
ipc::IPCResult WebGPUParent::RecvDeviceCreateComputePipeline(
|
||||
RawId aSelfId, const SerialComputePipelineDescriptor& aDesc, RawId aNewId) {
|
||||
NS_LossyConvertUTF16toASCII entryPoint(aDesc.mComputeStage.mEntryPoint);
|
||||
const NS_LossyConvertUTF16toASCII entryPoint(aDesc.mComputeStage.mEntryPoint);
|
||||
ffi::WGPUComputePipelineDescriptor desc = {};
|
||||
desc.layout = aDesc.mLayout;
|
||||
desc.compute_stage.module = aDesc.mComputeStage.mModule;
|
||||
|
@ -312,6 +312,62 @@ ipc::IPCResult WebGPUParent::RecvComputePipelineDestroy(RawId aSelfId) {
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
ipc::IPCResult WebGPUParent::RecvDeviceCreateRenderPipeline(
|
||||
RawId aSelfId, const SerialRenderPipelineDescriptor& aDesc, RawId aNewId) {
|
||||
const NS_LossyConvertUTF16toASCII vsEntryPoint(
|
||||
aDesc.mVertexStage.mEntryPoint);
|
||||
const NS_LossyConvertUTF16toASCII fsEntryPoint(
|
||||
aDesc.mFragmentStage.mEntryPoint);
|
||||
size_t totalAttributes = 0;
|
||||
for (const auto& vertexBuffer : aDesc.mVertexInput.mVertexBuffers) {
|
||||
totalAttributes += vertexBuffer.mAttributes.Length();
|
||||
}
|
||||
nsTArray<ffi::WGPUVertexBufferDescriptor> vertexBuffers(
|
||||
aDesc.mVertexInput.mVertexBuffers.Length());
|
||||
nsTArray<ffi::WGPUVertexAttributeDescriptor> vertexAttributes(
|
||||
totalAttributes);
|
||||
|
||||
ffi::WGPURenderPipelineDescriptor desc = {};
|
||||
ffi::WGPUProgrammableStageDescriptor fragmentDesc = {};
|
||||
desc.layout = aDesc.mLayout;
|
||||
desc.vertex_stage.module = aDesc.mVertexStage.mModule;
|
||||
desc.vertex_stage.entry_point = vsEntryPoint.get();
|
||||
if (aDesc.mFragmentStage.mModule != 0) {
|
||||
fragmentDesc.module = aDesc.mFragmentStage.mModule;
|
||||
fragmentDesc.entry_point = fsEntryPoint.get();
|
||||
desc.fragment_stage = &fragmentDesc;
|
||||
}
|
||||
desc.primitive_topology = aDesc.mPrimitiveTopology;
|
||||
if (aDesc.mRasterizationState.isSome()) {
|
||||
desc.rasterization_state = aDesc.mRasterizationState.ptr();
|
||||
}
|
||||
desc.color_states = aDesc.mColorStates.Elements();
|
||||
desc.color_states_length = aDesc.mColorStates.Length();
|
||||
if (aDesc.mDepthStencilState.isSome()) {
|
||||
desc.depth_stencil_state = aDesc.mDepthStencilState.ptr();
|
||||
}
|
||||
totalAttributes = 0;
|
||||
for (const auto& vertexBuffer : aDesc.mVertexInput.mVertexBuffers) {
|
||||
ffi::WGPUVertexBufferDescriptor vb = {};
|
||||
vb.stride = vertexBuffer.mStride;
|
||||
vb.step_mode = vertexBuffer.mStepMode;
|
||||
vb.attributes = vertexAttributes.Elements() + totalAttributes;
|
||||
vb.attributes_length = vertexBuffer.mAttributes.Length();
|
||||
for (const auto& attribute : vertexBuffer.mAttributes) {
|
||||
vertexAttributes.AppendElement(attribute);
|
||||
}
|
||||
}
|
||||
desc.vertex_input.index_format = aDesc.mVertexInput.mIndexFormat;
|
||||
desc.vertex_input.vertex_buffers = vertexBuffers.Elements();
|
||||
desc.vertex_input.vertex_buffers_length = vertexBuffers.Length();
|
||||
desc.sample_count = aDesc.mSampleCount;
|
||||
desc.sample_mask = aDesc.mSampleMask;
|
||||
desc.alpha_to_coverage_enabled = aDesc.mAlphaToCoverageEnabled;
|
||||
ffi::wgpu_server_device_create_render_pipeline(mContext, aSelfId, &desc,
|
||||
aNewId);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
ipc::IPCResult WebGPUParent::RecvRenderPipelineDestroy(RawId aSelfId) {
|
||||
ffi::wgpu_server_render_pipeline_destroy(mContext, aSelfId);
|
||||
return IPC_OK();
|
||||
|
|
|
@ -81,6 +81,8 @@ class WebGPUParent final : public PWebGPUParent {
|
|||
RawId aSelfId, const SerialComputePipelineDescriptor& aDesc,
|
||||
RawId aNewId);
|
||||
ipc::IPCResult RecvComputePipelineDestroy(RawId aSelfId);
|
||||
ipc::IPCResult RecvDeviceCreateRenderPipeline(
|
||||
RawId aSelfId, const SerialRenderPipelineDescriptor& aDesc, RawId aNewId);
|
||||
ipc::IPCResult RecvRenderPipelineDestroy(RawId aSelfId);
|
||||
ipc::IPCResult RecvShutdown();
|
||||
|
||||
|
|
|
@ -24,12 +24,28 @@ namespace IPC {
|
|||
DEFINE_IPC_SERIALIZER_ENUM_GUARD(something, something##_Sentinel)
|
||||
|
||||
DEFINE_IPC_SERIALIZER_DOM_ENUM(mozilla::dom::GPUPowerPreference);
|
||||
DEFINE_IPC_SERIALIZER_DOM_ENUM(mozilla::webgpu::SerialBindGroupBindingType);
|
||||
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUAddressMode);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUBindingType);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUBlendFactor);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUBlendOperation);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUCompareFunction);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUCullMode);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUFilterMode);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUFrontFace);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUIndexFormat);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUInputStepMode);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUPrimitiveTopology);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUStencilOperation);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUTextureAspect);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUTextureDimension);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUTextureFormat);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUTextureAspect);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUTextureViewDimension);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUVertexFormat);
|
||||
|
||||
DEFINE_IPC_SERIALIZER_WITHOUT_FIELDS(mozilla::dom::GPUCommandEncoderDescriptor);
|
||||
DEFINE_IPC_SERIALIZER_WITHOUT_FIELDS(mozilla::dom::GPUCommandBufferDescriptor);
|
||||
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::GPURequestAdapterOptions,
|
||||
mPowerPreference);
|
||||
|
@ -40,8 +56,6 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::GPUDeviceDescriptor,
|
|||
mExtensions, mLimits);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::GPUBufferDescriptor, mSize,
|
||||
mUsage);
|
||||
DEFINE_IPC_SERIALIZER_WITHOUT_FIELDS(mozilla::dom::GPUCommandEncoderDescriptor);
|
||||
DEFINE_IPC_SERIALIZER_WITHOUT_FIELDS(mozilla::dom::GPUCommandBufferDescriptor);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::ffi::WGPUExtent3d, width,
|
||||
height, depth);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::ffi::WGPUTextureDescriptor,
|
||||
|
@ -56,8 +70,25 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::ffi::WGPUSamplerDescriptor,
|
|||
mipmap_filter, lod_min_clamp, lod_max_clamp,
|
||||
compare_function);
|
||||
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUBindingType);
|
||||
DEFINE_IPC_SERIALIZER_FFI_ENUM(mozilla::webgpu::ffi::WGPUTextureViewDimension);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::ffi::WGPUBlendDescriptor,
|
||||
src_factor, dst_factor, operation);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::ffi::WGPURasterizationStateDescriptor, front_face,
|
||||
cull_mode, depth_bias, depth_bias_slope_scale, depth_bias_clamp);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::ffi::WGPUColorStateDescriptor, format, alpha_blend,
|
||||
color_blend, write_mask);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::ffi::WGPUStencilStateFaceDescriptor, compare, fail_op,
|
||||
depth_fail_op, pass_op);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::ffi::WGPUDepthStencilStateDescriptor, format,
|
||||
depth_write_enabled, depth_compare, stencil_front, stencil_back,
|
||||
stencil_read_mask, stencil_write_mask);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::ffi::WGPUVertexAttributeDescriptor, offset, format,
|
||||
shader_location);
|
||||
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::ffi::WGPUBindGroupLayoutBinding, binding, visibility, ty,
|
||||
texture_dimension, multisampled, dynamic);
|
||||
|
@ -65,7 +96,6 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
|||
mozilla::webgpu::SerialBindGroupLayoutDescriptor, mBindings);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::SerialPipelineLayoutDescriptor, mBindGroupLayouts);
|
||||
DEFINE_IPC_SERIALIZER_DOM_ENUM(mozilla::webgpu::SerialBindGroupBindingType);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::SerialBindGroupBinding,
|
||||
mBinding, mType, mValue, mBufferOffset,
|
||||
mBufferSize);
|
||||
|
@ -74,8 +104,17 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::SerialBindGroupDescriptor,
|
|||
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::SerialProgrammableStageDescriptor, mModule, mEntryPoint);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::SerialVertexBufferDescriptor,
|
||||
mStride, mStepMode, mAttributes);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::webgpu::SerialVertexInputDescriptor,
|
||||
mIndexFormat, mVertexBuffers);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::SerialComputePipelineDescriptor, mLayout, mComputeStage);
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
|
||||
mozilla::webgpu::SerialRenderPipelineDescriptor, mLayout, mVertexStage,
|
||||
mFragmentStage, mPrimitiveTopology, mRasterizationState, mColorStates,
|
||||
mDepthStencilState, mVertexInput, mSampleCount, mSampleMask,
|
||||
mAlphaToCoverageEnabled);
|
||||
|
||||
#undef DEFINE_IPC_SERIALIZER_FFI_ENUM
|
||||
#undef DEFINE_IPC_SERIALIZER_DOM_ENUM
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/webgpu/ffi/wgpu.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace webgpu {
|
||||
namespace ffi {
|
||||
struct WGPUBindGroupLayoutBinding;
|
||||
} // namespace ffi
|
||||
|
||||
typedef uint64_t RawId;
|
||||
typedef uint64_t BufferAddress;
|
||||
|
@ -56,6 +55,31 @@ struct SerialComputePipelineDescriptor {
|
|||
SerialProgrammableStageDescriptor mComputeStage;
|
||||
};
|
||||
|
||||
struct SerialVertexBufferDescriptor {
|
||||
ffi::WGPUBufferAddress mStride;
|
||||
ffi::WGPUInputStepMode mStepMode;
|
||||
nsTArray<ffi::WGPUVertexAttributeDescriptor> mAttributes;
|
||||
};
|
||||
|
||||
struct SerialVertexInputDescriptor {
|
||||
ffi::WGPUIndexFormat mIndexFormat;
|
||||
nsTArray<SerialVertexBufferDescriptor> mVertexBuffers;
|
||||
};
|
||||
|
||||
struct SerialRenderPipelineDescriptor {
|
||||
RawId mLayout;
|
||||
SerialProgrammableStageDescriptor mVertexStage;
|
||||
SerialProgrammableStageDescriptor mFragmentStage;
|
||||
ffi::WGPUPrimitiveTopology mPrimitiveTopology;
|
||||
Maybe<ffi::WGPURasterizationStateDescriptor> mRasterizationState;
|
||||
nsTArray<ffi::WGPUColorStateDescriptor> mColorStates;
|
||||
Maybe<ffi::WGPUDepthStencilStateDescriptor> mDepthStencilState;
|
||||
SerialVertexInputDescriptor mVertexInput;
|
||||
uint32_t mSampleCount;
|
||||
uint32_t mSampleMask;
|
||||
bool mAlphaToCoverageEnabled;
|
||||
};
|
||||
|
||||
} // namespace webgpu
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ interface GPUDevice {
|
|||
|
||||
GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
|
||||
GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
|
||||
//GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
|
||||
GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
|
||||
|
||||
[NewObject]
|
||||
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
|
||||
|
|
|
@ -443,6 +443,20 @@ pub extern "C" fn wgpu_client_kill_compute_pipeline_id(
|
|||
.free(id)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_client_make_render_pipeline_id(
|
||||
client: &Client,
|
||||
device_id: id::DeviceId,
|
||||
) -> id::RenderPipelineId {
|
||||
let backend = device_id.backend();
|
||||
client
|
||||
.identities
|
||||
.lock()
|
||||
.select(backend)
|
||||
.render_pipelines
|
||||
.alloc(backend)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_client_kill_render_pipeline_id(
|
||||
client: &Client,
|
||||
|
|
|
@ -327,6 +327,16 @@ pub extern "C" fn wgpu_server_compute_pipeline_destroy(
|
|||
gfx_select!(self_id => global.compute_pipeline_destroy(self_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_server_device_create_render_pipeline(
|
||||
global: &Global,
|
||||
self_id: id::DeviceId,
|
||||
desc: &core::pipeline::RenderPipelineDescriptor,
|
||||
new_id: id::RenderPipelineId,
|
||||
) {
|
||||
gfx_select!(self_id => global.device_create_render_pipeline(self_id, desc, new_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_server_render_pipeline_destroy(
|
||||
global: &Global,
|
||||
|
|
Загрузка…
Ссылка в новой задаче