I ran into an issue with this patch on Windows + DirectComposition + ANGLE. Write up below.
The mix-blend-mode optimizations I've been working on rely on the ability to do blits from picture cache tiles to render target textures.
This seems to be a bit tricky on Windows + DirectComposition + ANGLE. With my current patches, we get an assert at . This is because the SRV has not been initialized for the renderbuffer. I believe this is because the D3D texture does not have the
D3D11_BIND_SHADER_RESOURCE binding flag set (it does have the
DXGI_USAGE_SHADER_INPUT flag set on the resource though).
We can't control the creation or flags of the D3D texture, the pointer to the texture is returned to us by the
BeginDraw API in DirectComposition that we use to start drawing on a picture cache tile.
There are a few hacks / workarounds I tried, that prove it can be made to work. It's just a matter of working out which is the best option (or if there's a better option I haven't found yet).
a) Further down the method in , there is a fast path that uses
CopySubresourceRegion . The only thing that is stopping us hitting that fast path is that the target texture is DXGI_FORMAT_R8G8B8A8_UNORM, while the virtual surface backing texture is created as DXGI_FORMAT_B8G8R8A8_UNORM . If I change the virtual surface to be DXGI_FORMAT_R8G8B8A8_UNORM, and remove the assertion checks in (1), we hit the fast path in that method and it all seems to work. However, I'm not sure if there's any issues with changing the virtual surface format (e.g. with video surfaces?), and we'd need to patch ANGLE so that those asserts don't fire if the fast path is hit (since the
readSRV is not used in those cases). It's also a little fragile that it breaks if we don't hit the fast path, so I'm not sure if that's upstream-able?
b) I tried to change from creating a renderbuffer from the EGLImage to creating a texture that could be attached to the FBO at . This fails validation for the same reason above, that it's not possible to create an
SRV for the texture we get back from DirectComposition. Maybe there is another way to create an FBO via ANGLE which is bound to the D3D texture that we are able to read back from?
glCopyImageSubData is a GL4 (and ES 3.2) function that looks like it would do what we want (direct copy from a renderbuffer to a texture). It seems to be at least partially implemented in ANGLE  though I haven't tried it out yet (and I'm not sure if it's guaranteed always available when running ANGLE). Not sure if the specific renderbuffer -> texture impl is there either.
- Of the above, do any of those seem like a reasonable potential solution?
- Are there other options we could try to make this work in ANGLE (and hit a fast path)?