Skip to content

Commit 7d78e3c

Browse files
KangzDawn LUCI CQ
authored andcommitted
Stub out the PLS API.
Adds validation that using the additions for PLS is disallowed if the extension is not enabled, along with tests for that validation. Bug: dawn:1704 Change-Id: I93a3357a9e0ab5d3bfc67af7fddda10d30f52c82 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/145884 Reviewed-by: Austin Eng <[email protected]> Commit-Queue: Corentin Wallez <[email protected]> Kokoro: Kokoro <[email protected]>
1 parent b0ea368 commit 7d78e3c

File tree

18 files changed

+255
-4
lines changed

18 files changed

+255
-4
lines changed

dawn.json

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,7 @@
17961796
{"value": 10, "name": "RG11B10 ufloat renderable"},
17971797
{"value": 11, "name": "BGRA8 unorm storage"},
17981798
{"value": 12, "name": "float32 filterable"},
1799+
17991800
{"value": 1002, "name": "dawn internal usages", "tags": ["dawn"]},
18001801
{"value": 1003, "name": "dawn multi planar formats", "tags": ["dawn"]},
18011802
{"value": 1004, "name": "dawn native", "tags": ["dawn", "native"]},
@@ -1811,6 +1812,8 @@
18111812
{"value": 1014, "name": "chromium experimental subgroups", "tags": ["dawn"]},
18121813
{"value": 1015, "name": "chromium experimental subgroup uniform control flow", "tags": ["dawn"]},
18131814
{"value": 1016, "name": "chromium experimental read write storage texture", "tags": ["dawn"]},
1815+
{"value": 1017, "name": "pixel local storage coherent", "tags": ["dawn"]},
1816+
{"value": 1018, "name": "pixel local storage non coherent", "tags": ["dawn"]},
18141817

18151818
{"value": 1100, "name": "shared texture memory vk dedicated allocation", "tags": ["dawn", "native"]},
18161819
{"value": 1101, "name": "shared texture memory a hardware buffer", "tags": ["dawn", "native"]},
@@ -2005,6 +2008,26 @@
20052008
{"name": "bind group layouts", "type": "bind group layout", "annotation": "const*", "length": "bind group layout count"}
20062009
]
20072010
},
2011+
"pipeline layout pixel local storage": {
2012+
"category": "structure",
2013+
"tags": ["dawn"],
2014+
"chained": "in",
2015+
"chain roots": ["pipeline layout descriptor"],
2016+
"members": [
2017+
{"name": "total pixel local storage size", "type": "size_t"},
2018+
{"name": "storage attachment count", "type": "size_t", "default": 0},
2019+
{"name": "storage attachments", "type": "pipeline layout storage attachment", "annotation": "const*", "length": "storage attachment count"}
2020+
]
2021+
},
2022+
"pipeline layout storage attachment": {
2023+
"category": "structure",
2024+
"tags": ["dawn"],
2025+
"extensible": "in",
2026+
"members": [
2027+
{"name": "offset", "type": "uint64_t", "default": 0},
2028+
{"name": "format", "type": "texture format"}
2029+
]
2030+
},
20082031
"pipeline statistic name": {
20092032
"category": "enum",
20102033
"values": [
@@ -2390,6 +2413,29 @@
23902413
{"name": "max draw count", "type": "uint64_t", "default": 50000000}
23912414
]
23922415
},
2416+
"render pass pixel local storage": {
2417+
"category": "structure",
2418+
"tags": ["dawn"],
2419+
"chained": "in",
2420+
"chain roots": ["render pass descriptor"],
2421+
"members": [
2422+
{"name": "total pixel local storage size", "type": "size_t"},
2423+
{"name": "storage attachment count", "type": "size_t", "default": 0},
2424+
{"name": "storage attachments", "type": "render pass storage attachment", "annotation": "const*", "length": "storage attachment count"}
2425+
]
2426+
},
2427+
"render pass storage attachment": {
2428+
"category": "structure",
2429+
"tags": ["dawn"],
2430+
"extensible": "in",
2431+
"members": [
2432+
{"name": "offset", "type": "uint64_t", "default": 0},
2433+
{"name": "storage", "type": "texture view"},
2434+
{"name": "load op", "type": "load op"},
2435+
{"name": "store op", "type": "store op"},
2436+
{"name": "clear value", "type": "color"}
2437+
]
2438+
},
23932439
"render pass encoder": {
23942440
"category": "object",
23952441
"no autolock": true,
@@ -2540,6 +2586,10 @@
25402586
{"name": "query index", "type": "uint32_t"}
25412587
]
25422588
},
2589+
{
2590+
"name": "pixel local storage barrier",
2591+
"tags": ["dawn"]
2592+
},
25432593
{
25442594
"name": "end"
25452595
},
@@ -3008,6 +3058,8 @@
30083058
{"value": 1011, "name": "request adapter options get GL proc", "tags": ["dawn", "native"]},
30093059
{"value": 1012, "name": "dawn multisample state render to single sampled", "tags": ["dawn"]},
30103060
{"value": 1013, "name": "dawn render pass color attachment render to single sampled", "tags": ["dawn"]},
3061+
{"value": 1014, "name": "render pass pixel local storage", "tags": ["dawn"]},
3062+
{"value": 1015, "name": "pipeline layout pixel local storage", "tags": ["dawn"]},
30113063

