mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-17 17:17:58 -05:00
shader/other: Implement thread comparisons (NV_shader_thread_group)
Hardware S2R special registers match gl_Thread*MaskNV. We can trivially implement these using Nvidia's extension on OpenGL or naively stubbing them with the ARB instructions to match. This might cause issues if the host device warp size doesn't match Nvidia's. That said, this is unlikely on proper shaders. Refer to the attached url for more documentation about these flags. https://www.khronos.org/registry/OpenGL/extensions/NV/NV_shader_thread_group.txt
This commit is contained in:
@ -2309,6 +2309,18 @@ private:
|
||||
return {"gl_SubGroupInvocationARB", Type::Uint};
|
||||
}
|
||||
|
||||
template <const std::string_view& comparison>
|
||||
Expression ThreadMask(Operation) {
|
||||
if (device.HasWarpIntrinsics()) {
|
||||
return {fmt::format("gl_Thread{}MaskNV", comparison), Type::Uint};
|
||||
}
|
||||
if (device.HasShaderBallot()) {
|
||||
return {fmt::format("uint(gl_SubGroup{}MaskARB)", comparison), Type::Uint};
|
||||
}
|
||||
LOG_ERROR(Render_OpenGL, "Thread mask intrinsics are required by the shader");
|
||||
return {"0U", Type::Uint};
|
||||
}
|
||||
|
||||
Expression ShuffleIndexed(Operation operation) {
|
||||
std::string value = VisitOperand(operation, 0).AsFloat();
|
||||
|
||||
@ -2337,6 +2349,12 @@ private:
|
||||
static constexpr std::string_view NotEqual = "!=";
|
||||
static constexpr std::string_view GreaterEqual = ">=";
|
||||
|
||||
static constexpr std::string_view Eq = "Eq";
|
||||
static constexpr std::string_view Ge = "Ge";
|
||||
static constexpr std::string_view Gt = "Gt";
|
||||
static constexpr std::string_view Le = "Le";
|
||||
static constexpr std::string_view Lt = "Lt";
|
||||
|
||||
static constexpr std::string_view Add = "Add";
|
||||
static constexpr std::string_view Min = "Min";
|
||||
static constexpr std::string_view Max = "Max";
|
||||
@ -2554,6 +2572,11 @@ private:
|
||||
&GLSLDecompiler::VoteEqual,
|
||||
|
||||
&GLSLDecompiler::ThreadId,
|
||||
&GLSLDecompiler::ThreadMask<Func::Eq>,
|
||||
&GLSLDecompiler::ThreadMask<Func::Ge>,
|
||||
&GLSLDecompiler::ThreadMask<Func::Gt>,
|
||||
&GLSLDecompiler::ThreadMask<Func::Le>,
|
||||
&GLSLDecompiler::ThreadMask<Func::Lt>,
|
||||
&GLSLDecompiler::ShuffleIndexed,
|
||||
|
||||
&GLSLDecompiler::MemoryBarrierGL,
|
||||
|
Reference in New Issue
Block a user