|email@example.com <firstname.lastname@example.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>||Thu Jun 13 06:06:53 2019 +0000|
|email@example.com <firstname.lastname@example.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>||Thu Jun 13 06:06:53 2019 +0000|
[WHLSL] Hook up compute https://bugs.webkit.org/show_bug.cgi?id=198644 Reviewed by Saam Barati. Source/WebCore: This patch hooks up compute shaders in exactly the same way that vertex and fragment shaders are hooked up. I've modified the two patchs (compute and rendering) to be almost exactly the same code. This patch also adds support for the WHLSL compiler to determine what the numthreads() attribute in the shader says so that it can be hooked up to Metal's threads-per-threadgroup argument in the dispatch call. There is some logic to make sure that there aren't two numthreads() attributes on the same compute shader. It also adds a little bit of type renaming. For built-in variables, sometimes Metal's type doesn't always match WHLSL's (and HLSL's type). For example, in WHLSL and HLSL, SV_DispatchThreadID variables have to be a float3, but in Metal, they are a uint3. Therefore, I've added a little bit of code during each entry point's pack and unpack stages to handle this type conversion. Test: webgpu/whlsl-compute.html * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: (WebCore::WHLSL::Metal::internalTypeForSemantic): Determine which Metal type corresponds to each built-in variable. (WebCore::WHLSL::Metal::EntryPointScaffolding::builtInsSignature): Perform the type conversion. (WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns): Ditto. (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::VertexEntryPointScaffolding): Ditto. (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::helperTypes): Ditto. (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::pack): Ditto. (WebCore::WHLSL::Metal::FragmentEntryPointScaffolding::FragmentEntryPointScaffolding): Ditto. (WebCore::WHLSL::Metal::FragmentEntryPointScaffolding::helperTypes): Ditto. (WebCore::WHLSL::Metal::FragmentEntryPointScaffolding::pack): Ditto. (WebCore::WHLSL::Metal::ComputeEntryPointScaffolding::signature): Ditto. * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.h: * Modules/webgpu/WHLSL/WHLSLComputeDimensions.cpp: Added. Add a pass to determine whether or not any entry point has duplicate numthreads() attribute, and to determine what the appropriate numthreads() values should be for the current entry point. (WebCore::WHLSL::ComputeDimensionsVisitor::ComputeDimensionsVisitor): (WebCore::WHLSL::ComputeDimensionsVisitor::computeDimensions const): (WebCore::WHLSL::computeDimensions): * Modules/webgpu/WHLSL/WHLSLComputeDimensions.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h. * Modules/webgpu/WHLSL/WHLSLGatherEntryPointItems.cpp: (WebCore::WHLSL::gatherEntryPointItems): Compute shaders don't need to have a semantic for their return type. * Modules/webgpu/WHLSL/WHLSLPrepare.cpp: (WebCore::WHLSL::prepare): Run the computeDimensions() pass. * Modules/webgpu/WHLSL/WHLSLPrepare.h: * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp: In a left-value propertyAccessExpression, the index expression can be a right-value. Treat it as such. (WebCore::WHLSL::LeftValueSimplifier::finishVisiting): (WebCore::WHLSL::LeftValueSimplifier::visit): * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt: We need support for multiplication (for a test) and float3 for SV_DispatchThreadID. * Sources.txt: * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: * platform/graphics/gpu/GPUComputePipeline.h: Associate a compute dimensions with a particular compute pipeline. This is how Metal knows what values to use for a dispatch. (WebCore::GPUComputePipeline::computeDimensions const): * platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm: Use the saved compute dimensions. (WebCore::GPUComputePassEncoder::dispatch): * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm: Make the code match GPURenderPipelineMetal. (WebCore::trySetMetalFunctions): (WebCore::trySetFunctions): (WebCore::convertComputePipelineDescriptor): (WebCore::tryCreateMTLComputePipelineState): (WebCore::GPUComputePipeline::tryCreate): (WebCore::GPUComputePipeline::GPUComputePipeline): (WebCore::tryCreateMtlComputeFunction): Deleted. * platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.cpp: Added. Moved shared helper functions to a file where they can be accessed by multiple places. (WebCore::convertShaderStageFlags): (WebCore::convertBindingType): (WebCore::convertLayout): * platform/graphics/gpu/cocoa/GPUPipelineMetalConvertLayout.h: Copied from Source/WebCore/Modules/webgpu/WHLSL/WHLSLPrepare.h. * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: Delete the functions that were moved to GPUPipelineMetalConvertLayout. (WebCore::trySetFunctions): (WebCore::tryCreateMtlRenderPipelineState): (WebCore::convertShaderStageFlags): Deleted. (WebCore::convertBindingType): Deleted. (WebCore::convertLayout): Deleted. LayoutTests: This doesn't thoroughly test compute, but it's at least enough to unblock the WHLSL testing effort. * webgpu/compute-squares-expected.txt: Deleted. Covered by webgpu/whlsl-compute.html. * webgpu/compute-squares.html: Deleted. Ditto. * webgpu/whlsl-compute-expected.txt: Added. * webgpu/whlsl-compute.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@246396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone git://git.webkit.org/WebKit.git WebKit
git clone https://git.webkit.org/git/WebKit.git WebKit
If you want to be able to commit changes to the repository, or just want to check out branches that aren’t contained in WebKit.git, you will need track WebKit's Subversion repository. You can run the following command to configure this and other options of the new Git clone for WebKit development.
For information about this, and other aspects of using Git with WebKit, read the wiki page.
If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:
svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
Install Xcode and its command line tools if you haven't done so already:
Run the following command to build a debug build with debugging symbols and assertions:
For performance testing, and other purposes, use
You can open
WebKit.xcworkspace to build and debug WebKit within Xcode.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use
WebKitBuild directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter
WebKitBuild for both Products and Intermediates.
The first time after you install a new Xcode, you will need to run the following command to enable Xcode to build command line tools for iOS Simulator:
Without this step, you will see the error message: “
target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.” when building target
JSCLLIntOffsetsExtractor of project
Run the following command to build a debug build with debugging symbols and assertions for iOS:
Tools/Scripts/build-webkit --debug --ios-simulator
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
run-safari script sets the
DYLD_FRAMEWORK_PATH environment variable to point to your build products, and then launches
DYLD_FRAMEWORK_PATH tells the system loader to prefer your build products over the frameworks installed in
To run other applications with your local build of WebKit, run the following command:
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use
--release instead of
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of
--wpe to indicate the port to use.
Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.