mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 09:39:46 -06:00
VideoCommon: flush vertex manager if components change
This commit is contained in:
@ -114,9 +114,6 @@ public:
|
||||
u32 GetVertexStride() const { return vtx_decl.stride; }
|
||||
const PortableVertexDeclaration& GetVertexDeclaration() const { return vtx_decl; }
|
||||
|
||||
// TODO: move this under private:
|
||||
u32 m_components; // VB_HAS_X. Bitmask telling what vertex components are present.
|
||||
|
||||
protected:
|
||||
// Let subclasses construct.
|
||||
NativeVertexFormat() {}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "VideoCommon/LightingShaderGen.h"
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/PixelShaderGen.h"
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
#include "VideoCommon/XFMemory.h" // for texture projection mode
|
||||
@ -165,8 +166,9 @@ template<class T> static inline void WriteAlphaTest(T& out, pixel_shader_uid_dat
|
||||
template<class T> static inline void WriteFog(T& out, pixel_shader_uid_data* uid_data);
|
||||
|
||||
template<class T>
|
||||
static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
|
||||
static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
|
||||
{
|
||||
const u32 components = VertexLoaderManager::g_current_components;
|
||||
// Non-uid template parameters will write to the dummy data (=> gets optimized out)
|
||||
pixel_shader_uid_data dummy_data;
|
||||
pixel_shader_uid_data* uid_data = out.template GetUidData<pixel_shader_uid_data>();
|
||||
@ -1168,18 +1170,17 @@ static inline void WriteFog(T& out, pixel_shader_uid_data* uid_data)
|
||||
out.Write("\tprev.rgb = (prev.rgb * (256 - ifog) + " I_FOGCOLOR".rgb * ifog) >> 8;\n");
|
||||
}
|
||||
|
||||
void GetPixelShaderUid(PixelShaderUid& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
|
||||
void GetPixelShaderUid(PixelShaderUid& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
|
||||
{
|
||||
GeneratePixelShader<PixelShaderUid>(object, dstAlphaMode, ApiType, components);
|
||||
GeneratePixelShader<PixelShaderUid>(object, dstAlphaMode, ApiType);
|
||||
}
|
||||
|
||||
void GeneratePixelShaderCode(ShaderCode& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
|
||||
void GeneratePixelShaderCode(ShaderCode& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
|
||||
{
|
||||
GeneratePixelShader<ShaderCode>(object, dstAlphaMode, ApiType, components);
|
||||
GeneratePixelShader<ShaderCode>(object, dstAlphaMode, ApiType);
|
||||
}
|
||||
|
||||
void GetPixelShaderConstantProfile(PixelShaderConstantProfile& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
|
||||
void GetPixelShaderConstantProfile(PixelShaderConstantProfile& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType)
|
||||
{
|
||||
GeneratePixelShader<PixelShaderConstantProfile>(object, dstAlphaMode, ApiType, components);
|
||||
GeneratePixelShader<PixelShaderConstantProfile>(object, dstAlphaMode, ApiType);
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,6 @@ struct pixel_shader_uid_data
|
||||
typedef ShaderUid<pixel_shader_uid_data> PixelShaderUid;
|
||||
typedef ShaderConstantProfile PixelShaderConstantProfile; // TODO: Obsolete
|
||||
|
||||
void GeneratePixelShaderCode(ShaderCode& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
void GetPixelShaderUid(PixelShaderUid& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
void GetPixelShaderConstantProfile(PixelShaderConstantProfile& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
void GeneratePixelShaderCode(ShaderCode& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType);
|
||||
void GetPixelShaderUid(PixelShaderUid& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType);
|
||||
void GetPixelShaderConstantProfile(PixelShaderConstantProfile& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType);
|
||||
|
@ -32,6 +32,7 @@ u32 position_matrix_index[3];
|
||||
typedef std::unordered_map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat>> NativeVertexFormatMap;
|
||||
static NativeVertexFormatMap s_native_vertex_map;
|
||||
static NativeVertexFormat* s_current_vtx_fmt;
|
||||
u32 g_current_components;
|
||||
|
||||
typedef std::unordered_map<VertexLoaderUID, std::unique_ptr<VertexLoaderBase>> VertexLoaderMap;
|
||||
static std::mutex s_vertex_loader_map_lock;
|
||||
@ -153,7 +154,6 @@ static VertexLoaderBase* RefreshLoader(int vtx_attr_group, bool preprocess = fal
|
||||
{
|
||||
native.reset(g_vertex_manager->CreateNativeVertexFormat());
|
||||
native->Initialize(format);
|
||||
native->m_components = loader->m_native_components;
|
||||
}
|
||||
loader->m_native_vertex_format = native.get();
|
||||
}
|
||||
@ -185,9 +185,13 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
|
||||
return size;
|
||||
|
||||
// If the native vertex format changed, force a flush.
|
||||
if (loader->m_native_vertex_format != s_current_vtx_fmt)
|
||||
if (loader->m_native_vertex_format != s_current_vtx_fmt ||
|
||||
loader->m_native_components != g_current_components)
|
||||
{
|
||||
VertexManager::Flush();
|
||||
}
|
||||
s_current_vtx_fmt = loader->m_native_vertex_format;
|
||||
g_current_components = loader->m_native_components;
|
||||
|
||||
// if cull mode is CULL_ALL, tell VertexManager to skip triangles and quads.
|
||||
// They still need to go through vertex loading, because we need to calculate a zfreeze refrence slope.
|
||||
|
@ -33,5 +33,8 @@ namespace VertexLoaderManager
|
||||
// These arrays are in reverse order.
|
||||
extern float position_cache[3][4];
|
||||
extern u32 position_matrix_index[3];
|
||||
|
||||
// VB_HAS_X. Bitmask telling what vertex components are present.
|
||||
extern u32 g_current_components;
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,16 @@
|
||||
#include "VideoCommon/DriverDetails.h"
|
||||
#include "VideoCommon/LightingShaderGen.h"
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
static char text[16768];
|
||||
|
||||
template<class T>
|
||||
static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_type)
|
||||
static inline void GenerateVertexShader(T& out, API_TYPE api_type)
|
||||
{
|
||||
const u32 components = VertexLoaderManager::g_current_components;
|
||||
// Non-uid template parameters will write to the dummy data (=> gets optimized out)
|
||||
vertex_shader_uid_data dummy_data;
|
||||
vertex_shader_uid_data* uid_data = out.template GetUidData<vertex_shader_uid_data>();
|
||||
@ -394,12 +396,12 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||
}
|
||||
}
|
||||
|
||||
void GetVertexShaderUid(VertexShaderUid& object, u32 components, API_TYPE api_type)
|
||||
void GetVertexShaderUid(VertexShaderUid& object, API_TYPE api_type)
|
||||
{
|
||||
GenerateVertexShader<VertexShaderUid>(object, components, api_type);
|
||||
GenerateVertexShader<VertexShaderUid>(object, api_type);
|
||||
}
|
||||
|
||||
void GenerateVertexShaderCode(ShaderCode& object, u32 components, API_TYPE api_type)
|
||||
void GenerateVertexShaderCode(ShaderCode& object, API_TYPE api_type)
|
||||
{
|
||||
GenerateVertexShader<ShaderCode>(object, components, api_type);
|
||||
GenerateVertexShader<ShaderCode>(object, api_type);
|
||||
}
|
||||
|
@ -60,5 +60,5 @@ struct vertex_shader_uid_data
|
||||
|
||||
typedef ShaderUid<vertex_shader_uid_data> VertexShaderUid;
|
||||
|
||||
void GetVertexShaderUid(VertexShaderUid& object, u32 components, API_TYPE api_type);
|
||||
void GenerateVertexShaderCode(ShaderCode& object, u32 components, API_TYPE api_type);
|
||||
void GetVertexShaderUid(VertexShaderUid& object, API_TYPE api_type);
|
||||
void GenerateVertexShaderCode(ShaderCode& object, API_TYPE api_type);
|
||||
|
Reference in New Issue
Block a user