Skip to content

Commit 5ad54e9

Browse files
committed
glBufferUtils: Use the state cache when switching the vertex format.
1 parent 76b9cfa commit 5ad54e9

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/Layers/xrRenderGL/glBufferUtils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ GLsizei GetDeclVertexSize(const D3DVERTEXELEMENT9* decl)
141141
return size;
142142
}
143143

144-
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* decl, GLuint vao)
144+
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* dxdecl, SDeclaration* decl)
145145
{
146-
CHK_GL(glBindVertexArray(vao));
146+
RCache.set_Format(decl);
147147

148-
GLsizei stride = GetDeclVertexSize(decl);
148+
GLsizei stride = GetDeclVertexSize(dxdecl);
149149
for (int i = 0; i < MAXD3DDECLLENGTH; ++i)
150150
{
151-
const D3DVERTEXELEMENT9 &desc = decl[i];
151+
const D3DVERTEXELEMENT9 &desc = dxdecl[i];
152152

153153
if (desc.Stream == 0xFF)
154154
break;
@@ -203,9 +203,9 @@ GLsizei GetFVFVertexSize(u32 FVF)
203203
return offset;
204204
}
205205

206-
void ConvertVertexDeclaration(u32 FVF, GLuint vao)
206+
void ConvertVertexDeclaration(u32 FVF, SDeclaration* decl)
207207
{
208-
CHK_GL(glBindVertexArray(vao));
208+
RCache.set_Format(decl);
209209

210210
GLsizei stride = GetFVFVertexSize(FVF);
211211
u32 offset = 0;

src/Layers/xrRenderGL/glBufferUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace glBufferUtils
99
GLsizei GetFVFVertexSize(u32 FVF);
1010
GLsizei GetDeclVertexSize(const D3DVERTEXELEMENT9* decl);
1111
u32 GetDeclLength(const D3DVERTEXELEMENT9* decl);
12-
void ConvertVertexDeclaration(u32 FVF, GLuint vao);
13-
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* decl, GLuint vao);
12+
void ConvertVertexDeclaration(u32 FVF, SDeclaration* decl);
13+
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* dxdecl, SDeclaration* decl);
1414
};
1515

1616
#endif // USE_OGL

src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ SDeclaration* CResourceManager::_CreateDecl (u32 FVF)
121121
glGenVertexArrays(1, &D->dcl);
122122

123123
D->FVF = FVF;
124-
glBufferUtils::ConvertVertexDeclaration(FVF, D->dcl);
124+
glBufferUtils::ConvertVertexDeclaration(FVF, D);
125125
D->dwFlags |= xr_resource_flagged::RF_REGISTERED;
126126
v_declarations.push_back(D);
127127

@@ -143,7 +143,7 @@ SDeclaration* CResourceManager::_CreateDecl(D3DVERTEXELEMENT9* dcl)
143143
D->FVF = 0;
144144
u32 dcl_size = glBufferUtils::GetDeclLength(dcl) + 1;
145145
D->dcl_code.assign(dcl, dcl + dcl_size);
146-
glBufferUtils::ConvertVertexDeclaration(dcl, D->dcl);
146+
glBufferUtils::ConvertVertexDeclaration(dcl, D);
147147
D->dwFlags |= xr_resource_flagged::RF_REGISTERED;
148148
v_declarations.push_back(D);
149149

0 commit comments

Comments
 (0)