Skip to content
Permalink
Browse files
[WebGPU] Vertex and fragment shaders are not hooked up to pipeline cr…
…eation

https://bugs.webkit.org/show_bug.cgi?id=233166

Reviewed by Dean Jackson.

I simply forgot to implement them in r285831.

* pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp:
(PAL::WebGPU::supportedLimits):
* pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp:
(PAL::WebGPU::convertToBacking):



Canonical link: https://commits.webkit.org/244294@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
litherum committed Nov 16, 2021
1 parent 616dc9d commit eb4739a0bf6768e51047273eb1d7112b1b480560
Showing 6 changed files with 83 additions and 17 deletions.
@@ -1,3 +1,17 @@
2021-11-16 Myles C. Maxfield <mmaxfield@apple.com>

[WebGPU] Vertex and fragment shaders are not hooked up to pipeline creation
https://bugs.webkit.org/show_bug.cgi?id=233166

Reviewed by Dean Jackson.

I simply forgot to implement them in r285831.

* pal/graphics/WebGPU/Impl/WebGPUAdapterImpl.cpp:
(PAL::WebGPU::supportedLimits):
* pal/graphics/WebGPU/Impl/WebGPUDeviceImpl.cpp:
(PAL::WebGPU::convertToBacking):

2021-11-15 Sam Weinig <weinig@apple.com>

Add another <model> backend backed by SceneKit to prove out ModelPlayer infrastructure a bit more
@@ -89,7 +89,9 @@ static Ref<SupportedFeatures> supportedFeatures(WGPUAdapter adapter)
static Ref<SupportedLimits> supportedLimits(WGPUAdapter adapter)
{
WGPUSupportedLimits limits;
wgpuAdapterGetLimits(adapter, &limits);
limits.nextInChain = nullptr;
auto result = wgpuAdapterGetLimits(adapter, &limits);
ASSERT_UNUSED(result, result);
return SupportedLimits::create(
limits.limits.maxTextureDimension1D,
limits.limits.maxTextureDimension2D,
@@ -235,8 +235,18 @@ Ref<ShaderModule> DeviceImpl::createShaderModule(const ShaderModuleDescriptor& d
{
auto label = descriptor.label.utf8();

auto source = descriptor.code.utf8();

WGPUShaderModuleWGSLDescriptor backingWGSLDescriptor {
{
nullptr,
WGPUSType_ShaderModuleWGSLDescriptor,
},
source.data(),
};

WGPUShaderModuleDescriptor backingDescriptor {
nullptr,
&backingWGSLDescriptor.chain,
label.data(),
};

@@ -250,18 +260,18 @@ auto convertToBacking(const ComputePipelineDescriptor& descriptor, ConvertToBack

auto entryPoint = descriptor.compute.entryPoint.utf8();

Vector<CString> keys;
keys.reserveInitialCapacity(descriptor.compute.constants.size());
Vector<CString> constantNames;
constantNames.reserveInitialCapacity(descriptor.compute.constants.size());
for (const auto& constant : descriptor.compute.constants)
keys.uncheckedAppend(constant.key.utf8());
constantNames.uncheckedAppend(constant.key.utf8());

Vector<WGPUConstantEntry> backingConstantEntries;
backingConstantEntries.reserveInitialCapacity(descriptor.compute.constants.size());
for (size_t i = 0; i < descriptor.compute.constants.size(); ++i) {
const auto& constant = descriptor.compute.constants[i];
backingConstantEntries.uncheckedAppend(WGPUConstantEntry {
nullptr,
keys[i].data(),
constantNames[i].data(),
constant.value
});
}
@@ -293,6 +303,24 @@ auto convertToBacking(const RenderPipelineDescriptor& descriptor, ConvertToBacki
{
auto label = descriptor.label.utf8();

auto vertexEntryPoint = descriptor.vertex.entryPoint.utf8();

Vector<CString> vertexConstantNames;
vertexConstantNames.reserveInitialCapacity(descriptor.vertex.constants.size());
for (const auto& constant : descriptor.vertex.constants)
vertexConstantNames.uncheckedAppend(constant.key.utf8());

Vector<WGPUConstantEntry> vertexConstantEntries;
vertexConstantEntries.reserveInitialCapacity(descriptor.vertex.constants.size());
for (size_t i = 0; i < descriptor.vertex.constants.size(); ++i) {
const auto& constant = descriptor.vertex.constants[i];
vertexConstantEntries.uncheckedAppend(WGPUConstantEntry {
nullptr,
vertexConstantNames[i].data(),
constant.value,
});
}

Vector<Vector<WGPUVertexAttribute>> backingAttributes;
backingAttributes.reserveInitialCapacity(descriptor.vertex.buffers.size());
for (const auto& buffer : descriptor.vertex.buffers) {
@@ -345,6 +373,28 @@ auto convertToBacking(const RenderPipelineDescriptor& descriptor, ConvertToBacki
descriptor.depthStencil ? descriptor.depthStencil->depthBiasClamp : 0,
};

auto fragmentEntryPoint = descriptor.fragment ? descriptor.fragment->entryPoint.utf8() : CString("");

Vector<CString> fragmentConstantNames;
if (descriptor.fragment) {
fragmentConstantNames.reserveInitialCapacity(descriptor.fragment->constants.size());
for (const auto& constant : descriptor.fragment->constants)
fragmentConstantNames.uncheckedAppend(constant.key.utf8());
}

Vector<WGPUConstantEntry> fragmentConstantEntries;
if (descriptor.fragment) {
fragmentConstantEntries.reserveInitialCapacity(descriptor.fragment->constants.size());
for (size_t i = 0; i < descriptor.fragment->constants.size(); ++i) {
const auto& constant = descriptor.fragment->constants[i];
fragmentConstantEntries.uncheckedAppend(WGPUConstantEntry {
nullptr,
fragmentConstantNames[i].data(),
constant.value,
});
}
}

Vector<std::optional<WGPUBlendState>> blendStates;
if (descriptor.fragment) {
blendStates.reserveInitialCapacity(descriptor.fragment->targets.size());
@@ -382,10 +432,10 @@ auto convertToBacking(const RenderPipelineDescriptor& descriptor, ConvertToBacki

WGPUFragmentState fragmentState {
nullptr,
nullptr,
nullptr,
0,
nullptr,
descriptor.fragment ? convertToBackingContext.convertToBacking(descriptor.fragment->module) : nullptr,
fragmentEntryPoint.data(),
static_cast<uint32_t>(fragmentConstantEntries.size()),
fragmentConstantEntries.data(),
static_cast<uint32_t>(colorTargets.size()),
colorTargets.data(),
};
@@ -395,10 +445,10 @@ auto convertToBacking(const RenderPipelineDescriptor& descriptor, ConvertToBacki
label.data(),
descriptor.layout ? convertToBackingContext.convertToBacking(*descriptor.layout) : nullptr, {
nullptr,
nullptr,
nullptr,
0,
nullptr,
convertToBackingContext.convertToBacking(descriptor.vertex.module),
vertexEntryPoint.data(),
static_cast<uint32_t>(vertexConstantEntries.size()),
vertexConstantEntries.data(),
static_cast<uint32_t>(backingBuffers.size()),
backingBuffers.data(),
}, {
@@ -43,7 +43,7 @@ class DeviceImpl final : public Device {
return adoptRef(*new DeviceImpl(device, WTFMove(features), WTFMove(limits), convertToBackingContext));
}

~DeviceImpl();
virtual ~DeviceImpl();

private:
friend class DowncastConvertToBackingContext;
@@ -42,7 +42,7 @@ class RenderBundleEncoderImpl final : public RenderBundleEncoder {
return adoptRef(*new RenderBundleEncoderImpl(renderBundleEncoder, convertToBackingContext));
}

~RenderBundleEncoderImpl();
virtual ~RenderBundleEncoderImpl();

private:
friend class DowncastConvertToBackingContext;
@@ -42,7 +42,7 @@ class RenderPassEncoderImpl final : public RenderPassEncoder {
return adoptRef(*new RenderPassEncoderImpl(renderPassEncoder, convertToBackingContext));
}

~RenderPassEncoderImpl();
virtual ~RenderPassEncoderImpl();

private:
friend class DowncastConvertToBackingContext;

0 comments on commit eb4739a

Please sign in to comment.