Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
1f53cab0
Commit
1f53cab0
authored
Jul 22, 2013
by
Geoff Lang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache applied vertex buffers and input layout.
Issue #451 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang
parent
5ccc6248
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
+46
-2
InputLayoutCache.cpp
src/libGLESv2/renderer/InputLayoutCache.cpp
+38
-2
InputLayoutCache.h
src/libGLESv2/renderer/InputLayoutCache.h
+6
-0
Renderer11.cpp
src/libGLESv2/renderer/Renderer11.cpp
+2
-0
No files found.
src/libGLESv2/renderer/InputLayoutCache.cpp
View file @
1f53cab0
...
@@ -28,6 +28,13 @@ InputLayoutCache::InputLayoutCache() : mInputLayoutMap(kMaxInputLayouts, hashInp
...
@@ -28,6 +28,13 @@ InputLayoutCache::InputLayoutCache() : mInputLayoutMap(kMaxInputLayouts, hashInp
mCounter
=
0
;
mCounter
=
0
;
mDevice
=
NULL
;
mDevice
=
NULL
;
mDeviceContext
=
NULL
;
mDeviceContext
=
NULL
;
mCurrentIL
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<
gl
::
MAX_VERTEX_ATTRIBS
;
i
++
)
{
mCurrentBuffers
[
i
]
=
-
1
;
mCurrentVertexStrides
[
i
]
=
-
1
;
mCurrentVertexOffsets
[
i
]
=
-
1
;
}
}
}
InputLayoutCache
::~
InputLayoutCache
()
InputLayoutCache
::~
InputLayoutCache
()
...
@@ -49,6 +56,18 @@ void InputLayoutCache::clear()
...
@@ -49,6 +56,18 @@ void InputLayoutCache::clear()
i
->
second
.
inputLayout
->
Release
();
i
->
second
.
inputLayout
->
Release
();
}
}
mInputLayoutMap
.
clear
();
mInputLayoutMap
.
clear
();
markDirty
();
}
void
InputLayoutCache
::
markDirty
()
{
mCurrentIL
=
NULL
;
for
(
unsigned
int
i
=
0
;
i
<
gl
::
MAX_VERTEX_ATTRIBS
;
i
++
)
{
mCurrentBuffers
[
i
]
=
-
1
;
mCurrentVertexStrides
[
i
]
=
-
1
;
mCurrentVertexOffsets
[
i
]
=
-
1
;
}
}
}
GLenum
InputLayoutCache
::
applyVertexBuffers
(
TranslatedAttribute
attributes
[
gl
::
MAX_VERTEX_ATTRIBS
],
GLenum
InputLayoutCache
::
applyVertexBuffers
(
TranslatedAttribute
attributes
[
gl
::
MAX_VERTEX_ATTRIBS
],
...
@@ -66,6 +85,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
...
@@ -66,6 +85,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
InputLayoutKey
ilKey
=
{
0
};
InputLayoutKey
ilKey
=
{
0
};
ID3D11Buffer
*
vertexBuffers
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
NULL
};
ID3D11Buffer
*
vertexBuffers
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
NULL
};
unsigned
int
vertexBufferSerials
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
0
};
UINT
vertexStrides
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
0
};
UINT
vertexStrides
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
0
};
UINT
vertexOffsets
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
0
};
UINT
vertexOffsets
[
gl
::
MAX_VERTEX_ATTRIBS
]
=
{
0
};
...
@@ -98,6 +118,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
...
@@ -98,6 +118,7 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
ilKey
.
elementCount
++
;
ilKey
.
elementCount
++
;
vertexBuffers
[
i
]
=
bufferStorage
?
bufferStorage
->
getBuffer
(
GL_ARRAY_BUFFER
)
:
vertexBuffer
->
getBuffer
();
vertexBuffers
[
i
]
=
bufferStorage
?
bufferStorage
->
getBuffer
(
GL_ARRAY_BUFFER
)
:
vertexBuffer
->
getBuffer
();
vertexBufferSerials
[
i
]
=
bufferStorage
?
bufferStorage
->
getSerial
()
:
vertexBuffer
->
getSerial
();
vertexStrides
[
i
]
=
attributes
[
i
].
stride
;
vertexStrides
[
i
]
=
attributes
[
i
].
stride
;
vertexOffsets
[
i
]
=
attributes
[
i
].
offset
;
vertexOffsets
[
i
]
=
attributes
[
i
].
offset
;
}
}
...
@@ -146,8 +167,23 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
...
@@ -146,8 +167,23 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
mInputLayoutMap
.
insert
(
std
::
make_pair
(
ilKey
,
inputCounterPair
));
mInputLayoutMap
.
insert
(
std
::
make_pair
(
ilKey
,
inputCounterPair
));
}
}
mDeviceContext
->
IASetInputLayout
(
inputLayout
);
if
(
inputLayout
!=
mCurrentIL
)
mDeviceContext
->
IASetVertexBuffers
(
0
,
gl
::
MAX_VERTEX_ATTRIBS
,
vertexBuffers
,
vertexStrides
,
vertexOffsets
);
{
mDeviceContext
->
IASetInputLayout
(
inputLayout
);
mCurrentIL
=
inputLayout
;
}
for
(
unsigned
int
i
=
0
;
i
<
gl
::
MAX_VERTEX_ATTRIBS
;
i
++
)
{
if
(
vertexBufferSerials
[
i
]
!=
mCurrentBuffers
[
i
]
||
vertexStrides
[
i
]
!=
mCurrentVertexStrides
[
i
]
||
vertexOffsets
[
i
]
!=
mCurrentVertexOffsets
[
i
])
{
mDeviceContext
->
IASetVertexBuffers
(
i
,
1
,
&
vertexBuffers
[
i
],
&
vertexStrides
[
i
],
&
vertexOffsets
[
i
]);
mCurrentBuffers
[
i
]
=
vertexBufferSerials
[
i
];
mCurrentVertexStrides
[
i
]
=
vertexStrides
[
i
];
mCurrentVertexOffsets
[
i
]
=
vertexOffsets
[
i
];
}
}
return
GL_NO_ERROR
;
return
GL_NO_ERROR
;
}
}
...
...
src/libGLESv2/renderer/InputLayoutCache.h
View file @
1f53cab0
...
@@ -30,6 +30,7 @@ class InputLayoutCache
...
@@ -30,6 +30,7 @@ class InputLayoutCache
void
initialize
(
ID3D11Device
*
device
,
ID3D11DeviceContext
*
context
);
void
initialize
(
ID3D11Device
*
device
,
ID3D11DeviceContext
*
context
);
void
clear
();
void
clear
();
void
markDirty
();
GLenum
applyVertexBuffers
(
TranslatedAttribute
attributes
[
gl
::
MAX_VERTEX_ATTRIBS
],
GLenum
applyVertexBuffers
(
TranslatedAttribute
attributes
[
gl
::
MAX_VERTEX_ATTRIBS
],
gl
::
ProgramBinary
*
programBinary
);
gl
::
ProgramBinary
*
programBinary
);
...
@@ -50,6 +51,11 @@ class InputLayoutCache
...
@@ -50,6 +51,11 @@ class InputLayoutCache
unsigned
long
long
lastUsedTime
;
unsigned
long
long
lastUsedTime
;
};
};
ID3D11InputLayout
*
mCurrentIL
;
unsigned
int
mCurrentBuffers
[
gl
::
MAX_VERTEX_ATTRIBS
];
UINT
mCurrentVertexStrides
[
gl
::
MAX_VERTEX_ATTRIBS
];
UINT
mCurrentVertexOffsets
[
gl
::
MAX_VERTEX_ATTRIBS
];
static
std
::
size_t
hashInputLayout
(
const
InputLayoutKey
&
inputLayout
);
static
std
::
size_t
hashInputLayout
(
const
InputLayoutKey
&
inputLayout
);
static
bool
compareInputLayouts
(
const
InputLayoutKey
&
a
,
const
InputLayoutKey
&
b
);
static
bool
compareInputLayouts
(
const
InputLayoutKey
&
a
,
const
InputLayoutKey
&
b
);
...
...
src/libGLESv2/renderer/Renderer11.cpp
View file @
1f53cab0
...
@@ -1819,6 +1819,8 @@ void Renderer11::markAllStateDirty()
...
@@ -1819,6 +1819,8 @@ void Renderer11::markAllStateDirty()
mAppliedProgramBinarySerial
=
0
;
mAppliedProgramBinarySerial
=
0
;
memset
(
&
mAppliedVertexConstants
,
0
,
sizeof
(
dx_VertexConstants
));
memset
(
&
mAppliedVertexConstants
,
0
,
sizeof
(
dx_VertexConstants
));
memset
(
&
mAppliedPixelConstants
,
0
,
sizeof
(
dx_PixelConstants
));
memset
(
&
mAppliedPixelConstants
,
0
,
sizeof
(
dx_PixelConstants
));
mInputLayoutCache
.
markDirty
();
}
}
void
Renderer11
::
releaseDeviceResources
()
void
Renderer11
::
releaseDeviceResources
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment