stride3d/stride · error · NotImplementedException

Query type not supported

Error message

Query type {QueryType} not supported

What it means

QueryPool.Recreate on the Direct3D 11 backend only maps QueryType.Timestamp to a native ID3D11Query; every other query type falls into the switch's default arm and throws NotImplementedException. The D3D11 implementation of query pools is minimal and does not support occlusion or statistics queries.

Solutions

  1. Use QueryType.Timestamp only when creating QueryPool on the Direct3D 11 backend.
  2. Implement GPU queries via native D3D11 interop (ID3D11Query with occlusion/event descriptions) outside QueryPool if you need other types.
  3. If another query type is essential, target the backend that supports it or extend the D3D11 QueryPool implementation with the missing switch case.
  4. Guard pool creation so query type is checked against backend capabilities before construction.

Example fix

// before
var pool = new QueryPool(device, QueryType.Occlusion, 4);
// after
var pool = new QueryPool(device, QueryType.Timestamp, 4); // only Timestamp supported on D3D11
Defensive patterns

Strategy: validation

Validate before calling

if (queryType != QueryType.Timestamp)
    throw new NotSupportedException("D3D11 QueryPool supports only QueryType.Timestamp.");
var pool = new QueryPool(device, queryType, count);

Type guard

static bool IsD3D11SupportedQuery(QueryType t) => t == QueryType.Timestamp;

Try / catch

try { pool = new QueryPool(device, queryType, count); }
catch (NotImplementedException) { pool = null; FallBackToTimestampQueries(); }

Prevention

When it happens

Trigger: Creating or recreating a QueryPool with QueryType set to anything other than Timestamp (e.g. Occlusion, Event, Statistics) on the Direct3D 11 backend. Happens in the QueryPool constructor and OnRecreate after device reset.

Common situations: Porting rendering code using occlusion queries from Vulkan to D3D11; generic profiling/GPU-timing helpers that assume all query types exist; device-lost recovery paths that call Recreate with a non-timestamp pool.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/344acf77af5a4a8a. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Graphics/Direct3D11/QueryPool.Direct3D11.cs:83

        base.OnDestroyed(immediately);
    }

    /// <summary>
    ///   Implementation in Direct3D 11 that recreates the queries in the pool.
    /// </summary>
    /// <exception cref="NotImplementedException">
    ///   Only GPU queries of type <see cref="QueryType.Timestamp"/> are supported.
    /// </exception>
    private unsafe partial void Recreate()
    {
        var queryDescription = new QueryDesc
        {
            Query = QueryType switch
            {
                QueryType.Timestamp => Query.Timestamp,

                _ => throw new NotImplementedException($"Query type {QueryType} not supported")
            }
        };

        nativeQueries = new ComPtr<ID3D11Query>[QueryCount];
        for (var i = 0; i < QueryCount; i++)
        {
            ComPtr<ID3D11Query> query = default;
            HResult result = NativeDevice.CreateQuery(in queryDescription, ref query);

            if (result.IsFailure)
                result.Throw();

            nativeQueries[i] = query;
        }
    }
}

#endif

View on GitHub (pinned to 96fad776d2)