Skip to content

Commit

Permalink
[WebGPU] api/validation/render_pass/resolve is failing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267024
<radar://120400053>

Reviewed by Tadeu Zagallo.

Add validation and passing expectations for api/validation/render_pass/render_pass_descriptor
and api/validation/render_pass/resolve which both pass after these changes.

* LayoutTests/http/tests/webgpu/webgpu/api/validation/render_pass/render_pass_descriptor-expected.txt:
* LayoutTests/http/tests/webgpu/webgpu/api/validation/render_pass/resolve-expected.txt:
* Source/WebCore/Modules/WebGPU/GPUComputePassTimestampWrites.h:
* Source/WebCore/Modules/WebGPU/GPURenderPassDepthStencilAttachment.h:
(WebCore::GPURenderPassDepthStencilAttachment::convertToBacking const):
* Source/WebCore/Modules/WebGPU/GPURenderPassDepthStencilAttachment.idl:
* Source/WebCore/Modules/WebGPU/GPURenderPassTimestampWrites.h:
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUCommandEncoderImpl.cpp:
(WebCore::WebGPU::CommandEncoderImpl::beginRenderPass):
* Source/WebGPU/WebGPU/CommandEncoder.h:
(WebGPU::CommandEncoder::makeInvalid): Deleted.
* Source/WebGPU/WebGPU/CommandEncoder.mm:
(WebGPU::Device::createCommandEncoder):
(WebGPU::CommandEncoder::ensureBlitCommandEncoder):
(WebGPU::timestampWriteIndex):
(WebGPU::validateTimestampWrites):
(WebGPU::CommandEncoder::validateComputePassDescriptor const):
(WebGPU::CommandEncoder::beginComputePass):
(WebGPU::CommandEncoder::validateRenderPassDescriptor const):
(WebGPU::createSimplePso):
(WebGPU::CommandEncoder::runClearEncoder):
(WebGPU::isMultisampleTexture):
(WebGPU::isRenderableTextureView):
(WebGPU::CommandEncoder::beginRenderPass):
(WebGPU::CommandEncoder::makeInvalid):
(WebGPU::CommandEncoder::finish):
* Source/WebGPU/WebGPU/Device.h:
* Source/WebGPU/WebGPU/Device.mm:
(WebGPU::Device::create):
(WebGPU::Device::setUnusedCommandBuffer):
* Source/WebGPU/WebGPU/QuerySet.h:
* Source/WebGPU/WebGPU/QuerySet.mm:
(WebGPU::Device::createQuerySet):
* Source/WebGPU/WebGPU/RenderPassEncoder.h:
(WebGPU::RenderPassEncoder::create):
(WebGPU::RenderPassEncoder::createInvalid):
* Source/WebGPU/WebGPU/RenderPassEncoder.mm:
(WebGPU::RenderPassEncoder::RenderPassEncoder):
(WebGPU::RenderPassEncoder::endPass):
(WebGPU::RenderPassEncoder::makeInvalid):
(WebGPU::RenderPassEncoder::setPipeline):
(WebGPU::RenderPassEncoder::setScissorRect):
* Source/WebGPU/WebGPU/RenderPipeline.h:
(WebGPU::RenderPipeline::create):
* Source/WebGPU/WebGPU/RenderPipeline.mm:
(WebGPU::Device::createRenderPipeline):
(WebGPU::RenderPipeline::RenderPipeline):
(WebGPU::RenderPipeline::colorTargetsMatch const):
(WebGPU::RenderPipeline::depthAttachmentMatches const):
(WebGPU::RenderPipeline::stencilAttachmentMatches const):
* Source/WebGPU/WebGPU/Texture.h:
* Source/WebGPU/WebGPU/Texture.mm:
(WebGPU::Texture::isColorRenderableFormat):
(WebGPU::Texture::isDepthStencilRenderableFormat):
(WebGPU::Texture::supportsResolve):
(WebGPU::Texture::createView):
(WebGPU::Texture::destroy):
(WebGPU::Texture::recreateIfNeeded): Deleted.
(WebGPU::Texture::makeCanvasBacking): Deleted.
* Source/WebGPU/WebGPU/TextureView.h:
* Source/WebGPU/WebGPU/TextureView.mm:
(WebGPU::TextureView::parentTexture const):
(WebGPU::TextureView::width const):
(WebGPU::TextureView::height const):
(WebGPU::TextureView::parentFormat const):
(WebGPU::TextureView::format const):
(WebGPU::TextureView::parentMipLevelCount const):
(WebGPU::TextureView::mipLevelCount const):
(WebGPU::TextureView::baseMipLevel const):
(WebGPU::TextureView::aspect const):
(WebGPU::TextureView::arrayLayerCount const):
(WebGPU::TextureView::baseArrayLayer const):
(WebGPU::TextureView::dimension const):

Canonical link: https://commits.webkit.org/272798@main
  • Loading branch information
mwyrzykowski committed Jan 9, 2024
1 parent 7cc9219 commit 9ab872a
Show file tree
Hide file tree
Showing 22 changed files with 787 additions and 95 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,116 @@
(Populate me when we're ready to investigate this test)

PASS :attachments,one_color_attachment:
PASS :attachments,one_depth_stencil_attachment:
PASS :attachments,same_size:
PASS :attachments,color_depth_mismatch:
PASS :attachments,layer_count:arrayLayerCount=5;baseArrayLayer=0
PASS :attachments,layer_count:arrayLayerCount=1;baseArrayLayer=0
PASS :attachments,layer_count:arrayLayerCount=1;baseArrayLayer=9
PASS :attachments,mip_level_count:mipLevelCount=2;baseMipLevel=0
PASS :attachments,mip_level_count:mipLevelCount=1;baseMipLevel=0
PASS :attachments,mip_level_count:mipLevelCount=1;baseMipLevel=3
PASS :color_attachments,empty:
PASS :color_attachments,limits,maxColorAttachments:colorAttachmentsCountVariant={"mult":1,"add":0}
PASS :color_attachments,limits,maxColorAttachments:colorAttachmentsCountVariant={"mult":1,"add":1}
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r8unorm"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r8uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r8sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg8unorm"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg8uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg8sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba8unorm"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba8unorm-srgb"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba8uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba8sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="bgra8unorm"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="bgra8unorm-srgb"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r16uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r16sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r16float"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg16uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg16sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg16float"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba16uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba16sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba16float"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r32uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r32sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="r32float"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg32uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg32sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rg32float"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba32uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba32sint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgba32float"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgb10a2uint"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:format="rgb10a2unorm"
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,unaligned:formats=["r8unorm","r32float","rgba8unorm","rgba32float","r8unorm"]
PASS :color_attachments,limits,maxColorAttachmentBytesPerSample,unaligned:formats=["r32float","rgba8unorm","rgba32float","r8unorm","r8unorm"]
PASS :color_attachments,non_multisampled:
PASS :color_attachments,sample_count:
PASS :resolveTarget,sample_count:
PASS :resolveTarget,array_layer_count:
PASS :resolveTarget,mipmap_level_count:
PASS :resolveTarget,usage:usage=3
PASS :resolveTarget,usage:usage=12
PASS :resolveTarget,usage:usage=8
PASS :resolveTarget,usage:usage=20
PASS :resolveTarget,error_state:
PASS :resolveTarget,single_sample_count:
PASS :resolveTarget,different_format:
PASS :resolveTarget,different_size:
PASS :resolveTarget,format_supports_resolve:format="r8unorm"
PASS :resolveTarget,format_supports_resolve:format="r8uint"
PASS :resolveTarget,format_supports_resolve:format="r8sint"
PASS :resolveTarget,format_supports_resolve:format="rg8unorm"
PASS :resolveTarget,format_supports_resolve:format="rg8uint"
PASS :resolveTarget,format_supports_resolve:format="rg8sint"
PASS :resolveTarget,format_supports_resolve:format="rgba8unorm"
PASS :resolveTarget,format_supports_resolve:format="rgba8unorm-srgb"
PASS :resolveTarget,format_supports_resolve:format="rgba8uint"
PASS :resolveTarget,format_supports_resolve:format="rgba8sint"
PASS :resolveTarget,format_supports_resolve:format="bgra8unorm"
PASS :resolveTarget,format_supports_resolve:format="bgra8unorm-srgb"
PASS :resolveTarget,format_supports_resolve:format="r16uint"
PASS :resolveTarget,format_supports_resolve:format="r16sint"
PASS :resolveTarget,format_supports_resolve:format="r16float"
PASS :resolveTarget,format_supports_resolve:format="rg16uint"
PASS :resolveTarget,format_supports_resolve:format="rg16sint"
PASS :resolveTarget,format_supports_resolve:format="rg16float"
PASS :resolveTarget,format_supports_resolve:format="rgba16uint"
PASS :resolveTarget,format_supports_resolve:format="rgba16sint"
PASS :resolveTarget,format_supports_resolve:format="rgba16float"
PASS :resolveTarget,format_supports_resolve:format="r32float"
PASS :resolveTarget,format_supports_resolve:format="rgb10a2uint"
PASS :resolveTarget,format_supports_resolve:format="rgb10a2unorm"
PASS :depth_stencil_attachment,sample_counts_mismatch:
PASS :depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadOnly:format="stencil8"
PASS :depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadOnly:format="depth16unorm"
PASS :depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadOnly:format="depth32float"
PASS :depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadOnly:format="depth24plus"
PASS :depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadOnly:format="depth24plus-stencil8"
PASS :depth_stencil_attachment,loadOp_storeOp_match_depthReadOnly_stencilReadOnly:format="depth32float-stencil8"
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="load";depthClearValue="_undef_"
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="load";depthClearValue=-1
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="load";depthClearValue=0
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="load";depthClearValue=0.5
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="load";depthClearValue=1
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="load";depthClearValue=1.5
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="clear";depthClearValue="_undef_"
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="clear";depthClearValue=-1
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="clear";depthClearValue=0
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="clear";depthClearValue=0.5
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="clear";depthClearValue=1
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="clear";depthClearValue=1.5
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="_undef_";depthClearValue="_undef_"
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="_undef_";depthClearValue=-1
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="_undef_";depthClearValue=0
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="_undef_";depthClearValue=0.5
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="_undef_";depthClearValue=1
PASS :depth_stencil_attachment,depth_clear_value:depthLoadOp="_undef_";depthClearValue=1.5
PASS :timestampWrites,query_set_type:queryType="occlusion"
PASS :timestampWrites,query_set_type:queryType="timestamp"
PASS :timestampWrite,query_index:
PASS :occlusionQuerySet,query_set_type:queryType="occlusion"
PASS :occlusionQuerySet,query_set_type:queryType="timestamp"

Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
(Populate me when we're ready to investigate this test)

PASS :resolve_attachment:
PASS :resolve_attachment:colorAttachmentSamples=1
PASS :resolve_attachment:resolveTargetSamples=4
PASS :resolve_attachment:resolveTargetUsage=1
PASS :resolve_attachment:resolveTargetViewBaseMipLevel=1;resolveTargetHeight=4;resolveTargetWidth=4
PASS :resolve_attachment:resolveTargetViewBaseMipLevel=1;resolveTargetViewMipCount=2;resolveTargetHeight=4;resolveTargetWidth=4
PASS :resolve_attachment:resolveTargetInvalid=true
PASS :resolve_attachment:resolveTargetViewMipCount=2
PASS :resolve_attachment:resolveTargetViewBaseArrayLayer=1
PASS :resolve_attachment:resolveTargetViewBaseArrayLayer=1;resolveTargetViewArrayLayerCount=2
PASS :resolve_attachment:resolveTargetViewArrayLayerCount=2
PASS :resolve_attachment:otherAttachmentFormat="bgra8unorm"
PASS :resolve_attachment:colorAttachmentFormat="bgra8unorm"
PASS :resolve_attachment:colorAttachmentFormat="rgba8unorm-srgb"
PASS :resolve_attachment:resolveTargetFormat="bgra8unorm"
PASS :resolve_attachment:resolveTargetFormat="rgba8unorm-srgb"
PASS :resolve_attachment:colorAttachmentHeight=4
PASS :resolve_attachment:colorAttachmentWidth=4
PASS :resolve_attachment:resolveTargetHeight=4
PASS :resolve_attachment:resolveTargetWidth=4

4 changes: 2 additions & 2 deletions Source/WebCore/Modules/WebGPU/GPUComputePassTimestampWrites.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ struct GPUComputePassTimestampWrites {
}

GPUQuerySet* querySet { nullptr };
GPUSize32 beginningOfPassWriteIndex { 0 };
GPUSize32 endOfPassWriteIndex { 0 };
GPUSize32 beginningOfPassWriteIndex { UINT32_MAX };
GPUSize32 endOfPassWriteIndex { UINT32_MAX };
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct GPURenderPassDepthStencilAttachment {
ASSERT(view);
return {
view->backing(),
depthClearValue,
depthClearValue.value_or(-1.f),
depthLoadOp ? std::optional { WebCore::convertToBacking(*depthLoadOp) } : std::nullopt,
depthStoreOp ? std::optional { WebCore::convertToBacking(*depthStoreOp) } : std::nullopt,
depthReadOnly,
Expand All @@ -54,7 +54,7 @@ struct GPURenderPassDepthStencilAttachment {

GPUTextureView* view { nullptr };

float depthClearValue { 0 };
std::optional<float> depthClearValue;
std::optional<GPULoadOp> depthLoadOp;
std::optional<GPUStoreOp> depthStoreOp;
bool depthReadOnly { false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef [EnforceRange] unsigned long GPUStencilValue;
dictionary GPURenderPassDepthStencilAttachment {
required GPUTextureView view;

float depthClearValue = 0;
float depthClearValue;
GPULoadOp depthLoadOp;
GPUStoreOp depthStoreOp;
boolean depthReadOnly = false;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/Modules/WebGPU/GPURenderPassTimestampWrites.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ struct GPURenderPassTimestampWrites {
}

GPUQuerySet* querySet { nullptr };
GPUSize32 beginningOfPassWriteIndex { 0 };
GPUSize32 endOfPassWriteIndex { 0 };
GPUSize32 beginningOfPassWriteIndex { UINT32_MAX };
GPUSize32 endOfPassWriteIndex { UINT32_MAX };
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ Ref<RenderPassEncoder> CommandEncoderImpl::beginRenderPass(const RenderPassDescr
std::optional<WGPURenderPassDepthStencilAttachment> depthStencilAttachment;
if (descriptor.depthStencilAttachment) {
depthStencilAttachment = WGPURenderPassDepthStencilAttachment {
m_convertToBackingContext->convertToBacking(descriptor.depthStencilAttachment->view),
descriptor.depthStencilAttachment->depthLoadOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->depthLoadOp) : WGPULoadOp_Clear,
descriptor.depthStencilAttachment->depthStoreOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->depthStoreOp) : WGPUStoreOp_Discard,
descriptor.depthStencilAttachment->depthClearValue,
descriptor.depthStencilAttachment->depthReadOnly,
descriptor.depthStencilAttachment->stencilLoadOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->stencilLoadOp) : WGPULoadOp_Clear,
descriptor.depthStencilAttachment->stencilStoreOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->stencilStoreOp) : WGPUStoreOp_Discard,
descriptor.depthStencilAttachment->stencilClearValue,
descriptor.depthStencilAttachment->stencilReadOnly,
.view = m_convertToBackingContext->convertToBacking(descriptor.depthStencilAttachment->view),
.depthLoadOp = descriptor.depthStencilAttachment->depthLoadOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->depthLoadOp) : WGPULoadOp_Undefined,
.depthStoreOp = descriptor.depthStencilAttachment->depthStoreOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->depthStoreOp) : WGPUStoreOp_Undefined,
.depthClearValue = descriptor.depthStencilAttachment->depthClearValue,
.depthReadOnly = descriptor.depthStencilAttachment->depthReadOnly,
.stencilLoadOp = descriptor.depthStencilAttachment->stencilLoadOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->stencilLoadOp) : WGPULoadOp_Undefined,
.stencilStoreOp = descriptor.depthStencilAttachment->stencilStoreOp ? m_convertToBackingContext->convertToBacking(*descriptor.depthStencilAttachment->stencilStoreOp) : WGPUStoreOp_Undefined,
.stencilClearValue = descriptor.depthStencilAttachment->stencilClearValue,
.stencilReadOnly = descriptor.depthStencilAttachment->stencilReadOnly,
};
}

Expand Down
2 changes: 2 additions & 0 deletions Source/WebGPU/WebGPU/CommandEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class CommandEncoder : public WGPUCommandEncoderImpl, public RefCounted<CommandE
void runClearEncoder(NSMutableDictionary<NSNumber*, TextureAndClearColor*> *attachmentsToClear, id<MTLTexture> depthStencilAttachmentToClear, bool depthAttachmentToClear, bool stencilAttachmentToClear, float depthClearValue = 0, uint32_t stencilClearValue = 0, id<MTLRenderCommandEncoder> = nil);
static void clearTexture(const WGPUImageCopyTexture&, NSUInteger, id<MTLDevice>, id<MTLBlitCommandEncoder>);
void makeInvalid();
void makeSubmitInvalid();

private:
CommandEncoder(id<MTLCommandBuffer>, Device&);
Expand All @@ -117,6 +118,7 @@ class CommandEncoder : public WGPUCommandEncoderImpl, public RefCounted<CommandE
Vector<PendingTimestampWrites> m_pendingTimestampWrites;
uint64_t m_debugGroupStackSize { 0 };
WeakPtr<CommandBuffer> m_cachedCommandBuffer;
bool m_makeSubmitInvalid { false };

const Ref<Device> m_device;
};
Expand Down
Loading

0 comments on commit 9ab872a

Please sign in to comment.