30123064
{"value": 1100, "name": "shared texture memory vk image descriptor", "tags": ["dawn", "native"]},
30133065
{"value": 1101, "name": "shared texture memory vk dedicated allocation descriptor", "tags": ["dawn", "native"]},
@@ -3251,7 +3303,8 @@
32513303
{"value": 4, "name": "texture binding"},
32523304
{"value": 8, "name": "storage binding"},
32533305
{"value": 16, "name": "render attachment"},
3254-
{"value": 32, "name": "transient attachment", "tags": ["dawn"]}
3306+
{"value": 32, "name": "transient attachment", "tags": ["dawn"]},
3307+
{"value": 64, "name": "storage attachment", "tags": ["dawn"]}
32553308
]
32563309
},
32573310
"texture view descriptor": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO(dawn:1704): Fill out this feature doc once we know what the feature looks like.

src/dawn/native/CommandEncoder.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,9 @@ MaybeError ValidateRenderPassDescriptor(DeviceBase* device,
497497
uint32_t* sampleCount,
498498
uint32_t* implicitSampleCount,
499499
UsageValidationMode usageValidationMode) {
500-
DAWN_TRY(ValidateSingleSType(descriptor->nextInChain,
501-
wgpu::SType::RenderPassDescriptorMaxDrawCount));
500+
DAWN_TRY(
501+
ValidateSTypes(descriptor->nextInChain, {{wgpu::SType::RenderPassDescriptorMaxDrawCount},
502+
{wgpu::SType::RenderPassPixelLocalStorage}}));
502503

503504
uint32_t maxColorAttachments = device->GetLimits().v1.maxColorAttachments;
504505
DAWN_INVALID_IF(
@@ -592,6 +593,14 @@ MaybeError ValidateRenderPassDescriptor(DeviceBase* device,
592593
descriptor->colorAttachmentCount, *implicitSampleCount);
593594
}
594595

596+
const RenderPassPixelLocalStorage* pls = nullptr;
597+
FindInChain(descriptor->nextInChain, &pls);
598+
if (pls != nullptr) {
599+
DAWN_TRY(ValidateHasPLSFeature(device));
600+
601+
// TODO(dawn:1704): Validate limits, formats, offsets don't collide and the total size.
602+
}
603+
595604
return {};
596605
}
597606

src/dawn/native/CommandValidation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,4 +544,13 @@ MaybeError ValidateColorAttachmentBytesPerSample(DeviceBase* device,
544544
return {};
545545
}
546546

