locked
HLSL WindowsRuntimeComponent And SurfaceImageSource

    Question

  • I searched for an answer before asking and did not find one, came close but no cigar. I have a WindowsRuntimeComponent that's main class is a SurfaceImageSource all C++ and directx. I need to compile a HLSL and that requires a 'main' function. WindowsRuntimeComponents do not have 'main's therefore I'm getting erros. I tried a number of different settings in the HLSL complier properties tab to no avail. Any help?

    Thanks and regards,

    Bubba

    Wednesday, March 19, 2014 5:35 AM

Answers

  • The main function is part of your shader file, not a main function for the component itself.

    Take a look at the XAML SurfaceImageSource DirectX interop sample for a demonstration of using shaders for a SurfaceImageSource in a Windows Runtime Component. This should be very similar to your scenario.

    --Rob

    • Marked as answer by BubbaRichard Wednesday, March 19, 2014 2:26 PM
    Wednesday, March 19, 2014 6:02 AM
    Owner

All replies

  • The main function is part of your shader file, not a main function for the component itself.

    Take a look at the XAML SurfaceImageSource DirectX interop sample for a demonstration of using shaders for a SurfaceImageSource in a Windows Runtime Component. This should be very similar to your scenario.

    --Rob

    • Marked as answer by BubbaRichard Wednesday, March 19, 2014 2:26 PM
    Wednesday, March 19, 2014 6:02 AM
    Owner
  • It's strange because I took the original HLSL files from another windows sample project and they have no main.

    Thanks,

    Bubba

    Wednesday, March 19, 2014 2:27 PM
  • The actual name of the primary 'shader' function does not have to be "main".  Many hlsl files have a mix of different kinds of shaders (VS, PS, GS, etc.) and the exact name of the "Shader Function" set for each invocation changes. It just defaults to 'main' unless you provide a different name for compilation.

    Also, some older files are using the legacy Effects system which wraps this up into 'techniques' and 'passes'.

    http://blogs.msdn.com/b/chuckw/archive/2012/05/07/hlsl-fxc-and-d3dcompile.aspx


    Monday, March 24, 2014 7:45 PM
  • Techniques and passes are where I left Direct3d effects last.

    Thanks,

    Freddie Richard

    Tuesday, March 25, 2014 7:32 AM
  • You should take a look at DirectXTK. It includes a number of 'built-in' shaders that support many common scenarios. If nothing else, you can look at the HLSL source and the CompileShaders.cmd script for some examples.

    Tuesday, March 25, 2014 5:21 PM