Skip to content

Commit 7aac37e

Browse files
committed
Nuked TransformFeedbak query type
1 parent 13974d8 commit 7aac37e

File tree

5 files changed

+49
-109
lines changed

5 files changed

+49
-109
lines changed

include/nbl/video/IQueryPool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class IQueryPool : public core::IReferenceCounted, public IBackendObject
1616
EQT_OCCLUSION = 0,
1717
EQT_PIPELINE_STATISTICS = 1,
1818
EQT_TIMESTAMP = 2,
19-
EQT_TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, // VK_EXT_transform_feedback
2019
EQT_PERFORMANCE_QUERY = 1000116000, // VK_KHR_performance_query
2120
EQT_ACCELERATION_STRUCTURE_COMPACTED_SIZE = 1000150000, // VK_KHR_acceleration_structure
2221
EQT_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE = 1000150001, // VK_KHR_acceleration_structure

src/nbl/video/COpenGLCommandBuffer.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -992,18 +992,6 @@ COpenGLCommandBuffer::~COpenGLCommandBuffer()
992992

993993
getQueryBufferObject(query, bufferId, pname, currentDataPtrOffset);
994994
}
995-
else if(queryType == IQueryPool::E_QUERY_TYPE::EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
996-
{
997-
assert(queryPoolQueriesCount * 2 == queriesRange.size());
998-
assert(c.stride >= queryElementDataSize * 2);
999-
1000-
GLuint query1 = queries[i+c.firstQuery];
1001-
GLuint query2 = queries[i+c.firstQuery + queryPoolQueriesCount];
1002-
1003-
// Write All
1004-
getQueryBufferObject(query1, bufferId, pname, currentDataPtrOffset);
1005-
getQueryBufferObject(query2, bufferId, pname, currentDataPtrOffset + queryElementDataSize);
1006-
}
1007995
else
1008996
{
1009997
assert(false && "QueryType is not supported.");
@@ -1017,7 +1005,7 @@ COpenGLCommandBuffer::~COpenGLCommandBuffer()
10171005
{
10181006
auto& c = cmd.get<impl::ECT_WRITE_TIMESTAMP>();
10191007
const COpenGLQueryPool* qp = static_cast<const COpenGLQueryPool*>(c.queryPool.get());
1020-
const GLuint query = qp->getQueries()[c.query];
1008+
const GLuint query = qp->getQueryAt(c.query);
10211009
assert(qp->getCreationParameters().queryType == IQueryPool::E_QUERY_TYPE::EQT_TIMESTAMP);
10221010
gl->glQuery.pglQueryCounter(query, GL_TIMESTAMP);
10231011
}

src/nbl/video/COpenGLQueryPool.h

Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ class COpenGLQueryPool final : public IQueryPool
3636
queries.resize(_params.queryCount);
3737
gl->extGlCreateQueries(GL_TIMESTAMP, _params.queryCount, queries.data());
3838
}
39-
else if(_params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
40-
{
41-
// Vulkan Transform feedback queries write two integers;
42-
// The first integer is the number of primitives successfully written to the corresponding transform feedback buffer
43-
// and the second is the number of primitives output to the vertex stream.
44-
// But in OpenGL there you need twice the queries to get both values.
45-
queries.resize(_params.queryCount * 2);
46-
gl->extGlCreateQueries(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, _params.queryCount, queries.data());
47-
gl->extGlCreateQueries(GL_PRIMITIVES_GENERATED, _params.queryCount, queries.data() + _params.queryCount);
48-
}
4939
else
5040
{
5141
assert(false && "QueryType is not supported.");
@@ -56,6 +46,19 @@ class COpenGLQueryPool final : public IQueryPool
5646
{
5747
return core::SRange<const GLuint>(queries.data(), queries.data() + queries.size());
5848
}
49+
50+
inline GLuint getQueryAt(uint32_t index) const
51+
{
52+
if(index < queries.size())
53+
{
54+
return queries[index];
55+
}
56+
else
57+
{
58+
assert(false);
59+
return 0u; // is 0 an invalid GLuint?
60+
}
61+
}
5962

6063
inline void beginQuery(IOpenGL_FunctionTable* gl, uint32_t queryIndex, E_QUERY_CONTROL_FLAGS flags) const
6164
{
@@ -70,13 +73,6 @@ class COpenGLQueryPool final : public IQueryPool
7073
{
7174
assert(false && "TIMESTAMP Query doesn't work with begin/end functions.");
7275
}
73-
else if(params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
74-
{
75-
GLuint query1 = getQueryAt(queryIndex);
76-
GLuint query2 = getQueryAt(queryIndex + params.queryCount);
77-
gl->glQuery.pglBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query1);
78-
gl->glQuery.pglBeginQuery(GL_PRIMITIVES_GENERATED, query2);
79-
}
8076
else
8177
{
8278
assert(false && "QueryType is not supported.");
@@ -97,11 +93,6 @@ class COpenGLQueryPool final : public IQueryPool
9793
{
9894
assert(false && "TIMESTAMP Query doesn't work with begin/end functions.");
9995
}
100-
else if(params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
101-
{
102-
gl->glQuery.pglEndQuery(GL_PRIMITIVES_GENERATED);
103-
gl->glQuery.pglEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
104-
}
10596
else
10697
{
10798
assert(false && "QueryType is not supported.");
@@ -124,13 +115,6 @@ class COpenGLQueryPool final : public IQueryPool
124115
{
125116
assert(false && "TIMESTAMP Query doesn't work with begin/end functions.");
126117
}
127-
else if(params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
128-
{
129-
GLuint query1 = getQueryAt(queryIndex);
130-
GLuint query2 = getQueryAt(queryIndex + params.queryCount);
131-
gl->glQuery.pglBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, index, query1);
132-
gl->glQuery.pglBeginQueryIndexed(GL_PRIMITIVES_GENERATED, index, query2);
133-
}
134118
else
135119
{
136120
assert(false && "QueryType is not supported.");
@@ -151,11 +135,6 @@ class COpenGLQueryPool final : public IQueryPool
151135
{
152136
assert(false && "TIMESTAMP Query doesn't work with begin/end functions.");
153137
}
154-
else if(params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
155-
{
156-
gl->glQuery.pglEndQueryIndexed(GL_PRIMITIVES_GENERATED, index);
157-
gl->glQuery.pglEndQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, index);
158-
}
159138
else
160139
{
161140
assert(false && "QueryType is not supported.");
@@ -167,13 +146,9 @@ class COpenGLQueryPool final : public IQueryPool
167146
{
168147
// NOTE: There is no Reset Queries on OpenGL but to make the queries invalid/unavailable and not return the previous ones we just delete the queries and recreate them.
169148
// TODO: Needs test
170-
size_t logicalQuerySize = 0ull;
171-
if(params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
172-
logicalQuerySize = queries.size() / 2ull;
173-
else
174-
logicalQuerySize = queries.size();
149+
size_t querySize = queries.size();
175150

176-
if(query + queryCount > logicalQuerySize)
151+
if(query + queryCount > querySize)
177152
{
178153
assert(false);
179154
return false;
@@ -189,32 +164,10 @@ class COpenGLQueryPool final : public IQueryPool
189164
gl->glQuery.pglDeleteQueries(queryCount, queries.data() + query);
190165
gl->extGlCreateQueries(GL_TIMESTAMP, queryCount, queries.data() + query);
191166
}
192-
else if(params.queryType == EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
193-
{
194-
gl->glQuery.pglDeleteQueries(queryCount, queries.data() + query);
195-
gl->glQuery.pglDeleteQueries(queryCount, (queries.data() + logicalQuerySize) + query);
196-
gl->extGlCreateQueries(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queryCount, queries.data() + query);
197-
gl->extGlCreateQueries(GL_PRIMITIVES_GENERATED, queryCount, (queries.data() + logicalQuerySize) + query );
198-
}
199167

200168
return true;
201169
}
202170

203-
protected:
204-
205-
inline GLuint getQueryAt(uint32_t index) const
206-
{
207-
if(index < queries.size())
208-
{
209-
return queries[index];
210-
}
211-
else
212-
{
213-
assert(false);
214-
return 0u; // is 0 an invalid GLuint?
215-
}
216-
}
217-
218171
};
219172

220173
} // end namespace nbl::video

src/nbl/video/CVulkanQueryPool.h

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,49 @@ class ILogicalDevice;
1313
class CVulkanQueryPool : public IQueryPool
1414
{
1515
public:
16-
CVulkanQueryPool(core::smart_refctd_ptr<ILogicalDevice>&& dev, SCreationParams&& _params, VkQueryPool vkQueryPool)
17-
: IQueryPool(std::move(dev), std::move(_params)), m_queryPool(vkQueryPool)
18-
{ }
16+
CVulkanQueryPool(core::smart_refctd_ptr<ILogicalDevice>&& dev, SCreationParams&& _params, VkQueryPool vkQueryPool)
17+
: IQueryPool(std::move(dev), std::move(_params)), m_queryPool(vkQueryPool)
18+
{ }
1919

20-
~CVulkanQueryPool();
20+
~CVulkanQueryPool();
2121

2222
public:
23-
24-
inline VkQueryPool getInternalObject() const { return m_queryPool; }
25-
26-
static inline VkQueryType getVkQueryTypeFromQueryType(IQueryPool::E_QUERY_TYPE in) {
27-
return static_cast<VkQueryType>(in);
23+
24+
inline VkQueryPool getInternalObject() const { return m_queryPool; }
25+
26+
static inline VkQueryType getVkQueryTypeFromQueryType(IQueryPool::E_QUERY_TYPE in)
27+
{
28+
switch(in)
29+
{
30+
case EQT_OCCLUSION: return VK_QUERY_TYPE_OCCLUSION;
31+
case EQT_PIPELINE_STATISTICS: return VK_QUERY_TYPE_PIPELINE_STATISTICS;
32+
case EQT_TIMESTAMP: return VK_QUERY_TYPE_TIMESTAMP;
33+
case EQT_PERFORMANCE_QUERY: return VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR;
34+
case EQT_ACCELERATION_STRUCTURE_COMPACTED_SIZE: return VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR;
35+
case EQT_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE: return VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR;
36+
default:
37+
assert(false);
38+
return VK_QUERY_TYPE_MAX_ENUM;
39+
}
2840
}
29-
30-
static inline VkQueryPipelineStatisticFlags getVkPipelineStatisticsFlagsFromPipelineStatisticsFlags(IQueryPool::E_PIPELINE_STATISTICS_FLAGS in) {
41+
42+
static inline VkQueryPipelineStatisticFlags getVkPipelineStatisticsFlagsFromPipelineStatisticsFlags(IQueryPool::E_PIPELINE_STATISTICS_FLAGS in)
43+
{
3144
return static_cast<VkQueryPipelineStatisticFlags>(in);
3245
}
33-
34-
static inline VkQueryResultFlags getVkQueryResultsFlagsFromQueryResultsFlags(IQueryPool::E_QUERY_RESULTS_FLAGS in) {
46+
47+
static inline VkQueryResultFlags getVkQueryResultsFlagsFromQueryResultsFlags(IQueryPool::E_QUERY_RESULTS_FLAGS in)
48+
{
3549
return static_cast<VkQueryResultFlags>(in);
3650
}
37-
38-
static inline VkQueryControlFlags getVkQueryControlFlagsFromQueryControlFlags(IQueryPool::E_QUERY_CONTROL_FLAGS in) {
51+
52+
static inline VkQueryControlFlags getVkQueryControlFlagsFromQueryControlFlags(IQueryPool::E_QUERY_CONTROL_FLAGS in)
53+
{
3954
return static_cast<VkQueryControlFlags>(in);
4055
}
4156

42-
static inline VkQueryPoolCreateInfo getVkCreateInfoFromCreationParams(IQueryPool::SCreationParams&& params) {
57+
static inline VkQueryPoolCreateInfo getVkCreateInfoFromCreationParams(IQueryPool::SCreationParams&& params)
58+
{
4359
VkQueryPoolCreateInfo ret = {VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, nullptr};
4460
ret.flags = 0; // "flags is reserved for future use."
4561
ret.queryType = getVkQueryTypeFromQueryType(params.queryType);
@@ -49,7 +65,7 @@ class CVulkanQueryPool : public IQueryPool
4965
}
5066

5167
private:
52-
VkQueryPool m_queryPool;
68+
VkQueryPool m_queryPool;
5369
};
5470

5571
}

src/nbl/video/IOpenGL_LogicalDevice.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -729,22 +729,6 @@ class IOpenGL_LogicalDevice : public ILogicalDevice, protected impl::IOpenGL_Log
729729
uint8_t* pData = reinterpret_cast<uint8_t*>(p.pData) + currentDataPtrOffset;
730730
getQueryObject(query, pname, pData);
731731
}
732-
else if(queryType == IQueryPool::E_QUERY_TYPE::EQT_TRANSFORM_FEEDBACK_STREAM_EXT)
733-
{
734-
assert(queryPoolQueriesCount * 2 == queriesRange.size());
735-
assert(p.stride >= queryElementDataSize * 2);
736-
737-
GLuint query1 = queries[i+p.firstQuery];
738-
GLuint query2 = queries[i+p.firstQuery + queryPoolQueriesCount];
739-
740-
// If VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set, the final integer value written for each query is non-zero if the query’s status was available or zero if the status was unavailable.
741-
uint8_t* pData1 = reinterpret_cast<uint8_t*>(p.pData) + currentDataPtrOffset;
742-
uint8_t* pData2 = pData1 + queryElementDataSize;
743-
744-
// Write All
745-
getQueryObject(query1, pname, reinterpret_cast<GLuint64*>(pData1));
746-
getQueryObject(query2, pname, reinterpret_cast<GLuint64*>(pData2));
747-
}
748732
else
749733
{
750734
assert(false && "QueryType is not supported.");

0 commit comments

Comments
 (0)