2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2021-05-13 17:05:31 -06:00
|
|
|
#include <array>
|
2016-02-26 12:55:34 -07:00
|
|
|
#include <memory>
|
2009-08-10 00:18:10 -06:00
|
|
|
#include <string>
|
2016-01-07 20:38:00 -07:00
|
|
|
#include <unordered_map>
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2021-06-20 14:47:57 -06:00
|
|
|
#include "Common/EnumMap.h"
|
2021-03-26 16:46:37 -06:00
|
|
|
#include "VideoCommon/CPMemory.h"
|
2016-01-17 14:54:31 -07:00
|
|
|
|
2016-01-31 12:51:55 -07:00
|
|
|
class DataReader;
|
2016-01-17 14:54:31 -07:00
|
|
|
class NativeVertexFormat;
|
2016-01-07 20:38:00 -07:00
|
|
|
struct PortableVertexDeclaration;
|
2014-02-17 03:18:15 -07:00
|
|
|
|
2021-04-30 15:57:12 -06:00
|
|
|
namespace OpcodeDecoder
|
|
|
|
{
|
|
|
|
enum class Primitive : u8;
|
|
|
|
};
|
|
|
|
|
2008-10-25 06:35:55 -06:00
|
|
|
namespace VertexLoaderManager
|
|
|
|
{
|
2016-01-07 20:38:00 -07:00
|
|
|
using NativeVertexFormatMap =
|
|
|
|
std::unordered_map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat>>;
|
|
|
|
|
2008-12-25 14:44:56 -07:00
|
|
|
void Init();
|
2016-01-13 13:14:20 -07:00
|
|
|
void Clear();
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2008-10-25 09:53:43 -06:00
|
|
|
void MarkAllDirty();
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2017-07-03 03:43:47 -06:00
|
|
|
// Creates or obtains a pointer to a VertexFormat representing decl.
|
|
|
|
// If this results in a VertexFormat being created, if the game later uses a matching vertex
|
|
|
|
// declaration, the one that was previously created will be used.
|
|
|
|
NativeVertexFormat* GetOrCreateMatchingFormat(const PortableVertexDeclaration& decl);
|
|
|
|
|
|
|
|
// For vertex ubershaders, all attributes need to be present, even when the vertex
|
|
|
|
// format does not contain them. This function returns a vertex format with dummy
|
|
|
|
// offsets set to the unused attributes.
|
|
|
|
NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl);
|
|
|
|
|
2014-12-09 00:35:04 -07:00
|
|
|
// Returns -1 if buf_size is insufficient, else the amount of bytes consumed
|
2021-04-30 15:57:12 -06:00
|
|
|
int RunVertices(int vtx_attr_group, OpcodeDecoder::Primitive primitive, int count, DataReader src,
|
|
|
|
bool is_preprocess);
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2014-07-25 17:10:44 -06:00
|
|
|
NativeVertexFormat* GetCurrentVertexFormat();
|
2015-05-29 06:42:45 -06:00
|
|
|
|
|
|
|
// Resolved pointers to array bases. Used by vertex loaders.
|
2021-06-20 14:47:57 -06:00
|
|
|
extern Common::EnumMap<u8*, CPArray::TexCoord7> cached_arraybases;
|
2015-05-29 06:42:45 -06:00
|
|
|
void UpdateVertexArrayPointers();
|
2015-06-01 11:58:27 -06:00
|
|
|
|
|
|
|
// Position cache for zfreeze (3 vertices, 4 floats each to allow SIMD overwrite).
|
|
|
|
// These arrays are in reverse order.
|
2022-04-13 17:12:53 -06:00
|
|
|
extern std::array<std::array<float, 4>, 3> position_cache;
|
2022-04-14 13:01:57 -06:00
|
|
|
extern std::array<u32, 3> position_matrix_index_cache;
|
2022-04-13 23:03:34 -06:00
|
|
|
// Store the tangent and binormal vectors for games that use emboss texgens when the vertex format
|
|
|
|
// doesn't include them (e.g. RS2 and RS3). These too are 4 floats each for SIMD overwrites.
|
|
|
|
extern std::array<float, 4> tangent_cache;
|
|
|
|
extern std::array<float, 4> binormal_cache;
|
2015-11-01 14:39:31 -07:00
|
|
|
|
|
|
|
// VB_HAS_X. Bitmask telling what vertex components are present.
|
|
|
|
extern u32 g_current_components;
|
2021-05-13 17:05:31 -06:00
|
|
|
|
|
|
|
extern BitSet8 g_main_vat_dirty;
|
|
|
|
extern BitSet8 g_preprocess_vat_dirty;
|
|
|
|
extern bool g_bases_dirty; // Main only
|
|
|
|
extern u8 g_current_vat; // Main only
|
|
|
|
extern std::array<VertexLoaderBase*, CP_NUM_VAT_REG> g_main_vertex_loaders;
|
|
|
|
extern std::array<VertexLoaderBase*, CP_NUM_VAT_REG> g_preprocess_vertex_loaders;
|
2019-05-05 17:48:12 -06:00
|
|
|
} // namespace VertexLoaderManager
|