2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2022-12-28 15:38:46 +01:00
|
|
|
#include <array>
|
2016-01-17 16:54:31 -05:00
|
|
|
#include <string>
|
2022-03-05 14:52:43 -06:00
|
|
|
#include <vector>
|
2016-01-17 16:54:31 -05:00
|
|
|
|
2022-12-28 15:38:46 +01:00
|
|
|
#include "Common/BitSet.h"
|
2016-01-17 16:54:31 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2022-12-28 15:38:46 +01:00
|
|
|
#include "Common/Matrix.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "VideoCommon/ConstantManager.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2012-01-01 12:46:02 -08:00
|
|
|
class PointerWrap;
|
2022-06-18 01:09:35 -05:00
|
|
|
struct PortableVertexDeclaration;
|
2012-01-01 12:46:02 -08:00
|
|
|
|
2008-12-26 10:43:18 +00:00
|
|
|
// The non-API dependent parts.
|
2022-12-28 15:38:46 +01:00
|
|
|
class alignas(16) VertexShaderManager
|
2008-12-26 10:43:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-12-28 15:38:46 +01:00
|
|
|
void Init();
|
|
|
|
void Dirty();
|
|
|
|
void DoState(PointerWrap& p);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2009-09-15 21:49:15 +00:00
|
|
|
// constant management
|
2022-11-10 19:30:49 -06:00
|
|
|
void SetProjectionMatrix();
|
2022-12-28 15:38:46 +01:00
|
|
|
void SetConstants(const std::vector<std::string>& textures);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2022-12-28 15:38:46 +01:00
|
|
|
void InvalidateXFRange(int start, int end);
|
|
|
|
void SetTexMatrixChangedA(u32 value);
|
|
|
|
void SetTexMatrixChangedB(u32 value);
|
|
|
|
void SetViewportChanged();
|
|
|
|
void SetProjectionChanged();
|
|
|
|
void SetMaterialColorChanged(int index);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2022-12-28 15:38:46 +01:00
|
|
|
void SetVertexFormat(u32 components, const PortableVertexDeclaration& format);
|
|
|
|
void SetTexMatrixInfoChanged(int index);
|
|
|
|
void SetLightingConfigChanged();
|
2017-07-20 15:25:27 +10:00
|
|
|
|
2015-01-24 03:15:09 +13:00
|
|
|
// data: 3 floats representing the X, Y and Z vertex model coordinates and the posmatrix index.
|
2015-01-24 15:12:52 -05:00
|
|
|
// out: 4 floats which will be initialized with the corresponding clip space coordinates
|
2022-12-28 16:00:15 +01:00
|
|
|
// NOTE: m_projection_matrix must be up to date when this is called
|
2015-01-24 15:12:52 -05:00
|
|
|
// (i.e. VertexShaderManager::SetConstants needs to be called before using this!)
|
2022-12-28 15:38:46 +01:00
|
|
|
void TransformToClipSpace(const float* data, float* out, u32 mtxIdx);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2023-01-31 18:18:46 +13:00
|
|
|
static bool UseVertexDepthRange();
|
|
|
|
|
2022-12-28 15:38:46 +01:00
|
|
|
VertexShaderConstants constants{};
|
|
|
|
bool dirty = false;
|
|
|
|
|
|
|
|
private:
|
2022-12-28 16:00:15 +01:00
|
|
|
alignas(16) std::array<float, 16> m_projection_matrix;
|
2022-12-28 15:38:46 +01:00
|
|
|
|
|
|
|
// track changes
|
2022-12-28 16:00:15 +01:00
|
|
|
std::array<bool, 2> m_tex_matrices_changed{};
|
|
|
|
bool m_pos_normal_matrix_changed = false;
|
|
|
|
bool m_projection_changed = false;
|
|
|
|
bool m_viewport_changed = false;
|
|
|
|
bool m_tex_mtx_info_changed = false;
|
|
|
|
bool m_lighting_config_changed = false;
|
|
|
|
bool m_projection_graphics_mod_change = false;
|
|
|
|
BitSet32 m_materials_changed;
|
|
|
|
std::array<int, 2> m_minmax_transform_matrices_changed{};
|
|
|
|
std::array<int, 2> m_minmax_normal_matrices_changed{};
|
|
|
|
std::array<int, 2> m_minmax_post_transform_matrices_changed{};
|
|
|
|
std::array<int, 2> m_minmax_lights_changed{};
|
2022-12-28 15:38:46 +01:00
|
|
|
|
2022-12-28 16:00:15 +01:00
|
|
|
Common::Matrix44 m_viewport_correction{};
|
2022-11-10 19:30:49 -06:00
|
|
|
|
|
|
|
Common::Matrix44 LoadProjectionMatrix();
|
2008-07-17 21:09:18 +00:00
|
|
|
};
|