[Vulkan] Rename STMVkProperties to STMAHBProperties
All of these properties are for the AHB (including the format flags,
which we will be adding in a followup). Following discussion with Austin
we are doing the rename and requiring that the
SharedTextureMemoryAHardwareBuffer feature be set when chaining this
struct.
Bug: dawn:2476
Change-Id: I71fc894aa420edc5875982e4ec3e7ab7220b5ada
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/188560
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index 2167b30..b1366b8 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -1919,7 +1919,7 @@
{"name": "format", "type": "texture format"}
]
},
- "shared texture memory vk properties": {
+ "shared texture memory a hardware buffer properties": {
"category": "structure",
"chained": "out",
"chain roots": ["shared texture memory properties"],
@@ -3817,7 +3817,7 @@
{"value": 1215, "name": "shared buffer memory D3D12 resource descriptor", "tags": ["dawn", "native"]},
{"value": 1216, "name": "static sampler binding layout", "tags": ["dawn"]},
{"value": 1217, "name": "y cb cr vk descriptor", "tags": ["dawn"]},
- {"value": 1218, "name": "shared texture memory vk properties", "tags": ["dawn", "native"]}
+ {"value": 1218, "name": "shared texture memory a hardware buffer properties", "tags": ["dawn", "native"]}
]
},
"texture": {
diff --git a/src/dawn/native/SharedTextureMemory.cpp b/src/dawn/native/SharedTextureMemory.cpp
index ef3691f..3c715bd 100644
--- a/src/dawn/native/SharedTextureMemory.cpp
+++ b/src/dawn/native/SharedTextureMemory.cpp
@@ -107,15 +107,28 @@
}
void SharedTextureMemoryBase::APIGetProperties(SharedTextureMemoryProperties* properties) const {
+ if (GetDevice()->ConsumedError(GetProperties(properties), "calling %s.GetProperties", this)) {
+ return;
+ }
+}
+
+MaybeError SharedTextureMemoryBase::GetProperties(SharedTextureMemoryProperties* properties) const {
properties->usage = mProperties.usage;
properties->size = mProperties.size;
properties->format = mProperties.format;
UnpackedPtr<SharedTextureMemoryProperties> unpacked;
- if (GetDevice()->ConsumedError(ValidateAndUnpack(properties), &unpacked,
- "calling %s.GetProperties", this)) {
- return;
+ DAWN_TRY_ASSIGN(unpacked, ValidateAndUnpack(properties));
+
+ if (unpacked.Get<SharedTextureMemoryAHardwareBufferProperties>()) {
+ DAWN_INVALID_IF(
+ !GetDevice()->HasFeature(Feature::SharedTextureMemoryAHardwareBuffer),
+ "SharedTextureMemory properties (%s) have a chained "
+ "SharedTextureMemoryAHardwareBufferProperties without the %s feature being set.",
+ this, ToAPI(Feature::SharedTextureMemoryAHardwareBuffer));
}
+
+ return {};
}
TextureBase* SharedTextureMemoryBase::APICreateTexture(const TextureDescriptor* descriptor) {
diff --git a/src/dawn/native/SharedTextureMemory.h b/src/dawn/native/SharedTextureMemory.h
index 1346231..0455e01 100644
--- a/src/dawn/native/SharedTextureMemory.h
+++ b/src/dawn/native/SharedTextureMemory.h
@@ -70,6 +70,7 @@
private:
ResultOrError<Ref<TextureBase>> CreateTexture(const TextureDescriptor* rawDescriptor);
+ MaybeError GetProperties(SharedTextureMemoryProperties* properties) const;
virtual ResultOrError<Ref<TextureBase>> CreateTextureImpl(
const UnpackedPtr<TextureDescriptor>& descriptor) = 0;
diff --git a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
index 534487c..325ae01 100644
--- a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
+++ b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
@@ -1021,6 +1021,33 @@
EXPECT_EQ(properties1.format, properties2.format);
}
+// Test that calling GetProperties with a chained
+// SharedTextureMemoryAHardwareBufferProperties struct will generate an error
+// unless the required feature is present. In either case, the base properties
+// should still be populated.
+TEST_P(SharedTextureMemoryTests, GetPropertiesAHardwareBufferPropertiesRequiresAHBFeature) {
+ wgpu::SharedTextureMemory memory =
+ GetParam().mBackend->CreateSharedTextureMemory(device, GetParam().mLayerCount);
+
+ wgpu::SharedTextureMemoryAHardwareBufferProperties aHBProps;
+ wgpu::SharedTextureMemoryProperties properties1;
+ properties1.nextInChain = &aHBProps;
+ if (device.HasFeature(wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer)) {
+ memory.GetProperties(&properties1);
+ } else {
+ ASSERT_DEVICE_ERROR(memory.GetProperties(&properties1));
+ }
+
+ wgpu::SharedTextureMemoryProperties properties2;
+ memory.GetProperties(&properties2);
+
+ EXPECT_EQ(properties1.usage, properties2.usage);
+ EXPECT_EQ(properties1.size.width, properties2.size.width);
+ EXPECT_EQ(properties1.size.height, properties2.size.height);
+ EXPECT_EQ(properties1.size.depthOrArrayLayers, properties2.size.depthOrArrayLayers);
+ EXPECT_EQ(properties1.format, properties2.format);
+}
+
// Test that texture usages must be a subset of the shared texture memory's usage.
TEST_P(SharedTextureMemoryTests, UsageValidation) {
for (wgpu::SharedTextureMemory memory :