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