Implement wrapping IOSurfaces in dawn::Texture.

This allows wrapping IOSurfaces in a dawn::Texture so a Dawn application
can sample from, or render to an IOSurface. It uses Metal's
functionality for wrapping textures in MTLTexture.

Support for single-plane BGRA8, RG8 and R8 IOSurfaces is added as well
as tests for sampling and using BeginRenderPass to clear them.

BUG=dawn:112

Change-Id: I367dbd1a75a0c7b81901fb0aae05f1cd46af3f3a
Reviewed-on: https://dawn-review.googlesource.com/c/5101
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez
2019-03-01 12:01:18 +00:00
committed by Commit Bot service account
parent 2dfb3f01e7
commit 0cdf9e09c4
8 changed files with 592 additions and 39 deletions

View File

@@ -18,10 +18,24 @@
#include <dawn/dawn_wsi.h>
#include <dawn_native/DawnNative.h>
#import <Metal/Metal.h>
struct __IOSurface;
typedef __IOSurface* IOSurfaceRef;
#ifdef __OBJC__
# import <Metal/Metal.h>
#endif //__OBJC__
namespace dawn_native { namespace metal {
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(dawnDevice device);
DAWN_NATIVE_EXPORT dawnTexture WrapIOSurface(dawnDevice device,
const dawnTextureDescriptor* descriptor,
IOSurfaceRef ioSurface,
uint32_t plane);
}} // namespace dawn_native::metal
#ifdef __OBJC__
namespace dawn_native { namespace metal {
DAWN_NATIVE_EXPORT id<MTLDevice> GetMetalDevice(dawnDevice device);
}} // namespace dawn_native::metal
#endif // __OBJC__
#endif // DAWNNATIVE_METALBACKEND_H_