Skip to content

Commit 3721a94

Browse files
committed
xrRender: refactor compare ShaderElements
1 parent b2931c3 commit 3721a94

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/Layers/xrRender/Shader.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,26 @@ BOOL ShaderElement::equal(ShaderElement& S)
110110
return TRUE;
111111
}
112112

113-
BOOL ShaderElement::equal(ShaderElement* S)
113+
BOOL Shader::equal(Shader* S, int index)
114114
{
115-
if (nullptr == S && nullptr == this)
115+
if(nullptr == E[index] && nullptr == S->E[index])
116116
return TRUE;
117-
if (nullptr == S || nullptr == this)
117+
if(nullptr == E[index] || nullptr == S->E[index])
118118
return FALSE;
119-
return equal(*S);
119+
120+
return (E[index] == S->E[index]);
120121
}
121122

122-
//
123-
BOOL Shader::equal(Shader& S)
123+
BOOL Shader::equal(Shader* S)
124124
{
125-
return E[0]->equal(&*S.E[0]) && E[1]->equal(&*S.E[1]) && E[2]->equal(&*S.E[2]) && E[3]->equal(&*S.E[3]) &&
126-
E[4]->equal(&*S.E[4]);
125+
for (int i = 0; i < 4; i++)
126+
{
127+
if (!equal(S, i))
128+
return FALSE;
129+
}
130+
return TRUE;
127131
}
128-
BOOL Shader::equal(Shader* S) { return equal(*S); }
132+
129133
void STextureList::clear()
130134
{
131135
iterator it = begin();

src/Layers/xrRender/Shader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ struct ECORE_API Shader : public xr_resource_flagged
149149
~Shader();
150150
BOOL equal(Shader& S);
151151
BOOL equal(Shader* S);
152+
BOOL equal(Shader* S, int index);
152153
};
153154

154155
struct ECORE_API resptrcode_shader : public resptr_base<Shader>

0 commit comments

Comments
 (0)