From b170ef9651cda959a5bfa277bb533815f10de5d8 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Thu, 10 Nov 2022 19:30:49 -0600 Subject: VideoCommon: Add class for quickly transforming and culling vertices on the CPU --- Source/Core/VideoCommon/CPUCull.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Source/Core/VideoCommon/CPUCull.h (limited to 'Source/Core/VideoCommon/CPUCull.h') diff --git a/Source/Core/VideoCommon/CPUCull.h b/Source/Core/VideoCommon/CPUCull.h new file mode 100644 index 0000000000..40248035e8 --- /dev/null +++ b/Source/Core/VideoCommon/CPUCull.h @@ -0,0 +1,38 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "VideoCommon/BPMemory.h" +#include "VideoCommon/DataReader.h" +#include "VideoCommon/OpcodeDecoding.h" + +class CPUCull +{ +public: + ~CPUCull(); + void Init(); + bool AreAllVerticesCulled(VertexLoaderBase* loader, OpcodeDecoder::Primitive primitive, + const u8* src, u32 count); + + struct alignas(16) TransformedVertex + { + float x, y, z, w; + }; + + using TransformFunction = void (*)(void*, const void*, u32, int); + using CullFunction = bool (*)(const CPUCull::TransformedVertex*, int); + +private: + template + struct BufferDeleter + { + void operator()(T* ptr); + }; + std::unique_ptr> m_transform_buffer; + u32 m_transform_buffer_size = 0; + std::array, 2> m_transform_table; + Common::EnumMap, + OpcodeDecoder::Primitive::GX_DRAW_TRIANGLE_FAN> + m_cull_table; +}; -- cgit v1.2.3