{"record":{"id":"344acf77af5a4a8a","repo":"stride3d/stride","slug":"query-type-querytype-not-supported","errorCode":null,"errorMessage":"Query type {QueryType} not supported","messagePattern":"Query type (.+?) not supported","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/QueryPool.Direct3D11.cs","lineNumber":83,"sourceCode":"\n        base.OnDestroyed(immediately);\n    }\n\n    /// <summary>\n    ///   Implementation in Direct3D 11 that recreates the queries in the pool.\n    /// </summary>\n    /// <exception cref=\"NotImplementedException\">\n    ///   Only GPU queries of type <see cref=\"QueryType.Timestamp\"/> are supported.\n    /// </exception>\n    private unsafe partial void Recreate()\n    {\n        var queryDescription = new QueryDesc\n        {\n            Query = QueryType switch\n            {\n                QueryType.Timestamp => Query.Timestamp,\n\n                _ => throw new NotImplementedException($\"Query type {QueryType} not supported\")\n            }\n        };\n\n        nativeQueries = new ComPtr<ID3D11Query>[QueryCount];\n        for (var i = 0; i < QueryCount; i++)\n        {\n            ComPtr<ID3D11Query> query = default;\n            HResult result = NativeDevice.CreateQuery(in queryDescription, ref query);\n\n            if (result.IsFailure)\n                result.Throw();\n\n            nativeQueries[i] = query;\n        }\n    }\n}\n\n#endif","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/QueryPool.Direct3D11.cs#L65-L101","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use QueryType.Timestamp only when creating QueryPool on the Direct3D 11 backend.","Implement GPU queries via native D3D11 interop (ID3D11Query with occlusion/event descriptions) outside QueryPool if you need other types.","If another query type is essential, target the backend that supports it or extend the D3D11 QueryPool implementation with the missing switch case.","Guard pool creation so query type is checked against backend capabilities before construction."],"exampleFix":"// before\nvar pool = new QueryPool(device, QueryType.Occlusion, 4);\n// after\nvar pool = new QueryPool(device, QueryType.Timestamp, 4); // only Timestamp supported on D3D11","handlingStrategy":"validation","validationCode":"if (queryType != QueryType.Timestamp)\n    throw new NotSupportedException(\"D3D11 QueryPool supports only QueryType.Timestamp.\");\nvar pool = new QueryPool(device, queryType, count);","typeGuard":"static bool IsD3D11SupportedQuery(QueryType t) => t == QueryType.Timestamp;","tryCatchPattern":"try { pool = new QueryPool(device, queryType, count); }\ncatch (NotImplementedException) { pool = null; FallBackToTimestampQueries(); }","preventionTips":["Restrict query pools to Timestamp on D3D11","Check backend capabilities before choosing query types","Centralize query-type selection in one capability-aware factory","Handle Recreate calls after device reset so pools are only rebuilt with supported types"],"tags":["direct3d11","query-pool","not-implemented","querytype"],"backgroundTag":"unsupported-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}