Commit f42f2295 authored by Kai Ninomiya's avatar Kai Ninomiya Committed by Commit Bot

webgpu: Initialize Dawn descriptor structs; implement sampleMask/alphaToCoverageEnabled

Bug: 985135
Change-Id: I820dc3964671bbf87e9e0cbb186ea20528c0b8cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1707575Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678538}
parent ebbeb2a4
......@@ -543,7 +543,7 @@ DawnFrontFace AsDawnEnum<DawnFrontFace>(const WTF::String& webgpu_enum) {
DawnColor AsDawnType(const GPUColor* webgpu_color) {
DCHECK(webgpu_color);
DawnColor dawn_color;
DawnColor dawn_color = {};
dawn_color.r = webgpu_color->r();
dawn_color.g = webgpu_color->g();
dawn_color.b = webgpu_color->b();
......@@ -555,7 +555,7 @@ DawnColor AsDawnType(const GPUColor* webgpu_color) {
DawnExtent3D AsDawnType(const GPUExtent3D* webgpu_extent) {
DCHECK(webgpu_extent);
DawnExtent3D dawn_extent;
DawnExtent3D dawn_extent = {};
dawn_extent.width = webgpu_extent->width();
dawn_extent.height = webgpu_extent->height();
dawn_extent.depth = webgpu_extent->depth();
......@@ -566,7 +566,7 @@ DawnExtent3D AsDawnType(const GPUExtent3D* webgpu_extent) {
DawnOrigin3D AsDawnType(const GPUOrigin3D* webgpu_origin) {
DCHECK(webgpu_origin);
DawnOrigin3D dawn_origin;
DawnOrigin3D dawn_origin = {};
dawn_origin.x = webgpu_origin->x();
dawn_origin.y = webgpu_origin->y();
dawn_origin.z = webgpu_origin->z();
......@@ -587,7 +587,7 @@ OwnedPipelineStageDescriptor AsDawnType(
char* entry_point_ptr = entry_point_keepalive.get();
memcpy(entry_point_ptr, entry_point.c_str(), byte_size);
DawnPipelineStageDescriptor dawn_stage;
DawnPipelineStageDescriptor dawn_stage = {};
dawn_stage.module = webgpu_stage->module()->GetHandle();
dawn_stage.entryPoint = entry_point_ptr;
......
......@@ -54,7 +54,7 @@ GPUBindGroup* GPUBindGroup::Create(GPUDevice* device,
std::unique_ptr<DawnBindGroupBinding[]> bindings =
binding_count != 0 ? AsDawnType(webgpu_desc->bindings()) : nullptr;
DawnBindGroupDescriptor dawn_desc;
DawnBindGroupDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.layout = AsDawnType(webgpu_desc->layout());
dawn_desc.bindingCount = binding_count;
......
......@@ -36,7 +36,7 @@ GPUBindGroupLayout* GPUBindGroupLayout::Create(
std::unique_ptr<DawnBindGroupLayoutBinding[]> bindings =
binding_count != 0 ? AsDawnType(webgpu_desc->bindings()) : nullptr;
DawnBindGroupLayoutDescriptor dawn_desc;
DawnBindGroupLayoutDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.bindingCount = binding_count;
dawn_desc.bindings = bindings.get();
......
......@@ -47,7 +47,7 @@ bool ValidateMapSize(uint64_t buffer_size,
DawnBufferDescriptor AsDawnType(const GPUBufferDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnBufferDescriptor dawn_desc;
DawnBufferDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.usage = AsDawnEnum<DawnBufferUsageBit>(webgpu_desc->usage());
dawn_desc.size = webgpu_desc->size();
......
......@@ -27,7 +27,7 @@ DawnRenderPassColorAttachmentDescriptor AsDawnType(
const GPURenderPassColorAttachmentDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnRenderPassColorAttachmentDescriptor dawn_desc;
DawnRenderPassColorAttachmentDescriptor dawn_desc = {};
dawn_desc.attachment = webgpu_desc->attachment()->GetHandle();
dawn_desc.resolveTarget = webgpu_desc->resolveTarget()
? webgpu_desc->resolveTarget()->GetHandle()
......@@ -45,7 +45,7 @@ DawnRenderPassDepthStencilAttachmentDescriptor AsDawnType(
const GPURenderPassDepthStencilAttachmentDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnRenderPassDepthStencilAttachmentDescriptor dawn_desc;
DawnRenderPassDepthStencilAttachmentDescriptor dawn_desc = {};
dawn_desc.attachment = webgpu_desc->attachment()->GetHandle();
dawn_desc.depthLoadOp = AsDawnEnum<DawnLoadOp>(webgpu_desc->depthLoadOp());
dawn_desc.depthStoreOp = AsDawnEnum<DawnStoreOp>(webgpu_desc->depthStoreOp());
......@@ -91,7 +91,7 @@ DawnCommandEncoderDescriptor AsDawnType(
const GPUCommandEncoderDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnCommandEncoderDescriptor dawn_desc;
DawnCommandEncoderDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
return dawn_desc;
......@@ -137,7 +137,7 @@ GPURenderPassEncoder* GPUCommandEncoder::beginRenderPass(
uint32_t color_attachment_count =
static_cast<uint32_t>(descriptor->colorAttachments().size());
DawnRenderPassDescriptor dawn_desc;
DawnRenderPassDescriptor dawn_desc = {};
dawn_desc.colorAttachmentCount = color_attachment_count;
dawn_desc.colorAttachments = nullptr;
......
......@@ -20,7 +20,7 @@ GPUComputePipeline* GPUComputePipeline::Create(
DCHECK(device);
DCHECK(webgpu_desc);
DawnComputePipelineDescriptor dawn_desc;
DawnComputePipelineDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.layout = AsDawnType(webgpu_desc->layout());
......
......@@ -25,7 +25,7 @@ GPUPipelineLayout* GPUPipelineLayout::Create(
bind_group_layout_count != 0 ? AsDawnType(webgpu_desc->bindGroupLayouts())
: nullptr;
DawnPipelineLayoutDescriptor dawn_desc;
DawnPipelineLayoutDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.bindGroupLayoutCount = bind_group_layout_count;
dawn_desc.bindGroupLayouts = bind_group_layouts.get();
......
......@@ -48,7 +48,7 @@ void GPUQueue::signal(GPUFence* fence, uint64_t signal_value) {
GPUFence* GPUQueue::createFence(const GPUFenceDescriptor* descriptor) {
DCHECK(descriptor);
DawnFenceDescriptor desc;
DawnFenceDescriptor desc = {};
desc.nextInChain = nullptr;
desc.initialValue = descriptor->initialValue();
......
......@@ -24,7 +24,7 @@ namespace {
DawnBlendDescriptor AsDawnType(const GPUBlendDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnBlendDescriptor dawn_desc;
DawnBlendDescriptor dawn_desc = {};
dawn_desc.dstFactor = AsDawnEnum<DawnBlendFactor>(webgpu_desc->dstFactor());
dawn_desc.srcFactor = AsDawnEnum<DawnBlendFactor>(webgpu_desc->srcFactor());
dawn_desc.operation =
......@@ -39,7 +39,7 @@ DawnColorStateDescriptor AsDawnType(
const GPUColorStateDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnColorStateDescriptor dawn_desc;
DawnColorStateDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
GPUBlendDescriptor* gpu_alpha_blend = webgpu_desc->hasAlphaBlend()
......@@ -65,7 +65,7 @@ DawnStencilStateFaceDescriptor AsDawnType(
const GPUStencilStateFaceDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnStencilStateFaceDescriptor dawn_desc;
DawnStencilStateFaceDescriptor dawn_desc = {};
dawn_desc.compare = AsDawnEnum<DawnCompareFunction>(webgpu_desc->compare());
dawn_desc.depthFailOp =
AsDawnEnum<DawnStencilOperation>(webgpu_desc->depthFailOp());
......@@ -79,7 +79,7 @@ DawnDepthStencilStateDescriptor AsDawnType(
const GPUDepthStencilStateDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnDepthStencilStateDescriptor dawn_desc;
DawnDepthStencilStateDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.depthCompare =
AsDawnEnum<DawnCompareFunction>(webgpu_desc->depthCompare());
......@@ -101,7 +101,7 @@ DawnVertexInputInfo GPUVertexInputAsDawnInputState(
v8::Isolate* isolate,
const GPUVertexInputDescriptor* descriptor,
ExceptionState& exception_state) {
DawnVertexInputDescriptor dawn_desc;
DawnVertexInputDescriptor dawn_desc = {};
dawn_desc.indexFormat =
AsDawnEnum<DawnIndexFormat>(descriptor->indexFormat());
dawn_desc.bufferCount = 0;
......@@ -135,7 +135,7 @@ DawnVertexInputInfo GPUVertexInputAsDawnInputState(
v8::Local<v8::Value> value;
if (!maybe_value.ToLocal(&value) || value.IsEmpty() ||
value->IsNullOrUndefined()) {
DawnVertexBufferDescriptor dawn_vertex_buffer;
DawnVertexBufferDescriptor dawn_vertex_buffer = {};
dawn_vertex_buffer.stride = 0;
dawn_vertex_buffer.stepMode = DAWN_INPUT_STEP_MODE_VERTEX;
dawn_vertex_buffer.attributeCount = 0;
......@@ -152,7 +152,7 @@ DawnVertexInputInfo GPUVertexInputAsDawnInputState(
std::move(dawn_vertex_attributes));
}
DawnVertexBufferDescriptor dawn_vertex_buffer;
DawnVertexBufferDescriptor dawn_vertex_buffer = {};
dawn_vertex_buffer.stride = vertex_buffer.stride();
dawn_vertex_buffer.stepMode =
AsDawnEnum<DawnInputStepMode>(vertex_buffer.stepMode());
......@@ -164,7 +164,7 @@ DawnVertexInputInfo GPUVertexInputAsDawnInputState(
for (wtf_size_t j = 0; j < vertex_buffer.attributes().size(); ++j) {
const GPUVertexAttributeDescriptor* attribute =
vertex_buffer.attributes()[j];
DawnVertexAttributeDescriptor dawn_vertex_attribute;
DawnVertexAttributeDescriptor dawn_vertex_attribute = {};
dawn_vertex_attribute.shaderLocation = attribute->shaderLocation();
dawn_vertex_attribute.offset = attribute->offset();
dawn_vertex_attribute.format =
......@@ -193,7 +193,7 @@ DawnRasterizationStateDescriptor AsDawnType(
const GPURasterizationStateDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnRasterizationStateDescriptor dawn_desc;
DawnRasterizationStateDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.frontFace = AsDawnEnum<DawnFrontFace>(webgpu_desc->frontFace());
dawn_desc.cullMode = AsDawnEnum<DawnCullMode>(webgpu_desc->cullMode());
......@@ -214,7 +214,7 @@ GPURenderPipeline* GPURenderPipeline::Create(
DCHECK(device);
DCHECK(webgpu_desc);
DawnRenderPipelineDescriptor dawn_desc;
DawnRenderPipelineDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.layout = AsDawnType(webgpu_desc->layout());
......@@ -252,7 +252,7 @@ GPURenderPipeline* GPURenderPipeline::Create(
dawn_desc.sampleCount = webgpu_desc->sampleCount();
DawnDepthStencilStateDescriptor depth_stencil_state;
DawnDepthStencilStateDescriptor depth_stencil_state = {};
if (webgpu_desc->hasDepthStencilState()) {
depth_stencil_state = AsDawnType(webgpu_desc->depthStencilState());
dawn_desc.depthStencilState = &depth_stencil_state;
......@@ -268,6 +268,9 @@ GPURenderPipeline* GPURenderPipeline::Create(
DawnColorStateDescriptor* color_state_descriptors = color_states.get();
dawn_desc.colorStates = &color_state_descriptors;
dawn_desc.sampleMask = webgpu_desc->sampleMask();
dawn_desc.alphaToCoverageEnabled = webgpu_desc->alphaToCoverageEnabled();
return MakeGarbageCollected<GPURenderPipeline>(
device, device->GetProcs().deviceCreateRenderPipeline(device->GetHandle(),
&dawn_desc));
......
......@@ -16,6 +16,9 @@ dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
required GPUVertexInputDescriptor vertexInput;
unsigned long sampleCount = 1;
unsigned long sampleMask = 0xFFFFFFFF;
boolean alphaToCoverageEnabled = false;
};
enum GPUPrimitiveTopology {
......
......@@ -15,7 +15,7 @@ namespace {
DawnSamplerDescriptor AsDawnType(const GPUSamplerDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnSamplerDescriptor dawn_desc;
DawnSamplerDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.addressModeU =
AsDawnEnum<DawnAddressMode>(webgpu_desc->addressModeU());
......
......@@ -13,7 +13,7 @@ namespace {
DawnShaderModuleDescriptor AsDawnType(
const GPUShaderModuleDescriptor* webgpu_desc) {
DawnShaderModuleDescriptor dawn_desc;
DawnShaderModuleDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.code = webgpu_desc->code().View()->Data();
......
......@@ -17,7 +17,7 @@ namespace {
DawnTextureDescriptor AsDawnType(const GPUTextureDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnTextureDescriptor dawn_desc;
DawnTextureDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.usage = static_cast<DawnTextureUsageBit>(webgpu_desc->usage());
dawn_desc.dimension =
......@@ -35,7 +35,7 @@ DawnTextureViewDescriptor AsDawnType(
const GPUTextureViewDescriptor* webgpu_desc) {
DCHECK(webgpu_desc);
DawnTextureViewDescriptor dawn_desc;
DawnTextureViewDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.format = AsDawnEnum<DawnTextureFormat>(webgpu_desc->format());
dawn_desc.dimension =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment