diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2023-01-26 23:15:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-26 23:15:23 +0100 |
| commit | 9c9310bf44f0a7b0ad1de2e643f32ec00a553e0e (patch) | |
| tree | 613159524f59f9cabe66791dfa42856026e33ad8 /Source/Core/VideoCommon/CPUCull.h | |
| parent | 09a8d9591db06ebdbe5abdd3166c76982856fc55 (diff) | |
| parent | 7413be148705866efebd504ef7356377dce81274 (diff) | |
Merge pull request #11208 from TellowKrinkle/CPUCull
Cull vertices on the CPU
Diffstat (limited to 'Source/Core/VideoCommon/CPUCull.h')
| -rw-r--r-- | Source/Core/VideoCommon/CPUCull.h | 38 |
1 files changed, 38 insertions, 0 deletions
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 <typename T> + struct BufferDeleter + { + void operator()(T* ptr); + }; + std::unique_ptr<TransformedVertex[], BufferDeleter<TransformedVertex>> m_transform_buffer; + u32 m_transform_buffer_size = 0; + std::array<std::array<TransformFunction, 2>, 2> m_transform_table; + Common::EnumMap<Common::EnumMap<CullFunction, CullMode::All>, + OpcodeDecoder::Primitive::GX_DRAW_TRIANGLE_FAN> + m_cull_table; +}; |
