Windows 7/8, Direct3D9, 10, and 11 - Effects / Shaders - c#

Currently, i'm developing an app for the Windows 8 Store, Windows 8 Desktop and also Windows 7. The App should run smoothly on a Tablet and also on a "normal" Windows 7/8 Device. So, i got a tablet from my work and installed Windows 8 on it, just to realize, that the creepy Intel Graphics Media Accellerator (600) only supports DirectX 9.0c.
So, i tried for hours now to get my DirectX10/11 Effects/Shaders working on DirectX9, but nothing seems to work.. a Test with NVidia's FxComposer shows me, that DirectX9 Effects run good.
I'm programming with SharpDX / C#, and the technique10's and technique11's both are valid (MyTechnique.IsValid == true). To load the effect, i use theese lines of code:
var EffectByteCode = ShaderBytecode.CompileFromFile("DirectX/Shaders/"+FxFile, "fx_5_0", ShaderFlags.None, EffectFlags.None);
var Effect = new Effect(GraphicsProvider.Device, EffectByteCode, EffectFlags.None);
mEffect = FxEffect;
mTechnique11 = mEffect.GetTechniqueByName("main_11"); //works
mTechnique10 = mEffect.GetTechniqueByName("main_10"); //works
mTechnique9 = mEffect.GetTechniqueByName("main_9"); //doesn't work
I pasted the effect source code here: http://pastebin.com/KPxBN1DD.. excluded "main_11" and "main_10", in my tests, i commented them out, so i just removed those comment blocks.. i think dx9 should understand this very simple code..
So my final questions are:
- Is the parameter "fx_5_0" valid for loading technique, technique10 and technique11?
- Is my shader code correct? Or have i done something terribly wrong?
- Do i have to specify any other/additional information/functions/parameters for loading DX9 technique's?
- Maybe its a bug of SharpDX? I will take look on the code for this now i think..
Edit: Tried to make the question(s) a bit clearer..

The legacy Effect framework is not supported on Windows 8 Metro (because D3DCompiler_xx.dll is not supported), so you should better work with another solution. Also, Effect is deprecated by Microsoft and no longer supported.
The old Direct3D9 technique(compiled with vs_2_0 or ps_2_0) are not stored in FX files compiled with fx_5_0 (just check the output of fxc.exe compiler and you won't see them).
You have to use vs_4_0_level_9_x or ps_4_0_level_9_x in order to compile them for 9.x down level hardware support using technique10/11 syntax. Also, if all your original shaders could work with vs_4_0_level_9_x and you don't have any specific optimized version for 10.0 or 11.1, then you wouldn't have to compile a main_10 or main_11, as level_9_x shaders are working on any hardware from 9.x to 11.x.
You can probably have a look at SharpDX.Toolkit, not yet official, but It is supporting an Effect framework (with some XNA stock effects like BasicEffect or SpriteBatch). A beta of the toolkit will be available later this month.

Try replacing the SV_TARGET semantic with COLOR0. I've never seen SV_TARGET semantic in D3D9 shaders so far.

Related

C# OpenTK - Linux Console without X11

I was just wondering if it is possible to render the OpenTK gamewindow in a Linux Console (Raspberry Pi Raspbian) without any X11 Desktop?
If it possible, how do you do it?
Yes, it's experimental since 1.1 or 1.2. Adjust OpenTK.dll.config if some dll could not be found, and maybe you'll have to find correct libinput version (libinput-0.2.0 is working on my debian) to match api binding in opentk. I'm not fully sure, but I think that it's only working with modern GL (>3.0).
Ensure you have libdrm, libgbm and correct libinput on your system and latest mesa.
OpenTK will automaticaly detect linux console environment if program is launched from a console.
If you face trouble finding missing dll's, enable full debug messages in Otk.
I have this working but it took a bit of work. First I created a c library to call through to the native libraries for controlling the gl chipset on the PI and exposed these so that I could call them from C#.
Secondly I had to recompile the opentk with the switch to not use dynamic bindings. In the end I stripped out most of the game window logic and just used the bindings and the maths code from opentk.
More details and code here:
http://www.opentk.com/node/4024
Basically this is enough to get you clearing / swapping the screen etc and you can then add the binding code through to the GL ES 2.0 spec which you can generate in the opentk project / solution tools.

XNA 4.0 game doesn't do anything when ran on another PC

This issue is getting real tiresome and I've been spending atleast 2 days looking around for an answer. Basically, I want to publish a game, and I've hired a friend of mine to test it out before I officially release it. Whenever he runs it, reports as "nothing happends".
These conditions are met:
He has installed the .NET Framework 4.0 and the XNA Redistributable 4.0 (he most likely also has installed other .NET Frameworks and XNA Frameworks as well, because nothing worked).
The game is compiled onto a Release build.
GamerService referenced is removed.
A possible issue could be that he's using Win8, but as my searching experience goes, XNA DEVELOPMENT is only restricted on Windows 8, right?
So, what's going on? I'm clueless.. I even put a MessageBox.Show(); after the execution of my game in my Program.cs file via try/catch, and no results.
Are there any extreme conditions in my code that I need to meet?
Any site describing 100% of all requirements to run an XNA game and the most proper way to build it?
Any issues when using non-distributable "developer tools" in XNA coding? If so, what includes in these "developer tools", and what do I need to modify? (I noticed that on another thread).
An answer to this issue would more than make my day...
Ah, and also, I tried running it on a virtual machine ( Windows 7 ) but then it spat out a messagebox saying Index outside the bounds of the array on a perfectly valid code execution, and various other random errors such as missing files when they clearly are there.
Thank you greatly!
In summary I think your app wont run on Windows 8, let me explain:
Windows 8
A possible issue could be that he's using Win8, but as my searching experience goes, XNA DEVELOPMENT is only restricted on Windows 8, right?
Officially, desktop games using unmodified Microsoft XNA 4/is not supported on Windows 8 in any form:
Microsoft officials have said the XNA tools/runtime environment used primarily by game developers isn't supported on Windows 8. - Read more...
Redistributables
Any issues when using non-distributable "developer tools" in XNA coding?
That depends on whether they are required at runtime on the target machine. That might sound like an oxymoron but in Windows c/c++, I can have an app that depends on Microsoft DLLs but we are not allowed to deploy the DLLs, one must depend on it being present in the OS; service pack or some other form. Is there something you are missing?
Windows 7
Ah, and also, I tried running it on a virtual machine ( Windows 7 ) but then it spat out a messagebox saying Index outside the bounds of the array on a perfectly valid code execution
This is more interesting and I suspect is one of the more testable aspects of your application (also that it is not Windows 8). I suggest you setup a remote-debug session to your Win7 VM or if that is not possible, use Debug.WriteLine() or equivalent displaying critical state contents.

C# Joystick Input

I've got a Logitech Attack 3 (Standard Joystick) plugged into my computer and have confirmed that it is working. Now given that, I need a way via C# (only C#) to read the axis (and buttons would be nice too) values from the joystick. I have seen many examples which use DirectX, but are from 8 years ago and no longer work with .NET 4.5...Hence, I need a .NET 4.5 solution that works on Visual Studio 2012. I have done extensive research on this and cannot find a way to get simple coordinates from a joystick. Any help would be appreciated. Thanks!
I have tried to use SlimDx, but have no idea what code to write.
Also, this: http://www.codeproject.com/KB/directx/joystick.aspx <-- this is from 2006, and no longer works with .NET 4.5 for some reason.
Those examples you've looked at should still be fairly correct. What has changed is the directX version and I think you should have a look at directX11 to use in your project.

Creating a universal video player (XP, vista, 7)

Im trying to create a media player (in C# .net 4.0) that will work on windows XP (SP3), vista and 7. Normally I would just go the easy way and use WPF's own MediaElement, but since that relies on Windows Media Player 10 or newer, that wont work as Windows XP SP3 may only have WPM9.
First I tried downloading Jerimiah Morill's WPF MediaKit sample application, but this used the EVR which wont show on my test machine (a Windows xp SP3 only with default codecs and default programs, plus the various .Net framework installations). I also downloaded the binaries and tore these apart, creating a new project only with reference to the DirectShow-dll and the bare minimums from the WPF mediakit, this time with no reference whatsoever to EVR. Still no luck. This i'm having a hard time understanding - should'nt even Windows XP be able to play movies using VMR stright out of the box?
I found some samples of media players where one of these works. This one is called DxPlay and uses directshow's graphbuilder, but is built in winforms, has some rather raw-looking code, and will not scale, seek, handle audio, and in general seems rather sketchy.
So, Is there any easy way to create a media player that will play on all the mentioned platforms without pushing WMP10+? I had high hopes for WPF MediaKit, but something is preventing it from playing on Windows XP SP3 (any solution to this would be very interesting).
Thank you very much in advance!
-ruNury
I would try to wrap VLC media player in your .Net project.
Here are some .Net projects that might help you:
http://vlcdotnet.codeplex.com/
http://sourceforge.net/projects/libvlcnet/
http://www.codeproject.com/Articles/109639/nVLC
MSDN suggest EVR (Enhanced Video Renderer) for video output in systems where it is supported: Windows Vista and later. With its introduction, its predecessors - Video Mixing Renderer filter (versions 7 and 9) were cut on smooth scaling of video. Video Mixing Renderer 7 is also less capable in terms of customization, however it consumes far less resources (does not use Direct 3D) and you can output way more videos at once.
Your standard solution here is to support both VMR and EVR output and use the latter starting Windows Vista, fall back to the former otherwise.
EVR is "unofficially" installed in Windows XP with .NET runtime and can be used with an instantiation trick: you the respective DLL is not COM registered and you cannot create an instance using CoCreateInstance API, however you succeed if you do CoLoadLibrary, DllGetClassObject and friends.
For C# development you typically consume DirectShow through DirectShow.NET Library.

Problem arises in XNA when going between VSC# 2008 to 2010 [duplicate]

This question already has answers here:
Graphics Card and XNA 4.0
(3 answers)
Closed 2 years ago.
My problem is that I have written code in Visual C# for a background for a game that is part of my grade in a class. The background has multiple layers moving at different speeds is how I modified some code... I did this in 2008 version with XNA 3.1 and it worked fine and the background ran like intended. But when I went and ran the exact same code in the 2010 version on XNA 4.0 this error message appeared that states:
"No suitable graphics card found.
Could not find a Direct3D Device that supports the XNA Framework
HiDef profile.
Verify that a suitable graphics device is installed.
Make sure the desktop is not locked, and that no other application is
running in full screen mode.
Avoid running under Remote Desktop or as a Windows service.
Check the display properties to make sure hardware acceleration is set
to Full."
I understand that is says I need a better graphics card,but i was confused at the fact is worked in 2008 easily... so I went and change my setting to try and fix the problem to no avail. Is my graphic card not good, even though it worked in 2008 consistently? Have anyone else encountered this message and if so how did you fix it? I am wondering how do I make it so that I can run the said background in 2010 version. Appreciate any assistance...
There are many breaking changes between XNA 3 and 4. I would finish out the project in 3.1 if I were you. In 4.0:The HiDef profile requires DX10 hardware. The Reach profile supports older hardware.
This covers how to get to the older profile and what is covered by it.
Link
You need to have a better graphics card... Xna 3.1 uses Shader version 1.2 and Xna 4 uses shader 3 version. Your card doesn't support the correct shader version.

Categories

Resources