Debugging HLSL for Windows 8 application - directx

i'm currently in the process of creating a Windows 8 applicaiton using SharpDX (the managed c# directx wrapper). However I have ran into problems with one of my shaders and I want to know if its possible to debug such applications. PIX doesn't seem to work of directX apps as the executable does not like opening directly, and the new visual studio graphics debugging toolkit in VS2012 always states "unable to start the experiment" when I try to capture any information about my session.
Thanks!

I'm coming to this post a bit late, but I would just like to add for future visitors to this thread that I have successfully used the Visual Studio 2012 Graphics Diagnostics ('the DirectX Debugger') in both SlimDX and SharpDX projects. There are a few things that can disrupt the process, notably in SlimDX projects I couldn't debug apps with mixed DX10/11, DX10 doesn't seem to work with VS2012, at least for managed code. So if you have any text rendering for example, you will have to remove it for the debugging session. I'd say using the following to isolate your DX10 code should work
#define DXDIAGSESSION
// ...
#if DXDIAGSESSION
// your DX10 code goes here.
#endif
And for the SharpDX project (C# / WinRT / XAML / SharpDX) I couldn't use the Managed Only Debugger. I had to set the Debugger to Mixed (Managed and Native) to make it work.

The DirectX Visual Studio debugger only works with native code. You'll get the error that you are until you right-click on the project, select "Properties", go to the Debugging tab, and enable native debugging.
While that will remove the error it may or may not resolve the problem. I've got a similar scenario using SurfaceImageSource (C++) being hosted in a managed component and a DirectXPage in a C++ project. In both projects it appears that DirectX debugging is failing to capture frames. It appears this feature only works for programs that are using a DirectX UI (no managed UI components).

Related

IDXGIFactory2::CreateSwapChainForHwnd fails

https://1drv.ms/u/s!AkVRV9eGJ20rgTu13uTcNkhp0eZb?e=lwMe70
That links takes you to my OneDrive where you can download my Visual Studio 2022 solution and project (it is a .7z file of 17.7KB), it only has code to display a win32 window and little more. I also included an image that tells you my DirectX specs that the DirectX Diagnostic Tool reports. The image is the following image:
The problem is what the title says, I would like you to see if you can compile it without problems, I am afraid that it may be failing because I can't use Direct3D 11.1 (is Direct3D 11.1 a requirement? I can't find information about it), but then I tried creating the D3D device with the D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY creation flag (https://learn.microsoft.com/en-us/windows/win32/api/d3d11/ne-d3d11-d3d11_create_device_flag) just to test if I can use Direct3D 11.1 (because that flag is not supported until Direct3D 11.1) and the creation succeeded... so I don't know anymore...
When you program with DirectX make sure you always enable the "debug layer" in dev and check the output in Visual Studio's "Output" window (or other debugger output).
Check these links: Using the debug layer to debug apps and Direct3D SDK Debug Layer Tricks for more on this as the way it can be installed has changed over DirectX version and years...
This will show you why it fails:
Alpha blended swapchains must be created with
CreateSwapChainForComposition, or CreateSwapChainForCoreWindow with
the DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER flag.

Video player in JUCE (C++) - building on Windows running on iOS

I'd like to know what is the simplest way to build a video playing app that runs under iOS. I'm using the JUCE Framework that allows to develop under Windows with e.g. Visual Studio and code programs for Android, iOS, etc.
I've looke around libVLC, FFMPEG and so on. But all of these are intended to be developed under Linux, I think.
Does somebody have an easy Example for JUCE to build an iOS player app working under Visual Studio?
Coding
There's nothing to step you writing the code itself; IDEs are just fancy text editors with other tools built in (in the case of Visual Studio, a full code translation toolchain).
You'll probably find that things like code completion won't work, as JUCE will #ifdef parts of the codebase out depending on what project type you're launching, but last I checked (when I worked there) there was no Visual Studio iOS project exporter available, so you'll have to just use a Windows compatible one and program through that.
Building
In order to build an iOS app, you need a Mac. If you take a look at the documentation, it states:
For iOS projects, connect to a networked Mac and start the Mac emulator from Visual Studio.
No cross-platform library that I know can circumvent this restriction; I believe it's due to a legal requirement enforced by Apple.
With that said, if you don't own a Mac you might be able to "rent" one using a service like Mac In Cloud. I'm not a lawyer, some please make sure you check the legality of using such a cloud service for building iOS apps before doing so.
Debugging
Since you need to be able to compile in order to debug a specific build of the application, the section on building applies. Of course, there's nothing stopping you from debugging it without a build by reading the source code carefully, but I'm guessing that's not what you're asking about.

Can OpenCV libraries be called from a C++/CX app?

Is it technically possible (I don't think this would be restricted), and how do you go about it?
I got my little test app building fine, but when I run it I get a failure dialog.
The debug output is slightly more informative:
The thread 0xe4c has exited with code -1073741515 (0xc0000135).
The program '[3400] OpenCVTest2.exe' has exited with code -1073741515 (0xc0000135) 'A dependent dll was not found'.
Then I created a Win8 Desktop app, which also built fine but failed to run.
MSVP100D.dll is part of the VC++ 2010 Redistributable which is not compatible with Win8. (Being a hacker I tried it anyway, the installer runs to completion - but the bits aren't installed.)
Is there a compiler flag I can try? Possibly a custom build of OpenCV would fix it, but that would be a last resort, and it might only fix the desktop app.
This guy shows an example of using OpenCV library for performing face detection in a Windows 8 Store app written using C++/CX:
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/DEV322
Also, at the below post he also describes how the C++ Runtime works for Windows 8Store apps:
http://blogs.msdn.com/b/vcblog/archive/2012/09/28/10354327.aspx
MSVP100D is not a part of VC10 redist. Note the "D" at the end of its name. That package only includes release builds. Your release builds should work fine. But mixing libraries from different VC versions might get you in trouble. See this. Your best chance is to build from source with VC11.

Using DirectX Effect11 with Visual Studio 2012

I recently updated to Visual Studio 2012 Ultimate. I was programming previously with DirectX 11 June 2010 SDK and want to continue to do so using Visual Studio 2012. However, I discovered that VS2012 comes with its own DirectX SDK (in Windows Kit 8.0) and I've been trying to migrate my code using the newer versions of d3d11. Everything went fine until I try to use effect files in my project (.fx files). I had to compile the Effects11 Sample in the DirectX SDK using VS2012 and link the lib file in my project. That went fine too. However, when I compile my project the function D3DX11CreateEffectFromMemory returns a E_NOINTERFACE error (no such interface is supported). Can anyone tell me why is that? Note that I'm using the d3d11.lib from the Windows Kit and the d3dx11.lib from the DirectX SDK. Perhaps I shouldn't mix them? However, everything else works fine when I mix them, except for the effect file creation.
Any help would be appreciated.
P.S. I don't know if this is helpful but just so you know, if I add an additional library directory in the project settings of "DirectXSDKInstallPath\lib\x86\" it works. Why is that? Does it mean I'm using the older version of the libraries? This will give a ton of warnings about redefined headers in winerror.h
D3DX Library has been deprecated for the newest version of DirectX 11 (Windows 8). See http://msdn.microsoft.com/en-us/library/windows/desktop/bb172965(v=vs.85).aspx
Effects are now handled a different way. You can program your own library to load effects or use DirectX Tool Kit (DirectXTK): http://directxtk.codeplex.com/
Microsoft has recommended this tool kit on their web site, see http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx for more information.
Effect11 has moved to https://fx11.codeplex.com/, you need to compile it and link yourself.
DirectXTK does not provide the effect11 interface, but only simplified effects
This is probably caused by d3d library conflicts.
Make sure what d3d libraries you are using.Because there are 2 different d3d libraries.
One in DXSDK_DIR\Lib\x86 or \x64,and one in c:\program files(x86?)\Microsoft SDKs.
If you are using DXSDK, then pass $(DXSDK_DIR)Include $(DXSDK_DIR)Lib\x86 ahead of Microsoft SDKs' includes,libs directory in the Include directories and Library directories fields respectively.
In the previous version of Direct3D, the effects framework worked out of the box once you linked with the D3D10 library. In Direct3D 11, the effects framework has been moved to the D3DX library, and you have to include a separate header file (d3dx11Effect.h) and link with a separate library (D3DX11Effects.libfor release builds and D3DX11EffectsD.libfor debug builds).
Furthermore, in Direct3D 11, they give you the full source code for the effects library code (DirectX SDK\Samples\C++ \Effects11). Thus, you could modify the effects framework for your own needs. In this book, we will only be using the effects framework as is, without modification. In order to use the library, you need to first build the Effects11project in both release and debug mode to generate the D3DX11Effects.lib and D3DX11EffectsD.libfiles; you will only need to do this once unless the effects framework is updated (e.g., a new version of the DirectX SDK may update these files, so you may want to rebuild the .lib files to get the latest version). The d3dx11Effect.h header file can be found in DirectX SDK\Samples\C++\Effects11\Inc.
For our sample projects, we place the d3dx11Effect.h, D3DX11EffectsD.lib, and D3DX11Effects.libfiles in the Commondirectory that all of our projects share code from (see the “Introduction” for a description of the sample project organization).

OpenCV 2.4 VideoCapture gets no input from webcam when launched standalone

I am using OpenCV 2.4 in my project to process the images from webcam. Everything works fine in Visual Studio 2010 (both release and debug builds), but when I try to launch exes directly from explorer, the app does not the get input. The camera is started however - it's control LED is on.
Does someone know how to make it work standalone?
I have found something relevant here:
http://rafaelbarreto.com/2011/06/05/opencv-2-2-webcam-windows-not-working/
and here:
Can't access webcam with OpenCV
I tried to follow the steps, building OpenCV 2.4 with these prepocessor definitions, but it did not solve my problem.
Thanks
Solved. The problem was, that Visual Studio linked shader sources from somewhere else than during the exectution through IDE.
If the same happens to you, be sure to check it at least four times (I checked 3x).

Resources