Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow GPUShaderModules to contain MTLLibraries
> The resolution is to add a dictionary of entry point name to pipeline layout to createShaderModule(), which is optional, and implementations can totally ignore it 100% (no validation).

Fixes #1064.
  • Loading branch information
litherum committed Dec 5, 2021
commit 28b6c44ac4f8329f5e1dbdd9aad47a5672282ef0
38 changes: 38 additions & 0 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4040,9 +4040,14 @@ Issue(gpuweb/gpuweb#354): Finish defining multithreading API and add `[Serializa
### Shader Module Creation ### {#shader-module-creation}

<script type=idl>
dictionary GPUShaderModuleCompilationHint {
required GPUPipelineLayout layout;
};

dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
required USVString code;
object sourceMap;
record<USVString, GPUShaderModuleCompilationHint> hints;
};
</script>

Expand All @@ -4051,6 +4056,39 @@ source-map-v3 format.
Source maps are optional, but serve as a standardized way to support dev-tool
integration such as source-language debugging. [[SourceMap]]

{{GPUShaderModuleDescriptor/hints}}, if defined, maps an entry point name from
the shader to a {{GPUShaderModuleCompilationHint}}. No validation is performed with
any of these {{GPUShaderModuleCompilationHint}}. Implementations should use any
information present in the {{GPUShaderModuleCompilationHint}} to perform as much
compilation as is possible within {{GPUDevice/createShaderModule()}}.

Note: Supplying information in {{GPUShaderModuleDescriptor/hints}} does not have any
observable effect, other than performance. Because a single shader module can hold
multiple entry points, and multiple pipelines can be created from a single shader
module, it can be more performant for an implementation to do as much compilation as
possible once in {{GPUDevice/createShaderModule()}} rather than multiple times in
the multiple calls to {{GPUDevice/createComputePipeline()}} /
{{GPUDevice/createRenderPipeline()}}.

Note: If possible, authors should be supplying the same information to
{{GPUDevice/createShaderModule()}} and {{GPUDevice/createComputePipeline()}} /
{{GPUDevice/createRenderPipeline()}}.

Note: If an author is unable to provide this {{GPUShaderModuleDescriptor/hints}}
information at the time of calling {{GPUDevice/createShaderModule()}}, they should
usually not delay calling {{GPUDevice/createShaderModule()}}; but should instead just
omit the unknown information from {{GPUShaderModuleDescriptor/hints}} or
{{GPUShaderModuleCompilationHint}}. Omitting this information may cause compilation
to be deferred to {{GPUDevice/createComputePipeline()}} /
{{GPUDevice/createRenderPipeline()}}.

Note: If an author is not confident that the information passed to
{{GPUDevice/createShaderModule()}} will match the information later passed to
{{GPUDevice/createComputePipeline()}} / {{GPUDevice/createRenderPipeline()}} with that
same module, they should avoid passing that information to
{{GPUDevice/createShaderModule()}}, as passing mismatched information to
{{GPUDevice/createShaderModule()}} may cause unnecessary compilations to occur.

<dl dfn-type=method dfn-for=GPUDevice>
: <dfn>createShaderModule(descriptor)</dfn>
::
Expand Down