-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebGPU] Index buffer can read outside the range of a vertex buffer
https://bugs.webkit.org/show_bug.cgi?id=273828 <radar://127672770> Reviewed by Tadeu Zagallo. Prevent out of bounds accesses into vertex buffers via drawIndexed, drawIndirect, and drawIndexedIndirect by running a non-rasterizing vertex shader immedietly before the draw call. ICB path rewrites the ICB render commands to avoid out of bounds accesses. * Source/WebGPU/WebGPU/BindableResource.h: * Source/WebGPU/WebGPU/Buffer.h: * Source/WebGPU/WebGPU/Buffer.mm: (WebGPU::Buffer::Buffer): (WebGPU::Buffer::maxIndex const): (WebGPU::Buffer::indirectBuffer const): (WebGPU::Buffer::indirectIndexedBuffer const): (WebGPU::Buffer::indirectBufferRequiresRecomputation const): (WebGPU::Buffer::indirectBufferRecomputed): (WebGPU::Buffer::indirectBufferInvalidated): (WebGPU::Buffer::recomputeMaxIndexValues const): Deleted. * Source/WebGPU/WebGPU/CommandEncoder.h: * Source/WebGPU/WebGPU/CommandEncoder.mm: (WebGPU::CommandEncoder::copyBufferToBuffer): (WebGPU::CommandEncoder::copyTextureToBuffer): (WebGPU::CommandEncoder::clearBuffer): * Source/WebGPU/WebGPU/ComputePassEncoder.mm: (WebGPU::addResourceToActiveResources): (WebGPU::ComputePassEncoder::runPredispatchIndirectCallValidation): (WebGPU::setCommandEncoder): * Source/WebGPU/WebGPU/Device.h: * Source/WebGPU/WebGPU/Device.mm: (WebGPU::GPUFrameCapture::captureFrame): (WebGPU::Device::dispatchCallBuffer): (WebGPU::Device::dispatchCallPipelineState): (WebGPU::Device::copyIndexIndirectArgsPipeline): (wgpuDeviceReference): Deleted. (wgpuDeviceRelease): Deleted. (wgpuDeviceCreateBindGroup): Deleted. (wgpuDeviceCreateBindGroupLayout): Deleted. (wgpuDeviceCreateBuffer): Deleted. (wgpuDeviceCreateCommandEncoder): Deleted. (wgpuDeviceCreateComputePipeline): Deleted. (wgpuDeviceCreateComputePipelineAsync): Deleted. (wgpuDeviceCreateComputePipelineAsyncWithBlock): Deleted. (wgpuDeviceCreatePipelineLayout): Deleted. (wgpuDeviceCreateQuerySet): Deleted. (wgpuDeviceCreateRenderBundleEncoder): Deleted. (wgpuDeviceCreateRenderPipeline): Deleted. (wgpuDeviceCreateRenderPipelineAsync): Deleted. (wgpuDeviceCreateRenderPipelineAsyncWithBlock): Deleted. (wgpuDeviceCreateSampler): Deleted. (wgpuDeviceImportExternalTexture): Deleted. (wgpuDeviceCreateShaderModule): Deleted. (wgpuDeviceCreateSwapChain): Deleted. (wgpuDeviceCreateTexture): Deleted. (wgpuDeviceDestroy): Deleted. (wgpuDeviceEnumerateFeatures): Deleted. (wgpuDeviceGetLimits): Deleted. (wgpuDeviceGetQueue): Deleted. (wgpuDeviceHasFeature): Deleted. (wgpuDevicePopErrorScope): Deleted. (wgpuDevicePopErrorScopeWithBlock): Deleted. (wgpuDevicePushErrorScope): Deleted. (wgpuDeviceSetDeviceLostCallback): Deleted. (wgpuDeviceSetDeviceLostCallbackWithBlock): Deleted. (wgpuDeviceSetUncapturedErrorCallback): Deleted. (wgpuDeviceSetUncapturedErrorCallbackWithBlock): Deleted. (wgpuDeviceSetLabel): Deleted. * Source/WebGPU/WebGPU/Pipeline.mm: (WebGPU::validateBindGroup): * Source/WebGPU/WebGPU/RenderBundleEncoder.h: * Source/WebGPU/WebGPU/RenderBundleEncoder.mm: (-[RenderBundleICBWithResources initWithICB:containerBuffer:pipelineState:depthStencilState:cullMode:frontFace:depthClipMode:depthBias:depthBiasSlopeScale:depthBiasClamp:fragmentDynamicOffsetsBuffer:pipeline:]): (-[RenderBundleICBWithResources minVertexCountForDrawCommand]): (WebGPU::makeRenderBundleICBWithResources): (WebGPU::RenderBundleEncoder::addResource): (WebGPU::RenderBundleEncoder::computeMininumVertexCount const): (WebGPU::RenderBundleEncoder::storeVertexBufferCountsForValidation): (WebGPU::RenderBundleEncoder::drawIndexed): (WebGPU::RenderBundleEncoder::drawIndexedIndirect): (WebGPU::RenderBundleEncoder::drawIndirect): (WebGPU::RenderBundleEncoder::endCurrentICB): (WebGPU::RenderBundleEncoder::setIndexBuffer): (WebGPU::RenderBundleEncoder::setVertexBuffer): (-[RenderBundleICBWithResources initWithICB:pipelineState:depthStencilState:cullMode:frontFace:depthClipMode:depthBias:depthBiasSlopeScale:depthBiasClamp:fragmentDynamicOffsetsBuffer:pipeline:]): Deleted. * Source/WebGPU/WebGPU/RenderPassEncoder.h: * Source/WebGPU/WebGPU/RenderPassEncoder.mm: (WebGPU::m_maxDrawCount): (WebGPU::RenderPassEncoder::addResourceToActiveResources): (WebGPU::RenderPassEncoder::computeMininumVertexCount const): (WebGPU::RenderPassEncoder::clampIndexBufferToValidValues): (WebGPU::RenderPassEncoder::clampIndirectIndexBufferToValidValues): (WebGPU::RenderPassEncoder::clampIndirectBufferToValidValues): (WebGPU::RenderPassEncoder::drawIndexed): (WebGPU::RenderPassEncoder::drawIndexedIndirect): (WebGPU::RenderPassEncoder::drawIndirect): (WebGPU::RenderPassEncoder::setCommandEncoder): (WebGPU::RenderPassEncoder::executeBundles): Canonical link: https://commits.webkit.org/279182@main
- Loading branch information
1 parent
2b5ed00
commit e6d5e1a
Showing
13 changed files
with
751 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.