mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
VideoCommon: cleanup of "components" usage
This "u32 components" is a list of flags which attributes of the vertex loader are present. We are used to append this variable to lots of vertex generation functions, but some of them don't need it at all.
This commit is contained in:
parent
a561c436fc
commit
5e5db9fbc6
@ -172,7 +172,7 @@ bool LineGeometryShader::SetShader(u32 components, float lineWidth,
|
||||
static char buffer[16384];
|
||||
ShaderCode code;
|
||||
code.SetBuffer(buffer);
|
||||
GenerateVSOutputStructForGS(code, components, API_D3D);
|
||||
GenerateVSOutputStructForGS(code, API_D3D);
|
||||
code.Write("\n%s", LINE_GS_COMMON);
|
||||
|
||||
std::stringstream numTexCoordsStream;
|
||||
|
@ -166,7 +166,7 @@ bool PointGeometryShader::SetShader(u32 components, float pointSize,
|
||||
static char buffer[16384];
|
||||
ShaderCode code;
|
||||
code.SetBuffer(buffer);
|
||||
GenerateVSOutputStructForGS(code, components, API_D3D);
|
||||
GenerateVSOutputStructForGS(code, API_D3D);
|
||||
code.Write("\n%s", POINT_GS_COMMON);
|
||||
|
||||
std::stringstream numTexCoordsStream;
|
||||
|
@ -238,7 +238,7 @@ void VertexManager::vFlush()
|
||||
|
||||
// set global constants
|
||||
VertexShaderManager::SetConstants();
|
||||
PixelShaderManager::SetConstants(g_nativeVertexFmt->m_components);
|
||||
PixelShaderManager::SetConstants();
|
||||
|
||||
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate &&
|
||||
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
|
@ -259,7 +259,7 @@ void VertexManager::vFlush()
|
||||
|
||||
// set global constants
|
||||
VertexShaderManager::SetConstants();
|
||||
PixelShaderManager::SetConstants(g_nativeVertexFmt->m_components);
|
||||
PixelShaderManager::SetConstants();
|
||||
ProgramShaderCache::UploadConstants();
|
||||
|
||||
// setup the pointers
|
||||
@ -280,7 +280,7 @@ void VertexManager::vFlush()
|
||||
{
|
||||
// Need to set these again, if we don't support UBO
|
||||
VertexShaderManager::SetConstants();
|
||||
PixelShaderManager::SetConstants(g_nativeVertexFmt->m_components);
|
||||
PixelShaderManager::SetConstants();
|
||||
}
|
||||
|
||||
// only update alpha
|
||||
|
@ -101,7 +101,6 @@ public:
|
||||
|
||||
virtual void Initialize(const PortableVertexDeclaration &vtx_decl) = 0;
|
||||
virtual void SetupVertexPointers() = 0;
|
||||
virtual void EnableComponents(u32 components) {}
|
||||
|
||||
u32 GetVertexStride() const { return vertex_stride; }
|
||||
|
||||
|
@ -65,7 +65,7 @@ void PixelShaderManager::Shutdown()
|
||||
|
||||
}
|
||||
|
||||
void PixelShaderManager::SetConstants(u32 components)
|
||||
void PixelShaderManager::SetConstants()
|
||||
{
|
||||
if (s_bFogRangeAdjustChanged)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
static void Shutdown();
|
||||
static void DoState(PointerWrap &p);
|
||||
|
||||
static void SetConstants(u32 components); // sets pixel shader constants
|
||||
static void SetConstants(); // sets pixel shader constants
|
||||
|
||||
// constant management, should be called after memory is committed
|
||||
static void SetColorChanged(int type, int index);
|
||||
|
@ -178,7 +178,7 @@ VertexLoader::VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr)
|
||||
m_numLoadedVertices = 0;
|
||||
m_VertexSize = 0;
|
||||
m_numPipelineStages = 0;
|
||||
m_NativeFmt = g_vertex_manager->CreateNativeVertexFormat();
|
||||
m_NativeFmt = 0;
|
||||
loop_counter = 0;
|
||||
VertexLoader_Normal::Init();
|
||||
VertexLoader_Position::Init();
|
||||
@ -251,9 +251,7 @@ void VertexLoader::CompileVertexTranslator()
|
||||
|
||||
// Reset pipeline
|
||||
m_numPipelineStages = 0;
|
||||
|
||||
// It's a bit ugly that we poke inside m_NativeFmt in this function. Planning to fix this.
|
||||
m_NativeFmt->m_components = 0;
|
||||
u32 components = 0;
|
||||
|
||||
// Position in pc vertex format.
|
||||
int nat_offset = 0;
|
||||
@ -270,18 +268,18 @@ void VertexLoader::CompileVertexTranslator()
|
||||
if (m_VtxDesc.PosMatIdx)
|
||||
{
|
||||
WriteCall(PosMtx_ReadDirect_UByte);
|
||||
m_NativeFmt->m_components |= VB_HAS_POSMTXIDX;
|
||||
components |= VB_HAS_POSMTXIDX;
|
||||
m_VertexSize += 1;
|
||||
}
|
||||
|
||||
if (m_VtxDesc.Tex0MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX0; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex1MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX1; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex2MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX2; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex3MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX3; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex4MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX4; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex5MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX5; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex6MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX6; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex7MatIdx) {m_VertexSize += 1; m_NativeFmt->m_components |= VB_HAS_TEXMTXIDX7; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex0MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX0; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex1MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX1; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex2MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX2; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex3MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX3; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex4MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX4; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex5MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX5; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex6MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX6; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
if (m_VtxDesc.Tex7MatIdx) {m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX7; WriteCall(TexMtx_ReadDirect_UByte); }
|
||||
|
||||
// Write vertex position loader
|
||||
if(g_ActiveConfig.bUseBBox)
|
||||
@ -333,10 +331,10 @@ void VertexLoader::CompileVertexTranslator()
|
||||
}
|
||||
|
||||
int numNormals = (m_VtxAttr.NormalElements == 1) ? NRM_THREE : NRM_ONE;
|
||||
m_NativeFmt->m_components |= VB_HAS_NRM0;
|
||||
components |= VB_HAS_NRM0;
|
||||
|
||||
if (numNormals == NRM_THREE)
|
||||
m_NativeFmt->m_components |= VB_HAS_NRM1 | VB_HAS_NRM2;
|
||||
components |= VB_HAS_NRM1 | VB_HAS_NRM2;
|
||||
}
|
||||
|
||||
vtx_decl.color_gl_type = VAR_UNSIGNED_BYTE;
|
||||
@ -344,11 +342,11 @@ void VertexLoader::CompileVertexTranslator()
|
||||
vtx_decl.color_offset[1] = -1;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
m_NativeFmt->m_components |= VB_HAS_COL0 << i;
|
||||
components |= VB_HAS_COL0 << i;
|
||||
switch (col[i])
|
||||
{
|
||||
case NOT_PRESENT:
|
||||
m_NativeFmt->m_components &= ~(VB_HAS_COL0 << i);
|
||||
components &= ~(VB_HAS_COL0 << i);
|
||||
vtx_decl.color_offset[i] = -1;
|
||||
break;
|
||||
case DIRECT:
|
||||
@ -407,7 +405,7 @@ void VertexLoader::CompileVertexTranslator()
|
||||
|
||||
if (tc[i] == NOT_PRESENT)
|
||||
{
|
||||
m_NativeFmt->m_components &= ~(VB_HAS_UV0 << i);
|
||||
components &= ~(VB_HAS_UV0 << i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -415,12 +413,12 @@ void VertexLoader::CompileVertexTranslator()
|
||||
_assert_msg_(VIDEO, FORMAT_UBYTE <= format && format <= FORMAT_FLOAT, "Invalid texture coordinates format!\n(format = %d)", format);
|
||||
_assert_msg_(VIDEO, 0 <= elements && elements <= 1, "Invalid number of texture coordinates elements!\n(elements = %d)", elements);
|
||||
|
||||
m_NativeFmt->m_components |= VB_HAS_UV0 << i;
|
||||
components |= VB_HAS_UV0 << i;
|
||||
WriteCall(VertexLoader_TextCoord::GetFunction(tc[i], format, elements));
|
||||
m_VertexSize += VertexLoader_TextCoord::GetSize(tc[i], format, elements);
|
||||
}
|
||||
|
||||
if (m_NativeFmt->m_components & (VB_HAS_TEXMTXIDX0 << i))
|
||||
if (components & (VB_HAS_TEXMTXIDX0 << i))
|
||||
{
|
||||
if (tc[i] != NOT_PRESENT)
|
||||
{
|
||||
@ -433,7 +431,7 @@ void VertexLoader::CompileVertexTranslator()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NativeFmt->m_components |= VB_HAS_UV0 << i; // have to include since using now
|
||||
components |= VB_HAS_UV0 << i; // have to include since using now
|
||||
vtx_decl.texcoord_offset[i] = nat_offset;
|
||||
vtx_decl.texcoord_gl_type[i] = VAR_FLOAT;
|
||||
vtx_decl.texcoord_size[i] = 4;
|
||||
@ -465,7 +463,7 @@ void VertexLoader::CompileVertexTranslator()
|
||||
}
|
||||
}
|
||||
// tricky!
|
||||
if (j == 8 && !((m_NativeFmt->m_components & VB_HAS_TEXMTXIDXALL) & (VB_HAS_TEXMTXIDXALL << (i + 1))))
|
||||
if (j == 8 && !((components & VB_HAS_TEXMTXIDXALL) & (VB_HAS_TEXMTXIDXALL << (i + 1))))
|
||||
{
|
||||
// no more tex coords and tex matrices, so exit loop
|
||||
break;
|
||||
@ -500,6 +498,8 @@ void VertexLoader::CompileVertexTranslator()
|
||||
ABI_PopAllCalleeSavedRegsAndAdjustStack();
|
||||
RET();
|
||||
#endif
|
||||
m_NativeFmt = g_vertex_manager->CreateNativeVertexFormat();
|
||||
m_NativeFmt->m_components = components;
|
||||
m_NativeFmt->Initialize(vtx_decl);
|
||||
}
|
||||
|
||||
@ -565,8 +565,6 @@ int VertexLoader::SetupRunVertices(int vtx_attr_group, int primitive, int const
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_NativeFmt->EnableComponents(m_NativeFmt->m_components);
|
||||
|
||||
// Load position and texcoord scale factors.
|
||||
m_VtxAttr.PosFrac = g_VtxAttr[vtx_attr_group].g0.PosFrac;
|
||||
m_VtxAttr.texCoord[0].Frac = g_VtxAttr[vtx_attr_group].g0.Tex0Frac;
|
||||
|
@ -38,7 +38,7 @@ static void DefineVSOutputStructMember(T& object, API_TYPE api_type, const char*
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static inline void GenerateVSOutputStruct(T& object, u32 components, API_TYPE api_type)
|
||||
static inline void GenerateVSOutputStruct(T& object, API_TYPE api_type)
|
||||
{
|
||||
object.Write("struct VS_OUTPUT {\n");
|
||||
DefineVSOutputStructMember(object, api_type, "float4", "pos", -1, "POSITION");
|
||||
@ -99,7 +99,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
out.Write("};\n");
|
||||
|
||||
GenerateVSOutputStruct(out, components, api_type);
|
||||
GenerateVSOutputStruct(out, api_type);
|
||||
|
||||
uid_data.numTexGens = xfregs.numTexGen.numTexGens;
|
||||
uid_data.components = components;
|
||||
@ -467,7 +467,7 @@ void GenerateVertexShaderCode(VertexShaderCode& object, u32 components, API_TYPE
|
||||
GenerateVertexShader<VertexShaderCode>(object, components, api_type);
|
||||
}
|
||||
|
||||
void GenerateVSOutputStructForGS(ShaderCode& object, u32 components, API_TYPE api_type)
|
||||
void GenerateVSOutputStructForGS(ShaderCode& object, API_TYPE api_type)
|
||||
{
|
||||
GenerateVSOutputStruct<ShaderCode>(object, components, api_type);
|
||||
GenerateVSOutputStruct<ShaderCode>(object, api_type);
|
||||
}
|
||||
|
@ -90,6 +90,6 @@ typedef ShaderCode VertexShaderCode; // TODO: Obsolete..
|
||||
|
||||
void GetVertexShaderUid(VertexShaderUid& object, u32 components, API_TYPE api_type);
|
||||
void GenerateVertexShaderCode(VertexShaderCode& object, u32 components, API_TYPE api_type);
|
||||
void GenerateVSOutputStructForGS(ShaderCode& object, u32 components, API_TYPE api_type);
|
||||
void GenerateVSOutputStructForGS(ShaderCode& object, API_TYPE api_type);
|
||||
|
||||
#endif // GCOGL_VERTEXSHADER_H
|
||||
|
Loading…
Reference in New Issue
Block a user