Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple primitive generated query from xfb #2710

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/vkgcDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif

/// LLPC major interface version.
#define LLPC_INTERFACE_MAJOR_VERSION 68
#define LLPC_INTERFACE_MAJOR_VERSION 69

/// LLPC minor interface version.
#define LLPC_INTERFACE_MINOR_VERSION 0
Expand Down Expand Up @@ -80,6 +80,7 @@
// %Version History
// | %Version | Change Description |
// | -------- | ----------------------------------------------------------------------------------------------------- |
// | 69.0 | Add enablePrimGeneratedQuery to PipelineOptions |
// | 68.0 | Remove ICache *cache in all PipelineBuildInfo |
// | 67.0 | Modify the uber fetch shader. Adds locationMask(64bit) at the beginning of uber fetch shader internal |
// | | buffer which flags whether the related attribute data is valid. |
Expand Down Expand Up @@ -603,6 +604,7 @@ struct PipelineOptions {
bool enableCombinedTexture; ///< For OGL only, use the 'set' for DescriptorCombinedTexture
///< for sampled images and samplers
bool vertex64BitsAttribSingleLoc; ///< For OGL only, dvec3/dvec4 vertex attrib only consumes 1 location.
bool enablePrimGeneratedQuery; ///< If set, primitive generated query is enabled
unsigned reserved20;
};

Expand Down Expand Up @@ -1254,7 +1256,9 @@ struct ApiXfbOutData {
XfbOutInfo *pXfbOutInfos; ///< An array of XfbOutInfo items
unsigned numXfbOutInfo; ///< Count of XfbOutInfo items
bool forceDisableStreamOut; ///< Force to disable stream out XFB outputs
bool forceEnablePrimStats; ///< Force to enable counting generated primitives
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 69
bool forceEnablePrimStats; ///< Force to enable counting generated primitives
#endif
};

