stride3d/stride · error · NotImplementedException

Query type not supported

Error message

Query type {QueryType} not supported

What it means

QueryPool.Recreate creates a D3D12 query heap, but the switch only maps QueryType.Timestamp to a heap type; every other QueryType (e.g. Occlusion, PipelineStatistics) is unimplemented in this backend and throws NotImplementedException.

Solutions

  1. Use QueryType.Timestamp only on Direct3D12
  2. Guard feature code by graphics platform/API and disable non-timestamp queries on D3D12
  3. Implement or wait for backend support (contribute the QueryHeapType mapping for additional query types)

Example fix

// before
var pool = new QueryPool(device, QueryType.Occlusion, 64);
// after
var pool = new QueryPool(device, QueryType.Timestamp, 64);
Defensive patterns

Strategy: fallback

Validate before calling

if (queryType != QueryType.Timestamp) throw new PlatformNotSupportedException("Only Timestamp queries are supported on Direct3D12");

Type guard

bool IsSupportedQuery(QueryType q) => q == QueryType.Timestamp;

Try / catch

try { pool = new QueryPool(device, queryType, count); } catch (NotImplementedException) { pool = null; /* disable GPU timing feature */ }

Prevention

When it happens

Trigger: Creating a QueryPool with QueryType other than Timestamp on the Direct3D12 backend (e.g. new QueryPool(device, QueryType.Occlusion, count)).

Common situations: Code shared across backends (Vulkan supports more query types) running on D3D12; enabling profiling/GPU-stat features that request non-timestamp queries.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Graphics/Direct3D12/QueryPool.Direct3D12.cs:132

            return false;
        }

        /// <summary>
        ///   Implementation in Direct3D 12 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 description = new QueryHeapDesc
            {
                Count = (uint) QueryCount,
                Type = QueryType switch
                {
                    QueryType.Timestamp => QueryHeapType.Timestamp,

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

            HResult result = NativeDevice.CreateQueryHeap(in description, out ComPtr<ID3D12QueryHeap> queryHeap);

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

            nativeQueryHeap = queryHeap;

            var readbackBufferDesc = new ResourceDesc
            {
                Dimension = ResourceDimension.Buffer,
                Width = (uint) QueryCount * sizeof(long),
                Height = 1,
                DepthOrArraySize = 1,
                MipLevels = 1,
                Alignment = 0,

View on GitHub (pinned to 96fad776d2)