Managed Direct3D code--slow! - Windows Mobile Development and Hacking General

I wrote some Managed Direct3D Mobile code, using fixed point arithmetic. It runs slow as a dog and its performance relative to the floating point version of the code shows little improvement.
This is on a Kaiser phone. I know that there are issues with graphics on that thing. I am only trying to use the software renderer, but the speed of my app is so slow that I wonder if it's in my implementation. It is a cube with textured faces, spinning as as fast as it can, and I can only achieve 7 seconds per frame (yes... seconds per frame. Obviously my goal is something in the FPS range!).
Would anyone with experience in writing D3DM code care to give me a hand by looking at my code? I'm at kramer (underscore inserted) ae (at) hotmail (dot) com.
Thanks,
Brian

Sorry to say the Kaiser only has reference drivers for d3dm, all software driven. Thats why its a dog.

and it also dont help that ms stoped all development of Managed Directx along time agoe and most people who wanna do 3d from .net these days use opengl
also on a as weak platform as arm compared to pc
.net being much much relatively slow on arm compared to on x86
doing 3d in a not truely native language as c++ will never give much speed
less so when it comes to graphics

These comments aren't helping. I understand that my environment is not up to industry standards in terms of performance (15-60 fps, for example). But rendering a cube in Direct3D should not be as bad as one frame every 10 seconds. I'm in search of someone who knows the correct baseline performance expectation for my scenario and can help bring the perf of my simple 3D application in line with what is really expected. Alternatively, there may be anecotal information that says my application is actually performing as fast as expected. I don't know that.

The attached archive contains a native and a managed D3D example showing a rotating textured cylinder (from the WM6 SDK). Both run interactive on my HTC Touch (Elf).

Related

{Updated-12/10/09}[Project] DirectMobile - DirectX Accellerated UI Framework for WM

DirectMobile is a DirectX based Managed UI Framework for Windows Mobile. Aim of the framework is to provide an elegant UI for Windows Mobile devices which is simple to develop against.
Target Platform:
WM6.0+
.NET CF 3.5
Current Implementation:
All graphics rendered in Direct3D. Each DM Application gets access to the rendering device and has one host window. The host window renders one frame at a time. Each frame can hold other elements such as buttons, labels or lists.
Design Considerations:
Sharing of GPU by multiple applications [High Priority]: Ideally a DirectMobile Rendering service must be implemented and applications request rendering via named pipes. This will reduce GPU and CPU utilization.
Remove dependencies on System.Windows.Forms [Low Priority]: To reduce developer confusion, references to Windows Forms need to be removed. This can be implemented via native calls to AGL lib.
Tested Against:
Blackstone: WM 6.5 + Neo Driver Pack r3
Touch Cruise: WM 6.5
WM 6.5 Device Emulator
WM 6.1 Device Emulator
WM 6.0 Device Emulator
Sample Code:
public static void Main()
{
//Start DirectMobile Application
DMApplication.Run();
//Render a new Frame
DMApplication.Current.ShowFrame(new Controls.Frame{ BackgroundColor=Color.Black, ForeGroundColor=Color.White, Title="My First Frame"});
}
DirectMobile on Codeplex
put me down for pre-alpha, alpha, beta, rc tester.
Nice initiative. It is rumoured that MS will let go of Direct3D with the onset of WM7. Is OpenGLES not the way forward?
On a side note, I wouldn't mind beta testing, heh.
Thanks in advance.
Count me in for graphics and ideas (if needed).
nuke1 said:
Nice initiative. It is rumoured that MS will let go of Direct3D with the onset of WM7. Is OpenGLES not the way forward?
On a side note, I wouldn't mind beta testing, heh.
Thanks in advance.
Click to expand...
Click to collapse
I did a quick lookup and i dont see any references on OpenGLES been used with WM7. If you find something let us know but please lets not discuss this here
Am always willing to test for constructive purposes. Let me know if you need a tester for the HTC Fuze / Touch Pro
i am also willing for some alpha and beta testing!!!! using a diamond
twolf said:
Count me in for graphics and ideas (if needed).
Click to expand...
Click to collapse
me too, graphics and usability issues.
wondering if XDA Flame will support this in HW Accelerated mode.
Most of the drivers on Flame are reference BS, slapped from the MS emulator onto the device. Fingers crossed for this one.
Count me in to test it (VGA device, HTC Universal).
I'm in as a developer. I have a decent amount of c# experience.
will to beta test for usabilty and bugs - diamond user.
Count me in. Sprint touch pro
I'm also want to be a tester. Also, can help in development, if free time will be exists.
I'm not try use managed DirectX, only OpenGL small apps for PC.
HTC Blackstone.
I thought about writing something like this a while back - don't have a ton of cycles, but can contribute on the dev side and testing.
I can help with testing this time around. Maybe I can help with developing later on. I'm using an HTC Touch VOGU100
tester
just got a touch pro and can consider as intermediate user .....well i can help out as tester ... do giv me a pm ..... hopefully i can help out n also gain some exp ..... thanks
I will be happy to help with graphics and design. I have helped with the manila - framework.
BTW: my other account it call UknownDev
also I am have some nice TF3D Themes.
So.. I'll be more than happy to help.
nice!
I'm in for testing and graphics!
I own an ASUS P550 (greek WM6.1pro) and will probably switch to an Omnia variant soom.
This seems to me like a great idea!
I'm experienced with C# and would like to help in this project (the development part). I don't have much spare time because of my current job, but whenever I can find some, I'd love to help.
-- edit:
I've got a Codeplex Id: w0lf

