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;
struct TranslatedIndexData;
struct SourceIndexData;
class ProgramD3D;
class Renderer11;
class InputLayoutCache : angle::NonCopyable
{
......@@ -41,11 +42,12 @@ class InputLayoutCache : angle::NonCopyable
InputLayoutCache();
virtual ~InputLayoutCache();
void initialize(ID3D11Device *device, ID3D11DeviceContext *context);
void initialize();
void clear();
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> &currentValueAttribs,
GLenum mode,
......@@ -53,7 +55,8 @@ class InputLayoutCache : angle::NonCopyable
TranslatedIndexData *indexInfo,
GLsizei numIndicesPerInstance);
gl::Error updateVertexOffsetsForPointSpritesEmulation(GLint startVertex,
gl::Error updateVertexOffsetsForPointSpritesEmulation(Renderer11 *renderer,
GLint startVertex,
GLsizei emulatedInstanceId);
// Useful for testing
......@@ -87,11 +90,13 @@ class InputLayoutCache : angle::NonCopyable
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,
const AttribIndexArray &sortedSemanticIndices,
GLsizei numIndicesPerInstance);
gl::Error createInputLayout(const AttribIndexArray &sortedSemanticIndices,
gl::Error createInputLayout(Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
GLenum mode,
gl::Program *program,
GLsizei numIndicesPerInstance,
......@@ -99,7 +104,7 @@ class InputLayoutCache : angle::NonCopyable
std::map<PackedAttributeLayout, ID3D11InputLayout *> mLayoutMap;
ID3D11InputLayout *mCurrentIL;
uintptr_t mCurrentIL;
std::array<ID3D11Buffer *, gl::MAX_VERTEX_ATTRIBS> mCurrentBuffers;
std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexStrides;
std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexOffsets;
......@@ -109,10 +114,6 @@ class InputLayoutCache : angle::NonCopyable
ID3D11Buffer *mPointSpriteIndexBuffer;
unsigned int mCacheSize;
ID3D11Device *mDevice;
ID3D11DeviceContext *mDeviceContext;
D3D_FEATURE_LEVEL mFeatureLevel;
};
} // namespace rx
......
......@@ -796,7 +796,7 @@ void Renderer11::initializeDevice()
populateRenderer11DeviceCaps();
mStateCache.initialize(mDevice);
mInputLayoutCache.initialize(mDevice, mDeviceContext);
mInputLayoutCache.initialize();
ASSERT(!mVertexDataManager && !mIndexDataManager);
mVertexDataManager = new VertexDataManager(this);
......@@ -1811,8 +1811,9 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state,
}
const auto &vertexArrayAttribs = vertexArray11->getTranslatedAttribs();
const auto &currentValueAttribs = mStateManager.getCurrentValueAttribs();
ANGLE_TRY(mInputLayoutCache.applyVertexBuffers(state, vertexArrayAttribs, currentValueAttribs,
mode, first, indexInfo, numIndicesPerInstance));
ANGLE_TRY(mInputLayoutCache.applyVertexBuffers(this, state, vertexArrayAttribs,
currentValueAttribs, mode, first, indexInfo,
numIndicesPerInstance));
// InputLayoutCache::applyVertexBuffers calls through to the Bufer11 to get the native vertex
// buffer (ID3D11Buffer *). Because we allocate these buffers lazily, this will trigger
......@@ -1994,8 +1995,8 @@ gl::Error Renderer11::drawArraysImpl(const gl::ContextState &data,
// offsets.
for (GLsizei i = 0; i < instances; i++)
{
ANGLE_TRY(
mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(startVertex, i));
ANGLE_TRY(mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(
this, startVertex, i));
mDeviceContext->DrawIndexedInstanced(6, count, 0, 0, 0);
}
}
......@@ -2057,8 +2058,8 @@ gl::Error Renderer11::drawElementsImpl(const gl::ContextState &data,
// offsets.
for (GLsizei i = 0; i < instances; i++)
{
ANGLE_TRY(
mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(startVertex, i));
ANGLE_TRY(mInputLayoutCache.updateVertexOffsetsForPointSpritesEmulation(
this, startVertex, i));
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