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

Skip to content

Commit 2cc86e5

Browse files
author
Justin Fan
committed
Half-formed new validation rule structure for createBindGroupLayout
1 parent 14fbfab commit 2cc86e5

File tree

1 file changed

+56
-81
lines changed

1 file changed

+56
-81
lines changed

spec/index.bs

Lines changed: 56 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -778,53 +778,6 @@ interface GPUBindGroupLayout : GPUObjectBase {
778778
};
779779
</script>
780780

781-
A {{GPUBindGroupLayout}} object has the following internal slots:
782-
783-
<dl dfn-type=attribute dfn-for="GPUBindGroupLayout">
784-
: <dfn>\[[bindingsMap]]</dfn> of a Map of `unsigned long` {{GPUBindGroupLayoutBinding/binding}} keys to <dfn dfn for ="layout binding">layout binding</dfn> values.
785-
::
786-
The [=layout binding=] objects this {{GPUBindGroupLayout}} describes.
787-
788-
</dl>
789-
790-
An internal [=layout binding=] object has the following slots:
791-
792-
<dl dfn-type=attribute dfn-for="layout binding">
793-
: <dfn>\[[binding]]</dfn> of type unsigned long.
794-
::
795-
The unique identifier for this [=layout binding=] in shader stages.
796-
797-
: <dfn>\[[visibility]]</dfn> of type {{GPUShaderStageFlags}}.
798-
::
799-
The bitset representing from which shader stages this [=layout binding=]'s resource will be accessible.
800-
801-
: <dfn>\[[type]]</dfn> of type {{GPUBindingType}}.
802-
::
803-
The type of shader resource this [=layout binding=] describes.
804-
805-
: <dfn>\[[hasDynamicOffsets]]</dfn> of type boolean.
806-
::
807-
If `true`, indicates that this [=layout binding=] has dynamic offsets.
808-
809-
Ignored if {{layout binding/[[type]]}} is not {{GPUBindingType/uniform-buffer}}, {{GPUBindingType/storage-buffer}}, or {{GPUBindingType/readonly-storage-buffer}}.
810-
811-
: <dfn>\[[textureDimension]]</dfn> of type {{GPUTextureViewDimension}}.
812-
::
813-
The dimensionality of the texture resource described by this [=layout binding=].
814-
815-
Ignored if {{layout binding/[[type]]}} is not {{GPUBindingType/sampled-texture}} or {{GPUBindingType/storage-texture}}.
816-
817-
: <dfn>\[[textureComponentType]]</dfn> of type {{GPUTextureComponentType}}.
818-
::
819-
The data type of the texture resource described by this [=layout binding=].
820-
821-
Ignored if {{layout binding/[[type]]}} is not {{GPUBindingType/sampled-texture}} or {{GPUBindingType/storage-texture}}.
822-
823-
: <dfn>\[[multisampled]]</dfn> of type boolean.
824-
::
825-
If `true`, indicates that the texture resource described by this [=layout binding=] will be multisampled.
826-
</dl>
827-
828781
### Creation ### {#bind-group-layout-creation}
829782

830783
A {{GPUBindGroupLayout}} is created via {{GPUDevice/createBindGroupLayout()|GPUDevice.createBindGroupLayout()}}.
@@ -845,12 +798,12 @@ dictionary GPUBindGroupLayoutBinding {
845798
GPUTextureViewDimension textureDimension = "2d";
846799
GPUTextureComponentType textureComponentType = "float";
847800
boolean multisampled = false;
848-
boolean hasDynamicOffsets = false;
801+
boolean hasDynamicOffset = false;
849802
};
850803
</script>
851804

852805
* {{GPUBindGroupLayoutBinding/binding}}:
853-
A unique identifier for a resource binding in a {{GPUBindGroupLayoutBinding}}, a corresponding {{GPUBindGroupBinding}}, and shader stages.
806+
A unique identifier for a resource binding within a {{GPUBindGroupLayoutBinding}}, a corresponding {{GPUBindGroupBinding}}, and shader stages.
854807

855808
* {{GPUBindGroupLayoutBinding/visibility}}:
856809
A bitset of the members of {{GPUShaderStage}}. Each set bit indicates that a {{GPUBindGroupLayoutBinding}}'s resource will be accessible from the
@@ -882,63 +835,85 @@ enum GPUBindingType {
882835
</script>
883836

884837
* {{GPUBindGroupLayoutBinding/textureDimension}}, {{GPUBindGroupLayoutBinding/multisampled}}:
885-
The dimensions and multi-sampling properties of texture bindings.
838+
Describes the dimensionality of texture view bindings, and indicates if they are multisampled.
886839

887840
Note: This allows Metal-based implementations to back the respective bind
888841
groups with `MTLArgumentBuffer` objects that are more efficient to bind at
889842
run-time.
890843

891-
* {{GPUBindGroupLayoutBinding/hasDynamicOffsets}}:
844+
* {{GPUBindGroupLayoutBinding/hasDynamicOffset}}:
892845
For {{GPUBindingType/uniform-buffer}}, {{GPUBindingType/storage-buffer}}, and {{GPUBindingType/readonly-storage-buffer}} bindings,
893-
indicates that the binding has dynamic offsets. One offset must be passed to
846+
indicates that the binding has a dynamic offset. One offset must be passed to
894847
setBindGroup for each dynamic binding in increasing order of
895848
{{GPUBindGroupLayoutBinding/binding}} number.
896849

850+
A {{GPUBindGroupLayout}} object has the following internal slots:
851+
852+
<dl dfn-type=attribute dfn-for="GPUBindGroupLayout">
853+
: <dfn>\[[bindings]]</dfn> of type sequence<{{GPUBindGroupLayoutBinding}}>.
854+
::
855+
The [=layout binding=] objects this {{GPUBindGroupLayout}} describes.
856+
857+
</dl>
858+
897859
### {{GPUDevice/createBindGroupLayout()|GPUDevice.createBindGroupLayout(GPUBindGroupLayoutDescriptor)}} ### {#GPUDevice-createBindGroupLayout}
898860

899861
<div algorithm="GPUDevice.createBindGroupLayout(descriptor)">
862+
900863
The <dfn-type="method" dfn-for="GPUDevice">createBindGroupLayout(|descriptor|)</dfn> method is used to create {{GPUBindGroupLayout}}s.
901864

865+
1. If the device is lost, [=return an invalid GPUBindGroupLayout=].
902866
1. Let |layout| be a new valid {{GPUBindGroupLayout}} object.
903867
1. For each {{GPUBindGroupLayoutBinding}} |bindingDescriptor| in |descriptor|.{{GPUBindGroupLayoutDescriptor/bindings}}:
904-
1. Let |layoutBinding| be a new internal [=layout binding=] object.
868+
1. Ensure |bindingDescriptor|.{{GPUBindGroupLayoutBinding/binding}} does not violate [=binding validation=].
905869
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}} is {{GPUBindingType/uniform-buffer}}:
906-
1. Set |layoutBinding|.{{layout binding/[[hasDynamicOffsets]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/hasDynamicOffsets}}.
870+
1. Ensure [=uniform buffer validation=] is not violated.
871+
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/dynamic}} is `true`, ensure [=dynamic uniform buffer validation=] is not violated.
907872
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}} is {{GPUBindingType/storage-buffer}} or {{GPUBindingType/readonly-storage-buffer}}:
908-
1. Set |layoutBinding|.{{layout binding/[[hasDynamicOffsets]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/hasDynamicOffsets}}.
909-
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}} is {{GPUBindingType/sampled-texture}} or {{GPUBindingType/storage-texture}}:
910-
1. Set |layoutBinding|.{{layout binding/[[textureDimension]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/textureDimension}}.
911-
1. Set |layoutBinding|.{{layout binding/[[textureComponentType]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/textureComponentType}}.
912-
1. Set |layoutBinding|.{{layout binding/[[multisampled]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/multisampled}}.
913-
1. Set |layoutBinding|.{{layout binding/[[binding]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/binding}}.
914-
1. Set |layoutBinding|.{{layout binding/[[visibility]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/visibility}}.
915-
1. Set |layoutBinding|.{{layout binding/[[type]]}} to the value of |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}}.
916-
1. Insert |layoutBinding| into |layout|.{{GPUBindGroupLayout/[[bindingsMap]]}} with a key of |layoutBinding|.{{layout binding/[[binding]]}}.
873+
1. Ensure [=storage buffer validation=] is not violated.
874+
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/dynamic}} is `true`, ensure [=dynamic storage buffer validation=] is not violated.
875+
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}} is {{GPUBindingType/sampled-texture}}
876+
, ensure [=sampled texture validation=] is not violated.
877+
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}} is {{GPUBindingType/storage-texture}}
878+
, ensure [=storage texture validation=] is not violated.
879+
1. If |bindingDescriptor|.{{GPUBindGroupLayoutBinding/type}} is {{GPUBindingType/sampler}}
880+
, ensure [=sampler validation=] is not violated.
881+
1. Insert |bindingDescriptor| into |layout|.{{GPUBindGroupLayout/[[bindings]]}}.
917882
1. Return |layout|.
918883

919-
<b>Validation</b>
920-
* The device must not be lost.
921-
* Each |bindingDescriptor|.{{GPUBindGroupLayoutBinding/binding}} in |descriptor| must be unique.
922-
* There must be {{GPULimits/maxUniformBuffersPerShaderStage|GPULimits.maxUniformBuffersPerShaderStage}} or
884+
<b>Validation Conditions</b>
885+
886+
<dl dfn-for="createBindGroupLayout(descriptor)">
887+
If any of the following conditions are violated:
888+
1. Generate a {{GPUValidationError}} in the current scope with appropriate error message.
889+
1. Create a new invalid {{GPUBindGroupLayout}} and return the result.
890+
891+
<dfn>binding validation</dfn>: Each |bindingDescriptor|.{{GPUBindGroupLayoutBinding/binding}} in |descriptor| must be unique.
892+
893+
<dfn>uniform buffer validation</dfn>: There must be {{GPULimits/maxUniformBuffersPerShaderStage|GPULimits.maxUniformBuffersPerShaderStage}} or
923894
fewer |bindingDescriptor|s of type {{GPUBindingType/uniform-buffer}} visible on each shader stage in |descriptor|.
924-
* There must be {{GPULimits/maxDynamicUniformBuffersPerPipelineLayout|GPULimits.maxDynamicUniformBuffersPerPipelineLayout}} or
925-
fewer |bindingDescriptor|s of type {{GPUBindingType/uniform-buffer}} with {{GPUBindGroupLayoutBinding/hasDynamicOffsets}} set to `true`
926-
visible across <b>all</b> shader stages in |descriptor|.
927-
* There must be {{GPULimits/maxStorageBuffersPerPipelineLayout|GPULimits.maxStorageBuffersPerPipelineLayout}} or
928-
fewer |bindingDescriptor|s of type {{GPUBindingType/storage-buffer}} visible across <b>all</b> shader stages in |descriptor|.
929-
* There must be {{GPULimits/maxDynamicStorageBuffersPerPipelineLayout|GPULimits.maxDynamicStorageBuffersPerPipelineLayout}} or
930-
fewer |bindingDescriptor|s of type {{GPUBindingType/storage-buffer}} with {{GPUBindGroupLayoutBinding/hasDynamicOffsets}} set to `true`
931-
visible across <b>all</b> shader stages in |descriptor|.
932-
* There must be {{GPULimits/maxSampledTexturesPerShaderStage|GPULimits.maxSampledTexturesPerShaderStage}} or
895+
896+
<dfn>dynamic uniform buffer validation</dfn>: There must be {{GPULimits/maxDynamicUniformBuffersPerPipelineLayout|GPULimits.maxDynamicUniformBuffersPerPipelineLayout}} or
897+
fewer |bindingDescriptor|s of type {{GPUBindingType/uniform-buffer}} with {{GPUBindGroupLayoutBinding/hasDynamicOffset}} set to `true` in
898+
|descriptor| that are visible to any shader stage.
899+
900+
<dfn>storage buffer validation</dfn>: There must be {{GPULimits/maxStorageBuffersPerPipelineLayout|GPULimits.maxStorageBuffersPerPipelineLayout}} or
901+
fewer |bindingDescriptor|s of type {{GPUBindingType/storage-buffer}} in |descriptor| that are visible to any shader stage.
902+
903+
<dfn>dynamic storage buffer validation</dfn>: There must be {{GPULimits/maxDynamicStorageBuffersPerPipelineLayout|GPULimits.maxDynamicStorageBuffersPerPipelineLayout}} or
904+
fewer |bindingDescriptor|s of type {{GPUBindingType/storage-buffer}} with {{GPUBindGroupLayoutBinding/hasDynamicOffset}} set to `true`
905+
in |descriptor| that are visible to any shader stage.
906+
907+
<dfn>sampled texture validation</dfn>: There must be {{GPULimits/maxSampledTexturesPerShaderStage|GPULimits.maxSampledTexturesPerShaderStage}} or
933908
fewer |bindingDescriptor|s of type {{GPUBindingType/sampled-texture}} visible on each shader stage in |descriptor|.
934-
* There must be {{GPULimits/maxStorageTexturesPerShaderStage|GPULimits.maxStorageTexturesPerShaderStage}} or
909+
910+
<dfn>storage texture validation</dfn>: There must be {{GPULimits/maxStorageTexturesPerShaderStage|GPULimits.maxStorageTexturesPerShaderStage}} or
935911
fewer |bindingDescriptor|s of type {{GPUBindingType/storage-texture}} visible on each shader stage in |descriptor|.
936-
* There must be {{GPULimits/maxSamplersPerShaderStage|GPULimits.maxSamplersPerShaderStage}} or
912+
913+
<dfn>sampler validation</dfn>: There must be {{GPULimits/maxSamplersPerShaderStage|GPULimits.maxSamplersPerShaderStage}} or
937914
fewer |bindingDescriptor|s of type {{GPUBindingType/sampler}} visible on each shader stage in |descriptor|.
938915

939-
At any point in the algorithm, if any of the above conditions are violated, run the following steps:
940-
1. Generate a {{GPUValidationError}} in the current scope with appropriate error message.
941-
1. Create a new invalid {{GPUBindGroupLayout}} and return the result.
916+
</dl>
942917
</div>
943918

944919
## GPUBindGroup ## {#bind-groups}

0 commit comments

Comments
 (0)