IDE to run on WM...

I think here is the right place to ask
Do u know/is there any C/C++ IDE that can actually run on WM?
I do not mean writing apps for WM. I mean writing, compiling (and y not debugging) programms directly on the PDA.
And generally is there such an IDE for any other programming language?
thx in advance
there is some for c# .net
and pocketVI support some c not to compile to native code or a real IDe though
I don't even think the pocket pc is powerful enough (yet) to handle the task of compiling software (unless you get a real os on there like linux).
I dont know if this is what you are looking for, but you can try Basic4PPC
I've tried it and I love'd it!
Rudegar said:
there is some for c# .net
and pocketVI support some c not to compile to native code or a real IDe though
Click to expand...
Click to collapse
yes i've seen that! i guess u r talking about http://www.geocities.com/hrowson/wm5_software/index.htm
just wondering if there are similar IDEs for other langs, like C, C++
Steven855 said:
I don't even think the pocket pc is powerful enough (yet) to handle the task of compiling software (unless you get a real os on there like linux).
Click to expand...
Click to collapse
hm.. i do not think that compiling is such an intensive task.. Well if u have like 5000 lines on ur windows mobile sure will take long..
But generally testing smal progs etc would be fine i think
Compiling is not something that came out with along with the fast CPUs!
What is more, the HD has a pretty fast CPU (i think!). Still remember that my first desktop PC's CPU was around 500MHz (!)
fredamexis said:
I dont know if this is what you are looking for, but you can try Basic4PPC
I've tried it and I love'd it!
Click to expand...
Click to collapse
u can use it to write progs directly @ ur PDA? (withour PC)
thx i will check it anyway!
See this thread: http://forum.xda-developers.com/showthread.php?t=445396
The following will compile (I've tried them) on the phone:
PocketGCC (FREEWARE)
Pocket C# Combo (Everything you need to compile and write apps for WM-- FREEWARE)
However, they do have limitations.
I'm completely positive FPC can be made to run on ARM. I'd say the chances of getting Lazarus (*the* FPC IDE) to run on WM are 30% out-of-the-box, and 70% after a day of hacking
The real question is... WHYYYY!?!?!?!?!?! would you want to?
LiKBeAsT said:
hm.. i do not think that compiling is such an intensive task.. Well if u have like 5000 lines on ur windows mobile sure will take long..
But generally testing smal progs etc would be fine i think
Click to expand...
Click to collapse
Dude seriously, compiling is a very CPU intensive task. 5000 lines? That is exactly one nothing in code terms.
Compiling is not something that came out with along with the fast CPUs!
What is more, the HD has a pretty fast CPU (i think!). Still remember that my first desktop PC's CPU was around 500MHz (!)
Click to expand...
Click to collapse
Oh please. My first desktop PC's CPU was 4.77mhz (with a turbo switch to 8!) and I'm considered a newbie in that area. While 500mhz is not necessarily slow, HTC hasn't produced a fast device in over two years. The HD is a horribly slow device.
Just a guess, but I'd say that the HD should still be fine for compiling. No floating point operations and no graphics.
Limitations to compilation probably memory size and memory speed, more than anything else? This will be a particular problem for C++, especially if you're doing anything more than minimal templating.
And putting Linux on it won't suddenly make it much better at compiling things - very little of this will be reliant on the OS subsystem.
ajige said:
See this thread: http://forum.xda-developers.com/showthread.php?t=445396
The following will compile (I've tried them) on the phone:
PocketGCC (FREEWARE)
Pocket C# Combo (Everything you need to compile and write apps for WM-- FREEWARE)
However, they do have limitations.
Click to expand...
Click to collapse
yea checked that out but it also had many other stuff and i wasn't sure about what i was asking
Chainfire said:
I'm completely positive FPC can be made to run on ARM. I'd say the chances of getting Lazarus (*the* FPC IDE) to run on WM are 30% out-of-the-box, and 70% after a day of hacking
The real question is... WHYYYY!?!?!?!?!?! would you want to?
Click to expand...
Click to collapse
erm.. i guess for fun, testing small progs and keep in touch with the lang when away from PC
Chainfire said:
Dude seriously, compiling is a very CPU intensive task. 5000 lines? That is exactly one nothing in code terms.
Oh please. My first desktop PC's CPU was 4.77mhz (with a turbo switch to 8!) and I'm considered a newbie in that area. While 500mhz is not necessarily slow, HTC hasn't produced a fast device in over two years. The HD is a horribly slow device.
Click to expand...
Click to collapse
Well, obviously i ammuch more younger (going to 20!) So my first PC was turbo-machine
Anyway! i guess nobody is going to use PPC IDE for that big progs and of course yes. they will take hours to compile (i guess)
Fast is a bit subjective i think.. What do u mean horribly slow? in terms of CPU, response time etc?
Thx everyone for the input!
PPC is pretty fast. You feel it is slow just because it has too many bad designed apps slow it down (must have while(1000) {Sleep(1000)} inside! no joking, I did see it sometimes!) and it has lack of good graphic driver (or chipset) so your TF3D has to use software to simulate semi-transparent effects and support z-order by allocating large buffer and repeatedly copy them.
Try pocketdos (or bochs emulator), you can run a windows 3.1 on ppc.
Then you can use TC, or old version of VC++/VB/Delphi etc on windows 3.1/dos
Considering emulator running on a real machine usually ~100 times slower than virtual machine, and ARM processor is a RISC chipset usually faster than CISC, your PPC is much faster than a Pentium even some Pentium III computer.
You may not understand how RISC faster than CISC. a function call in x86 cpu usually like
PUSH param1
PUSH Param2
Call function1 ( which push IP and stack again)
and more PUSH inside the function1.
it involves a lot of memory operations. memory is out of CPU so it is low.
A function call in ARM cpu usually like
MOV R0, param1
MOV R1, param2
BL function1 (which set return address in a register)
It doesn't use memory at all. everything is done within processor.
Pentium and after that solve this bottle neck by adding cache. But your code may not in cache when switching context. RISC is naturally faster.
ARM in general can be fast. However in MSM7K devices it usually isn't. All floating point operations for example are done in software, not hardware - this is why a lot of stuff is slow (try for example a Samsung chipset based on ARM, they are much faster for a lot of things). Hardware floating point is an absolute must for any multimedia related thing, and can affect any multiplication or division (and similar) where your compiler does not know at design time whether it will be an integer operation or not.
Furthermore, TF3D is actually one of the few things on these devices that actually does use hardware graphics acceleration.
Even then, while I do agree that RISC in general can be faster than CISC , no compiler worth its salt will use a stack-based calling convention (at least for non-exported functions) unless explicitly specified to do so. Register based function calling exactly like you give for your ARM example is quite normal on x86 as well.
And yes, my old and rusty 500mhz Pentium laptop literally ran circles around any MSM7K.
As far as I known compiler or IDE almost doesn't need float pointer operations at all.
386SX or 486SX works well and fast with old version of VB and VC.
That was an example for why MSM7K was slow. Even if it isn't applicable to compiling, it's still a slow-ass chip
Meme IDE
you could try this...its not c# or c++ but very similar
Build with a drag and drop editor. Develop complex functions using the unique MemeScript. A language created to make elements simple and cohesive on any platform.
It is currently in beta release and at the moment you can develop for Android and WM. IOS will be included in the full release and Blackberry further down the line.
OH and its FREE
find out more or download and play with it at www.memeapps.com
joememe said:
you could try this...its not c# or c++ but very similar
Build with a drag and drop editor. Develop complex functions using the unique MemeScript. A language created to make elements simple and cohesive on any platform.
It is currently in beta release and at the moment you can develop for Android and WM. IOS will be included in the full release and Blackberry further down the line.
OH and its FREE
find out more or download and play with it at www.memeapps.com
http://www.memeapps.com/
Click to expand...
Click to collapse
it is worth to try after the running download. Thank's for the hint.

Render-To-Texture with HTC Diamond 2

Hi everyone,
I have a small technical problem to solve and hopefully someone knows an answer for it. Someone gave me a HTC Diamond 2 (very nice toy I think). I don’t know which hardware is exactly inside the phone but I assume it’s an ATI ImageOn 2300 which fully supports OpenGL ES 1.0 + Extension Pack (that’s what GL_EXTENSION is saying). And all of these extensions are doing fine. As everyone knows HTC is not providing a D3D driver for their phones and all other drivers I have seen are just a wrapper around OpenGL ES. So using D3D is currently not an option.
I have to write an application which requires some render-to-texture functionality in realtime and here my problems are starting to grow.
[1] glCopyTexImage2D:
I recognized that glCopyTexImage2D() is very slow. My framerate is dropping dramatically from >100 frames down to ~20 frames. Somehow this is done in software by the driver and not hardware- accelerated. glCopyTexSubImage2D() is even more slow (down to ~10 frames per second), but both functions are working. I tried to move it into a different thread, but the driver is not supporting shared contexts. Also it’s not supporting two bound contexts at the same time with two different windows and threads. So this can’t be improved or I’m doing something wrong.
[2]PBuffers:
PBuffer are working fine. But PBuffers which can be bound to a texture are not supported by OpenGL ES 1.0. And that’s what happens also on this ATI card.
[3]GL_OES_framebuffer_object:
This was my preferred choice. But framebuffers are not officially supported by the installed OpenGL driver. But the libgles_cm.dll on the HTC is exporting these functions so I tried them and recognized that they are not working correctly. Somehow the vertex pipeline is allowing only triangles in the center of the viewport. All others will be discarded. When I turn it off it renders correct. Using glDrawTexiOES() will be ignored while using framebuffers. I assume that either the current implementation of the framebuffers is just waste of some development guys or the functionality is locked in some way.
[4]D3D:
Normally D3DM is supporting to switch between different rendertargets. But we are all know the D3D problem. I tested some other D3D drivers but they are not usable. Also I can’t imagine how render-to-texture will be implemented in these drivers while it’s not working in OpenGL.
I’m wondering what TouchFlow3D is using internally, whether they are using render-to-texture or not. The only thing I know is that they are using OpenGL ES and some extensions. But Manila.exe is querying the functions of libgles_cm.dll during runtime. So I have to write a few proxy dlls first and need to hook into the system to track what they are doing. And I don’t want to spend time on this.
Does someone knows an alternative to do some render-to-texture on the ATI or knows some secrets of the libgles_cm.dll which I don’t know? There are a lot of private functions inside but can’t find some documentation about it. Also ATI and Qualcomm are not very helpful to me.
Thanks.
Maybe, glReadPixels and then glTexSubImage2D (what probably glCopyTexImage2D is doing)?
(I know that this goes two times over the graphics bus, but you never know...)
What kind of scene (number of triangles, lights, textures) are you rendering with > 100fps?
glReadPixels() + glTexImage2D() is even more slow than glCopyTexImage2D...
Also this can't be parallized. I thought using AHI2DATI.dll instead to do the same thing, but I don't know how to get a surface handle from a OpenGL texture id.
>>>What kind of scene?
A very simple scene yet. Only a few depth sorted + material sorted objects (via VBO) with some textures (backed lighting) on it. Textures are compressed. Currently no lighting, no skinning or other things. While the render thread is waiting for glFinish() to return, a second thread prepares the next frame. Also the rendering thread is not redrawing the entire viewport each time.
The OpenGL texture id is the handle. There's nothing more you can do with it. PBuffers or framebuffer objects are the only way I know for doing performant render to texture in OpenGL.
No...I mean the surface handle of the AHI2DATI library. Here you have access to the raw data of the surface. Somehow the libgles_cm.dll uses these surfaces for it own buffers and/or textures or not?!
But this is not really useful unless someone tells us whats going on inside libgles_cm.dll.
See:http://greengalaxy.wordpress.com/2009/04/18/ati-direct-access-to-hardware/
Hi jeansmsixer, I don't think there is no efficient way to do it. Have you tried eglCopyBuffers?
Aren't all textures stored in system memory? - they surely have to be because the device reports no available video mem.
Even if you get a pointer to the color buffer, it's impossible to wrap the memory in a HBITMAP to select onto a HDC and use GDI fonts for instance. (which is what I need to do).
If you do write the proxy dll like you were suggesting, can you please let me know what TF3D does for fonts? Are they textures or have they somehow mixed 3D with GDI?
Hi jeansmsixer, something else you could try is what is described here:
http://brewforums.qualcomm.com/showthread.php?t=10668
Looking on glbenchmark.com it looks like HTC devices support the extension. You should be able to get a pointer directly to the color buffer (which I presume is in normal system memory) so you could copy off pixels fairly efficiently with your own memcpy(). However, you will need to eglWaitGL() etc to ensure 3d stuff is complete before attempting to access it.
I love the irony of the only helpful information for WM opengl being found on a brew site for symbian. If WM7 is as terrible as the current mess, then I'm moving to iPhone.

[C++] OpenGL Performance

hi developers,
i have developing in OpenGL for testing but i have a problem with the performance (tested in Diamond).
In attachements files you have a example compiled and the source code, its very simple, the scene is a set de icons (quads with 2 triangles). I do not understand how can this simple program has this performance (my iphonetoday its faster and its pure GDI), some developer can say me where is the problem?
I tried it on my diamond and I can confirm it's very choppy... maybe you could force the code to skip less frames somehow, I'm currently a noob at c++ and don't know anything about Open GL so..
Good luck anyways!
I use Vincent 3D, have i enable the graphics acceleration with some function?
Vincent3D is a software implementation, don't use it on the device! I'm using it only on the emulator while developing.
Just tried to run your example on my device but it starts and closes again without any message. (tried with and without Vincent3D)
Had a quick look in the code: you are requesting a 24bit framebuffer (R8G8B8) try (R5G6B5))!
Maybe you want to try my OpenGL test app found in my sig (check first post to get the latest version).
heliosdev said:
Vincent3D is a software implementation/QUOTE]
ooooooohhhh these is the key!!! Can you test now?? its very very fast!!
Click to expand...
Click to collapse
Cool, now it works on my device, too!
Now add an alpha layer to the texture to be 0 at the white corners and 1 everywhere else and enable alpha blending to get rid of the white corners to have 'round' icons.
To read an RGBA texture you'll have to use IImagingFactory::CreateImageFrom*.

Need help getting started with app development (windows, BSD) for stylus input note making app!

I have with experience in VLSI, shell scripting (bash, windows powershell) and basic programming languages like C and Python (Matlab too, which uses a similar syntax).
I want to get into app development but I am completely new to this and unfamiliar with the whole structure - the IO libraries, rendering libraries especially. I mainly like to develop it for Windows 11 (but would be nice if I could make it cross platform, say using something like Vulkan as rendering library).
I wish to make a stylus based note making app (similar to one note, drawboard pdf etc). I wish to know about the libraries available for taking input from surface pen (or other pens). I found that there are a few API available for windows - RealtimeStylus, Windows Ink, etc but I am unable to find anything cross platform. I would like to know if there are open source, or cross platform alternatives. Alternately, I would like to know if it is possible to bypass these and create a custom API myself (including my own algorithms for tracing curves and predicting handwriting etc, at present I am left to use whatever was done in these APIs I think), also possibly making it lower latency within the app. To some extent I realized that pen position is very similar to trackpad input (on the data input to pc side) and then we have tilt and pressure sensitivity data which I'm not sure how it is accessed and used. I remember reading a little about libsdl sometime ago. I would like to know if there are alternatives to libsdl, or if Vulkan supports any alternate libraries.
I would like to know how I could code a program that works on both x64 and aarch64 on windows 11 (Not into 32 bit as I belive my tool will use more than 4GB RAM anyway, as a priority), and as mentioned above, it would be fantastic if I could make it cross platform. What I got from this page is that ( https://docs.microsoft.com/en-us/windows/arm/ ) if I write my program in C++ it should be possible to compile it for both x64 and aarch64 (and make possible optimizations for each of them separately). I am not sure how the whole development environment works - what is dotnet, what is unity, what is xamarin, and differences between each. I found a few code macros in dotnet that help in rejecting certain inputs (could be useful for palm rejection etc) : ( https://docs.microsoft.com/en-us/do...s.uielement.isinputmethodenabled?view=net-5.0 ) (https://docs.microsoft.com/en-us/dotnet/api/system.windows.uielement.ishittestvisible?view=net-5.0 ). As far as I am aware dotnet is cross platform. I might want to make instruction level optimizations to the software (like SSE, AVX, certain 64 bit instructions etc if that gives any hint) and would like to know if the dotnet environment/toolkit has sufficient low level coding possibility to access these. Also, I am curious if it supports vulkan or opengl. Vulkan is written in C++ and supports multiple platforms so I am more inclined to try it.

Resources