From c783cd2aaf102a006782be64f6a6da3476382eeb Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 20 Jul 2017 13:52:23 +1000 Subject: [PATCH] GeometryShaderGen: Add UID enumeration functions --- Source/Core/VideoCommon/GeometryShaderGen.cpp | 20 +++++++++++++++++++ Source/Core/VideoCommon/GeometryShaderGen.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/Source/Core/VideoCommon/GeometryShaderGen.cpp b/Source/Core/VideoCommon/GeometryShaderGen.cpp index bb201ddb0f..4b06c0f7f3 100644 --- a/Source/Core/VideoCommon/GeometryShaderGen.cpp +++ b/Source/Core/VideoCommon/GeometryShaderGen.cpp @@ -364,3 +364,23 @@ static void EndPrimitive(ShaderCode& out, const ShaderHostConfig& host_config, else out.Write("\toutput.RestartStrip();\n"); } + +void EnumerateGeometryShaderUids(const std::function& callback) +{ + GeometryShaderUid uid; + std::memset(&uid, 0, sizeof(uid)); + + static constexpr std::array primitive_lut = { + {PRIMITIVE_TRIANGLES, PRIMITIVE_LINES, PRIMITIVE_POINTS}}; + for (u32 primitive : primitive_lut) + { + auto* guid = uid.GetUidData(); + guid->primitive_type = primitive; + + for (u32 texgens = 0; texgens <= 8; texgens++) + { + guid->numTexGens = texgens; + callback(uid); + } + } +} diff --git a/Source/Core/VideoCommon/GeometryShaderGen.h b/Source/Core/VideoCommon/GeometryShaderGen.h index 58ab01f757..f138207e14 100644 --- a/Source/Core/VideoCommon/GeometryShaderGen.h +++ b/Source/Core/VideoCommon/GeometryShaderGen.h @@ -4,6 +4,7 @@ #pragma once +#include #include "Common/CommonTypes.h" #include "VideoCommon/ShaderGenCommon.h" #include "VideoCommon/VertexManagerBase.h" @@ -28,3 +29,4 @@ typedef ShaderUid GeometryShaderUid; ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& host_config, const geometry_shader_uid_data* uid_data); GeometryShaderUid GetGeometryShaderUid(u32 primitive_type); +void EnumerateGeometryShaderUids(const std::function& callback);