.netdirectx-12

Why do I get a System.AccessViolationException when using DirectX12 with Evergine?


Problem Description

I try to draw a white triangle on the screen using Evergine with DirectX 12.

I've made a repository with minimal code base for this purpose, see HelloTriangle

Using DirectX 11 as a graphic context, it works fine, but with DirectX 12, it does not. See Renderable.cs -> Initialize().

When using DirectX 12, I get following exception:

An unhandled exception of type 'System.AccessViolationException' occurred in Vortice.Direct3D12.dll Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

at the line 118 at Triangle.cs -> RenderInternal(...):

commandBuffer.SetGraphicsPipelineState(_pipelineState);

Can somebody explain me, what might be the cause for this exception and how to fix it?

Things I've tried so far

1. Changing position in HLSL to float3

Since the vertices are stored as Vector3 data, I changed the input position in the HLSL file to float3. Didn't help.

I also tried storing Vector4 data instead of Vector3 and accessing them with float4 in the shader. Didn't work too.

2. Compile Shader with higher profile

Since DirectX12 needs shader model language 5.1, I tried to compile with a higher profile:

var compilerParams = CompilerParameters.Default with { Profile = GraphicsProfile.Level_12_0 };
var byteCode = graphicsContext.ShaderCompile(sourceCode, entryPoint, shaderStages, compilerParams).ByteCode;

This made no difference.

Summary

I suspect that something's wrong with the Evergine.DirectX12 package, but at the same time, this only seems too improbable.

Thanks for any help.

If it helps, there is a sample project by Evergine showing how to use the low-level API where I get my inspirations from: Link


Solution

  • Updating the Intel HD Graphics driver was the solution.

    I was assuming, that my application would run using the Nvidia GPU of my system, but that was not the case. Instead, the processor graphics of Intel was used. And its driver was outdated.

    Thanks to Paweł Łukasik for the hint.