/// Represents the tessellation level passed from driver API
Expand Down
5 changes: 3 additions & 2 deletions lgc/include/lgc/state/PipelineState.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ class PipelineState final : public Pipeline {
// Check if transform feedback is active
bool enableXfb() const { return m_xfbStateMetadata.enableXfb; }

// Check if we need primitive statistics counting
bool enablePrimStats() const { return m_xfbStateMetadata.enablePrimStats; }
// Check if we need count primitives if XFB is disabled
// NOTE: The old interface m_xfbStateMetadata.enablePrimStats will be removed later
bool enablePrimStats() const { return m_options.enablePrimGeneratedQuery || m_xfbStateMetadata.enablePrimStats; }

// Get transform feedback strides
const std::array<unsigned, MaxTransformFeedbackBuffers> &getXfbBufferStrides() const {
Expand Down
1 change: 1 addition & 0 deletions lgc/interface/lgc/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ union Options {
bool disableSampleMask; // Disable export of sample mask from PS
bool reserved20;
RayTracingIndirectMode rtIndirectMode; // Ray tracing indirect mode
bool enablePrimGeneratedQuery; // Whether to enable primitive generated counter
};
};
static_assert(sizeof(Options) == sizeof(Options::u32All));
Expand Down
1 change: 1 addition & 0 deletions llpc/context/llpcPipelineContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ Options PipelineContext::computePipelineOptions() const {
options.internalRtShaders = getPipelineOptions()->internalRtShaders;
options.disableSampleMask = getPipelineOptions()->disableSampleMask;
options.disableTruncCoordForGather = getPipelineOptions()->disableTruncCoordForGather;
options.enablePrimGeneratedQuery = getPipelineOptions()->enablePrimGeneratedQuery;

return options;
}
Expand Down
7 changes: 5 additions & 2 deletions llpc/translator/lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9739,8 +9739,11 @@ void SPIRVToLLVM::insertScratchBoundsChecks(SPIRVValue *memOp, const ScratchBoun
void SPIRVToLLVM::createXfbMetadata(bool hasXfbOuts) {
auto llpcContext = static_cast<Llpc::Context *>(m_context);
auto pipelineBuildInfo = static_cast<const Vkgc::GraphicsPipelineBuildInfo *>(llpcContext->getPipelineBuildInfo());
const bool needXfbMetadata = (hasXfbOuts && !pipelineBuildInfo->apiXfbOutData.forceDisableStreamOut) ||
pipelineBuildInfo->apiXfbOutData.forceEnablePrimStats;
bool needXfbMetadata = hasXfbOuts && !pipelineBuildInfo->apiXfbOutData.forceDisableStreamOut;
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 69
needXfbMetadata |= pipelineBuildInfo->apiXfbOutData.forceEnablePrimStats;
#endif

if (!needXfbMetadata)
return;

Expand Down
6 changes: 6 additions & 0 deletions tool/dumper/vkgcPipelineDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ void PipelineDumper::dumpPipelineOptions(const PipelineOptions *options, std::os
dumpFile << "options.buildResourcesDataForShaderModule = " << options->buildResourcesDataForShaderModule << "\n";
dumpFile << "options.disableTruncCoordForGather = " << options->disableTruncCoordForGather << "\n";
dumpFile << "options.vertex64BitsAttribSingleLoc = " << options->vertex64BitsAttribSingleLoc << "\n";
dumpFile << "options.enablePrimGeneratedQuery = " << options->enablePrimGeneratedQuery << "\n";
}

// =====================================================================================================================
Expand Down Expand Up @@ -1016,7 +1017,9 @@ void PipelineDumper::dumpGraphicsStateInfo(const GraphicsPipelineBuildInfo *pipe

dumpFile << "\n[ApiXfbOutInfo]\n";
dumpFile << "forceDisableStreamOut = " << pipelineInfo->apiXfbOutData.forceDisableStreamOut << "\n";
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 69
dumpFile << "forceEnablePrimStats = " << pipelineInfo->apiXfbOutData.forceEnablePrimStats << "\n";
#endif
const auto pXfbOutInfos = pipelineInfo->apiXfbOutData.pXfbOutInfos;
for (unsigned idx = 0; idx < pipelineInfo->apiXfbOutData.numXfbOutInfo; ++idx) {
dumpFile << "xfbOutInfo[" << idx << "].isBuiltIn = " << pXfbOutInfos[idx].isBuiltIn << "\n";
Expand Down Expand Up @@ -1566,7 +1569,9 @@ void PipelineDumper::updateHashForNonFragmentState(const GraphicsPipelineBuildIn
}

hasher->Update(pipeline->apiXfbOutData.forceDisableStreamOut);
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 69
hasher->Update(pipeline->apiXfbOutData.forceEnablePrimStats);
#endif
}

// =====================================================================================================================
Expand Down Expand Up @@ -1653,6 +1658,7 @@ void PipelineDumper::updateHashForPipelineOptions(const PipelineOptions *options
hasher->Update(options->forceNonUniformResourceIndexStageMask);
hasher->Update(options->replaceSetWithResourceType);
hasher->Update(options->disableTruncCoordForGather);
hasher->Update(options->enablePrimGeneratedQuery);
}

// =====================================================================================================================
Expand Down
3 changes: 3 additions & 0 deletions tool/vfx/vfxVkSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ class SectionPipelineOption : public Section {
INIT_STATE_MEMBER_NAME_TO_ADDR(SectionPipelineOption, buildResourcesDataForShaderModule, MemberTypeBool, false);
INIT_STATE_MEMBER_NAME_TO_ADDR(SectionPipelineOption, disableTruncCoordForGather, MemberTypeBool, false);
INIT_STATE_MEMBER_NAME_TO_ADDR(SectionPipelineOption, vertex64BitsAttribSingleLoc, MemberTypeBool, false);
INIT_STATE_MEMBER_NAME_TO_ADDR(SectionPipelineOption, enablePrimGeneratedQuery, MemberTypeBool, false);
return addrTableInitializer;
}();
return {addrTable.data(), addrTable.size()};
Expand Down Expand Up @@ -1033,7 +1034,9 @@ class SectionApiXfbOutput : public Section {
static std::vector<StrToMemberAddr> addrTable = []() {
std::vector<StrToMemberAddr> addrTableInitializer;
INIT_STATE_MEMBER_NAME_TO_ADDR(SectionApiXfbOutput, forceDisableStreamOut, MemberTypeBool, false);
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 69
INIT_STATE_MEMBER_NAME_TO_ADDR(SectionApiXfbOutput, forceEnablePrimStats, MemberTypeBool, false);
#endif
INIT_MEMBER_DYNARRAY_NAME_TO_ADDR(SectionApiXfbOutput, m_xfbOutInfo, MemberTypeXfbOutInfo, true);
return addrTableInitializer;
}();
Expand Down