547+
MaybeError ValidateHasPLSFeature(const DeviceBase* device) {
548+
DAWN_INVALID_IF(
549+
!(device->HasFeature(Feature::PixelLocalStorageCoherent) ||
550+
device->HasFeature(Feature::PixelLocalStorageNonCoherent)),
551+
"Pixel Local Storage feature used without either of the pixel-local-storage-coherent or "
552+
"pixel-local-storage-non-coherent features enabled.");
553+
return {};
554+
}
555+
547556
} // namespace dawn::native

src/dawn/native/CommandValidation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ using ColorAttachmentFormats = StackVector<const Format*, kMaxColorAttachments>;
9999
MaybeError ValidateColorAttachmentBytesPerSample(DeviceBase* device,
100100
const ColorAttachmentFormats& formats);
101101

102+
MaybeError ValidateHasPLSFeature(const DeviceBase* device);
103+
102104
} // namespace dawn::native
103105

104106
#endif // SRC_DAWN_NATIVE_COMMANDVALIDATION_H_

src/dawn/native/Commands.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ void FreeCommands(CommandIterator* commands) {
125125
cmd->~ClearBufferCmd();
126126
break;
127127
}
128+
case Command::PixelLocalStorageBarrier: {
129+
PixelLocalStorageBarrierCmd* cmd =
130+
commands->NextCommand<PixelLocalStorageBarrierCmd>();
131+
cmd->~PixelLocalStorageBarrierCmd();
132+
break;
133+
}
128134
case Command::InsertDebugMarker: {
129135
InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
130136
commands->NextData<char>(cmd->length + 1);
@@ -288,6 +294,10 @@ void SkipCommand(CommandIterator* commands, Command type) {
288294
commands->NextCommand<ClearBufferCmd>();
289295
break;
290296

297+
case Command::PixelLocalStorageBarrier:
298+
commands->NextCommand<PixelLocalStorageBarrierCmd>();
299+
break;
300+
291301
case Command::InsertDebugMarker: {
292302
InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
293303
commands->NextData<char>(cmd->length + 1);

src/dawn/native/Commands.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enum class Command {
5555
EndRenderPass,
5656
ExecuteBundles,
5757
InsertDebugMarker,
58+
PixelLocalStorageBarrier,
5859
PopDebugGroup,
5960
PushDebugGroup,
6061
ResolveQuerySet,
@@ -266,6 +267,8 @@ struct InsertDebugMarkerCmd {
266267
uint32_t length;
267268
};
268269

270+
struct PixelLocalStorageBarrierCmd {};
271+
269272
struct PopDebugGroupCmd {};
270273

271274
struct PushDebugGroupCmd {

src/dawn/native/Features.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,23 @@ static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {{
157157
"https://chromium.googlesource.com/angle/angle/+/refs/heads/main/extensions/"
158158
"EGL_ANGLE_display_texture_share_group.txt",
159159
FeatureInfo::FeatureState::Stable}},
160+
{Feature::PixelLocalStorageCoherent,
161+
{"pixel-local-storage-coherent",
162+
"Supports passing information between invocation in a render pass that cover the same pixel."
163+
"This helps more efficiently implement algorithms that would otherwise require ping-ponging"
164+
"between render targets. The coherent version of this extension means that no barrier calls"
165+
"are needed to prevent data races between fragment shaders on the same pixel.",
166+
"https://bugs.chromium.org/p/dawn/issues/detail?id=1704",
167+
FeatureInfo::FeatureState::Experimental}},
168+
{Feature::PixelLocalStorageNonCoherent,
169+
{"pixel-local-storage-non-coherent",
170+
"Supports passing information between invocation in a render pass that cover the same pixel."
171+
"This helps more efficiently implement algorithms that would otherwise require ping-ponging"
172+
"between render targets. The non-coherent version of this extension means that barrier calls"
173+
"are needed to prevent data races between fragment shaders on the same pixels (note that "
174+
"overlapping fragments from the same draw cannot be made data race free).",
175+
"https://bugs.chromium.org/p/dawn/issues/detail?id=1704",
176+
FeatureInfo::FeatureState::Experimental}},
160177
{Feature::SharedTextureMemoryVkDedicatedAllocation,
161178
{"shared-texture-memory-vk-dedicated-allocation",
162179
"Support specifying whether a Vulkan allocation for shared texture memory is a dedicated "
@@ -288,6 +305,10 @@ Feature FromAPIFeature(wgpu::FeatureName feature) {
288305
return Feature::D3D11MultithreadProtected;
289306
case wgpu::FeatureName::ANGLETextureSharing:
290307
return Feature::ANGLETextureSharing;
308+
case wgpu::FeatureName::PixelLocalStorageCoherent:
309+
return Feature::PixelLocalStorageCoherent;
310+
case wgpu::FeatureName::PixelLocalStorageNonCoherent:
311+
return Feature::PixelLocalStorageNonCoherent;
291312
case wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation:
292313
return Feature::SharedTextureMemoryVkDedicatedAllocation;
293314
case wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer:
@@ -376,6 +397,10 @@ wgpu::FeatureName ToAPIFeature(Feature feature) {
376397
return wgpu::FeatureName::D3D11MultithreadProtected;
377398
case Feature::ANGLETextureSharing:
378399
return wgpu::FeatureName::ANGLETextureSharing;
400+
case Feature::PixelLocalStorageCoherent:
401+
return wgpu::FeatureName::PixelLocalStorageCoherent;
402+
case Feature::PixelLocalStorageNonCoherent:
403+
return wgpu::FeatureName::PixelLocalStorageNonCoherent;
379404
case Feature::SharedTextureMemoryVkDedicatedAllocation:
380405
return wgpu::FeatureName::SharedTextureMemoryVkDedicatedAllocation;
381406
case Feature::SharedTextureMemoryAHardwareBuffer:

src/dawn/native/Features.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ enum class Feature {
5656
DualSourceBlending,
5757
D3D11MultithreadProtected,
5858
ANGLETextureSharing,
59+
PixelLocalStorageCoherent,
60+
PixelLocalStorageNonCoherent,
5961

6062
SharedTextureMemoryVkDedicatedAllocation,
6163
SharedTextureMemoryAHardwareBuffer,

src/dawn/native/PipelineLayout.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "dawn/common/Numeric.h"
2424
#include "dawn/common/ityp_stack_vec.h"
2525
#include "dawn/native/BindGroupLayout.h"
26+
#include "dawn/native/ChainUtils.h"
27+
#include "dawn/native/CommandValidation.h"
2628
#include "dawn/native/Device.h"
2729
#include "dawn/native/ObjectContentHasher.h"
2830
#include "dawn/native/ObjectType_autogen.h"
@@ -33,7 +35,14 @@ namespace dawn::native {
3335
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase* device,
3436
const PipelineLayoutDescriptor* descriptor,
3537
PipelineCompatibilityToken pipelineCompatibilityToken) {
36-
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain is not nullptr.");
38+
const PipelineLayoutPixelLocalStorage* pls = nullptr;
39+
FindInChain(descriptor->nextInChain, &pls);
40+
if (pls != nullptr) {
41+
DAWN_TRY(ValidateHasPLSFeature(device));
42+
43+
// TODO(dawn:1704): Validate limits, formats, offsets don't collide and the total size.
44+
}
45+
3746
DAWN_INVALID_IF(descriptor->bindGroupLayoutCount > kMaxBindGroups,
3847
"bindGroupLayoutCount (%i) is larger than the maximum allowed (%i).",
3948
descriptor->bindGroupLayoutCount, kMaxBindGroups);

0 commit comments

Comments
 (0)