WrapIOSurface: Add support for RGBA8

BUG=dawn:112

Change-Id: I18d2e8bc0bcca2725f2087913955c8ecadbd5852
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9642
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Idan Raiter <idanr@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2019-08-01 17:58:05 +00:00 committed by Commit Bot service account
parent 351ea23830
commit 56f3a7b90d
2 changed files with 22 additions and 1 deletions

View File

@ -109,6 +109,8 @@ namespace dawn_native { namespace metal {
ResultOrError<dawn::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) {
switch (format) {
case 'RGBA':
return dawn::TextureFormat::RGBA8Unorm;
case 'BGRA':
return dawn::TextureFormat::BGRA8Unorm;
case '2C08':

View File

@ -407,7 +407,7 @@ TEST_P(IOSurfaceUsageTests, ClearRG8IOSurface) {
}
// Test sampling from a BGRA8 IOSurface
TEST_P(IOSurfaceUsageTests, SampleFromBGRA8888IOSurface) {
TEST_P(IOSurfaceUsageTests, SampleFromBGRA8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'BGRA', 4);
@ -425,5 +425,24 @@ TEST_P(IOSurfaceUsageTests, ClearBGRA8IOSurface) {
DoClearTest(ioSurface.get(), dawn::TextureFormat::BGRA8Unorm, &data, sizeof(data));
}
// Test sampling from an RGBA8 IOSurface
TEST_P(IOSurfaceUsageTests, SampleFromRGBA8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'RGBA', 4);
uint32_t data = 0x01020304; // Stored as (A, B, G, R)
DoSampleTest(ioSurface.get(), dawn::TextureFormat::RGBA8Unorm, &data, sizeof(data),
RGBA8(4, 3, 2, 1));
}
// Test clearing an RGBA8 IOSurface
TEST_P(IOSurfaceUsageTests, ClearRGBA8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'RGBA', 4);
uint32_t data = 0x04030201;
DoClearTest(ioSurface.get(), dawn::TextureFormat::RGBA8Unorm, &data, sizeof(data));
}
DAWN_INSTANTIATE_TEST(IOSurfaceValidationTests, MetalBackend);
DAWN_INSTANTIATE_TEST(IOSurfaceUsageTests, MetalBackend);