From 44024e7a7a8ac758e5b4b3b624877d5ddf8474c6 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 31 Aug 2018 16:10:55 +0200 Subject: [PATCH] [d3d11] Implement Stream Output queries --- src/d3d11/d3d11_device.cpp | 10 -------- src/d3d11/d3d11_query.cpp | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index aa5065da3..214c3668f 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -985,16 +985,6 @@ namespace dxvk { ID3D11Query** ppQuery) { InitReturnPtr(ppQuery); - if (pQueryDesc->Query != D3D11_QUERY_EVENT - && pQueryDesc->Query != D3D11_QUERY_OCCLUSION - && pQueryDesc->Query != D3D11_QUERY_TIMESTAMP - && pQueryDesc->Query != D3D11_QUERY_TIMESTAMP_DISJOINT - && pQueryDesc->Query != D3D11_QUERY_PIPELINE_STATISTICS - && pQueryDesc->Query != D3D11_QUERY_OCCLUSION_PREDICATE) { - Logger::warn(str::format("D3D11Query: Unsupported query type ", pQueryDesc->Query)); - return E_INVALIDARG; - } - if (ppQuery == nullptr) return S_FALSE; diff --git a/src/d3d11/d3d11_query.cpp b/src/d3d11/d3d11_query.cpp index 3e64e22c5..5ca413a2a 100644 --- a/src/d3d11/d3d11_query.cpp +++ b/src/d3d11/d3d11_query.cpp @@ -36,6 +36,35 @@ namespace dxvk { VK_QUERY_TYPE_PIPELINE_STATISTICS, 0); break; + case D3D11_QUERY_SO_STATISTICS: + case D3D11_QUERY_SO_STATISTICS_STREAM0: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0: + // FIXME it is technically incorrect to map + // SO_OVERFLOW_PREDICATE to the first stream, + // but this is good enough for D3D10 behaviour + m_query = new DxvkQuery( + VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT, 0, 0); + break; + + case D3D11_QUERY_SO_STATISTICS_STREAM1: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1: + m_query = new DxvkQuery( + VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT, 0, 1); + break; + + case D3D11_QUERY_SO_STATISTICS_STREAM2: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2: + m_query = new DxvkQuery( + VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT, 0, 2); + break; + + case D3D11_QUERY_SO_STATISTICS_STREAM3: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3: + m_query = new DxvkQuery( + VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT, 0, 3); + break; + default: throw DxvkError(str::format("D3D11: Unhandled query type: ", desc.Query)); } @@ -246,7 +275,27 @@ namespace dxvk { data->DSInvocations = queryData.statistic.tesInvocations; data->CSInvocations = queryData.statistic.csInvocations; } return S_OK; + + case D3D11_QUERY_SO_STATISTICS: + case D3D11_QUERY_SO_STATISTICS_STREAM0: + case D3D11_QUERY_SO_STATISTICS_STREAM1: + case D3D11_QUERY_SO_STATISTICS_STREAM2: + case D3D11_QUERY_SO_STATISTICS_STREAM3: { + auto data = static_cast(pData); + data->NumPrimitivesWritten = queryData.xfbStream.primitivesWritten; + data->PrimitivesStorageNeeded = queryData.xfbStream.primitivesNeeded; + } return S_OK; + case D3D11_QUERY_SO_OVERFLOW_PREDICATE: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2: + case D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3: { + auto data = static_cast(pData); + *data = queryData.xfbStream.primitivesNeeded + > queryData.xfbStream.primitivesWritten; + } return S_OK; + default: Logger::err(str::format("D3D11: Unhandled query type in GetData: ", m_desc.Query)); return E_INVALIDARG;