Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render to target on WP8.1 issue! #56

Closed
MihaiBairac opened this issue Feb 12, 2016 · 4 comments
Closed

Render to target on WP8.1 issue! #56

MihaiBairac opened this issue Feb 12, 2016 · 4 comments

Comments

@MihaiBairac
Copy link

Hello guys,

I am very pleased by your work! I am happy you created such a great framework!

Now, I have a problem with Render to Target technique.

I created a small project in OpenGL ES 2.0. Decided to port it to Windows 8.1 & Windows Phone 8.1.
I chose to use the Angle Project.


I use the ms-master branch. I got it on 1st february 2016.

To create the application I first installed the windows store ANGLE template (XAML) located at this path: angle-ms-master\templates\8.1\Store Apps\Universal Apps\UniversalSwapChainPanel\ using the install.bat script from angle-ms-master\templates.

I built the libs (libANGLE.lib, libEGL.lib, libEGLESv2.lib and the others) myself using VS 2013 + Update 4.


All works well, except the render to target part of the code on windows phone 8.1.

To debug I tried to render a simple spinning cube. Which renders ok on windows phone if I use the default framebuffer, but not with a custom one. I get nothing. The screen is black. While debugging I searched the angle sources and used breakpoints inside sources, but to no extent.

The spinning cube and the project altoghether work well when using the custom framebuffer on PC or a surface tablet.

I tested on Nokia Lumia 1520 and Nokia Lumia 920, but to no result. Same black screen.

I did this test: on both devices if I just bind the FBO, but don't render anything in it I just get the framebuffer clear color on screen (which is ok).

In all cases I also get a message in console:

D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader unit expects a Sampler to be set at Slot 0, but none is bound. This is perfectly valid, as a NULL Sampler maps to default Sampler state. However, the developer may not want to rely on the defaults. [ EXECUTION WARNING #352: DEVICE_DRAW_SAMPLER_NOT_SET]

I have almost none DirectX knowledge, so I looked it up. It seems I get this warning, because DirectX creates and sets a default sampler state to the texture. Usually the dev should use his/her own sampler state.

I see no reason why the FBO should not work on WP8.1. I am just missing something. Hope you guys can help me!

One more thing: I observed that both devices (lumia 1520 and 920) don't support depth texture. This means I won't be able to sample from it directly. The other way is to attach a renderbuffer to the FBO as a depth attachement and copy the data from VRAM to a texture and then sample from it.

Second thing: I saw that there is a closed issue #49 regarding depth textures on WP8.1 and I know it's because the lack of hardware support.

If you need more info from me, just ask!

Thanks!

@austinkinross
Copy link
Member

Hi, thanks a lot for your kind words!

I suspect that ANGLE thinks that one of your OpenGL ES textures is incomplete (i.e. misconfigured). My first guess would be that it's caused by a "bug" in your app's GL code- unfortunately it's very easy to write GL code that creates a valid and complete texture on some versions of OpenGL ES (with certain extensions), but the code accidentally depends on a minor detail of one of these extensions and therefore doesn't work when these extensions aren't present!

Could you try putting a break point in "Context::recordError" in /src/libANGLE/Context.cpp, on the line "mErrors.insert(error.getCode());"? If you hit that breakpoint then try looking at the rest of the callstack within ANGLE- the code is probably validating your app's GL code, and you can hopefully use it to figure out what the issue is. If you don't hit that breakpoint or if you have trouble figuring out the cause then then let me know, and we can try something else to find the problem.

Thanks!
Austin

@MihaiBairac
Copy link
Author

Hello Austin,

Thank you very much for your quick answer!

I put a breakpoint where you suggested and solved some bugs in my application.
In this way I:

  • removed glGenerateMipmap(GL_TEXTURE_CUBE_MAP); (it seems generating mipmaps for cubemaps is not supported on any platform, be it: PC, tablet or phone).
  • put some guards for vertex attribute locations

Beside these fixes I still couldn't figure out why I am not having complete textures for FBO on wp8.1 (if this is the case). They seem to be complete and the FBO is always complete on any platform. (Of course on wp8.1 it was incomplete at first, but this is how I got it that the device does not support depth textures).

I also looked at the string that contains all the existing extensions for the current device that's running the application. I also tried to see if there are any needed extensions for using FBO with one color attachement (it shouldn't be the case, still I checked). My application has post processing effects, this is why I need render to target to work. Actually, I use 2 FBO each one with one color attachement and one depth attachment (I do ping-pong between them :) ), for wp8.1 though I'll probably have to use renderbuffer instead of depth textures as they are not supported, but I haven't got to that part. First, it would be a blessing for the color attachement to work.

I observed the thin Validation layer you have in ANGLE while debugging and it's cool! Everyhting get's checked!

Hope you can guide me further.

Thank you for your insights,
Mihai

@MihaiBairac
Copy link
Author

Hello guys,

I have found the issue. It is the lack of NPOT texture support. The render targets are initially void textures with width and height of the screen. So, for post processing to work I modify the incoming width and height to the nearest power of two number (it is smaller or equal to the actual width or height).

OpenGL ES 2.0 should have support for NPOT textures, but as always if you really gonna get them working depends on the hardware your application runs on. So the only way I could get them working would be to have support for GL_OES_texture_npot extension and even then I would be limited, as the specs say down below.

From OpenGL ES 2.0 specs:
"OpenGL ES 2.0 supports non-power of two 2D textures, and cubemaps, with the caveat that mip- mapping and texture wrap modes other than clamp to edge are not supported. Mip-mapping and all OpenGL ES 2.0 texture wrap modes are supported for power of two 2D textures, and cubemaps. The OES texture npot extension allows implementations to support mip-mapping and REPEAT and MIRRORED REPEAT texture wrap modes for non-power of two 2D textures, cubemaps, and also for 3D textures, if OES texture 3D extension is supported. "

Thanks,
Mihai

@austinkinross
Copy link
Member

I'm glad you figured out your issue!

In addition to the lack of support for GL_OES_texture_npot, it's worth noting that ANGLE running on D3D11 Feature Level 9_3 devices (such as all devices running Windows Phone 8.1) can't support any non-power-of-two cubemaps. This is documented in our "Known Issues" wiki page: https://github.com/MSOpenTech/angle/wiki/Known-Issues

Feel free to reopen this issue if you have continue to have problems here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants