I currently have a working app that can process images with a window handle. This of course makes use of the swap chain and so on... I need to process an image with pixel shader off screen without a window handle. I have not been able to successfully port this to an off screen model. Can any please help educate me on the best way to do this? I have the Device, context for both Direct3D and Direct2D available. I'm having issues with using the correct texture to image process...


First up create the DirectX device by calling New Direct3D11.Device and then you simply call DeviceContext.Flush in place of present.

Setup the device

    Dim FL As FeatureLevel() = New FeatureLevel(0) {}
    FL(0) = FeatureLevel.Level_11_1
    MainDevice = New Direct3D11.Device(Direct3D.DriverType.Hardware, DeviceCreationFlags.None, FL)

At the end of the frame


Texture creation

Dim ColorFormat As Format = Format.R8G8B8A8_UNorm
Dim BufferDesc As New Texture2DDescription() With {
 .ArraySize = 1,
 .BindFlags = BindFlags.RenderTarget Or BindFlags.ShaderResource,
 .CpuAccessFlags = CpuAccessFlags.None,
 .Format = ColorFormat,
 .Height = Height,
 .Width = Width,
 .MipLevels = 1,
 .OptionFlags = ResourceOptionFlags.None,
 .SampleDescription = New SampleDescription(1, 0),
 .Usage = ResourceUsage.Default

    Dim ColorBuffer As Texture2D = New Texture2D(MainDevice, BufferDesc)
    Dim ClorBufferRT AS RenderTargetView = New RenderTargetView(MainDevice, _buffer)
  • \$\begingroup\$ How can I create my RenderTargetView and so on without the SwapChain? Without the SwapChain I'm not sure how to get the textures that I would normally pull from SwapChain... \$\endgroup\$
    – user96556
    Jan 18 '17 at 23:03
  • \$\begingroup\$ just set textures up the normal way. Ill update my answer. \$\endgroup\$ Jan 18 '17 at 23:08
  • \$\begingroup\$ Outstanding! Thanks for that help. Just for giggles while I have you thinking about this... I've never done any off screen like this. I'm trying to shorten the process... I have an Image to process, single frame render... I need to pass in the image... convert to texture, then apply a compensation effect via pixel shader... I'm looking for speed and ease of use... any thoughts? \$\endgroup\$
    – user96556
    Jan 19 '17 at 1:02
  • \$\begingroup\$ Not really a faster way, what you are doing sounds about right but if you want to talk about it more we should proly turn this into a chat rather then spamming the comments \$\endgroup\$ Jan 19 '17 at 6:09
  • \$\begingroup\$ I'm new to this site. How would we turn this into a chat? I'm new to SharpDX and I'm struggling with stripping this app down to the bear bones... perhaps you know much better than me (I'm sure you do)... what is the minimum to run a pixel shader... this is OJT for me with SharpDX thrown in... \$\endgroup\$
    – user96556
    Jan 19 '17 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.