Advertisement

Exception when creating a 2D render target

Started by January 25, 2018 05:40 PM
4 comments, last by SoldierOfLight 7 years ago

A new player of my game reported an issue. When he starts the game, it immediately crashes, before he even can see the main menu. He sent me a log file of my game and it turns out that the game crashes, when my game creates a 2D render target. Here is the full "Interface not supported" error message:


HRESULT: [0x80004002], Module: [General], ApiCode: [E_NOINTERFACE/No such interface supported], Message: Schnittstelle nicht unterstützt
    bei SharpDX.Result.CheckError()
    bei SharpDX.Direct2D1.Factory.CreateDxgiSurfaceRenderTarget(Surface dxgiSurface, RenderTargetProperties& renderTargetProperties, RenderTarget renderTarget)
    bei SharpDX.Direct2D1.RenderTarget..ctor(Factory factory, Surface dxgiSurface, RenderTargetProperties properties)
    bei Game.AGame.Initialize()

Because of the log file's content, I know exactly where the game crashes:


Factory2D = new SharpDX.Direct2D1.Factory();

_surface = backBuffer.QueryInterface<SharpDX.DXGI.Surface>();

// It crashes when calling this line!
RenderTarget2D = new SharpDX.Direct2D1.RenderTarget(Factory2D, _surface, new SharpDX.Direct2D1.RenderTargetProperties(new SharpDX.Direct2D1.PixelFormat(_dxgiFormat, SharpDX.Direct2D1.AlphaMode.Premultiplied)));

RenderTarget2D.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.Aliased;

I did some research on this error message and all similar problems I found were around six to seven years old, when people tried to work with DirectX 11 3D graphics and Dirext 10.1 2D graphics. However, I am using DirectX 11 for all visual stuff. The game runs very well on the computers of all other 2500 players. So I am trying to figure out, why the source code crashes on this player's computer. He used Windows 7 with all Windows Updates, 17179 MB memory and a NVIDIA GeForce GTX 870M graphics card. This is more than enough to run my game.

Below, you can see the code I use for creating the 3D device and the swap chain. I made sure to use BGRA-Support when creating the device, because it is required when using Direct2D in a 3D game in DirectX 11. The same DXGI format is used in creating 2D and 3D content. The refresh rate is read from the used adapter.


// Set swap chain flags, DXGI format and default refresh rate.
_swapChainFlags = SharpDX.DXGI.SwapChainFlags.None;
_dxgiFormat = SharpDX.DXGI.Format.B8G8R8A8_UNorm;
SharpDX.DXGI.Rational refreshRate = new SharpDX.DXGI.Rational(60, 1);

// Get proper video adapter and create device and swap chain.
using (var factory = new SharpDX.DXGI.Factory1())
{
    SharpDX.DXGI.Adapter adapter = GetAdapter(factory);
    if (adapter != null)
    {
        // Get refresh rate.
        refreshRate = GetRefreshRate(adapter, _dxgiFormat, refreshRate);

        // Create Device and SwapChain
        _device = new SharpDX.Direct3D11.Device(adapter, SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport, new SharpDX.Direct3D.FeatureLevel[]
        {
            SharpDX.Direct3D.FeatureLevel.Level_10_1
        });

        _swapChain = new SharpDX.DXGI.SwapChain(factory, _device, GetSwapChainDescription(clientSize, outputHandle, refreshRate));

        _deviceContext = _device.ImmediateContext;
    }
}

 

Are you sure that his Windows 7 is fully updated? The D3D11 + D2D interop came to Win7 as a platform update, KB2670838.

Advertisement

No, I am not. He told me he has all Windows Updates. I can't spy my players' computer and I don't want to do it :-) I will ask him.

Dear SoldierOfLight, thank you very much! My player installed this update manually and he could play the game afterwards! Thank you!!

Cool, glad I could help. That number is burned into my brain from all the troubles it caused, but I'm glad it's helping at least one person.

This topic is closed to new replies.

Advertisement