Skip to content

Commit

Permalink
glBufferUtils: Use the state cache when switching the vertex format.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Mar 24, 2016
1 parent 76b9cfa commit 5ad54e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/Layers/xrRenderGL/glBufferUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ GLsizei GetDeclVertexSize(const D3DVERTEXELEMENT9* decl)
return size;
}

void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* decl, GLuint vao)
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* dxdecl, SDeclaration* decl)
{
CHK_GL(glBindVertexArray(vao));
RCache.set_Format(decl);

GLsizei stride = GetDeclVertexSize(decl);
GLsizei stride = GetDeclVertexSize(dxdecl);
for (int i = 0; i < MAXD3DDECLLENGTH; ++i)
{
const D3DVERTEXELEMENT9 &desc = decl[i];
const D3DVERTEXELEMENT9 &desc = dxdecl[i];

if (desc.Stream == 0xFF)
break;
Expand Down Expand Up @@ -203,9 +203,9 @@ GLsizei GetFVFVertexSize(u32 FVF)
return offset;
}

void ConvertVertexDeclaration(u32 FVF, GLuint vao)
void ConvertVertexDeclaration(u32 FVF, SDeclaration* decl)
{
CHK_GL(glBindVertexArray(vao));
RCache.set_Format(decl);

GLsizei stride = GetFVFVertexSize(FVF);
u32 offset = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderGL/glBufferUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace glBufferUtils
GLsizei GetFVFVertexSize(u32 FVF);
GLsizei GetDeclVertexSize(const D3DVERTEXELEMENT9* decl);
u32 GetDeclLength(const D3DVERTEXELEMENT9* decl);
void ConvertVertexDeclaration(u32 FVF, GLuint vao);
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* decl, GLuint vao);
void ConvertVertexDeclaration(u32 FVF, SDeclaration* decl);
void ConvertVertexDeclaration(const D3DVERTEXELEMENT9* dxdecl, SDeclaration* decl);
};

#endif // USE_OGL
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_GL/glResourceManager_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ SDeclaration* CResourceManager::_CreateDecl (u32 FVF)
glGenVertexArrays(1, &D->dcl);

D->FVF = FVF;
glBufferUtils::ConvertVertexDeclaration(FVF, D->dcl);
glBufferUtils::ConvertVertexDeclaration(FVF, D);
D->dwFlags |= xr_resource_flagged::RF_REGISTERED;
v_declarations.push_back(D);

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

Expand Down

0 comments on commit 5ad54e9

Please sign in to comment.