Commit caafd890 by Jamie Madill Committed by Commit Bot

D3D11: Don't store device in InputLayoutCache.

We will need the Renderer pointer for resource allocation, so pass it around instead of storing the device and context. BUG=angleproject:2034 Change-Id: Iaf271913f88c5402895aa81de310aa22fcd72cc4 Reviewed-on: https://chromium-review.googlesource.com/509930Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 341a36cc
...@@ -34,6 +34,7 @@ struct TranslatedAttribute; ...@@ -34,6 +34,7 @@ struct TranslatedAttribute;
struct TranslatedIndexData; struct TranslatedIndexData;
struct SourceIndexData; struct SourceIndexData;
class ProgramD3D; class ProgramD3D;
class Renderer11;
class InputLayoutCache : angle::NonCopyable class InputLayoutCache : angle::NonCopyable
{ {
...@@ -41,11 +42,12 @@ class InputLayoutCache : angle::NonCopyable ...@@ -41,11 +42,12 @@ class InputLayoutCache : angle::NonCopyable
InputLayoutCache(); InputLayoutCache();
virtual ~InputLayoutCache(); virtual ~InputLayoutCache();
void initialize(ID3D11Device *device, ID3D11DeviceContext *context); void initialize();
void clear(); void clear();
void markDirty(); void markDirty();
gl::Error applyVertexBuffers(const gl::State &state, gl::Error applyVertexBuffers(Renderer11 *renderer,
const gl::State &state,
const std::vector<TranslatedAttribute> &vertexArrayAttribs, const std::vector<TranslatedAttribute> &vertexArrayAttribs,
const std::vector<TranslatedAttribute> &currentValueAttribs, const std::vector<TranslatedAttribute> &currentValueAttribs,
GLenum mode, GLenum mode,
...@@ -53,7 +55,8 @@ class InputLayoutCache : angle::NonCopyable ...@@ -53,7 +55,8 @@ class InputLayoutCache : angle::NonCopyable
TranslatedIndexData *indexInfo, TranslatedIndexData *indexInfo,
GLsizei numIndicesPerInstance); GLsizei numIndicesPerInstance);
gl::Error updateVertexOffsetsForPointSpritesEmulation(GLint startVertex, gl::Error updateVertexOffsetsForPointSpritesEmulation(Renderer11 *renderer,
GLint startVertex,
GLsizei emulatedInstanceId); GLsizei emulatedInstanceId);
// Useful for testing // Useful for testing
...@@ -87,11 +90,13 @@ class InputLayoutCache : angle::NonCopyable ...@@ -87,11 +90,13 @@ class InputLayoutCache : angle::NonCopyable
uint32_t attributeData[gl::MAX_VERTEX_ATTRIBS]; uint32_t attributeData[gl::MAX_VERTEX_ATTRIBS];
}; };
gl::Error updateInputLayout(const gl::State &state, gl::Error updateInputLayout(Renderer11 *renderer,
const gl::State &state,
GLenum mode, GLenum mode,
const AttribIndexArray &sortedSemanticIndices, const AttribIndexArray &sortedSemanticIndices,
GLsizei numIndicesPerInstance); GLsizei numIndicesPerInstance);
gl::Error createInputLayout(const AttribIndexArray &sortedSemanticIndices, gl::Error createInputLayout(Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
GLenum mode, GLenum mode,
gl::Program *program, gl::Program *program,
GLsizei numIndicesPerInstance, GLsizei numIndicesPerInstance,
...@@ -99,7 +104,7 @@ class InputLayoutCache : angle::NonCopyable ...@@ -99,7 +104,7 @@ class InputLayoutCache : angle::NonCopyable
std::map<PackedAttributeLayout, ID3D11InputLayout *> mLayoutMap; std::map<PackedAttributeLayout, ID3D11InputLayout *> mLayoutMap;
ID3D11InputLayout *mCurrentIL; uintptr_t mCurrentIL;
std::array<ID3D11Buffer *, gl::MAX_VERTEX_ATTRIBS> mCurrentBuffers; std::array<ID3D11Buffer *, gl::MAX_VERTEX_ATTRIBS> mCurrentBuffers;
std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexStrides; std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexStrides;
std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexOffsets; std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexOffsets;
...@@ -109,10 +114,6 @@ class InputLayoutCache : angle::NonCopyable ...@@ -109,10 +114,6 @@ class InputLayoutCache : angle::NonCopyable
ID3D11Buffer *mPointSpriteIndexBuffer; ID3D11Buffer *mPointSpriteIndexBuffer;
unsigned int mCacheSize; unsigned int mCacheSize;
ID3D11Device *mDevice;
ID3D11DeviceContext *mDeviceContext;
D3D_FEATURE_LEVEL mFeatureLevel;
}; };
} // namespace rx } // namespace rx
......
...@@ -796,7 +796,7 @@ void Renderer11::initializeDevice() ...@@ -796,7 +796,7 @@ void Renderer11::initializeDevice()
populateRenderer11DeviceCaps(); populateRenderer11DeviceCaps();
mStateCache.initialize(mDevice); mStateCache.initialize(mDevice);
mInputLayoutCache.initialize(mDevice, mDeviceContext); mInputLayoutCache.initialize();
ASSERT(!mVertexDataManager && !mIndexDataManager); ASSERT(!mVertexDataManager && !mIndexDataManager);
mVertexDataManager = new VertexDataManager(this); mVertexDataManager = new VertexDataManager(this);
...@@ -1811,8 +1811,9 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state, ...@@ -1811,8 +1811,9 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state,
} }
const auto &vertexArrayAttribs = vertexArray11->getTranslatedAttribs(); const auto &vertexArrayAttribs = vertexArray11->getTranslatedAttribs();
const auto &currentValueAttribs = mStateManager.getCurrentValueAttribs(); const auto &currentValueAttribs = mStateManager.getCurrentValueAttribs();
ANGLE_TRY(mInputLayoutCache.applyVertexBuffers(state, vertexArrayAttribs, currentValueAttribs, ANGLE_TRY(mInputLayoutCache.applyVertexBuffers(this, state, vertexArrayAttribs,
mode, first, indexInfo, numIndicesPerInstance)); currentValueAttribs, mode, first, indexInfo,
numIndicesPerInstance));
// InputLayoutCache::applyVertexBuffers calls through to the Bufer11 to get the native vertex // InputLayoutCache::applyVertexBuffers calls through to the Bufer11 to get the native vertex
// buffer (ID3D11Buffer *). Because we allocate these buffers lazily, this will trigger // buffer (ID3D11Buffer *). Because we allocate these buffers lazily, this will trigger
...@@ -1994,8 +1995,8 @@ gl::Error Renderer11::drawArraysImpl(const gl::ContextState &data, ...@@ -1994,8 +1995,8 @@ gl::Error Renderer11::drawArraysImpl(const gl::ContextState &data,
// offsets. // offsets.
for (GLsizei i = 0; i < instances; i++) for (GLsizei i = 0; i < instances; i++)
{ {
ANGLE_TRY( ANGLE_TRY(mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(
mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(startVertex, i)); this, startVertex, i));
mDeviceContext->DrawIndexedInstanced(6, count, 0, 0, 0); mDeviceContext->DrawIndexedInstanced(6, count, 0, 0, 0);
} }
} }
...@@ -2057,8 +2058,8 @@ gl::Error Renderer11::drawElementsImpl(const gl::ContextState &data, ...@@ -2057,8 +2058,8 @@ gl::Error Renderer11::drawElementsImpl(const gl::ContextState &data,
// offsets. // offsets.
for (GLsizei i = 0; i < instances; i++) for (GLsizei i = 0; i < instances; i++)
{ {
ANGLE_TRY( ANGLE_TRY(mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(
mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(startVertex, i)); this, startVertex, i));
mDeviceContext->DrawIndexedInstanced(6, elementsToRender, 0, 0, 0); mDeviceContext->DrawIndexedInstanced(6, elementsToRender, 0, 0, 0);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment