Commit 3dddccff by Jeff Gilbert Committed by Commit Bot

Support RGB gl-tex-external stream consumers for StreamProducerNV12.

This makes it relatively simple to sample from a D3D11Texture of arbitrary format. From: https://bugzilla.mozilla.org/show_bug.cgi?id=1322746 BUG=angleproject:2233 TEST=angle_end2end_tests Change-Id: I10cd3043b5cb0c5d36dd613467ba6c0ceadf41af Reviewed-on: https://chromium-review.googlesource.com/758042 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 614dd0f5
Name Name
ANGLE_stream_producer_d3d_texture_nv12 ANGLE_stream_producer_d3d_texture
Name Strings Name Strings
EGL_ANGLE_stream_producer_d3d_texture_nv12 EGL_ANGLE_stream_producer_d3d_texture
Contributors Contributors
Ian Ewell Ian Ewell
Geoff Lang Geoff Lang
John Bauman John Bauman
Jeff Gilbert
Contacts Contacts
...@@ -22,7 +23,7 @@ Status ...@@ -22,7 +23,7 @@ Status
Version Version
Version 1, April 6, 2016 Version 2, November 15, 2017
Number Number
...@@ -30,34 +31,36 @@ Number ...@@ -30,34 +31,36 @@ Number
Dependencies Dependencies
Requires EGL 1.5. Requires EGL 1.4.
Requires OpenGL ES 2.0. Requires OpenGL ES 2.0.
Requires the EGL_KHR_stream extension. Requires the EGL_KHR_stream extension.
Requires the EGL_NV_stream_consumer_gltexture_yuv extension. Requires the EGL_NV_stream_consumer_gltexture_yuv extension.
Requires the EGL_KHR_stream_consumer_gltexture extension.
Requires the EGL_ANGLE_device_d3d extension. Requires the EGL_ANGLE_device_d3d extension.
Overview Overview
This extension allows D3D11 NV12 textures to be inserted into an EGL stream This extension allows D3D11 textures to be inserted into an EGL stream
with the expectation that the stream consumer will be a YUV GL texture with the expectation that the stream consumer will be either an RGB GL
consumer using a two plane configuration (i.e. a Y plane and a UV plane). texture consumer, or a YUV GL texture consumer using a two plane
configuration (i.e. a Y plane and a UV plane).
This will act as the producer of the stream. This will act as the producer of the stream.
New procedures and functions New procedures and functions
EGLBoolean eglCreateStreamProducerD3DTextureNV12ANGLE EGLBoolean eglCreateStreamProducerD3DTextureANGLE(
(EGLDisplay dpy, EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
EGLBoolean eglStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLBoolean eglStreamPostD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
void *texture, void *texture,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
New Tokens New Tokens
Accepted as an <attribute> in eglStreamPostD3DTextureNV12ANGLE: Accepted as an <attribute> in eglStreamPostD3DTextureANGLE:
EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x33AB EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x33AB
...@@ -68,25 +71,24 @@ EGL_KHR_stream extension with this: ...@@ -68,25 +71,24 @@ EGL_KHR_stream extension with this:
Call Call
EGLBoolean eglCreateStreamProducerD3DTextureNV12ANGLE( EGLBoolean eglCreateStreamProducerD3DTextureANGLE(
EGLDisplay dpy, EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
to create a producer that accepts D3D11 NV12 textures and connect it as the to create a producer that accepts D3D11 textures and connect it as the
producer of <stream>. <attrib_list> is used to specify attributes for the producer of <stream>. <attrib_list> is used to specify attributes for the
stream producer. Currently there are no attributes to specify, and the stream producer. Currently there are no attributes to specify, and the
attribute list is used as a placeholder for future additions. attribute list is used as a placeholder for future additions.
On failure, eglCreateStreamProducerD3DTextureNV12ANGLE returns EGL_FALSE and On failure, eglCreateStreamProducerD3DTextureANGLE returns EGL_FALSE and
generates an error. generates an error.
- EGL_BAD_STATE_KHR is generated if <stream> is not in the state - EGL_BAD_STATE_KHR is generated if <stream> is not in the state
EGL_STREAM_STATE_CONNECTING_KHR. EGL_STREAM_STATE_CONNECTING_KHR.
- EGL_BAD_MATCH is generated if <stream> does not have a connected GL - EGL_BAD_MATCH is generated if <stream> does not have a connected GL
texture YUV consumer that is configured to bind to two OpenGL texture consumer.
textures: one for the Y plane and one for the UV plane.
- EGL_BAD_STREAM_KHR is generated if <stream> is not a valid EGLStream - EGL_BAD_STREAM_KHR is generated if <stream> is not a valid EGLStream
generated for <dpy>. generated for <dpy>.
...@@ -98,16 +100,16 @@ Add a section preceding "3.9.3 Posting Semantics" in the EGL specification: ...@@ -98,16 +100,16 @@ Add a section preceding "3.9.3 Posting Semantics" in the EGL specification:
3.9.x Posting to a Stream 3.9.x Posting to a Stream
To post a D3D11 NV12 texture to a stream, call To post a D3D11 texture to a stream, call
EGLBoolean eglStreamPostD3DTextureNV12ANGLE( EGLBoolean eglStreamPostD3DTextureANGLE(
EGLDisplay dpy, EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
void *texture, void *texture,
const EGLAttrib *attrib_list); const EGLAttrib *attrib_list);
If <stream> is an appropriately configured stream and <texture> points to a If <stream> is an appropriately configured stream and <texture> points to a
valid ID3D11Texture2D object of the format DXGI_FORMAT_NV12 that is owned valid ID3D11Texture2D object of a supported format that is owned
by the same ID3D11Device that is queried with the EGL_ANGLE_device_d3d by the same ID3D11Device that is queried with the EGL_ANGLE_device_d3d
extension, the texture will be posted to the stream and can be bound as one extension, the texture will be posted to the stream and can be bound as one
or more OpenGL texture objects. or more OpenGL texture objects.
...@@ -129,7 +131,7 @@ Add a section preceding "3.9.3 Posting Semantics" in the EGL specification: ...@@ -129,7 +131,7 @@ Add a section preceding "3.9.3 Posting Semantics" in the EGL specification:
insertion is successful and will release the texture object when a new frame insertion is successful and will release the texture object when a new frame
is inserted or when the stream is destroyed. is inserted or when the stream is destroyed.
On failure, eglStreamInsertD3DTextureNV12 returns EGL_FALSE and generates an On failure, eglStreamInsertD3DTexture returns EGL_FALSE and generates an
error. error.
- EGL_BAD_STATE is generated if <stream> is not in the state - EGL_BAD_STATE is generated if <stream> is not in the state
...@@ -137,11 +139,11 @@ Add a section preceding "3.9.3 Posting Semantics" in the EGL specification: ...@@ -137,11 +139,11 @@ Add a section preceding "3.9.3 Posting Semantics" in the EGL specification:
or EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR. or EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR.
- EGL_BAD_MATCH is generated if the stream is not associated with a - EGL_BAD_MATCH is generated if the stream is not associated with a
D3D11 NV12 texture producer. D3D11 texture producer.
- EGL_BAD_PARAMETER is generated if <texture> is not owned by the - EGL_BAD_PARAMETER is generated if <texture> is not owned by the
queried device, is not in the format DXGI_FORMAT_NV12, is not queried device, is not a supported format, is not compatible with the
compatible with the implementation, or if the specified value for implementation, or if the specified value for
EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE is not a valid subresource id for EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE is not a valid subresource id for
the texture. the texture.
...@@ -154,3 +156,10 @@ Revision History ...@@ -154,3 +156,10 @@ Revision History
#1 (April 6, 2016) Ian Ewell #1 (April 6, 2016) Ian Ewell
- initial draft - initial draft
#2 (November 15, 2017) Jeff Gilbert
- Rename from EGL_ANGLE_stream_producer_d3d_texture_nv12 to
EGL_ANGLE_stream_producer_d3d_texture
- Remove NV12 suffix from function names
- add RGB GL texture consumer support
- reduce required EGL version to 1.4 (from 1.5)
...@@ -105,16 +105,16 @@ ...@@ -105,16 +105,16 @@
#define EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE 0x33AA #define EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE 0x33AA
#endif /* EGL_ANGLE_experimental_present_path */ #endif /* EGL_ANGLE_experimental_present_path */
#ifndef EGL_ANGLE_stream_producer_d3d_texture_nv12 #ifndef EGL_ANGLE_stream_producer_d3d_texture
#define EGL_ANGLE_stream_producer_d3d_texture_nv12 #define EGL_ANGLE_stream_producer_d3d_texture
#define EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x33AB #define EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x33AB
typedef EGLBoolean(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERD3DTEXTURENV12ANGLEPROC)(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); typedef EGLBoolean(EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERD3DTEXTUREANGLEPROC)(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMPOSTD3DTEXTURENV12ANGLEPROC)(EGLDisplay dpy, EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list); typedef EGLBoolean(EGLAPIENTRYP PFNEGLSTREAMPOSTD3DTEXTUREANGLEPROC)(EGLDisplay dpy, EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list);
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglCreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglCreateStreamProducerD3DTextureANGLE(EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglStreamPostD3DTextureANGLE(EGLDisplay dpy, EGLStreamKHR stream, void *texture, const EGLAttrib *attrib_list);
#endif #endif
#endif /* EGL_ANGLE_stream_producer_d3d_texture_nv12 */ #endif /* EGL_ANGLE_stream_producer_d3d_texture */
#ifndef EGL_ANGLE_create_context_webgl_compatibility #ifndef EGL_ANGLE_create_context_webgl_compatibility
#define EGL_ANGLE_create_context_webgl_compatibility 1 #define EGL_ANGLE_create_context_webgl_compatibility 1
......
...@@ -1141,7 +1141,7 @@ DisplayExtensions::DisplayExtensions() ...@@ -1141,7 +1141,7 @@ DisplayExtensions::DisplayExtensions()
stream(false), stream(false),
streamConsumerGLTexture(false), streamConsumerGLTexture(false),
streamConsumerGLTextureYUV(false), streamConsumerGLTextureYUV(false),
streamProducerD3DTextureNV12(false), streamProducerD3DTexture(false),
createContextWebGLCompatibility(false), createContextWebGLCompatibility(false),
createContextBindGeneratesResource(false), createContextBindGeneratesResource(false),
getSyncValues(false), getSyncValues(false),
...@@ -1185,7 +1185,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const ...@@ -1185,7 +1185,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_KHR_stream_consumer_gltexture", streamConsumerGLTexture, &extensionStrings); InsertExtensionString("EGL_KHR_stream_consumer_gltexture", streamConsumerGLTexture, &extensionStrings);
InsertExtensionString("EGL_NV_stream_consumer_gltexture_yuv", streamConsumerGLTextureYUV, &extensionStrings); InsertExtensionString("EGL_NV_stream_consumer_gltexture_yuv", streamConsumerGLTextureYUV, &extensionStrings);
InsertExtensionString("EGL_ANGLE_flexible_surface_compatibility", flexibleSurfaceCompatibility, &extensionStrings); InsertExtensionString("EGL_ANGLE_flexible_surface_compatibility", flexibleSurfaceCompatibility, &extensionStrings);
InsertExtensionString("EGL_ANGLE_stream_producer_d3d_texture_nv12", streamProducerD3DTextureNV12, &extensionStrings); InsertExtensionString("EGL_ANGLE_stream_producer_d3d_texture", streamProducerD3DTexture, &extensionStrings);
InsertExtensionString("EGL_ANGLE_create_context_webgl_compatibility", createContextWebGLCompatibility, &extensionStrings); InsertExtensionString("EGL_ANGLE_create_context_webgl_compatibility", createContextWebGLCompatibility, &extensionStrings);
InsertExtensionString("EGL_CHROMIUM_create_context_bind_generates_resource", createContextBindGeneratesResource, &extensionStrings); InsertExtensionString("EGL_CHROMIUM_create_context_bind_generates_resource", createContextBindGeneratesResource, &extensionStrings);
InsertExtensionString("EGL_CHROMIUM_sync_control", getSyncValues, &extensionStrings); InsertExtensionString("EGL_CHROMIUM_sync_control", getSyncValues, &extensionStrings);
......
...@@ -678,8 +678,8 @@ struct DisplayExtensions ...@@ -678,8 +678,8 @@ struct DisplayExtensions
// EGL_NV_stream_consumer_gltexture_yuv // EGL_NV_stream_consumer_gltexture_yuv
bool streamConsumerGLTextureYUV; bool streamConsumerGLTextureYUV;
// EGL_ANGLE_stream_producer_d3d_texture_nv12 // EGL_ANGLE_stream_producer_d3d_texture
bool streamProducerD3DTextureNV12; bool streamProducerD3DTexture;
// EGL_ANGLE_create_context_webgl_compatibility // EGL_ANGLE_create_context_webgl_compatibility
bool createContextWebGLCompatibility; bool createContextWebGLCompatibility;
......
...@@ -160,16 +160,16 @@ Error Stream::createConsumerGLTextureExternal(const AttributeMap &attributes, gl ...@@ -160,16 +160,16 @@ Error Stream::createConsumerGLTextureExternal(const AttributeMap &attributes, gl
return NoError(); return NoError();
} }
Error Stream::createProducerD3D11TextureNV12(const AttributeMap &attributes) Error Stream::createProducerD3D11Texture(const AttributeMap &attributes)
{ {
ASSERT(mState == EGL_STREAM_STATE_CONNECTING_KHR); ASSERT(mState == EGL_STREAM_STATE_CONNECTING_KHR);
ASSERT(mConsumerType == ConsumerType::GLTextureYUV); ASSERT(mConsumerType == ConsumerType::GLTextureRGB ||
mConsumerType == ConsumerType::GLTextureYUV);
ASSERT(mProducerType == ProducerType::NoProducer); ASSERT(mProducerType == ProducerType::NoProducer);
ASSERT(mPlaneCount == 2);
mProducerImplementation = mDisplay->getImplementation()->createStreamProducerD3DTextureNV12( mProducerImplementation =
mConsumerType, attributes); mDisplay->getImplementation()->createStreamProducerD3DTexture(mConsumerType, attributes);
mProducerType = ProducerType::D3D11TextureNV12; mProducerType = ProducerType::D3D11Texture;
mState = EGL_STREAM_STATE_EMPTY_KHR; mState = EGL_STREAM_STATE_EMPTY_KHR;
return NoError(); return NoError();
...@@ -182,7 +182,7 @@ Error Stream::consumerAcquire(const gl::Context *context) ...@@ -182,7 +182,7 @@ Error Stream::consumerAcquire(const gl::Context *context)
mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR); mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR);
ASSERT(mConsumerType == ConsumerType::GLTextureRGB || ASSERT(mConsumerType == ConsumerType::GLTextureRGB ||
mConsumerType == ConsumerType::GLTextureYUV); mConsumerType == ConsumerType::GLTextureYUV);
ASSERT(mProducerType == ProducerType::D3D11TextureNV12); ASSERT(mProducerType == ProducerType::D3D11Texture);
mState = EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR; mState = EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR;
mConsumerFrame++; mConsumerFrame++;
...@@ -206,7 +206,7 @@ Error Stream::consumerRelease(const gl::Context *context) ...@@ -206,7 +206,7 @@ Error Stream::consumerRelease(const gl::Context *context)
mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR); mState == EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR);
ASSERT(mConsumerType == ConsumerType::GLTextureRGB || ASSERT(mConsumerType == ConsumerType::GLTextureRGB ||
mConsumerType == ConsumerType::GLTextureYUV); mConsumerType == ConsumerType::GLTextureYUV);
ASSERT(mProducerType == ProducerType::D3D11TextureNV12); ASSERT(mProducerType == ProducerType::D3D11Texture);
// Release the images // Release the images
for (int i = 0; i < mPlaneCount; i++) for (int i = 0; i < mPlaneCount; i++)
...@@ -226,23 +226,23 @@ bool Stream::isConsumerBoundToContext(const gl::Context *context) const ...@@ -226,23 +226,23 @@ bool Stream::isConsumerBoundToContext(const gl::Context *context) const
return (context == mContext); return (context == mContext);
} }
Error Stream::validateD3D11NV12Texture(void *texture) const Error Stream::validateD3D11Texture(void *texture, const AttributeMap &attributes) const
{ {
ASSERT(mConsumerType == ConsumerType::GLTextureRGB || ASSERT(mConsumerType == ConsumerType::GLTextureRGB ||
mConsumerType == ConsumerType::GLTextureYUV); mConsumerType == ConsumerType::GLTextureYUV);
ASSERT(mProducerType == ProducerType::D3D11TextureNV12); ASSERT(mProducerType == ProducerType::D3D11Texture);
ASSERT(mProducerImplementation != nullptr); ASSERT(mProducerImplementation != nullptr);
return mProducerImplementation->validateD3DNV12Texture(texture); return mProducerImplementation->validateD3DTexture(texture, attributes);
} }
Error Stream::postD3D11NV12Texture(void *texture, const AttributeMap &attributes) Error Stream::postD3D11Texture(void *texture, const AttributeMap &attributes)
{ {
ASSERT(mConsumerType == ConsumerType::GLTextureRGB || ASSERT(mConsumerType == ConsumerType::GLTextureRGB ||
mConsumerType == ConsumerType::GLTextureYUV); mConsumerType == ConsumerType::GLTextureYUV);
ASSERT(mProducerType == ProducerType::D3D11TextureNV12); ASSERT(mProducerType == ProducerType::D3D11Texture);
mProducerImplementation->postD3DNV12Texture(texture, attributes); mProducerImplementation->postD3DTexture(texture, attributes);
mProducerFrame++; mProducerFrame++;
mState = EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR; mState = EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR;
......
...@@ -51,7 +51,7 @@ class Stream final : angle::NonCopyable ...@@ -51,7 +51,7 @@ class Stream final : angle::NonCopyable
enum class ProducerType enum class ProducerType
{ {
NoProducer, NoProducer,
D3D11TextureNV12, D3D11Texture,
}; };
// A GL texture interpretation of a part of a producer frame. For use with GL texture consumers // A GL texture interpretation of a part of a producer frame. For use with GL texture consumers
...@@ -85,7 +85,7 @@ class Stream final : angle::NonCopyable ...@@ -85,7 +85,7 @@ class Stream final : angle::NonCopyable
Error createConsumerGLTextureExternal(const AttributeMap &attributes, gl::Context *context); Error createConsumerGLTextureExternal(const AttributeMap &attributes, gl::Context *context);
// Producer creation methods // Producer creation methods
Error createProducerD3D11TextureNV12(const AttributeMap &attributes); Error createProducerD3D11Texture(const AttributeMap &attributes);
// Consumer methods // Consumer methods
Error consumerAcquire(const gl::Context *context); Error consumerAcquire(const gl::Context *context);
...@@ -96,8 +96,8 @@ class Stream final : angle::NonCopyable ...@@ -96,8 +96,8 @@ class Stream final : angle::NonCopyable
bool isConsumerBoundToContext(const gl::Context *context) const; bool isConsumerBoundToContext(const gl::Context *context) const;
// Producer methods // Producer methods
Error validateD3D11NV12Texture(void *texture) const; Error validateD3D11Texture(void *texture, const AttributeMap &attributes) const;
Error postD3D11NV12Texture(void *texture, const AttributeMap &attributes); Error postD3D11Texture(void *texture, const AttributeMap &attributes);
private: private:
// Associated display // Associated display
......
...@@ -58,7 +58,7 @@ class EGLImplFactory : angle::NonCopyable ...@@ -58,7 +58,7 @@ class EGLImplFactory : angle::NonCopyable
virtual ContextImpl *createContext(const gl::ContextState &state) = 0; virtual ContextImpl *createContext(const gl::ContextState &state) = 0;
virtual StreamProducerImpl *createStreamProducerD3DTextureNV12( virtual StreamProducerImpl *createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) = 0; const egl::AttributeMap &attribs) = 0;
}; };
......
...@@ -23,11 +23,12 @@ class StreamProducerImpl : angle::NonCopyable ...@@ -23,11 +23,12 @@ class StreamProducerImpl : angle::NonCopyable
// Validates the ability for the producer to accept an arbitrary pointer to a frame. All // Validates the ability for the producer to accept an arbitrary pointer to a frame. All
// pointers should be validated through this function before being used to produce a frame. // pointers should be validated through this function before being used to produce a frame.
virtual egl::Error validateD3DNV12Texture(void *pointer) const = 0; virtual egl::Error validateD3DTexture(void *pointer,
const egl::AttributeMap &attributes) const = 0;
// Constructs a frame from an arbitrary external pointer that points to producer specific frame // Constructs a frame from an arbitrary external pointer that points to producer specific frame
// data. Replaces the internal frame with the new one. // data. Replaces the internal frame with the new one.
virtual void postD3DNV12Texture(void *pointer, const egl::AttributeMap &attributes) = 0; virtual void postD3DTexture(void *pointer, const egl::AttributeMap &attributes) = 0;
// Returns an OpenGL texture interpretation of some frame attributes for the purpose of // Returns an OpenGL texture interpretation of some frame attributes for the purpose of
// constructing an OpenGL texture from a frame. Depending on the producer and consumer, some // constructing an OpenGL texture from a frame. Depending on the producer and consumer, some
......
...@@ -206,12 +206,12 @@ ContextImpl *DisplayD3D::createContext(const gl::ContextState &state) ...@@ -206,12 +206,12 @@ ContextImpl *DisplayD3D::createContext(const gl::ContextState &state)
return mRenderer->createContext(state); return mRenderer->createContext(state);
} }
StreamProducerImpl *DisplayD3D::createStreamProducerD3DTextureNV12( StreamProducerImpl *DisplayD3D::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
ASSERT(mRenderer != nullptr); ASSERT(mRenderer != nullptr);
return mRenderer->createStreamProducerD3DTextureNV12(consumerType, attribs); return mRenderer->createStreamProducerD3DTexture(consumerType, attribs);
} }
egl::Error DisplayD3D::makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) egl::Error DisplayD3D::makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context)
......
...@@ -44,8 +44,7 @@ class DisplayD3D : public DisplayImpl ...@@ -44,8 +44,7 @@ class DisplayD3D : public DisplayImpl
ContextImpl *createContext(const gl::ContextState &state) override; ContextImpl *createContext(const gl::ContextState &state) override;
StreamProducerImpl *createStreamProducerD3DTextureNV12( StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override; egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override;
......
...@@ -283,7 +283,7 @@ class RendererD3D : public BufferFactoryD3D, public MultisampleTextureInitialize ...@@ -283,7 +283,7 @@ class RendererD3D : public BufferFactoryD3D, public MultisampleTextureInitialize
bool presentPathFastEnabled() const { return mPresentPathFastEnabled; } bool presentPathFastEnabled() const { return mPresentPathFastEnabled; }
// Stream creation // Stream creation
virtual StreamProducerImpl *createStreamProducerD3DTextureNV12( virtual StreamProducerImpl *createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) = 0; const egl::AttributeMap &attribs) = 0;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include "libANGLE/renderer/d3d/d3d11/Query11.h" #include "libANGLE/renderer/d3d/d3d11/Query11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/ShaderExecutable11.h" #include "libANGLE/renderer/d3d/d3d11/ShaderExecutable11.h"
#include "libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h" #include "libANGLE/renderer/d3d/d3d11/StreamProducerD3DTexture.h"
#include "libANGLE/renderer/d3d/d3d11/SwapChain11.h" #include "libANGLE/renderer/d3d/d3d11/SwapChain11.h"
#include "libANGLE/renderer/d3d/d3d11/TextureStorage11.h" #include "libANGLE/renderer/d3d/d3d11/TextureStorage11.h"
#include "libANGLE/renderer/d3d/d3d11/TransformFeedback11.h" #include "libANGLE/renderer/d3d/d3d11/TransformFeedback11.h"
...@@ -1204,11 +1204,7 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions ...@@ -1204,11 +1204,7 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions
outExtensions->stream = true; outExtensions->stream = true;
outExtensions->streamConsumerGLTexture = true; outExtensions->streamConsumerGLTexture = true;
outExtensions->streamConsumerGLTextureYUV = true; outExtensions->streamConsumerGLTextureYUV = true;
// Not all D3D11 devices support NV12 textures outExtensions->streamProducerD3DTexture = true;
if (getNV12TextureSupport())
{
outExtensions->streamProducerD3DTextureNV12 = true;
}
outExtensions->flexibleSurfaceCompatibility = true; outExtensions->flexibleSurfaceCompatibility = true;
outExtensions->directComposition = !!mDCompModule; outExtensions->directComposition = !!mDCompModule;
...@@ -2305,18 +2301,6 @@ bool Renderer11::getShareHandleSupport() const ...@@ -2305,18 +2301,6 @@ bool Renderer11::getShareHandleSupport() const
return true; return true;
} }
bool Renderer11::getNV12TextureSupport() const
{
HRESULT result;
UINT formatSupport;
result = mDevice->CheckFormatSupport(DXGI_FORMAT_NV12, &formatSupport);
if (result == E_FAIL)
{
return false;
}
return (formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0;
}
int Renderer11::getMajorShaderModel() const int Renderer11::getMajorShaderModel() const
{ {
switch (mRenderer11DeviceCaps.featureLevel) switch (mRenderer11DeviceCaps.featureLevel)
...@@ -2996,11 +2980,11 @@ IndexBuffer *Renderer11::createIndexBuffer() ...@@ -2996,11 +2980,11 @@ IndexBuffer *Renderer11::createIndexBuffer()
return new IndexBuffer11(this); return new IndexBuffer11(this);
} }
StreamProducerImpl *Renderer11::createStreamProducerD3DTextureNV12( StreamProducerImpl *Renderer11::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
return new StreamProducerNV12(this); return new StreamProducerD3DTexture(this);
} }
bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const bool Renderer11::supportsFastCopyBufferToTexture(GLenum internalFormat) const
......
...@@ -164,8 +164,6 @@ class Renderer11 : public RendererD3D ...@@ -164,8 +164,6 @@ class Renderer11 : public RendererD3D
bool getShareHandleSupport() const; bool getShareHandleSupport() const;
bool getNV12TextureSupport() const;
int getMajorShaderModel() const override; int getMajorShaderModel() const override;
int getMinorShaderModel() const override; int getMinorShaderModel() const override;
std::string getShaderModelSuffix() const override; std::string getShaderModelSuffix() const override;
...@@ -299,8 +297,7 @@ class Renderer11 : public RendererD3D ...@@ -299,8 +297,7 @@ class Renderer11 : public RendererD3D
IndexBuffer *createIndexBuffer() override; IndexBuffer *createIndexBuffer() override;
// Stream Creation // Stream Creation
StreamProducerImpl *createStreamProducerD3DTextureNV12( StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
// D3D11-renderer specific methods // D3D11-renderer specific methods
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// StreamProducerNV12.cpp: Implements the stream producer for NV12 textures // StreamProducerD3DTexture.cpp: Implements the stream producer for D3D11 textures
#include "libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h" #include "libANGLE/renderer/d3d/d3d11/StreamProducerD3DTexture.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
...@@ -15,17 +15,81 @@ ...@@ -15,17 +15,81 @@
namespace rx namespace rx
{ {
StreamProducerNV12::StreamProducerNV12(Renderer11 *renderer) namespace
: mRenderer(renderer), mTexture(nullptr), mArraySlice(0), mTextureWidth(0), mTextureHeight(0)
{ {
egl::Error GetGLDescFromTex(ID3D11Texture2D *const tex,
const UINT planeIndex,
egl::Stream::GLTextureDescription *const out)
{
if (!tex)
return egl::EglBadParameter() << "Texture is null";
D3D11_TEXTURE2D_DESC desc;
tex->GetDesc(&desc);
if (desc.Width < 1 || desc.Height < 1)
return egl::EglBadParameter() << "Width or height < 1";
out->width = desc.Width;
out->height = desc.Height;
out->mipLevels = 0;
UINT maxPlaneIndex = 0;
switch (desc.Format)
{
case DXGI_FORMAT_NV12:
// The UV plane of NV12 textures has half the width/height of the Y plane
if ((desc.Width % 2) != 0 || (desc.Height % 2) != 0)
return egl::EglBadParameter() << "NV12 tetxures must have even width and height.";
maxPlaneIndex = 1;
if (planeIndex == 0)
{
out->internalFormat = GL_R8;
}
else
{
out->internalFormat = GL_RG8;
out->width /= 2;
out->height /= 2;
}
break;
case DXGI_FORMAT_R8_UNORM:
out->internalFormat = GL_R8;
break;
case DXGI_FORMAT_R8G8_UNORM:
out->internalFormat = GL_RG8;
break;
case DXGI_FORMAT_R8G8B8A8_UNORM:
out->internalFormat = GL_RGBA8;
break;
default:
return egl::EglBadParameter() << "Unsupported format";
}
if (planeIndex > maxPlaneIndex) // Just kidding, there's no plane out there.
return egl::EglBadParameter() << "Plane out of range";
return egl::NoError();
} }
StreamProducerNV12::~StreamProducerNV12() } // namespace
StreamProducerD3DTexture::StreamProducerD3DTexture(Renderer11 *renderer)
: mRenderer(renderer), mTexture(nullptr), mArraySlice(0), mPlaneOffset(0)
{
}
StreamProducerD3DTexture::~StreamProducerD3DTexture()
{ {
SafeRelease(mTexture); SafeRelease(mTexture);
} }
egl::Error StreamProducerNV12::validateD3DNV12Texture(void *pointer) const egl::Error StreamProducerD3DTexture::validateD3DTexture(void *pointer,
const egl::AttributeMap &attributes) const
{ {
ID3D11Texture2D *textureD3D = static_cast<ID3D11Texture2D *>(pointer); ID3D11Texture2D *textureD3D = static_cast<ID3D11Texture2D *>(pointer);
...@@ -37,64 +101,39 @@ egl::Error StreamProducerNV12::validateD3DNV12Texture(void *pointer) const ...@@ -37,64 +101,39 @@ egl::Error StreamProducerNV12::validateD3DNV12Texture(void *pointer) const
return egl::EglBadParameter() << "Texture not created on ANGLE D3D device"; return egl::EglBadParameter() << "Texture not created on ANGLE D3D device";
} }
// Get the description and validate it const auto planeId = static_cast<UINT>(attributes.get(EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG, 0));
D3D11_TEXTURE2D_DESC desc; egl::Stream::GLTextureDescription unused;
textureD3D->GetDesc(&desc); return GetGLDescFromTex(textureD3D, planeId, &unused);
if (desc.Format != DXGI_FORMAT_NV12)
{
return egl::EglBadParameter() << "Texture format not DXGI_FORMAT_NV12";
}
if (desc.Width < 1 || desc.Height < 1)
{
return egl::EglBadParameter() << "Texture is of size 0";
}
if ((desc.Width % 2) != 0 || (desc.Height % 2) != 0)
{
return egl::EglBadParameter() << "Texture dimensions are not even";
}
return egl::NoError();
} }
void StreamProducerNV12::postD3DNV12Texture(void *pointer, const egl::AttributeMap &attributes) void StreamProducerD3DTexture::postD3DTexture(void *pointer, const egl::AttributeMap &attributes)
{ {
ASSERT(pointer != nullptr); ASSERT(pointer != nullptr);
ID3D11Texture2D *textureD3D = static_cast<ID3D11Texture2D *>(pointer); ID3D11Texture2D *textureD3D = static_cast<ID3D11Texture2D *>(pointer);
// Check that the texture originated from our device
ID3D11Device *device;
textureD3D->GetDevice(&device);
// Get the description
D3D11_TEXTURE2D_DESC desc;
textureD3D->GetDesc(&desc);
// Release the previous texture if there is one // Release the previous texture if there is one
SafeRelease(mTexture); SafeRelease(mTexture);
mTexture = textureD3D; mTexture = textureD3D;
mTexture->AddRef(); mTexture->AddRef();
mTextureWidth = desc.Width; mPlaneOffset = static_cast<UINT>(attributes.get(EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG, 0));
mTextureHeight = desc.Height;
mArraySlice = static_cast<UINT>(attributes.get(EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, 0)); mArraySlice = static_cast<UINT>(attributes.get(EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, 0));
} }
egl::Stream::GLTextureDescription StreamProducerNV12::getGLFrameDescription(int planeIndex) egl::Stream::GLTextureDescription StreamProducerD3DTexture::getGLFrameDescription(int planeIndex)
{ {
// The UV plane of NV12 textures has half the width/height of the Y plane const auto planeOffsetIndex = static_cast<UINT>(planeIndex + mPlaneOffset);
egl::Stream::GLTextureDescription desc; egl::Stream::GLTextureDescription ret;
desc.width = (planeIndex == 0) ? mTextureWidth : (mTextureWidth / 2); ANGLE_SWALLOW_ERR(GetGLDescFromTex(mTexture, planeOffsetIndex, &ret));
desc.height = (planeIndex == 0) ? mTextureHeight : (mTextureHeight / 2); return ret;
desc.internalFormat = (planeIndex == 0) ? GL_R8 : GL_RG8;
desc.mipLevels = 0;
return desc;
} }
ID3D11Texture2D *StreamProducerNV12::getD3DTexture() ID3D11Texture2D *StreamProducerD3DTexture::getD3DTexture()
{ {
return mTexture; return mTexture;
} }
UINT StreamProducerNV12::getArraySlice() UINT StreamProducerD3DTexture::getArraySlice()
{ {
return mArraySlice; return mArraySlice;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// StreamProducerNV12.h: Interface for a NV12 texture stream producer // StreamProducerD3DTexture.h: Interface for a D3D11 texture stream producer
#ifndef LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_STREAM11_H_
...@@ -15,14 +15,15 @@ namespace rx ...@@ -15,14 +15,15 @@ namespace rx
{ {
class Renderer11; class Renderer11;
class StreamProducerNV12 : public StreamProducerImpl class StreamProducerD3DTexture : public StreamProducerImpl
{ {
public: public:
StreamProducerNV12(Renderer11 *renderer); StreamProducerD3DTexture(Renderer11 *renderer);
~StreamProducerNV12() override; ~StreamProducerD3DTexture() override;
egl::Error validateD3DNV12Texture(void *pointer) const override; egl::Error validateD3DTexture(void *pointer,
void postD3DNV12Texture(void *pointer, const egl::AttributeMap &attributes) override; const egl::AttributeMap &attributes) const override;
void postD3DTexture(void *pointer, const egl::AttributeMap &attributes) override;
egl::Stream::GLTextureDescription getGLFrameDescription(int planeIndex) override; egl::Stream::GLTextureDescription getGLFrameDescription(int planeIndex) override;
// Gets a pointer to the internal D3D texture // Gets a pointer to the internal D3D texture
...@@ -36,8 +37,7 @@ class StreamProducerNV12 : public StreamProducerImpl ...@@ -36,8 +37,7 @@ class StreamProducerNV12 : public StreamProducerImpl
ID3D11Texture2D *mTexture; ID3D11Texture2D *mTexture;
UINT mArraySlice; UINT mArraySlice;
UINT mTextureWidth; UINT mPlaneOffset;
UINT mTextureHeight;
}; };
} // namespace rx } // namespace rx
......
...@@ -14,19 +14,19 @@ ...@@ -14,19 +14,19 @@
#include "common/MemoryBuffer.h" #include "common/MemoryBuffer.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/ImageIndex.h" #include "libANGLE/ImageIndex.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/EGLImageD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/d3d11/Blit11.h" #include "libANGLE/renderer/d3d/d3d11/Blit11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/Image11.h" #include "libANGLE/renderer/d3d/d3d11/Image11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/StreamProducerD3DTexture.h"
#include "libANGLE/renderer/d3d/d3d11/SwapChain11.h" #include "libANGLE/renderer/d3d/d3d11/SwapChain11.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/d3d/EGLImageD3D.h"
#include "libANGLE/renderer/d3d/TextureD3D.h"
namespace rx namespace rx
{ {
...@@ -1297,8 +1297,8 @@ TextureStorage11_External::TextureStorage11_External( ...@@ -1297,8 +1297,8 @@ TextureStorage11_External::TextureStorage11_External(
const egl::Stream::GLTextureDescription &glDesc) const egl::Stream::GLTextureDescription &glDesc)
: TextureStorage11(renderer, D3D11_BIND_SHADER_RESOURCE, 0, glDesc.internalFormat) : TextureStorage11(renderer, D3D11_BIND_SHADER_RESOURCE, 0, glDesc.internalFormat)
{ {
ASSERT(stream->getProducerType() == egl::Stream::ProducerType::D3D11TextureNV12); ASSERT(stream->getProducerType() == egl::Stream::ProducerType::D3D11Texture);
StreamProducerNV12 *producer = static_cast<StreamProducerNV12 *>(stream->getImplementation()); auto *producer = static_cast<StreamProducerD3DTexture *>(stream->getImplementation());
mTexture.set(producer->getD3DTexture(), mFormatInfo); mTexture.set(producer->getD3DTexture(), mFormatInfo);
mSubresourceIndex = producer->getArraySlice(); mSubresourceIndex = producer->getArraySlice();
mTexture.get()->AddRef(); mTexture.get()->AddRef();
......
...@@ -906,7 +906,7 @@ IndexBuffer *Renderer9::createIndexBuffer() ...@@ -906,7 +906,7 @@ IndexBuffer *Renderer9::createIndexBuffer()
return new IndexBuffer9(this); return new IndexBuffer9(this);
} }
StreamProducerImpl *Renderer9::createStreamProducerD3DTextureNV12( StreamProducerImpl *Renderer9::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
......
...@@ -318,8 +318,7 @@ class Renderer9 : public RendererD3D ...@@ -318,8 +318,7 @@ class Renderer9 : public RendererD3D
IndexBuffer *createIndexBuffer() override; IndexBuffer *createIndexBuffer() override;
// Stream Creation // Stream Creation
StreamProducerImpl *createStreamProducerD3DTextureNV12( StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
// Buffer-to-texture and Texture-to-buffer copies // Buffer-to-texture and Texture-to-buffer copies
......
...@@ -63,7 +63,7 @@ ContextImpl *DisplayGL::createContext(const gl::ContextState &state) ...@@ -63,7 +63,7 @@ ContextImpl *DisplayGL::createContext(const gl::ContextState &state)
return new ContextGL(state, mRenderer); return new ContextGL(state, mRenderer);
} }
StreamProducerImpl *DisplayGL::createStreamProducerD3DTextureNV12( StreamProducerImpl *DisplayGL::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
......
...@@ -37,8 +37,7 @@ class DisplayGL : public DisplayImpl ...@@ -37,8 +37,7 @@ class DisplayGL : public DisplayImpl
ContextImpl *createContext(const gl::ContextState &state) override; ContextImpl *createContext(const gl::ContextState &state) override;
StreamProducerImpl *createStreamProducerD3DTextureNV12( StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override; egl::Error makeCurrent(egl::Surface *drawSurface, egl::Surface *readSurface, gl::Context *context) override;
......
...@@ -174,7 +174,7 @@ ContextImpl *DisplayNULL::createContext(const gl::ContextState &state) ...@@ -174,7 +174,7 @@ ContextImpl *DisplayNULL::createContext(const gl::ContextState &state)
return new ContextNULL(state, mAllocationTracker.get()); return new ContextNULL(state, mAllocationTracker.get());
} }
StreamProducerImpl *DisplayNULL::createStreamProducerD3DTextureNV12( StreamProducerImpl *DisplayNULL::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
......
...@@ -64,8 +64,7 @@ class DisplayNULL : public DisplayImpl ...@@ -64,8 +64,7 @@ class DisplayNULL : public DisplayImpl
ContextImpl *createContext(const gl::ContextState &state) override; ContextImpl *createContext(const gl::ContextState &state) override;
StreamProducerImpl *createStreamProducerD3DTextureNV12( StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
private: private:
......
...@@ -183,7 +183,7 @@ ContextImpl *DisplayVk::createContext(const gl::ContextState &state) ...@@ -183,7 +183,7 @@ ContextImpl *DisplayVk::createContext(const gl::ContextState &state)
return new ContextVk(state, mRenderer.get()); return new ContextVk(state, mRenderer.get());
} }
StreamProducerImpl *DisplayVk::createStreamProducerD3DTextureNV12( StreamProducerImpl *DisplayVk::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType, egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
......
...@@ -60,8 +60,7 @@ class DisplayVk : public DisplayImpl ...@@ -60,8 +60,7 @@ class DisplayVk : public DisplayImpl
ContextImpl *createContext(const gl::ContextState &state) override; ContextImpl *createContext(const gl::ContextState &state) override;
StreamProducerImpl *createStreamProducerD3DTextureNV12( StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
gl::Version getMaxSupportedESVersion() const override; gl::Version getMaxSupportedESVersion() const override;
......
...@@ -1972,14 +1972,14 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, ...@@ -1972,14 +1972,14 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display,
return NoError(); return NoError();
} }
Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display, Error ValidateCreateStreamProducerD3DTextureANGLE(const Display *display,
const Stream *stream, const Stream *stream,
const AttributeMap &attribs) const AttributeMap &attribs)
{ {
ANGLE_TRY(ValidateDisplay(display)); ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions(); const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.streamProducerD3DTextureNV12) if (!displayExtensions.streamProducerD3DTexture)
{ {
return EglBadAccess() << "Stream producer extension not active"; return EglBadAccess() << "Stream producer extension not active";
} }
...@@ -1996,16 +1996,30 @@ Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display, ...@@ -1996,16 +1996,30 @@ Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display,
return EglBadState() << "Stream not in connecting state"; return EglBadState() << "Stream not in connecting state";
} }
if (stream->getConsumerType() != Stream::ConsumerType::GLTextureYUV || switch (stream->getConsumerType())
stream->getPlaneCount() != 2) {
case Stream::ConsumerType::GLTextureYUV:
if (stream->getPlaneCount() != 2)
{
return EglBadMatch() << "Incompatible stream consumer type";
}
break;
case Stream::ConsumerType::GLTextureRGB:
if (stream->getPlaneCount() != 1)
{ {
return EglBadMatch() << "Incompatible stream consumer type"; return EglBadMatch() << "Incompatible stream consumer type";
} }
break;
default:
return EglBadMatch() << "Incompatible stream consumer type";
}
return NoError(); return NoError();
} }
Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, Error ValidateStreamPostD3DTextureANGLE(const Display *display,
const Stream *stream, const Stream *stream,
void *texture, void *texture,
const AttributeMap &attribs) const AttributeMap &attribs)
...@@ -2013,7 +2027,7 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, ...@@ -2013,7 +2027,7 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display,
ANGLE_TRY(ValidateDisplay(display)); ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions(); const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.streamProducerD3DTextureNV12) if (!displayExtensions.streamProducerD3DTexture)
{ {
return EglBadAccess() << "Stream producer extension not active"; return EglBadAccess() << "Stream producer extension not active";
} }
...@@ -2033,6 +2047,12 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, ...@@ -2033,6 +2047,12 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display,
return EglBadParameter() << "Invalid subresource index"; return EglBadParameter() << "Invalid subresource index";
} }
break; break;
case EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG:
if (value < 0)
{
return EglBadParameter() << "Invalid plane offset";
}
break;
default: default:
return EglBadAttribute() << "Invalid attribute"; return EglBadAttribute() << "Invalid attribute";
} }
...@@ -2045,7 +2065,7 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, ...@@ -2045,7 +2065,7 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display,
return EglBadState() << "Stream not fully configured"; return EglBadState() << "Stream not fully configured";
} }
if (stream->getProducerType() != Stream::ProducerType::D3D11TextureNV12) if (stream->getProducerType() != Stream::ProducerType::D3D11Texture)
{ {
return EglBadMatch() << "Incompatible stream producer"; return EglBadMatch() << "Incompatible stream producer";
} }
...@@ -2055,7 +2075,7 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, ...@@ -2055,7 +2075,7 @@ Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display,
return EglBadParameter() << "Texture is null"; return EglBadParameter() << "Texture is null";
} }
return stream->validateD3D11NV12Texture(texture); return stream->validateD3D11Texture(texture, attribs);
} }
Error ValidateGetSyncValuesCHROMIUM(const Display *display, Error ValidateGetSyncValuesCHROMIUM(const Display *display,
......
...@@ -90,10 +90,10 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display, ...@@ -90,10 +90,10 @@ Error ValidateStreamConsumerGLTextureExternalAttribsNV(const Display *display,
gl::Context *context, gl::Context *context,
const Stream *stream, const Stream *stream,
const AttributeMap &attribs); const AttributeMap &attribs);
Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display, Error ValidateCreateStreamProducerD3DTextureANGLE(const Display *display,
const Stream *stream, const Stream *stream,
const AttributeMap &attribs); const AttributeMap &attribs);
Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display, Error ValidateStreamPostD3DTextureANGLE(const Display *display,
const Stream *stream, const Stream *stream,
void *texture, void *texture,
const AttributeMap &attribs); const AttributeMap &attribs);
......
...@@ -344,19 +344,19 @@ EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV(EGLDisplay dp ...@@ -344,19 +344,19 @@ EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV(EGLDisplay dp
return egl::StreamConsumerGLTextureExternalAttribsNV(dpy, stream, attrib_list); return egl::StreamConsumerGLTextureExternalAttribsNV(dpy, stream, attrib_list);
} }
EGLBoolean EGLAPIENTRY eglCreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EGLBoolean EGLAPIENTRY eglCreateStreamProducerD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
{ {
return egl::CreateStreamProducerD3DTextureNV12ANGLE(dpy, stream, attrib_list); return egl::CreateStreamProducerD3DTextureANGLE(dpy, stream, attrib_list);
} }
EGLBoolean EGLAPIENTRY eglStreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLBoolean EGLAPIENTRY eglStreamPostD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
void *texture, void *texture,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
{ {
return egl::StreamPostD3DTextureNV12ANGLE(dpy, stream, texture, attrib_list); return egl::StreamPostD3DTextureANGLE(dpy, stream, texture, attrib_list);
} }
EGLBoolean EGLAPIENTRY eglGetSyncValuesCHROMIUM(EGLDisplay dpy, EGLBoolean EGLAPIENTRY eglGetSyncValuesCHROMIUM(EGLDisplay dpy,
......
...@@ -55,8 +55,8 @@ EXPORTS ...@@ -55,8 +55,8 @@ EXPORTS
eglStreamConsumerAcquireKHR @61 eglStreamConsumerAcquireKHR @61
eglStreamConsumerReleaseKHR @62 eglStreamConsumerReleaseKHR @62
eglStreamConsumerGLTextureExternalAttribsNV @63 eglStreamConsumerGLTextureExternalAttribsNV @63
eglCreateStreamProducerD3DTextureNV12ANGLE @64 eglCreateStreamProducerD3DTextureANGLE @64
eglStreamPostD3DTextureNV12ANGLE @65 eglStreamPostD3DTextureANGLE @65
eglGetSyncValuesCHROMIUM @66 eglGetSyncValuesCHROMIUM @66
eglSwapBuffersWithDamageEXT @67 eglSwapBuffersWithDamageEXT @67
eglProgramCacheGetAttribANGLE @68 eglProgramCacheGetAttribANGLE @68
......
...@@ -525,8 +525,8 @@ ...@@ -525,8 +525,8 @@
'libANGLE/renderer/d3d/d3d11/shaders/compiled/swizzleui3dps.h', 'libANGLE/renderer/d3d/d3d11/shaders/compiled/swizzleui3dps.h',
'libANGLE/renderer/d3d/d3d11/StateManager11.cpp', 'libANGLE/renderer/d3d/d3d11/StateManager11.cpp',
'libANGLE/renderer/d3d/d3d11/StateManager11.h', 'libANGLE/renderer/d3d/d3d11/StateManager11.h',
'libANGLE/renderer/d3d/d3d11/StreamProducerNV12.cpp', 'libANGLE/renderer/d3d/d3d11/StreamProducerD3DTexture.cpp',
'libANGLE/renderer/d3d/d3d11/StreamProducerNV12.h', 'libANGLE/renderer/d3d/d3d11/StreamProducerD3DTexture.h',
'libANGLE/renderer/d3d/d3d11/SwapChain11.cpp', 'libANGLE/renderer/d3d/d3d11/SwapChain11.cpp',
'libANGLE/renderer/d3d/d3d11/SwapChain11.h', 'libANGLE/renderer/d3d/d3d11/SwapChain11.h',
'libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp', 'libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp',
......
...@@ -657,7 +657,7 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, ...@@ -657,7 +657,7 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy,
return EGL_TRUE; return EGL_TRUE;
} }
EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
{ {
...@@ -670,15 +670,14 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, ...@@ -670,15 +670,14 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy,
Stream *streamObject = static_cast<Stream *>(stream); Stream *streamObject = static_cast<Stream *>(stream);
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list); AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
Error error = Error error = ValidateCreateStreamProducerD3DTextureANGLE(display, streamObject, attributes);
ValidateCreateStreamProducerD3DTextureNV12ANGLE(display, streamObject, attributes);
if (error.isError()) if (error.isError())
{ {
thread->setError(error); thread->setError(error);
return EGL_FALSE; return EGL_FALSE;
} }
error = streamObject->createProducerD3D11TextureNV12(attributes); error = streamObject->createProducerD3D11Texture(attributes);
if (error.isError()) if (error.isError())
{ {
thread->setError(error); thread->setError(error);
...@@ -689,7 +688,7 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, ...@@ -689,7 +688,7 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy,
return EGL_TRUE; return EGL_TRUE;
} }
EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, EGLBoolean EGLAPIENTRY StreamPostD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
void *texture, void *texture,
const EGLAttrib *attrib_list) const EGLAttrib *attrib_list)
...@@ -704,14 +703,14 @@ EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, ...@@ -704,14 +703,14 @@ EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy,
Stream *streamObject = static_cast<Stream *>(stream); Stream *streamObject = static_cast<Stream *>(stream);
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list); AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
Error error = ValidateStreamPostD3DTextureNV12ANGLE(display, streamObject, texture, attributes); Error error = ValidateStreamPostD3DTextureANGLE(display, streamObject, texture, attributes);
if (error.isError()) if (error.isError())
{ {
thread->setError(error); thread->setError(error);
return EGL_FALSE; return EGL_FALSE;
} }
error = streamObject->postD3D11NV12Texture(texture, attributes); error = streamObject->postD3D11Texture(texture, attributes);
if (error.isError()) if (error.isError())
{ {
thread->setError(error); thread->setError(error);
......
...@@ -70,12 +70,12 @@ StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy, ...@@ -70,12 +70,12 @@ StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
const EGLAttrib *attrib_list); const EGLAttrib *attrib_list);
// EGL_ANGLE_stream_producer_d3d_texture_nv12 // EGL_ANGLE_stream_producer_d3d_texture
ANGLE_EXPORT EGLBoolean EGLAPIENTRY ANGLE_EXPORT EGLBoolean EGLAPIENTRY
CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy, CreateStreamProducerD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
const EGLAttrib *attrib_list); const EGLAttrib *attrib_list);
ANGLE_EXPORT EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy, ANGLE_EXPORT EGLBoolean EGLAPIENTRY StreamPostD3DTextureANGLE(EGLDisplay dpy,
EGLStreamKHR stream, EGLStreamKHR stream,
void *texture, void *texture,
const EGLAttrib *attrib_list); const EGLAttrib *attrib_list);
......
#!/usr/bin/python #!python
# Copyright 2017 The ANGLE Project Authors. All rights reserved. # Copyright 2017 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -65,7 +65,7 @@ for description, functions in json_data.iteritems(): ...@@ -65,7 +65,7 @@ for description, functions in json_data.iteritems():
proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())] proc_data = [(' {"%s", P(%s)}' % (func, angle_func)) for func, angle_func in sorted(all_functions.iteritems())]
with open(out_file_name, 'wt') as out_file: with open(out_file_name, 'wb') as out_file:
output_cpp = template_cpp.format( output_cpp = template_cpp.format(
script_name = sys.argv[0], script_name = sys.argv[0],
data_source_name = data_source_name, data_source_name = data_source_name,
......
// GENERATED FILE - DO NOT EDIT. // GENERATED FILE - DO NOT EDIT.
// Generated by gen_proc_table.py using data from proc_table_data.json. // Generated by ./gen_proc_table.py using data from proc_table_data.json.
// //
// Copyright 2017 The ANGLE Project Authors. All rights reserved. // Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
...@@ -41,7 +41,7 @@ ProcEntry g_procTable[] = { ...@@ -41,7 +41,7 @@ ProcEntry g_procTable[] = {
{"eglCreatePlatformPixmapSurface", P(egl::CreatePlatformPixmapSurface)}, {"eglCreatePlatformPixmapSurface", P(egl::CreatePlatformPixmapSurface)},
{"eglCreatePlatformWindowSurface", P(egl::CreatePlatformWindowSurface)}, {"eglCreatePlatformWindowSurface", P(egl::CreatePlatformWindowSurface)},
{"eglCreateStreamKHR", P(egl::CreateStreamKHR)}, {"eglCreateStreamKHR", P(egl::CreateStreamKHR)},
{"eglCreateStreamProducerD3DTextureNV12ANGLE", P(egl::CreateStreamProducerD3DTextureNV12ANGLE)}, {"eglCreateStreamProducerD3DTextureANGLE", P(egl::CreateStreamProducerD3DTextureANGLE)},
{"eglCreateSync", P(egl::CreateSync)}, {"eglCreateSync", P(egl::CreateSync)},
{"eglCreateWindowSurface", P(egl::CreateWindowSurface)}, {"eglCreateWindowSurface", P(egl::CreateWindowSurface)},
{"eglDestroyContext", P(egl::DestroyContext)}, {"eglDestroyContext", P(egl::DestroyContext)},
...@@ -88,7 +88,7 @@ ProcEntry g_procTable[] = { ...@@ -88,7 +88,7 @@ ProcEntry g_procTable[] = {
P(egl::StreamConsumerGLTextureExternalAttribsNV)}, P(egl::StreamConsumerGLTextureExternalAttribsNV)},
{"eglStreamConsumerGLTextureExternalKHR", P(egl::StreamConsumerGLTextureExternalKHR)}, {"eglStreamConsumerGLTextureExternalKHR", P(egl::StreamConsumerGLTextureExternalKHR)},
{"eglStreamConsumerReleaseKHR", P(egl::StreamConsumerReleaseKHR)}, {"eglStreamConsumerReleaseKHR", P(egl::StreamConsumerReleaseKHR)},
{"eglStreamPostD3DTextureNV12ANGLE", P(egl::StreamPostD3DTextureNV12ANGLE)}, {"eglStreamPostD3DTextureANGLE", P(egl::StreamPostD3DTextureANGLE)},
{"eglSurfaceAttrib", P(egl::SurfaceAttrib)}, {"eglSurfaceAttrib", P(egl::SurfaceAttrib)},
{"eglSwapBuffers", P(egl::SwapBuffers)}, {"eglSwapBuffers", P(egl::SwapBuffers)},
{"eglSwapBuffersWithDamageEXT", P(egl::SwapBuffersWithDamageEXT)}, {"eglSwapBuffersWithDamageEXT", P(egl::SwapBuffersWithDamageEXT)},
......
...@@ -635,9 +635,9 @@ ...@@ -635,9 +635,9 @@
"eglStreamConsumerGLTextureExternalAttribsNV" "eglStreamConsumerGLTextureExternalAttribsNV"
], ],
"EGL_ANGLE_stream_producer_d3d_texture_nv12": [ "EGL_ANGLE_stream_producer_d3d_texture": [
"eglCreateStreamProducerD3DTextureNV12ANGLE", "eglCreateStreamProducerD3DTextureANGLE",
"eglStreamPostD3DTextureNV12ANGLE" "eglStreamPostD3DTextureANGLE"
], ],
"EGL_CHROMIUM_get_sync_values": [ "EGL_CHROMIUM_get_sync_values": [
......
...@@ -119,7 +119,7 @@ class MockEGLFactory : public EGLImplFactory ...@@ -119,7 +119,7 @@ class MockEGLFactory : public EGLImplFactory
MOCK_METHOD3(createImage, MOCK_METHOD3(createImage,
ImageImpl *(const egl::ImageState &, EGLenum, const egl::AttributeMap &)); ImageImpl *(const egl::ImageState &, EGLenum, const egl::AttributeMap &));
MOCK_METHOD1(createContext, ContextImpl *(const gl::ContextState &)); MOCK_METHOD1(createContext, ContextImpl *(const gl::ContextState &));
MOCK_METHOD2(createStreamProducerD3DTextureNV12, MOCK_METHOD2(createStreamProducerD3DTexture,
StreamProducerImpl *(egl::Stream::ConsumerType, const egl::AttributeMap &)); StreamProducerImpl *(egl::Stream::ConsumerType, const egl::AttributeMap &));
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment