Hello,
can you be please more specific what are the problems of native Direct3D renderer for new cocos version 3?
I spent last several hours (not much) of removing ANGLE libraries and I managed to implement Direct3D rendering for W8 (C++) and WP8 (hybrid XAML solution) and did not encounter any serious problem so far.
What I changed:
Render window creation
Texture loading to D3D texture (it is still in cocos2d::Texture2D)
Shaders - I rewrite cocos shaders to HSLS which was pretty straightforward
Rendering - It is very similar with OGL - vertex buffer, index buffer, input layout from shader etc.
What is still need to do:
Complete resource management (possible use of DDS textures)
Generalization of shaders (input layouts, constant buffers)
State cache
Some specific node rendering (labels, progress bar, scissor node, …)
What it brings to us?
In the first case - performance - native render is much more faster (on our W8 tablet 8FPS->60FPS), actually ANGLE solution is not usable for some serious work.
Prevent memory problems with ANGLE - especially when I use DDS textures (it is much more better now with 32-bit textures).
My solution is not probably so clean (I need to refactor few things since I wanted to test the solution firstly) and universal since we are using quite small subset of cocos features. Nevertheless I think that result will be much usable than ANGLE for many people. Fortunately D3D11 interface is very clean and intuitive.
-> I wanted to thank you for 3.0 renderer which allows this native implementation very easy and dynamic batching is super cool feature.
You can start experiment with this. So far there is only mods for basic render, Angel window is not created anymore, instead standard Direct3D creation process there (W8/WP8). Nevertheless angel libraries are still in the projects because there is a lot of gl methods to replace.
I’ve also added W8 proj files for Box2D and Audio but there are no tests so you have to create solution manually (I am using native C++ app without XAML for W8 - the native initialization is much simplier than XAML one).
WP8 XAML cpp-tests should work but there will be only red solid background since there is not render so far (just clearing the buffer).
I will push more code I have now: textures, shaders, rendering.
Hello, it seems that pixel shader HLSL is set as vertex shader. You can change it in the properties of the file but it is strange because I have not this problem. I’ll check it later.
As you can see, some shaders are not still rewritten (all that have commented GLSL code below). You can rewrite them to HLSL. It is very straightforward. When you define input (attributes) and const values (uniforms) you have to edit shader descriptor in ccShaders.cpp where is defined these thing manually (it seems that shader reflection is not supported on WP). You can inspire on Label* shaders, there is usage of input and uniform definition (note that uniform/const values are separated for VS and PS).
Next it seems that cocos tests are some problem with rendering (I merge all changes from my project where everything is working well), you can check it. Visual Studio has very fine tool for debugging of D3D.
Thank you for starting to implement native Direct X renderer. The Angle project is awful and completely useless on W8. I might be contributing to this project as I have wanted this for a long time and thought about writing it by myself.
dungmv: I know about the rendering problem. Sorry I have not time to solve it during the week. I suppose there is some minor problem (it’s working perfectly on my project). I recommend create some test project for W8. You can do better debugging of D3D (maybe it is also possible on WP8, I don’t know). It is Alt+F5 - Graphics - Start diagnostics. You see what is rendered, complete pipeline settings even shader debugging. Really cool feature.
The link error is strange again - there should be lib in the project: dxguid.lib. But I added it already so maybe vcproj file is not updated… I’ll check it but you can add this lib to the linker settings, It should work.
To all: If you tell me your github logins, I can add you as contributors.
Added DX state cache + shader cache (I do not undestand sense of this functionality since it is not used in cocos itself). Many nodes are not functional now. It is needed to add DX functionality as in Label (Atlas) or Renderer. It is very straightforward.