From e80fd5081e1d6d8efd0385d51a9a7e4a591d8723 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 1 Apr 2020 11:49:59 -0400 Subject: [PATCH 1/5] Add minimumBufferSize to BGL entry --- spec/index.bs | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index 1abdac2585..73ebd25f64 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -1950,6 +1950,9 @@ dictionary GPUBindGroupLayoutEntry { // Used for uniform buffer and storage buffer bindings. boolean hasDynamicOffset = false; + // Used for uniform buffer and storage buffer bindings. + GPUSize64 minimumBufferBindingSize = 0; + // Used for sampled texture and storage texture bindings. GPUTextureViewDimension viewDimension; @@ -2105,8 +2108,8 @@ A {{GPUBindGroupLayout}} object has the following internal slots: {{GPUBindingType/"storage-buffer"}}, or {{GPUBindingType/"readonly-storage-buffer"}}, ensure - |bindingDescriptor|.{{GPUBindGroupLayoutEntry/hasDynamicOffset}} - is `false`. + |bindingDescriptor|.{{GPUBindGroupLayoutEntry/hasDynamicOffset}} is `false`, + and |bindingDescriptor|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} is zero. 1. If |bindingDescriptor|.{{GPUBindGroupLayoutEntry/type}} is **not** {{GPUBindingType/"sampled-texture"}}, {{GPUBindingType/"readonly-storage-texture"}}, or @@ -2188,24 +2191,7 @@ A {{GPUBindGroupLayout}} object has the following internal slots: Two {{GPUBindGroupLayout}} objects |a| and |b| are considered group-equivalent if and only if, for any binding number |binding|, one of the following is true: - it's missing from both |a|.{{GPUBindGroupLayout/[[entryMap]]}} and |b|.{{GPUBindGroupLayout/[[entryMap]]}}. - - |a|.{{GPUBindGroupLayout/[[entryMap]]}}[|binding|] is [=entry-equivalent=] to |b|.{{GPUBindGroupLayout/[[entryMap]]}}[|binding|] - - -
-Two {{GPUBindGroupLayoutEntry}} entries |a| and |b| are considered entry-equivalent if all of the conditions are true: - - 1. |a|.{{GPUBindGroupLayoutEntry/binding}} == |b|.{{GPUBindGroupLayoutEntry/binding}} - 1. |a|.{{GPUBindGroupLayoutEntry/visibility}} == |b|.{{GPUBindGroupLayoutEntry/visibility}} - 1. |a|.{{GPUBindGroupLayoutEntry/type}} == |b|.{{GPUBindGroupLayoutEntry/type}} - 1. if |a|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"uniform-buffer"}}, {{GPUBindingType/"storage-buffer"}}, or {{GPUBindingType/"readonly-storage-buffer"}}, then: - - |a|.{{GPUBindGroupLayoutEntry/hasDynamicOffset}} == |b|.{{GPUBindGroupLayoutEntry/hasDynamicOffset}} - 1. if |a|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"sampled-texture"}}, then: - - |a|.{{GPUBindGroupLayoutEntry/viewDimension}} == |b|.{{GPUBindGroupLayoutEntry/viewDimension}} - - |a|.{{GPUBindGroupLayoutEntry/textureComponentType}} == |b|.{{GPUBindGroupLayoutEntry/textureComponentType}} - - |a|.{{GPUBindGroupLayoutEntry/multisampled}} == |b|.{{GPUBindGroupLayoutEntry/multisampled}} - 1. if |a|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"readonly-storage-texture"}} or {{GPUBindingType/"writeonly-storage-texture"}}, then: - - |a|.{{GPUBindGroupLayoutEntry/viewDimension}} == |b|.{{GPUBindGroupLayoutEntry/viewDimension}} - - |a|.{{GPUBindGroupLayoutEntry/storageTextureFormat}} == |b|.{{GPUBindGroupLayoutEntry/storageTextureFormat}} + - |a|.{{GPUBindGroupLayout/[[entryMap]]}}[|binding|] == |b|.{{GPUBindGroupLayout/[[entryMap]]}}[|binding|]
If bind groups layouts are [=group-equivalent=] they can be interchangeably used in all contents. @@ -2379,6 +2365,9 @@ A {{GPUBindGroup}} object has the following internal slots: with {{GPUBufferUsage/STORAGE}} flag. 1. The bound part designated by |bufferBinding|.{{GPUBufferBinding/offset}} and |bufferBinding|.{{GPUBufferBinding/size}} must reside inside the buffer. + 1. The effective binding size, that is either explict in |bufferBinding|.{{GPUBufferBinding/size}} + or derived from |bufferBinding|.{{GPUBufferBinding/offset}} and the full size of the buffer, + is greater or equal to {{GPUBindGroupLayoutEntry/minimumBufferBindingSize|GPUBindGroupLayoutEntry.minimumBufferBindingSize}}. From 75082d29e0c463d80c4a734e52a4aa9f58fec4c8 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 8 Jun 2020 18:38:32 -0400 Subject: [PATCH 2/5] Add pipeline validation text --- spec/index.bs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/index.bs b/spec/index.bs index 73ebd25f64..5c8bed2c25 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -1965,6 +1965,8 @@ dictionary GPUBindGroupLayoutEntry { }; +Issue(https://github.com/gpuweb/gpuweb/issues/851): consider making `textureComponentType` and `storageTextureFormat` truly optional. +
: binding :: @@ -2746,6 +2748,15 @@ A {{GPUProgrammableStageDescriptor}} describes the entry point in the user-provi the |binding| has to be a read-only storage buffer. 1. If |entry|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"sampled-texture"}}, {{GPUBindingType/"readonly-storage-texture"}}, or {{GPUBindingType/"writeonly-storage-texture"}}, the shader view dimension of the texture has to match |entry|.{{GPUBindGroupLayoutEntry/viewDimension}}. + 1. If |entry|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} is not zero, + |entry|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"uniform-buffer"}}, {{GPUBindingType/"storage-buffer"}}, or + {{GPUBindingType/"readonly-storage-buffer"}}: + - if the corresponding structure defined in the shader has the last field being an unbound array type, + then the value of |entry|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} must be greater or equal to the + byte offset of that field plus the stride of the unbound array. + - if the corresponding shader structure doesn't end with an unbound array type, + then the value of |entry|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} must be greater or equal to the + size of the structure. Issue: is there a match/switch statement in bikeshed? From 83111fc55465012ae0ecc438cfe5fec302a9a3ed Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 10 Jun 2020 12:17:04 -0400 Subject: [PATCH 3/5] Rename to minBufferBindingSize, address review nots --- spec/index.bs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index 5c8bed2c25..8848bb5afc 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -1951,7 +1951,7 @@ dictionary GPUBindGroupLayoutEntry { boolean hasDynamicOffset = false; // Used for uniform buffer and storage buffer bindings. - GPUSize64 minimumBufferBindingSize = 0; + GPUSize64 minBufferBindingSize = 0; // Used for sampled texture and storage texture bindings. GPUTextureViewDimension viewDimension; @@ -2111,7 +2111,7 @@ A {{GPUBindGroupLayout}} object has the following internal slots: {{GPUBindingType/"readonly-storage-buffer"}}, ensure |bindingDescriptor|.{{GPUBindGroupLayoutEntry/hasDynamicOffset}} is `false`, - and |bindingDescriptor|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} is zero. + and |bindingDescriptor|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} is zero. 1. If |bindingDescriptor|.{{GPUBindGroupLayoutEntry/type}} is **not** {{GPUBindingType/"sampled-texture"}}, {{GPUBindingType/"readonly-storage-texture"}}, or @@ -2369,10 +2369,12 @@ A {{GPUBindGroup}} object has the following internal slots: |bufferBinding|.{{GPUBufferBinding/size}} must reside inside the buffer. 1. The effective binding size, that is either explict in |bufferBinding|.{{GPUBufferBinding/size}} or derived from |bufferBinding|.{{GPUBufferBinding/offset}} and the full size of the buffer, - is greater or equal to {{GPUBindGroupLayoutEntry/minimumBufferBindingSize|GPUBindGroupLayoutEntry.minimumBufferBindingSize}}. + is greater or equal to |layoutBinding|.{{GPUBindGroupLayoutEntry/minBufferBindingSize|GPUBindGroupLayoutEntry.minBufferBindingSize}}. +Issue: define the "effective buffer binding size" separately. + ## GPUPipelineLayout ## {#pipeline-layout} A {{GPUPipelineLayout}} defines the mapping between resources of all {{GPUBindGroup}} objects set up during command encoding in {{GPUProgrammablePassEncoder/setBindGroup(index, bindGroup, dynamicOffsets)|setBindGroup}}, and the shaders of the pipeline set by {{GPURenderEncoderBase/setPipeline(pipeline)|GPURenderEncoderBase.setPipeline}} or {{GPUComputePassEncoder/setPipeline(pipeline)|GPUComputePassEncoder.setPipeline}}. @@ -2748,14 +2750,12 @@ A {{GPUProgrammableStageDescriptor}} describes the entry point in the user-provi the |binding| has to be a read-only storage buffer. 1. If |entry|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"sampled-texture"}}, {{GPUBindingType/"readonly-storage-texture"}}, or {{GPUBindingType/"writeonly-storage-texture"}}, the shader view dimension of the texture has to match |entry|.{{GPUBindGroupLayoutEntry/viewDimension}}. - 1. If |entry|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} is not zero, - |entry|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"uniform-buffer"}}, {{GPUBindingType/"storage-buffer"}}, or - {{GPUBindingType/"readonly-storage-buffer"}}: + 1. If |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} is not zero: - if the corresponding structure defined in the shader has the last field being an unbound array type, - then the value of |entry|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} must be greater or equal to the + then the value of |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} must be greater or equal to the byte offset of that field plus the stride of the unbound array. - if the corresponding shader structure doesn't end with an unbound array type, - then the value of |entry|.{{GPUBindGroupLayoutEntry/minimumBufferBindingSize}} must be greater or equal to the + then the value of |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} must be greater or equal to the size of the structure. From 15d8a8d70978d5b5d1303bbb9cc6e198d02e2d3e Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 15 Jun 2020 17:15:02 -0400 Subject: [PATCH 4/5] Update spec/index.bs Co-authored-by: Justin Fan --- spec/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/index.bs b/spec/index.bs index 8848bb5afc..42a7fd2c46 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -2369,7 +2369,7 @@ A {{GPUBindGroup}} object has the following internal slots: |bufferBinding|.{{GPUBufferBinding/size}} must reside inside the buffer. 1. The effective binding size, that is either explict in |bufferBinding|.{{GPUBufferBinding/size}} or derived from |bufferBinding|.{{GPUBufferBinding/offset}} and the full size of the buffer, - is greater or equal to |layoutBinding|.{{GPUBindGroupLayoutEntry/minBufferBindingSize|GPUBindGroupLayoutEntry.minBufferBindingSize}}. + is greater than or equal to |layoutBinding|.{{GPUBindGroupLayoutEntry/minBufferBindingSize|GPUBindGroupLayoutEntry.minBufferBindingSize}}. From 23c2851eb1291683cbdc1ea6f16150ee67185fdb Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 15 Jun 2020 17:15:30 -0400 Subject: [PATCH 5/5] Update spec/index.bs Co-authored-by: Justin Fan --- spec/index.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/index.bs b/spec/index.bs index 42a7fd2c46..26d529bf48 100644 --- a/spec/index.bs +++ b/spec/index.bs @@ -2751,11 +2751,11 @@ A {{GPUProgrammableStageDescriptor}} describes the entry point in the user-provi 1. If |entry|.{{GPUBindGroupLayoutEntry/type}} is {{GPUBindingType/"sampled-texture"}}, {{GPUBindingType/"readonly-storage-texture"}}, or {{GPUBindingType/"writeonly-storage-texture"}}, the shader view dimension of the texture has to match |entry|.{{GPUBindGroupLayoutEntry/viewDimension}}. 1. If |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} is not zero: - - if the corresponding structure defined in the shader has the last field being an unbound array type, - then the value of |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} must be greater or equal to the - byte offset of that field plus the stride of the unbound array. - - if the corresponding shader structure doesn't end with an unbound array type, - then the value of |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} must be greater or equal to the + - If the last field of the corresponding structure defined in the shader has an unbounded array type, + then the value of |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} must be greater than or equal to the + byte offset of that field plus the stride of the unbounded array. + - If the corresponding shader structure doesn't end with an unbounded array type, + then the value of |entry|.{{GPUBindGroupLayoutEntry/minBufferBindingSize}} must be greater than or equal to the size of the structure.