D3D: Pass gl::Context to many more functions.
This makes the Context more available for logging errors.
Also includes more refactoring to VertexDataManager to ensure we can
access the gl::Context.
Bug: angleproject:2738
Change-Id: Iae3d22a1403078d236bfe63a3e2d203c13678dc4
Reviewed-on: https://chromium-review.googlesource.com/1151449
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/EGLImageD3D.cpp b/src/libANGLE/renderer/d3d/EGLImageD3D.cpp
index 8c8e196..a9a53aa 100644
--- a/src/libANGLE/renderer/d3d/EGLImageD3D.cpp
+++ b/src/libANGLE/renderer/d3d/EGLImageD3D.cpp
@@ -85,6 +85,6 @@
target->getSubject()->onStateChange(context, angle::SubjectMessage::DEPENDENT_DIRTY_BITS);
}
- return mRenderer->createRenderTargetCopy(curRenderTarget, &mRenderTarget);
+ return mRenderer->createRenderTargetCopy(context, curRenderTarget, &mRenderTarget);
}
} // namespace rx
diff --git a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
index db0bffb..4427e44 100644
--- a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
+++ b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
@@ -108,7 +108,7 @@
release();
}
-gl::Error HLSLCompiler::ensureInitialized()
+gl::Error HLSLCompiler::ensureInitialized(const gl::Context *context)
{
if (mInitialized)
{
@@ -177,9 +177,14 @@
}
}
-gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
- const std::vector<CompileConfig> &configs, const D3D_SHADER_MACRO *overrideMacros,
- ID3DBlob **outCompiledBlob, std::string *outDebugInfo)
+gl::Error HLSLCompiler::compileToBinary(const gl::Context *context,
+ gl::InfoLog &infoLog,
+ const std::string &hlsl,
+ const std::string &profile,
+ const std::vector<CompileConfig> &configs,
+ const D3D_SHADER_MACRO *overrideMacros,
+ ID3DBlob **outCompiledBlob,
+ std::string *outDebugInfo)
{
ASSERT(mInitialized);
@@ -273,7 +278,7 @@
}
std::string disassembly;
- ANGLE_TRY(disassembleBinary(binary, &disassembly));
+ ANGLE_TRY(disassembleBinary(context, binary, &disassembly));
(*outDebugInfo) += "\n" + disassembly + "\n// ASSEMBLY END\n";
#endif // ANGLE_APPEND_ASSEMBLY_TO_SHADER_DEBUG_INFO == ANGLE_ENABLED
return gl::NoError();
@@ -300,9 +305,11 @@
return gl::NoError();
}
-gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *disassemblyOut)
+gl::Error HLSLCompiler::disassembleBinary(const gl::Context *context,
+ ID3DBlob *shaderBinary,
+ std::string *disassemblyOut)
{
- ANGLE_TRY(ensureInitialized());
+ ANGLE_TRY(ensureInitialized(context));
// Retrieve disassembly
UINT flags = D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS | D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING;
diff --git a/src/libANGLE/renderer/d3d/HLSLCompiler.h b/src/libANGLE/renderer/d3d/HLSLCompiler.h
index c8f9eac..d346faa 100644
--- a/src/libANGLE/renderer/d3d/HLSLCompiler.h
+++ b/src/libANGLE/renderer/d3d/HLSLCompiler.h
@@ -19,6 +19,7 @@
namespace gl
{
+class Context;
class InfoLog;
}
@@ -44,12 +45,19 @@
// Attempt to compile a HLSL shader using the supplied configurations, may output a NULL compiled blob
// even if no GL errors are returned.
- gl::Error compileToBinary(gl::InfoLog &infoLog, const std::string &hlsl, const std::string &profile,
- const std::vector<CompileConfig> &configs, const D3D_SHADER_MACRO *overrideMacros,
- ID3DBlob **outCompiledBlob, std::string *outDebugInfo);
+ gl::Error compileToBinary(const gl::Context *context,
+ gl::InfoLog &infoLog,
+ const std::string &hlsl,
+ const std::string &profile,
+ const std::vector<CompileConfig> &configs,
+ const D3D_SHADER_MACRO *overrideMacros,
+ ID3DBlob **outCompiledBlob,
+ std::string *outDebugInfo);
- gl::Error disassembleBinary(ID3DBlob *shaderBinary, std::string *disassemblyOut);
- gl::Error ensureInitialized();
+ gl::Error disassembleBinary(const gl::Context *context,
+ ID3DBlob *shaderBinary,
+ std::string *disassemblyOut);
+ gl::Error ensureInitialized(const gl::Context *context);
private:
diff --git a/src/libANGLE/renderer/d3d/IndexBuffer.cpp b/src/libANGLE/renderer/d3d/IndexBuffer.cpp
index 937512a..68e926e 100644
--- a/src/libANGLE/renderer/d3d/IndexBuffer.cpp
+++ b/src/libANGLE/renderer/d3d/IndexBuffer.cpp
@@ -66,7 +66,10 @@
return mIndexBuffer->getSerial();
}
-gl::Error IndexBufferInterface::mapBuffer(unsigned int size, void **outMappedMemory, unsigned int *streamOffset)
+gl::Error IndexBufferInterface::mapBuffer(const gl::Context *context,
+ unsigned int size,
+ void **outMappedMemory,
+ unsigned int *streamOffset)
{
// Protect against integer overflow
if (mWritePosition + size < mWritePosition)
@@ -75,7 +78,7 @@
<< "Mapping of internal index buffer would cause an integer overflow.";
}
- gl::Error error = mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory);
+ gl::Error error = mIndexBuffer->mapBuffer(context, mWritePosition, size, outMappedMemory);
if (error.isError())
{
if (outMappedMemory)
@@ -94,9 +97,9 @@
return gl::NoError();
}
-gl::Error IndexBufferInterface::unmapBuffer()
+gl::Error IndexBufferInterface::unmapBuffer(const gl::Context *context)
{
- return mIndexBuffer->unmapBuffer();
+ return mIndexBuffer->unmapBuffer(context);
}
IndexBuffer * IndexBufferInterface::getIndexBuffer() const
@@ -114,20 +117,22 @@
mWritePosition = writePosition;
}
-gl::Error IndexBufferInterface::discard()
+gl::Error IndexBufferInterface::discard(const gl::Context *context)
{
- return mIndexBuffer->discard();
+ return mIndexBuffer->discard(context);
}
-gl::Error IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType)
+gl::Error IndexBufferInterface::setBufferSize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType)
{
if (mIndexBuffer->getBufferSize() == 0)
{
- return mIndexBuffer->initialize(bufferSize, indexType, mDynamic);
+ return mIndexBuffer->initialize(context, bufferSize, indexType, mDynamic);
}
else
{
- return mIndexBuffer->setSize(bufferSize, indexType);
+ return mIndexBuffer->setSize(context, bufferSize, indexType);
}
}
@@ -140,18 +145,20 @@
{
}
-gl::Error StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
+gl::Error StreamingIndexBufferInterface::reserveBufferSpace(const gl::Context *context,
+ unsigned int size,
+ GLenum indexType)
{
unsigned int curBufferSize = getBufferSize();
unsigned int writePos = getWritePosition();
if (size > curBufferSize)
{
- ANGLE_TRY(setBufferSize(std::max(size, 2 * curBufferSize), indexType));
+ ANGLE_TRY(setBufferSize(context, std::max(size, 2 * curBufferSize), indexType));
setWritePosition(0);
}
else if (writePos + size > curBufferSize || writePos + size < writePos)
{
- ANGLE_TRY(discard());
+ ANGLE_TRY(discard(context));
setWritePosition(0);
}
@@ -168,12 +175,14 @@
{
}
-gl::Error StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType)
+gl::Error StaticIndexBufferInterface::reserveBufferSpace(const gl::Context *context,
+ unsigned int size,
+ GLenum indexType)
{
unsigned int curSize = getBufferSize();
if (curSize == 0)
{
- return setBufferSize(size, indexType);
+ return setBufferSize(context, size, indexType);
}
else if (curSize >= size && indexType == getIndexType())
{
diff --git a/src/libANGLE/renderer/d3d/IndexBuffer.h b/src/libANGLE/renderer/d3d/IndexBuffer.h
index 969cf6a..0b1f291 100644
--- a/src/libANGLE/renderer/d3d/IndexBuffer.h
+++ b/src/libANGLE/renderer/d3d/IndexBuffer.h
@@ -13,6 +13,11 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
+namespace gl
+{
+class Context;
+} // namespace gl
+
namespace rx
{
class BufferFactoryD3D;
@@ -23,16 +28,24 @@
IndexBuffer();
virtual ~IndexBuffer();
- virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0;
+ virtual gl::Error initialize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType,
+ bool dynamic) = 0;
- virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0;
- virtual gl::Error unmapBuffer() = 0;
+ virtual gl::Error mapBuffer(const gl::Context *context,
+ unsigned int offset,
+ unsigned int size,
+ void **outMappedMemory) = 0;
+ virtual gl::Error unmapBuffer(const gl::Context *context) = 0;
- virtual gl::Error discard() = 0;
+ virtual gl::Error discard(const gl::Context *context) = 0;
virtual GLenum getIndexType() const = 0;
virtual unsigned int getBufferSize() const = 0;
- virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType) = 0;
+ virtual gl::Error setSize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType) = 0;
unsigned int getSerial() const;
@@ -50,15 +63,20 @@
IndexBufferInterface(BufferFactoryD3D *factory, bool dynamic);
virtual ~IndexBufferInterface();
- virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType) = 0;
+ virtual gl::Error reserveBufferSpace(const gl::Context *context,
+ unsigned int size,
+ GLenum indexType) = 0;
GLenum getIndexType() const;
unsigned int getBufferSize() const;
unsigned int getSerial() const;
- gl::Error mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset);
- gl::Error unmapBuffer();
+ gl::Error mapBuffer(const gl::Context *context,
+ unsigned int size,
+ void **outMappedMemory,
+ unsigned int *streamOffset);
+ gl::Error unmapBuffer(const gl::Context *context);
IndexBuffer *getIndexBuffer() const;
@@ -66,9 +84,9 @@
unsigned int getWritePosition() const;
void setWritePosition(unsigned int writePosition);
- gl::Error discard();
+ gl::Error discard(const gl::Context *context);
- gl::Error setBufferSize(unsigned int bufferSize, GLenum indexType);
+ gl::Error setBufferSize(const gl::Context *context, unsigned int bufferSize, GLenum indexType);
private:
IndexBuffer *mIndexBuffer;
@@ -83,7 +101,9 @@
explicit StreamingIndexBufferInterface(BufferFactoryD3D *factory);
~StreamingIndexBufferInterface() override;
- gl::Error reserveBufferSpace(unsigned int size, GLenum indexType) override;
+ gl::Error reserveBufferSpace(const gl::Context *context,
+ unsigned int size,
+ GLenum indexType) override;
};
class StaticIndexBufferInterface : public IndexBufferInterface
@@ -92,9 +112,11 @@
explicit StaticIndexBufferInterface(BufferFactoryD3D *factory);
~StaticIndexBufferInterface() override;
- gl::Error reserveBufferSpace(unsigned int size, GLenum indexType) override;
+ gl::Error reserveBufferSpace(const gl::Context *context,
+ unsigned int size,
+ GLenum indexType) override;
};
-}
+} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_INDEXBUFFER_H_
diff --git a/src/libANGLE/renderer/d3d/IndexDataManager.cpp b/src/libANGLE/renderer/d3d/IndexDataManager.cpp
index 6e3ead4..183303c 100644
--- a/src/libANGLE/renderer/d3d/IndexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/IndexDataManager.cpp
@@ -82,7 +82,8 @@
UNREACHABLE();
}
-gl::Error StreamInIndexBuffer(IndexBufferInterface *buffer,
+gl::Error StreamInIndexBuffer(const gl::Context *context,
+ IndexBufferInterface *buffer,
const void *data,
unsigned int count,
GLenum srcType,
@@ -99,14 +100,14 @@
}
unsigned int bufferSizeRequired = count << dstTypeInfo.bytesShift;
- ANGLE_TRY(buffer->reserveBufferSpace(bufferSizeRequired, dstType));
+ ANGLE_TRY(buffer->reserveBufferSpace(context, bufferSizeRequired, dstType));
void *output = nullptr;
- ANGLE_TRY(buffer->mapBuffer(bufferSizeRequired, &output, offset));
+ ANGLE_TRY(buffer->mapBuffer(context, bufferSizeRequired, &output, offset));
ConvertIndices(srcType, dstType, data, count, output, usePrimitiveRestartFixedIndex);
- ANGLE_TRY(buffer->unmapBuffer());
+ ANGLE_TRY(buffer->unmapBuffer(context));
return gl::NoError();
}
@@ -184,8 +185,8 @@
if (glBuffer == nullptr)
{
translated->storage = nullptr;
- return streamIndexData(indices, count, srcType, dstType, primitiveRestartFixedIndexEnabled,
- translated);
+ return streamIndexData(context, indices, count, srcType, dstType,
+ primitiveRestartFixedIndexEnabled, translated);
}
// Case 2: the indices are already in a buffer
@@ -226,7 +227,7 @@
ANGLE_TRY(buffer->getData(context, &bufferData));
ASSERT(bufferData != nullptr);
- ANGLE_TRY(streamIndexData(bufferData + offset, count, srcType, dstType,
+ ANGLE_TRY(streamIndexData(context, bufferData + offset, count, srcType, dstType,
primitiveRestartFixedIndexEnabled, translated));
buffer->promoteStaticUsage(context, count << srcTypeInfo.bytesShift);
}
@@ -240,8 +241,8 @@
unsigned int convertCount =
static_cast<unsigned int>(buffer->getSize()) >> srcTypeInfo.bytesShift;
- ANGLE_TRY(StreamInIndexBuffer(staticBuffer, bufferData, convertCount, srcType, dstType,
- primitiveRestartFixedIndexEnabled, nullptr));
+ ANGLE_TRY(StreamInIndexBuffer(context, staticBuffer, bufferData, convertCount, srcType,
+ dstType, primitiveRestartFixedIndexEnabled, nullptr));
}
ASSERT(offsetAligned && staticBuffer->getIndexType() == dstType);
@@ -254,7 +255,8 @@
return gl::NoError();
}
-gl::Error IndexDataManager::streamIndexData(const void *data,
+gl::Error IndexDataManager::streamIndexData(const gl::Context *context,
+ const void *data,
unsigned int count,
GLenum srcType,
GLenum dstType,
@@ -264,11 +266,11 @@
const gl::Type &dstTypeInfo = gl::GetTypeInfo(dstType);
IndexBufferInterface *indexBuffer = nullptr;
- ANGLE_TRY(getStreamingIndexBuffer(dstType, &indexBuffer));
+ ANGLE_TRY(getStreamingIndexBuffer(context, dstType, &indexBuffer));
ASSERT(indexBuffer != nullptr);
unsigned int offset;
- ANGLE_TRY(StreamInIndexBuffer(indexBuffer, data, count, srcType, dstType,
+ ANGLE_TRY(StreamInIndexBuffer(context, indexBuffer, data, count, srcType, dstType,
usePrimitiveRestartFixedIndex, &offset));
translated->indexBuffer = indexBuffer->getIndexBuffer();
@@ -279,7 +281,8 @@
return gl::NoError();
}
-gl::Error IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType,
+gl::Error IndexDataManager::getStreamingIndexBuffer(const gl::Context *context,
+ GLenum destinationIndexType,
IndexBufferInterface **outBuffer)
{
ASSERT(outBuffer);
@@ -291,7 +294,8 @@
if (!streamingBuffer)
{
StreamingBuffer newBuffer(new StreamingIndexBufferInterface(mFactory));
- ANGLE_TRY(newBuffer->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, destinationIndexType));
+ ANGLE_TRY(newBuffer->reserveBufferSpace(context, INITIAL_INDEX_BUFFER_SIZE,
+ destinationIndexType));
streamingBuffer = std::move(newBuffer);
}
diff --git a/src/libANGLE/renderer/d3d/IndexDataManager.h b/src/libANGLE/renderer/d3d/IndexDataManager.h
index b837531..a0c6d88 100644
--- a/src/libANGLE/renderer/d3d/IndexDataManager.h
+++ b/src/libANGLE/renderer/d3d/IndexDataManager.h
@@ -78,13 +78,15 @@
TranslatedIndexData *translated);
private:
- gl::Error streamIndexData(const void *data,
+ gl::Error streamIndexData(const gl::Context *context,
+ const void *data,
unsigned int count,
GLenum srcType,
GLenum dstType,
bool usePrimitiveRestartFixedIndex,
TranslatedIndexData *translated);
- gl::Error getStreamingIndexBuffer(GLenum destinationIndexType,
+ gl::Error getStreamingIndexBuffer(const gl::Context *context,
+ GLenum destinationIndexType,
IndexBufferInterface **outBuffer);
using StreamingBuffer = std::unique_ptr<StreamingIndexBufferInterface>;
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index 048cefe..a681a3a 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -911,7 +911,7 @@
ShaderExecutableD3D *shaderExecutable = nullptr;
- ANGLE_TRY(mRenderer->loadExecutable(vertexShaderFunction, vertexShaderSize,
+ ANGLE_TRY(mRenderer->loadExecutable(context, vertexShaderFunction, vertexShaderSize,
gl::ShaderType::Vertex, mStreamOutVaryings,
separateAttribs, &shaderExecutable));
@@ -946,7 +946,7 @@
const unsigned char *pixelShaderFunction = binary + stream->offset();
ShaderExecutableD3D *shaderExecutable = nullptr;
- ANGLE_TRY(mRenderer->loadExecutable(pixelShaderFunction, pixelShaderSize,
+ ANGLE_TRY(mRenderer->loadExecutable(context, pixelShaderFunction, pixelShaderSize,
gl::ShaderType::Fragment, mStreamOutVaryings,
separateAttribs, &shaderExecutable));
@@ -974,7 +974,7 @@
const unsigned char *geometryShaderFunction = binary + stream->offset();
ShaderExecutableD3D *geometryExecutable = nullptr;
- ANGLE_TRY(mRenderer->loadExecutable(geometryShaderFunction, geometryShaderSize,
+ ANGLE_TRY(mRenderer->loadExecutable(context, geometryShaderFunction, geometryShaderSize,
gl::ShaderType::Geometry, mStreamOutVaryings,
separateAttribs, &geometryExecutable));
@@ -995,7 +995,7 @@
const unsigned char *computeShaderFunction = binary + stream->offset();
ShaderExecutableD3D *computeExecutable = nullptr;
- ANGLE_TRY(mRenderer->loadExecutable(computeShaderFunction, computeShaderSize,
+ ANGLE_TRY(mRenderer->loadExecutable(context, computeShaderFunction, computeShaderSize,
gl::ShaderType::Compute, std::vector<D3DVarying>(),
false, &computeExecutable));
@@ -1193,7 +1193,8 @@
{
}
-gl::Error ProgramD3D::getPixelExecutableForCachedOutputLayout(ShaderExecutableD3D **outExecutable,
+gl::Error ProgramD3D::getPixelExecutableForCachedOutputLayout(const gl::Context *context,
+ ShaderExecutableD3D **outExecutable,
gl::InfoLog *infoLog)
{
if (mCachedPixelExecutableIndex.valid())
@@ -1213,7 +1214,7 @@
gl::InfoLog *currentInfoLog = infoLog ? infoLog : &tempInfoLog;
ANGLE_TRY(mRenderer->compileToExecutable(
- *currentInfoLog, finalPixelHLSL, gl::ShaderType::Fragment, mStreamOutVaryings,
+ context, *currentInfoLog, finalPixelHLSL, gl::ShaderType::Fragment, mStreamOutVaryings,
(mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS),
mShaderWorkarounds[gl::ShaderType::Fragment], &pixelExecutable));
@@ -1233,7 +1234,8 @@
return gl::NoError();
}
-gl::Error ProgramD3D::getVertexExecutableForCachedInputLayout(ShaderExecutableD3D **outExectuable,
+gl::Error ProgramD3D::getVertexExecutableForCachedInputLayout(const gl::Context *context,
+ ShaderExecutableD3D **outExectuable,
gl::InfoLog *infoLog)
{
if (mCachedVertexExecutableIndex.valid())
@@ -1254,7 +1256,7 @@
gl::InfoLog *currentInfoLog = infoLog ? infoLog : &tempInfoLog;
ANGLE_TRY(mRenderer->compileToExecutable(
- *currentInfoLog, finalVertexHLSL, gl::ShaderType::Vertex, mStreamOutVaryings,
+ context, *currentInfoLog, finalVertexHLSL, gl::ShaderType::Vertex, mStreamOutVaryings,
(mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS),
mShaderWorkarounds[gl::ShaderType::Vertex], &vertexExecutable));
@@ -1311,7 +1313,7 @@
ShaderExecutableD3D *geometryExecutable = nullptr;
gl::Error error = mRenderer->compileToExecutable(
- *currentInfoLog, geometryHLSL, gl::ShaderType::Geometry, mStreamOutVaryings,
+ context, *currentInfoLog, geometryHLSL, gl::ShaderType::Geometry, mStreamOutVaryings,
(mState.getTransformFeedbackBufferMode() == GL_SEPARATE_ATTRIBS),
angle::CompilerWorkaroundsD3D(), &geometryExecutable);
@@ -1336,8 +1338,8 @@
class ProgramD3D::GetExecutableTask : public Closure
{
public:
- GetExecutableTask(ProgramD3D *program)
- : mProgram(program), mError(gl::NoError()), mInfoLog(), mResult(nullptr)
+ GetExecutableTask(ProgramD3D *program, const gl::Context *context)
+ : mProgram(program), mError(gl::NoError()), mInfoLog(), mResult(nullptr), mContext(context)
{
}
@@ -1354,26 +1356,24 @@
gl::Error mError;
gl::InfoLog mInfoLog;
ShaderExecutableD3D *mResult;
+ const gl::Context *mContext;
};
class ProgramD3D::GetVertexExecutableTask : public ProgramD3D::GetExecutableTask
{
public:
GetVertexExecutableTask(ProgramD3D *program, const gl::Context *context)
- : GetExecutableTask(program), mContext(context)
+ : GetExecutableTask(program, context)
{
}
gl::Error run() override
{
mProgram->updateCachedInputLayoutFromShader(mContext);
- ANGLE_TRY(mProgram->getVertexExecutableForCachedInputLayout(&mResult, &mInfoLog));
+ ANGLE_TRY(mProgram->getVertexExecutableForCachedInputLayout(mContext, &mResult, &mInfoLog));
return gl::NoError();
}
-
- private:
- const gl::Context *mContext;
};
void ProgramD3D::updateCachedInputLayoutFromShader(const gl::Context *context)
@@ -1387,12 +1387,15 @@
class ProgramD3D::GetPixelExecutableTask : public ProgramD3D::GetExecutableTask
{
public:
- GetPixelExecutableTask(ProgramD3D *program) : GetExecutableTask(program) {}
+ GetPixelExecutableTask(ProgramD3D *program, const gl::Context *context)
+ : GetExecutableTask(program, context)
+ {
+ }
gl::Error run() override
{
mProgram->updateCachedOutputLayoutFromShader();
- ANGLE_TRY(mProgram->getPixelExecutableForCachedOutputLayout(&mResult, &mInfoLog));
+ ANGLE_TRY(mProgram->getPixelExecutableForCachedOutputLayout(mContext, &mResult, &mInfoLog));
return gl::NoError();
}
@@ -1408,7 +1411,7 @@
{
public:
GetGeometryExecutableTask(ProgramD3D *program, const gl::Context *context)
- : GetExecutableTask(program), mContext(context)
+ : GetExecutableTask(program, context)
{
}
@@ -1424,9 +1427,6 @@
return gl::NoError();
}
-
- private:
- const gl::Context *mContext;
};
gl::Error ProgramD3D::getComputeExecutable(ShaderExecutableD3D **outExecutable)
@@ -1443,12 +1443,12 @@
gl::InfoLog &infoLog)
{
// Ensure the compiler is initialized to avoid race conditions.
- ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized());
+ ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized(context));
WorkerThreadPool *workerPool = mRenderer->getWorkerThreadPool();
GetVertexExecutableTask vertexTask(this, context);
- GetPixelExecutableTask pixelTask(this);
+ GetPixelExecutableTask pixelTask(this, context);
GetGeometryExecutableTask geometryTask(this, context);
std::array<WaitableEvent, 3> waitEvents = {{workerPool->postWorkerTask(&vertexTask),
@@ -1511,16 +1511,16 @@
gl::InfoLog &infoLog)
{
// Ensure the compiler is initialized to avoid race conditions.
- ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized());
+ ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized(context));
gl::Shader *computeShaderGL = mState.getAttachedShader(gl::ShaderType::Compute);
ASSERT(computeShaderGL);
std::string computeShader = computeShaderGL->getTranslatedSource(context);
ShaderExecutableD3D *computeExecutable = nullptr;
- ANGLE_TRY(mRenderer->compileToExecutable(infoLog, computeShader, gl::ShaderType::Compute,
- std::vector<D3DVarying>(), false,
- angle::CompilerWorkaroundsD3D(), &computeExecutable));
+ ANGLE_TRY(mRenderer->compileToExecutable(
+ context, infoLog, computeShader, gl::ShaderType::Compute, std::vector<D3DVarying>(), false,
+ angle::CompilerWorkaroundsD3D(), &computeExecutable));
if (computeExecutable == nullptr)
{
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.h b/src/libANGLE/renderer/d3d/ProgramD3D.h
index 077a155..beda51c 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.h
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.h
@@ -186,13 +186,15 @@
void setBinaryRetrievableHint(bool retrievable) override;
void setSeparable(bool separable) override;
- gl::Error getVertexExecutableForCachedInputLayout(ShaderExecutableD3D **outExectuable,
+ gl::Error getVertexExecutableForCachedInputLayout(const gl::Context *context,
+ ShaderExecutableD3D **outExectuable,
gl::InfoLog *infoLog);
gl::Error getGeometryExecutableForPrimitiveType(const gl::Context *context,
gl::PrimitiveMode drawMode,
ShaderExecutableD3D **outExecutable,
gl::InfoLog *infoLog);
- gl::Error getPixelExecutableForCachedOutputLayout(ShaderExecutableD3D **outExectuable,
+ gl::Error getPixelExecutableForCachedOutputLayout(const gl::Context *context,
+ ShaderExecutableD3D **outExectuable,
gl::InfoLog *infoLog);
gl::Error getComputeExecutable(ShaderExecutableD3D **outExecutable);
gl::LinkResult link(const gl::Context *context,
diff --git a/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp b/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp
index f4fe567..4eaa602 100644
--- a/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp
+++ b/src/libANGLE/renderer/d3d/RenderbufferD3D.cpp
@@ -70,8 +70,9 @@
}
RenderTargetD3D *newRT = nullptr;
- ANGLE_TRY(mRenderer->createRenderTarget(static_cast<int>(width), static_cast<int>(height),
- creationFormat, static_cast<GLsizei>(samples), &newRT));
+ ANGLE_TRY(mRenderer->createRenderTarget(context, static_cast<int>(width),
+ static_cast<int>(height), creationFormat,
+ static_cast<GLsizei>(samples), &newRT));
deleteRenderTarget(context);
mImage = nullptr;
@@ -124,7 +125,7 @@
{
RenderTargetD3D *renderTarget = nullptr;
ANGLE_TRY(getRenderTarget(context, &renderTarget));
- return mRenderer->initRenderTarget(renderTarget);
+ return mRenderer->initRenderTarget(context, renderTarget);
}
} // namespace rx
diff --git a/src/libANGLE/renderer/d3d/RendererD3D.cpp b/src/libANGLE/renderer/d3d/RendererD3D.cpp
index 34636c1..cbb9d87 100644
--- a/src/libANGLE/renderer/d3d/RendererD3D.cpp
+++ b/src/libANGLE/renderer/d3d/RendererD3D.cpp
@@ -187,9 +187,9 @@
mode == gl::PrimitiveMode::Points;
}
-gl::Error RendererD3D::initRenderTarget(RenderTargetD3D *renderTarget)
+gl::Error RendererD3D::initRenderTarget(const gl::Context *context, RenderTargetD3D *renderTarget)
{
- return clearRenderTarget(renderTarget, gl::ColorF(0, 0, 0, 0), 1, 0);
+ return clearRenderTarget(context, renderTarget, gl::ColorF(0, 0, 0, 0), 1, 0);
}
void RendererD3D::onDirtyUniformBlockBinding(GLuint /*uniformBlockIndex*/)
diff --git a/src/libANGLE/renderer/d3d/RendererD3D.h b/src/libANGLE/renderer/d3d/RendererD3D.h
index c756ded..f4ee62d 100644
--- a/src/libANGLE/renderer/d3d/RendererD3D.h
+++ b/src/libANGLE/renderer/d3d/RendererD3D.h
@@ -94,6 +94,7 @@
// Warning: you should ensure binding really matches attrib.bindingIndex before using this
// function.
virtual gl::ErrorOrResult<unsigned int> getVertexSpaceRequired(
+ const gl::Context *context,
const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
@@ -199,28 +200,33 @@
GLint destLevel) = 0;
// RenderTarget creation
- virtual gl::Error createRenderTarget(int width,
+ virtual gl::Error createRenderTarget(const gl::Context *context,
+ int width,
int height,
GLenum format,
GLsizei samples,
- RenderTargetD3D **outRT) = 0;
- virtual gl::Error createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT) = 0;
+ RenderTargetD3D **outRT) = 0;
+ virtual gl::Error createRenderTargetCopy(const gl::Context *context,
+ RenderTargetD3D *source,
+ RenderTargetD3D **outRT) = 0;
// Shader operations
- virtual gl::Error loadExecutable(const uint8_t *function,
+ virtual gl::Error loadExecutable(const gl::Context *context,
+ const uint8_t *function,
size_t length,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
bool separatedOutputBuffers,
- ShaderExecutableD3D **outExecutable) = 0;
- virtual gl::Error compileToExecutable(gl::InfoLog &infoLog,
+ ShaderExecutableD3D **outExecutable) = 0;
+ virtual gl::Error compileToExecutable(const gl::Context *context,
+ gl::InfoLog &infoLog,
const std::string &shaderHLSL,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
bool separatedOutputBuffers,
const angle::CompilerWorkaroundsD3D &workarounds,
- ShaderExecutableD3D **outExectuable) = 0;
- virtual gl::Error ensureHLSLCompilerInitialized() = 0;
+ ShaderExecutableD3D **outExectuable) = 0;
+ virtual gl::Error ensureHLSLCompilerInitialized(const gl::Context *context) = 0;
virtual UniformStorageD3D *createUniformStorage(size_t storageSize) = 0;
@@ -301,7 +307,8 @@
GLint getGPUDisjoint();
GLint64 getTimestamp();
- virtual gl::Error clearRenderTarget(RenderTargetD3D *renderTarget,
+ virtual gl::Error clearRenderTarget(const gl::Context *context,
+ RenderTargetD3D *renderTarget,
const gl::ColorF &clearColorValue,
const float clearDepthValue,
const unsigned int clearStencilValue) = 0;
@@ -325,7 +332,7 @@
virtual gl::Version getMaxSupportedESVersion() const = 0;
- gl::Error initRenderTarget(RenderTargetD3D *renderTarget);
+ gl::Error initRenderTarget(const gl::Context *context, RenderTargetD3D *renderTarget);
angle::WorkerThreadPool *getWorkerThreadPool();
diff --git a/src/libANGLE/renderer/d3d/SurfaceD3D.cpp b/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
index c418e4a..f70141b 100644
--- a/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
+++ b/src/libANGLE/renderer/d3d/SurfaceD3D.cpp
@@ -420,16 +420,16 @@
return gl::NoError();
}
-gl::Error SurfaceD3D::initializeContents(const gl::Context * /*context*/,
+gl::Error SurfaceD3D::initializeContents(const gl::Context *context,
const gl::ImageIndex & /*imageIndex*/)
{
if (mState.config->renderTargetFormat != GL_NONE)
{
- ANGLE_TRY(mRenderer->initRenderTarget(mSwapChain->getColorRenderTarget()));
+ ANGLE_TRY(mRenderer->initRenderTarget(context, mSwapChain->getColorRenderTarget()));
}
if (mState.config->depthStencilFormat != GL_NONE)
{
- ANGLE_TRY(mRenderer->initRenderTarget(mSwapChain->getDepthStencilRenderTarget()));
+ ANGLE_TRY(mRenderer->initRenderTarget(context, mSwapChain->getDepthStencilRenderTarget()));
}
return gl::NoError();
}
diff --git a/src/libANGLE/renderer/d3d/TextureD3D.cpp b/src/libANGLE/renderer/d3d/TextureD3D.cpp
index d016e4e..cb9b32a 100644
--- a/src/libANGLE/renderer/d3d/TextureD3D.cpp
+++ b/src/libANGLE/renderer/d3d/TextureD3D.cpp
@@ -707,7 +707,7 @@
ASSERT(mTexStorage);
RenderTargetD3D *renderTarget = nullptr;
ANGLE_TRY(mTexStorage->getRenderTarget(context, imageIndex, &renderTarget));
- ANGLE_TRY(mRenderer->initRenderTarget(renderTarget));
+ ANGLE_TRY(mRenderer->initRenderTarget(context, renderTarget));
return gl::NoError();
}
diff --git a/src/libANGLE/renderer/d3d/VertexBuffer.cpp b/src/libANGLE/renderer/d3d/VertexBuffer.cpp
index d8d3348..3659820 100644
--- a/src/libANGLE/renderer/d3d/VertexBuffer.cpp
+++ b/src/libANGLE/renderer/d3d/VertexBuffer.cpp
@@ -80,24 +80,25 @@
return mVertexBuffer->getBufferSize();
}
-gl::Error VertexBufferInterface::setBufferSize(unsigned int size)
+gl::Error VertexBufferInterface::setBufferSize(const gl::Context *context, unsigned int size)
{
if (mVertexBuffer->getBufferSize() == 0)
{
- return mVertexBuffer->initialize(size, mDynamic);
+ return mVertexBuffer->initialize(context, size, mDynamic);
}
- return mVertexBuffer->setBufferSize(size);
+ return mVertexBuffer->setBufferSize(context, size);
}
gl::ErrorOrResult<unsigned int> VertexBufferInterface::getSpaceRequired(
+ const gl::Context *context,
const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances) const
{
unsigned int spaceRequired = 0;
- ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(attrib, binding, count, instances),
+ ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(context, attrib, binding, count, instances),
spaceRequired);
// Align to 16-byte boundary
@@ -112,9 +113,9 @@
return alignedSpaceRequired;
}
-gl::Error VertexBufferInterface::discard()
+gl::Error VertexBufferInterface::discard(const gl::Context *context)
{
- return mVertexBuffer->discard();
+ return mVertexBuffer->discard(context);
}
VertexBuffer *VertexBufferInterface::getVertexBuffer() const
@@ -128,9 +129,10 @@
{
}
-gl::Error StreamingVertexBufferInterface::initialize(std::size_t initialSize)
+gl::Error StreamingVertexBufferInterface::initialize(const gl::Context *context,
+ std::size_t initialSize)
{
- return setBufferSize(static_cast<unsigned int>(initialSize));
+ return setBufferSize(context, static_cast<unsigned int>(initialSize));
}
void StreamingVertexBufferInterface::reset()
@@ -146,24 +148,26 @@
{
}
-gl::Error StreamingVertexBufferInterface::reserveSpace(unsigned int size)
+gl::Error StreamingVertexBufferInterface::reserveSpace(const gl::Context *context,
+ unsigned int size)
{
unsigned int curBufferSize = getBufferSize();
if (size > curBufferSize)
{
- ANGLE_TRY(setBufferSize(std::max(size, 3 * curBufferSize / 2)));
+ ANGLE_TRY(setBufferSize(context, std::max(size, 3 * curBufferSize / 2)));
mWritePosition = 0;
}
else if (mWritePosition + size > curBufferSize)
{
- ANGLE_TRY(discard());
+ ANGLE_TRY(discard(context));
mWritePosition = 0;
}
return gl::NoError();
}
-gl::Error StreamingVertexBufferInterface::storeDynamicAttribute(const gl::VertexAttribute &attrib,
+gl::Error StreamingVertexBufferInterface::storeDynamicAttribute(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -173,7 +177,7 @@
const uint8_t *sourceData)
{
unsigned int spaceRequired = 0;
- ANGLE_TRY_RESULT(getSpaceRequired(attrib, binding, count, instances), spaceRequired);
+ ANGLE_TRY_RESULT(getSpaceRequired(context, attrib, binding, count, instances), spaceRequired);
// Protect against integer overflow
angle::CheckedNumeric<unsigned int> checkedPosition(mWritePosition);
@@ -184,11 +188,12 @@
<< "Internal error, new vertex buffer write position would overflow.";
}
- ANGLE_TRY(reserveSpace(mReservedSpace));
+ ANGLE_TRY(reserveSpace(context, mReservedSpace));
mReservedSpace = 0;
- ANGLE_TRY(mVertexBuffer->storeVertexAttributes(attrib, binding, currentValueType, start, count,
- instances, mWritePosition, sourceData));
+ ANGLE_TRY(mVertexBuffer->storeVertexAttributes(context, attrib, binding, currentValueType,
+ start, count, instances, mWritePosition,
+ sourceData));
if (outStreamOffset)
{
@@ -200,13 +205,14 @@
return gl::NoError();
}
-gl::Error StreamingVertexBufferInterface::reserveVertexSpace(const gl::VertexAttribute &attrib,
+gl::Error StreamingVertexBufferInterface::reserveVertexSpace(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances)
{
unsigned int requiredSpace = 0;
- ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(attrib, binding, count, instances),
+ ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(context, attrib, binding, count, instances),
requiredSpace);
// Align to 16-byte boundary
@@ -282,7 +288,8 @@
return mSignature.set(attrib, binding);
}
-gl::Error StaticVertexBufferInterface::storeStaticAttribute(const gl::VertexAttribute &attrib,
+gl::Error StaticVertexBufferInterface::storeStaticAttribute(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLint start,
GLsizei count,
@@ -290,11 +297,11 @@
const uint8_t *sourceData)
{
unsigned int spaceRequired = 0;
- ANGLE_TRY_RESULT(getSpaceRequired(attrib, binding, count, instances), spaceRequired);
- ANGLE_TRY(setBufferSize(spaceRequired));
+ ANGLE_TRY_RESULT(getSpaceRequired(context, attrib, binding, count, instances), spaceRequired);
+ ANGLE_TRY(setBufferSize(context, spaceRequired));
ASSERT(attrib.enabled);
- ANGLE_TRY(mVertexBuffer->storeVertexAttributes(attrib, binding, GL_NONE, start, count,
+ ANGLE_TRY(mVertexBuffer->storeVertexAttributes(context, attrib, binding, GL_NONE, start, count,
instances, 0, sourceData));
mSignature.set(attrib, binding);
diff --git a/src/libANGLE/renderer/d3d/VertexBuffer.h b/src/libANGLE/renderer/d3d/VertexBuffer.h
index 634b57a..270723c 100644
--- a/src/libANGLE/renderer/d3d/VertexBuffer.h
+++ b/src/libANGLE/renderer/d3d/VertexBuffer.h
@@ -21,10 +21,11 @@
namespace gl
{
+class Context;
struct VertexAttribute;
class VertexBinding;
struct VertexAttribCurrentValueData;
-}
+} // namespace gl
namespace rx
{
@@ -37,11 +38,14 @@
public:
VertexBuffer();
- virtual gl::Error initialize(unsigned int size, bool dynamicUsage) = 0;
+ virtual gl::Error initialize(const gl::Context *context,
+ unsigned int size,
+ bool dynamicUsage) = 0;
// Warning: you should ensure binding really matches attrib.bindingIndex before using this
// function.
- virtual gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
+ virtual gl::Error storeVertexAttributes(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -51,8 +55,8 @@
const uint8_t *sourceData) = 0;
virtual unsigned int getBufferSize() const = 0;
- virtual gl::Error setBufferSize(unsigned int size) = 0;
- virtual gl::Error discard() = 0;
+ virtual gl::Error setBufferSize(const gl::Context *context, unsigned int size) = 0;
+ virtual gl::Error discard(const gl::Context *context) = 0;
unsigned int getSerial() const;
@@ -87,11 +91,12 @@
VertexBuffer *getVertexBuffer() const;
protected:
- gl::Error discard();
+ gl::Error discard(const gl::Context *context);
- gl::Error setBufferSize(unsigned int size);
+ gl::Error setBufferSize(const gl::Context *context, unsigned int size);
- gl::ErrorOrResult<unsigned int> getSpaceRequired(const gl::VertexAttribute &attrib,
+ gl::ErrorOrResult<unsigned int> getSpaceRequired(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances) const;
@@ -106,10 +111,11 @@
StreamingVertexBufferInterface(BufferFactoryD3D *factory);
~StreamingVertexBufferInterface() override;
- gl::Error initialize(std::size_t initialSize);
+ gl::Error initialize(const gl::Context *context, std::size_t initialSize);
void reset();
- gl::Error storeDynamicAttribute(const gl::VertexAttribute &attrib,
+ gl::Error storeDynamicAttribute(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -118,13 +124,14 @@
unsigned int *outStreamOffset,
const uint8_t *sourceData);
- gl::Error reserveVertexSpace(const gl::VertexAttribute &attribute,
+ gl::Error reserveVertexSpace(const gl::Context *context,
+ const gl::VertexAttribute &attribute,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances);
private:
- gl::Error reserveSpace(unsigned int size);
+ gl::Error reserveSpace(const gl::Context *context, unsigned int size);
unsigned int mWritePosition;
unsigned int mReservedSpace;
@@ -138,7 +145,8 @@
// Warning: you should ensure binding really matches attrib.bindingIndex before using these
// functions.
- gl::Error storeStaticAttribute(const gl::VertexAttribute &attrib,
+ gl::Error storeStaticAttribute(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLint start,
GLsizei count,
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index e9f8df6..e8b2482 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -56,7 +56,9 @@
}
// Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
-bool DirectStoragePossible(const gl::VertexAttribute &attrib, const gl::VertexBinding &binding)
+bool DirectStoragePossible(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
+ const gl::VertexBinding &binding)
{
// Current value attribs may not use direct storage.
if (!attrib.enabled)
@@ -94,7 +96,7 @@
if (attrib.type != GL_FLOAT)
{
- auto errorOrElementSize = factory->getVertexSpaceRequired(attrib, binding, 1, 0);
+ auto errorOrElementSize = factory->getVertexSpaceRequired(context, attrib, binding, 1, 0);
if (errorOrElementSize.isError())
{
ERR() << "Unlogged error in DirectStoragePossible.";
@@ -146,7 +148,8 @@
}
// Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
-VertexStorageType ClassifyAttributeStorage(const gl::VertexAttribute &attrib,
+VertexStorageType ClassifyAttributeStorage(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding)
{
// If attribute is disabled, we use the current value.
@@ -163,7 +166,7 @@
}
// Check if the buffer supports direct storage.
- if (DirectStoragePossible(attrib, binding))
+ if (DirectStoragePossible(context, attrib, binding))
{
return VertexStorageType::DIRECT;
}
@@ -183,7 +186,8 @@
}
}
-VertexDataManager::CurrentValueState::CurrentValueState() : buffer(), offset(0)
+VertexDataManager::CurrentValueState::CurrentValueState(BufferFactoryD3D *factory)
+ : buffer(new StreamingVertexBufferInterface(factory)), offset(0)
{
data.FloatValues[0] = std::numeric_limits<float>::quiet_NaN();
data.FloatValues[1] = std::numeric_limits<float>::quiet_NaN();
@@ -192,22 +196,33 @@
data.Type = GL_FLOAT;
}
+VertexDataManager::CurrentValueState::CurrentValueState(CurrentValueState &&other)
+{
+ std::swap(buffer, other.buffer);
+ std::swap(data, other.data);
+ std::swap(offset, other.offset);
+}
+
VertexDataManager::CurrentValueState::~CurrentValueState()
{
}
VertexDataManager::VertexDataManager(BufferFactoryD3D *factory)
- : mFactory(factory), mStreamingBuffer(factory), mCurrentValueCache(gl::MAX_VERTEX_ATTRIBS)
+ : mFactory(factory), mStreamingBuffer(factory)
{
+ for (int currentValueIndex = 0; currentValueIndex < gl::MAX_VERTEX_ATTRIBS; ++currentValueIndex)
+ {
+ mCurrentValueCache.emplace_back(factory);
+ }
}
VertexDataManager::~VertexDataManager()
{
}
-gl::Error VertexDataManager::initialize()
+gl::Error VertexDataManager::initialize(const gl::Context *context)
{
- return mStreamingBuffer.initialize(INITIAL_STREAM_BUFFER_SIZE);
+ return mStreamingBuffer.initialize(context, INITIAL_STREAM_BUFFER_SIZE);
}
void VertexDataManager::deinitialize()
@@ -254,7 +269,7 @@
translated->currentValueType = currentValueData.Type;
translated->divisor = binding.getDivisor();
- switch (ClassifyAttributeStorage(attrib, binding))
+ switch (ClassifyAttributeStorage(context, attrib, binding))
{
case VertexStorageType::STATIC:
{
@@ -268,11 +283,11 @@
break;
case VertexStorageType::DIRECT:
// Update translated data for direct attributes.
- StoreDirectAttrib(translated);
+ StoreDirectAttrib(context, translated);
break;
case VertexStorageType::CURRENT_VALUE:
{
- ANGLE_TRY(storeCurrentValue(currentValueData, translated, attribIndex));
+ ANGLE_TRY(storeCurrentValue(context, currentValueData, translated, attribIndex));
break;
}
default:
@@ -295,7 +310,8 @@
}
// static
-void VertexDataManager::StoreDirectAttrib(TranslatedAttribute *directAttrib)
+void VertexDataManager::StoreDirectAttrib(const gl::Context *context,
+ TranslatedAttribute *directAttrib)
{
ASSERT(directAttrib->attribute && directAttrib->binding);
const auto &attrib = *directAttrib->attribute;
@@ -305,7 +321,7 @@
ASSERT(buffer);
BufferD3D *bufferD3D = GetImplAs<BufferD3D>(buffer);
- ASSERT(DirectStoragePossible(attrib, binding));
+ ASSERT(DirectStoragePossible(context, attrib, binding));
directAttrib->vertexBuffer.set(nullptr);
directAttrib->storage = bufferD3D;
directAttrib->serial = bufferD3D->getSerial();
@@ -326,7 +342,7 @@
const auto &binding = *translated->binding;
gl::Buffer *buffer = binding.getBuffer().get();
- ASSERT(buffer && attrib.enabled && !DirectStoragePossible(attrib, binding));
+ ASSERT(buffer && attrib.enabled && !DirectStoragePossible(context, attrib, binding));
BufferD3D *bufferD3D = GetImplAs<BufferD3D>(buffer);
// Compute source data pointer
@@ -339,8 +355,9 @@
unsigned int streamOffset = 0;
translated->storage = nullptr;
- ANGLE_TRY_RESULT(bufferD3D->getFactory()->getVertexSpaceRequired(attrib, binding, 1, 0),
- translated->stride);
+ ANGLE_TRY_RESULT(
+ bufferD3D->getFactory()->getVertexSpaceRequired(context, attrib, binding, 1, 0),
+ translated->stride);
auto *staticBuffer = bufferD3D->getStaticVertexBuffer(attrib, binding);
ASSERT(staticBuffer);
@@ -352,8 +369,8 @@
ElementsInBuffer(attrib, binding, static_cast<unsigned int>(bufferD3D->getSize()));
int startIndex = offset / static_cast<int>(ComputeVertexAttributeStride(attrib, binding));
- ANGLE_TRY(staticBuffer->storeStaticAttribute(attrib, binding, -startIndex, totalCount, 0,
- sourceData));
+ ANGLE_TRY(staticBuffer->storeStaticAttribute(context, attrib, binding, -startIndex,
+ totalCount, 0, sourceData));
}
unsigned int firstElementOffset =
@@ -411,7 +428,7 @@
for (auto attribIndex : dynamicAttribsMask)
{
const auto &dynamicAttrib = (*translatedAttribs)[attribIndex];
- ANGLE_TRY(reserveSpaceForAttrib(dynamicAttrib, start, count, instances));
+ ANGLE_TRY(reserveSpaceForAttrib(context, dynamicAttrib, start, count, instances));
}
// Store dynamic attributes
@@ -447,7 +464,8 @@
}
}
-gl::Error VertexDataManager::reserveSpaceForAttrib(const TranslatedAttribute &translatedAttrib,
+gl::Error VertexDataManager::reserveSpaceForAttrib(const gl::Context *context,
+ const TranslatedAttribute &translatedAttrib,
GLint start,
size_t count,
GLsizei instances)
@@ -456,7 +474,7 @@
const auto &attrib = *translatedAttrib.attribute;
const auto &binding = *translatedAttrib.binding;
- ASSERT(!DirectStoragePossible(attrib, binding));
+ ASSERT(!DirectStoragePossible(context, attrib, binding));
gl::Buffer *buffer = binding.getBuffer().get();
BufferD3D *bufferD3D = buffer ? GetImplAs<BufferD3D>(buffer) : nullptr;
@@ -481,7 +499,7 @@
return gl::InvalidOperation() << "Vertex buffer is not big enough for the draw call.";
}
}
- return mStreamingBuffer.reserveVertexSpace(attrib, binding, totalCount, instances);
+ return mStreamingBuffer.reserveVertexSpace(context, attrib, binding, totalCount, instances);
}
gl::Error VertexDataManager::storeDynamicAttrib(const gl::Context *context,
@@ -521,13 +539,14 @@
unsigned int streamOffset = 0;
translated->storage = nullptr;
- ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(attrib, binding, 1, 0), translated->stride);
+ ANGLE_TRY_RESULT(mFactory->getVertexSpaceRequired(context, attrib, binding, 1, 0),
+ translated->stride);
size_t totalCount = gl::ComputeVertexBindingElementCount(binding.getDivisor(), count,
static_cast<size_t>(instances));
ANGLE_TRY(mStreamingBuffer.storeDynamicAttribute(
- attrib, binding, translated->currentValueType, firstVertexIndex,
+ context, attrib, binding, translated->currentValueType, firstVertexIndex,
static_cast<GLsizei>(totalCount), instances, &streamOffset, sourceData));
VertexBuffer *vertexBuffer = mStreamingBuffer.getVertexBuffer();
@@ -540,17 +559,17 @@
return gl::NoError();
}
-gl::Error VertexDataManager::storeCurrentValue(const gl::VertexAttribCurrentValueData ¤tValue,
+gl::Error VertexDataManager::storeCurrentValue(const gl::Context *context,
+ const gl::VertexAttribCurrentValueData ¤tValue,
TranslatedAttribute *translated,
size_t attribIndex)
{
CurrentValueState *cachedState = &mCurrentValueCache[attribIndex];
- auto &buffer = cachedState->buffer;
+ StreamingVertexBufferInterface &buffer = *cachedState->buffer;
- if (!buffer)
+ if (buffer.getBufferSize() == 0)
{
- buffer.reset(new StreamingVertexBufferInterface(mFactory));
- ANGLE_TRY(buffer->initialize(CONSTANT_VERTEX_BUFFER_SIZE));
+ ANGLE_TRY(buffer.initialize(context, CONSTANT_VERTEX_BUFFER_SIZE));
}
if (cachedState->data != currentValue)
@@ -559,23 +578,23 @@
const auto &attrib = *translated->attribute;
const auto &binding = *translated->binding;
- ANGLE_TRY(buffer->reserveVertexSpace(attrib, binding, 1, 0));
+ ANGLE_TRY(buffer.reserveVertexSpace(context, attrib, binding, 1, 0));
const uint8_t *sourceData = reinterpret_cast<const uint8_t*>(currentValue.FloatValues);
unsigned int streamOffset;
- ANGLE_TRY(buffer->storeDynamicAttribute(attrib, binding, currentValue.Type, 0, 1, 0,
- &streamOffset, sourceData));
+ ANGLE_TRY(buffer.storeDynamicAttribute(context, attrib, binding, currentValue.Type, 0, 1, 0,
+ &streamOffset, sourceData));
- buffer->getVertexBuffer()->hintUnmapResource();
+ buffer.getVertexBuffer()->hintUnmapResource();
cachedState->data = currentValue;
cachedState->offset = streamOffset;
}
- translated->vertexBuffer.set(buffer->getVertexBuffer());
+ translated->vertexBuffer.set(buffer.getVertexBuffer());
translated->storage = nullptr;
- translated->serial = buffer->getSerial();
+ translated->serial = buffer.getSerial();
translated->divisor = 0;
translated->stride = 0;
translated->baseOffset = static_cast<unsigned int>(cachedState->offset);
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.h b/src/libANGLE/renderer/d3d/VertexDataManager.h
index 18d38fd..6227c2a 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.h
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.h
@@ -11,9 +11,9 @@
#define LIBANGLE_RENDERER_D3D_VERTEXDATAMANAGER_H_
#include "common/angleutils.h"
-#include "libANGLE/angletypes.h"
#include "libANGLE/Constants.h"
#include "libANGLE/VertexAttribute.h"
+#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/d3d/VertexBuffer.h"
namespace gl
@@ -80,7 +80,8 @@
};
// Given a vertex attribute, return the type of storage it will use.
-VertexStorageType ClassifyAttributeStorage(const gl::VertexAttribute &attrib,
+VertexStorageType ClassifyAttributeStorage(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding);
class VertexDataManager : angle::NonCopyable
@@ -89,7 +90,7 @@
VertexDataManager(BufferFactoryD3D *factory);
virtual ~VertexDataManager();
- gl::Error initialize();
+ gl::Error initialize(const gl::Context *context);
void deinitialize();
gl::Error prepareVertexData(const gl::Context *context,
@@ -98,7 +99,7 @@
std::vector<TranslatedAttribute> *translatedAttribs,
GLsizei instances);
- static void StoreDirectAttrib(TranslatedAttribute *directAttrib);
+ static void StoreDirectAttrib(const gl::Context *context, TranslatedAttribute *directAttrib);
static gl::Error StoreStaticAttrib(const gl::Context *context, TranslatedAttribute *translated);
@@ -115,14 +116,16 @@
const gl::AttributesMask &dynamicAttribsMask,
size_t count);
- gl::Error storeCurrentValue(const gl::VertexAttribCurrentValueData ¤tValue,
+ gl::Error storeCurrentValue(const gl::Context *context,
+ const gl::VertexAttribCurrentValueData ¤tValue,
TranslatedAttribute *translated,
size_t attribIndex);
private:
- struct CurrentValueState
+ struct CurrentValueState final : angle::NonCopyable
{
- CurrentValueState();
+ CurrentValueState(BufferFactoryD3D *factory);
+ CurrentValueState(CurrentValueState &&other);
~CurrentValueState();
std::unique_ptr<StreamingVertexBufferInterface> buffer;
@@ -130,7 +133,8 @@
size_t offset;
};
- gl::Error reserveSpaceForAttrib(const TranslatedAttribute &translatedAttrib,
+ gl::Error reserveSpaceForAttrib(const gl::Context *context,
+ const TranslatedAttribute &translatedAttrib,
GLint start,
size_t count,
GLsizei instances);
diff --git a/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp b/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp
index 781e1f7..ee86360 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Blit11.cpp
@@ -1116,7 +1116,7 @@
// Set vertices
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(mRenderer->mapResource(mVertexBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
+ ANGLE_TRY(mRenderer->mapResource(context, mVertexBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
&mappedResource));
ShaderSupport support;
@@ -1133,8 +1133,8 @@
deviceContext->Unmap(mVertexBuffer.get(), 0);
// Set constant buffer
- ANGLE_TRY(
- mRenderer->mapResource(mSwizzleCB.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource));
+ ANGLE_TRY(mRenderer->mapResource(context, mSwizzleCB.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
+ &mappedResource));
unsigned int *swizzleIndices = static_cast<unsigned int *>(mappedResource.pData);
swizzleIndices[0] = GetSwizzleIndex(swizzleTarget.swizzleRed);
@@ -1222,7 +1222,7 @@
// Set vertices
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(mRenderer->mapResource(mVertexBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
+ ANGLE_TRY(mRenderer->mapResource(context, mVertexBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
&mappedResource));
UINT stride = 0;
@@ -1325,7 +1325,7 @@
// Set vertices
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(mRenderer->mapResource(mVertexBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
+ ANGLE_TRY(mRenderer->mapResource(context, mVertexBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
&mappedResource));
UINT stride = 0;
@@ -1485,11 +1485,12 @@
sourceSubresource, nullptr);
D3D11_MAPPED_SUBRESOURCE sourceMapping;
- ANGLE_TRY(mRenderer->mapResource(sourceStaging.get(), 0, D3D11_MAP_READ, 0, &sourceMapping));
+ ANGLE_TRY(
+ mRenderer->mapResource(context, sourceStaging.get(), 0, D3D11_MAP_READ, 0, &sourceMapping));
D3D11_MAPPED_SUBRESOURCE destMapping;
gl::Error error =
- mRenderer->mapResource(destStaging.get(), 0, D3D11_MAP_WRITE, 0, &destMapping);
+ mRenderer->mapResource(context, destStaging.get(), 0, D3D11_MAP_WRITE, 0, &destMapping);
if (error.isError())
{
deviceContext->Unmap(sourceStaging.get(), 0);
@@ -1558,7 +1559,8 @@
if (mRenderer->getWorkarounds().depthStencilBlitExtraCopy)
{
D3D11_MAPPED_SUBRESOURCE mapped;
- ANGLE_TRY(mRenderer->mapResource(destStaging.get(), 0, D3D11_MAP_READ, 0, &mapped));
+ ANGLE_TRY(
+ mRenderer->mapResource(context, destStaging.get(), 0, D3D11_MAP_READ, 0, &mapped));
deviceContext->UpdateSubresource(dest.get(), destSubresource, nullptr, mapped.pData,
mapped.RowPitch, mapped.DepthPitch);
deviceContext->Unmap(destStaging.get(), 0);
diff --git a/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp
index eab7472..ed913d6 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp
@@ -123,13 +123,14 @@
CopyResult *resultOut) = 0;
virtual gl::Error resize(const gl::Context *context, size_t size, bool preserveData) = 0;
- virtual gl::Error map(size_t offset,
+ virtual gl::Error map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut) = 0;
virtual void unmap() = 0;
- gl::Error setData(const uint8_t *data, size_t offset, size_t size);
+ gl::Error setData(const gl::Context *context, const uint8_t *data, size_t offset, size_t size);
protected:
BufferStorage(Renderer11 *renderer, BufferUsage usage);
@@ -161,13 +162,16 @@
CopyResult *resultOut) override;
gl::Error resize(const gl::Context *context, size_t size, bool preserveData) override;
- gl::Error map(size_t offset,
+ gl::Error map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut) override;
void unmap() override;
- gl::Error getSRVForFormat(DXGI_FORMAT srvFormat, const d3d11::ShaderResourceView **srvOut);
+ gl::Error getSRVForFormat(const gl::Context *context,
+ DXGI_FORMAT srvFormat,
+ const d3d11::ShaderResourceView **srvOut);
private:
static void FillBufferDesc(D3D11_BUFFER_DESC *bufferDesc,
@@ -194,7 +198,8 @@
bool isGPUAccessible() const override { return false; }
- gl::Error getBuffer(SourceIndexData *indexInfo,
+ gl::Error getBuffer(const gl::Context *context,
+ SourceIndexData *indexInfo,
const TranslatedAttribute &attribute,
GLint startVertex,
const d3d11::Buffer **bufferOut);
@@ -208,7 +213,8 @@
gl::Error resize(const gl::Context *context, size_t size, bool preserveData) override;
- gl::Error map(size_t offset,
+ gl::Error map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut) override;
@@ -240,7 +246,8 @@
CopyResult *resultOut) override;
gl::Error resize(const gl::Context *context, size_t size, bool preserveData) override;
- gl::Error map(size_t offset,
+ gl::Error map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut) override;
@@ -251,7 +258,7 @@
const PackPixelsParams ¶ms);
private:
- gl::Error flushQueuedPackCommand();
+ gl::Error flushQueuedPackCommand(const gl::Context *context);
TextureHelper11 mStagingTexture;
angle::MemoryBuffer mMemoryBuffer;
@@ -281,7 +288,8 @@
CopyResult *resultOut) override;
gl::Error resize(const gl::Context *context, size_t size, bool preserveData) override;
- gl::Error map(size_t offset,
+ gl::Error map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut) override;
@@ -394,7 +402,7 @@
ANGLE_TRY(writeBuffer->resize(context, requiredSize, preserveData));
}
- ANGLE_TRY(writeBuffer->setData(static_cast<const uint8_t *>(data), offset, size));
+ ANGLE_TRY(writeBuffer->setData(context, static_cast<const uint8_t *>(data), offset, size));
onStorageUpdate(writeBuffer);
}
@@ -510,7 +518,7 @@
}
uint8_t *mappedBuffer = nullptr;
- ANGLE_TRY(mMappedStorage->map(offset, length, access, &mappedBuffer));
+ ANGLE_TRY(mMappedStorage->map(context, offset, length, access, &mappedBuffer));
ASSERT(mappedBuffer);
*mapPtr = static_cast<void *>(mappedBuffer);
@@ -639,7 +647,8 @@
ANGLE_TRY(getBufferStorage(context, BUFFER_USAGE_EMULATED_INDEXED_VERTEX, &emulatedStorage));
const d3d11::Buffer *nativeBuffer = nullptr;
- ANGLE_TRY(emulatedStorage->getBuffer(indexInfo, attribute, startVertex, &nativeBuffer));
+ ANGLE_TRY(
+ emulatedStorage->getBuffer(context, indexInfo, attribute, startVertex, &nativeBuffer));
*bufferOut = nativeBuffer->get();
return gl::NoError();
}
@@ -675,7 +684,7 @@
{
NativeStorage *nativeStorage = nullptr;
ANGLE_TRY(getBufferStorage(context, BUFFER_USAGE_PIXEL_UNPACK, &nativeStorage));
- return nativeStorage->getSRVForFormat(srvFormat, srvOut);
+ return nativeStorage->getSRVForFormat(context, srvFormat, srvOut);
}
gl::Error Buffer11::packPixels(const gl::Context *context,
@@ -936,7 +945,10 @@
{
}
-gl::Error Buffer11::BufferStorage::setData(const uint8_t *data, size_t offset, size_t size)
+gl::Error Buffer11::BufferStorage::setData(const gl::Context *context,
+ const uint8_t *data,
+ size_t offset,
+ size_t size)
{
ASSERT(isCPUAccessible(GL_MAP_WRITE_BIT));
@@ -945,7 +957,7 @@
size_t mapSize = std::min(size, mBufferSize - offset);
uint8_t *writePointer = nullptr;
- ANGLE_TRY(map(offset, mapSize, GL_MAP_WRITE_BIT, &writePointer));
+ ANGLE_TRY(map(context, offset, mapSize, GL_MAP_WRITE_BIT, &writePointer));
memcpy(writePointer, data, mapSize);
@@ -1016,9 +1028,9 @@
ASSERT(!(preserveData && mUsage == BUFFER_USAGE_UNIFORM));
uint8_t *sourcePointer = nullptr;
- ANGLE_TRY(source->map(sourceOffset, clampedSize, GL_MAP_READ_BIT, &sourcePointer));
+ ANGLE_TRY(source->map(context, sourceOffset, clampedSize, GL_MAP_READ_BIT, &sourcePointer));
- auto err = setData(sourcePointer, destOffset, clampedSize);
+ auto err = setData(context, sourcePointer, destOffset, clampedSize);
source->unmap();
ANGLE_TRY(err);
}
@@ -1159,7 +1171,8 @@
}
}
-gl::Error Buffer11::NativeStorage::map(size_t offset,
+gl::Error Buffer11::NativeStorage::map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut)
@@ -1170,7 +1183,8 @@
D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(mUsage, access);
UINT d3dMapFlag = ((access & GL_MAP_UNSYNCHRONIZED_BIT) != 0 ? D3D11_MAP_FLAG_DO_NOT_WAIT : 0);
- ANGLE_TRY(mRenderer->mapResource(mBuffer.get(), 0, d3dMapType, d3dMapFlag, &mappedResource));
+ ANGLE_TRY(
+ mRenderer->mapResource(context, mBuffer.get(), 0, d3dMapType, d3dMapFlag, &mappedResource));
ASSERT(mappedResource.pData);
*mapPointerOut = static_cast<uint8_t *>(mappedResource.pData) + offset;
return gl::NoError();
@@ -1183,7 +1197,8 @@
context->Unmap(mBuffer.get(), 0);
}
-gl::Error Buffer11::NativeStorage::getSRVForFormat(DXGI_FORMAT srvFormat,
+gl::Error Buffer11::NativeStorage::getSRVForFormat(const gl::Context *context,
+ DXGI_FORMAT srvFormat,
const d3d11::ShaderResourceView **srvOut)
{
auto bufferSRVIt = mBufferResourceViews.find(srvFormat);
@@ -1225,7 +1240,8 @@
{
}
-gl::Error Buffer11::EmulatedIndexedStorage::getBuffer(SourceIndexData *indexInfo,
+gl::Error Buffer11::EmulatedIndexedStorage::getBuffer(const gl::Context *context,
+ SourceIndexData *indexInfo,
const TranslatedAttribute &attribute,
GLint startVertex,
const d3d11::Buffer **bufferOut)
@@ -1344,7 +1360,7 @@
{
ASSERT(source->isCPUAccessible(GL_MAP_READ_BIT));
uint8_t *sourceData = nullptr;
- ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
+ ANGLE_TRY(source->map(context, sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
ASSERT(destOffset + size <= mMemoryBuffer.size());
memcpy(mMemoryBuffer.data() + destOffset, sourceData, size);
source->unmap();
@@ -1368,7 +1384,8 @@
return gl::NoError();
}
-gl::Error Buffer11::EmulatedIndexedStorage::map(size_t offset,
+gl::Error Buffer11::EmulatedIndexedStorage::map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut)
@@ -1401,12 +1418,12 @@
size_t destOffset,
CopyResult *resultOut)
{
- ANGLE_TRY(flushQueuedPackCommand());
+ ANGLE_TRY(flushQueuedPackCommand(context));
// For all use cases of pack buffers, we must copy through a readable buffer.
ASSERT(source->isCPUAccessible(GL_MAP_READ_BIT));
uint8_t *sourceData = nullptr;
- ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
+ ANGLE_TRY(source->map(context, sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
ASSERT(destOffset + size <= mMemoryBuffer.size());
memcpy(mMemoryBuffer.data() + destOffset, sourceData, size);
source->unmap();
@@ -1428,7 +1445,8 @@
return gl::NoError();
}
-gl::Error Buffer11::PackStorage::map(size_t offset,
+gl::Error Buffer11::PackStorage::map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut)
@@ -1439,7 +1457,7 @@
// and if D3D packs the staging texture memory identically to how we would fill
// the pack buffer according to the current pack state.
- ANGLE_TRY(flushQueuedPackCommand());
+ ANGLE_TRY(flushQueuedPackCommand(context));
mDataModified = (mDataModified || (access & GL_MAP_WRITE_BIT) != 0);
@@ -1456,7 +1474,7 @@
const gl::FramebufferAttachment &readAttachment,
const PackPixelsParams ¶ms)
{
- ANGLE_TRY(flushQueuedPackCommand());
+ ANGLE_TRY(flushQueuedPackCommand(context));
RenderTarget11 *renderTarget = nullptr;
ANGLE_TRY(readAttachment.getRenderTarget(context, &renderTarget));
@@ -1501,14 +1519,14 @@
return gl::NoError();
}
-gl::Error Buffer11::PackStorage::flushQueuedPackCommand()
+gl::Error Buffer11::PackStorage::flushQueuedPackCommand(const gl::Context *context)
{
ASSERT(mMemoryBuffer.size() > 0);
if (mQueuedPackCommand)
{
- ANGLE_TRY(
- mRenderer->packPixels(mStagingTexture, *mQueuedPackCommand, mMemoryBuffer.data()));
+ ANGLE_TRY(mRenderer->packPixels(context, mStagingTexture, *mQueuedPackCommand,
+ mMemoryBuffer.data()));
mQueuedPackCommand.reset(nullptr);
}
@@ -1531,7 +1549,7 @@
{
ASSERT(source->isCPUAccessible(GL_MAP_READ_BIT));
uint8_t *sourceData = nullptr;
- ANGLE_TRY(source->map(sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
+ ANGLE_TRY(source->map(context, sourceOffset, size, GL_MAP_READ_BIT, &sourceData));
ASSERT(destOffset + size <= mSystemCopy.size());
memcpy(mSystemCopy.data() + destOffset, sourceData, size);
source->unmap();
@@ -1555,7 +1573,8 @@
return gl::NoError();
}
-gl::Error Buffer11::SystemMemoryStorage::map(size_t offset,
+gl::Error Buffer11::SystemMemoryStorage::map(const gl::Context *context,
+ size_t offset,
size_t length,
GLbitfield access,
uint8_t **mapPointerOut)
diff --git a/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp b/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
index af1d590..59a33c7 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Clear11.cpp
@@ -740,8 +740,8 @@
// Update the constant buffer with the updated cache contents
// TODO(Shahmeer): Consider using UpdateSubresource1 D3D11_COPY_DISCARD where possible.
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(mRenderer->mapResource(mConstantBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
- &mappedResource));
+ ANGLE_TRY(mRenderer->mapResource(context, mConstantBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD,
+ 0, &mappedResource));
memcpy(mappedResource.pData, &mShaderData, g_ConstantBufferSize);
deviceContext->Unmap(mConstantBuffer.get(), 0);
diff --git a/src/libANGLE/renderer/d3d/d3d11/Context11.cpp b/src/libANGLE/renderer/d3d/d3d11/Context11.cpp
index 3841734..5bd3ffd 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Context11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Context11.cpp
@@ -507,14 +507,15 @@
}
// Load the compiler if necessary and recompile the programs.
- ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized());
+ ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized(context));
gl::InfoLog infoLog;
if (recompileVS)
{
ShaderExecutableD3D *vertexExe = nullptr;
- ANGLE_TRY(programD3D->getVertexExecutableForCachedInputLayout(&vertexExe, &infoLog));
+ ANGLE_TRY(
+ programD3D->getVertexExecutableForCachedInputLayout(context, &vertexExe, &infoLog));
if (!programD3D->hasVertexExecutableForCachedInputLayout())
{
ASSERT(infoLog.getLength() > 0);
@@ -541,7 +542,8 @@
if (recompilePS)
{
ShaderExecutableD3D *pixelExe = nullptr;
- ANGLE_TRY(programD3D->getPixelExecutableForCachedOutputLayout(&pixelExe, &infoLog));
+ ANGLE_TRY(
+ programD3D->getPixelExecutableForCachedOutputLayout(context, &pixelExe, &infoLog));
if (!programD3D->hasPixelExecutableForCachedOutputLayout())
{
ASSERT(infoLog.getLength() > 0);
@@ -592,6 +594,7 @@
gl::ImageIndex index = gl::ImageIndex::Make2DMultisample();
RenderTargetD3D *renderTarget = nullptr;
ANGLE_TRY(textureD3D->getRenderTarget(context, index, &renderTarget));
- return mRenderer->clearRenderTarget(renderTarget, gl::ColorF(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, 0);
+ return mRenderer->clearRenderTarget(context, renderTarget, gl::ColorF(0.0f, 0.0f, 0.0f, 1.0f),
+ 1.0f, 0);
}
} // namespace rx
diff --git a/src/libANGLE/renderer/d3d/d3d11/Image11.cpp b/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
index 22f1f5e..ef7d7a4 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Image11.cpp
@@ -635,7 +635,8 @@
ASSERT(stagingTexture && stagingTexture->valid());
- ANGLE_TRY(mRenderer->mapResource(stagingTexture->get(), subresourceIndex, mapType, 0, map));
+ ANGLE_TRY(
+ mRenderer->mapResource(context, stagingTexture->get(), subresourceIndex, mapType, 0, map));
mDirty = true;
diff --git a/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp b/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp
index d520469..0d0a7f8 100644
--- a/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.cpp
@@ -23,7 +23,10 @@
{
}
-gl::Error IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic)
+gl::Error IndexBuffer11::initialize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType,
+ bool dynamic)
{
mBuffer.reset();
@@ -58,7 +61,10 @@
return gl::NoError();
}
-gl::Error IndexBuffer11::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory)
+gl::Error IndexBuffer11::mapBuffer(const gl::Context *context,
+ unsigned int offset,
+ unsigned int size,
+ void **outMappedMemory)
{
if (!mBuffer.valid())
{
@@ -72,14 +78,14 @@
}
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(
- mRenderer->mapResource(mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource));
+ ANGLE_TRY(mRenderer->mapResource(context, mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0,
+ &mappedResource));
*outMappedMemory = static_cast<char *>(mappedResource.pData) + offset;
return gl::NoError();
}
-gl::Error IndexBuffer11::unmapBuffer()
+gl::Error IndexBuffer11::unmapBuffer(const gl::Context *context)
{
if (!mBuffer.valid())
{
@@ -101,11 +107,13 @@
return mBufferSize;
}
-gl::Error IndexBuffer11::setSize(unsigned int bufferSize, GLenum indexType)
+gl::Error IndexBuffer11::setSize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType)
{
if (bufferSize > mBufferSize || indexType != mIndexType)
{
- return initialize(bufferSize, indexType, mDynamicUsage);
+ return initialize(context, bufferSize, indexType, mDynamicUsage);
}
else
{
@@ -113,7 +121,7 @@
}
}
-gl::Error IndexBuffer11::discard()
+gl::Error IndexBuffer11::discard(const gl::Context *context)
{
if (!mBuffer.valid())
{
@@ -123,8 +131,8 @@
ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(
- mRenderer->mapResource(mBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource));
+ ANGLE_TRY(mRenderer->mapResource(context, mBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
+ &mappedResource));
dxContext->Unmap(mBuffer.get(), 0);
diff --git a/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.h b/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.h
index 7b5d744..80f7188 100644
--- a/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/IndexBuffer11.h
@@ -22,16 +22,24 @@
explicit IndexBuffer11(Renderer11 *const renderer);
~IndexBuffer11() override;
- gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) override;
+ gl::Error initialize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType,
+ bool dynamic) override;
- gl::Error mapBuffer(unsigned int offset, unsigned int size, void **outMappedMemory) override;
- gl::Error unmapBuffer() override;
+ gl::Error mapBuffer(const gl::Context *context,
+ unsigned int offset,
+ unsigned int size,
+ void **outMappedMemory) override;
+ gl::Error unmapBuffer(const gl::Context *context) override;
GLenum getIndexType() const override;
unsigned int getBufferSize() const override;
- gl::Error setSize(unsigned int bufferSize, GLenum indexType) override;
+ gl::Error setSize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType) override;
- gl::Error discard() override;
+ gl::Error discard(const gl::Context *context) override;
DXGI_FORMAT getIndexFormat() const;
const d3d11::Buffer &getBuffer() const;
diff --git a/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp b/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp
index c58cb4a..6387bc3 100644
--- a/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.cpp
@@ -114,6 +114,7 @@
}
gl::Error InputLayoutCache::getInputLayout(
+ const gl::Context *context,
Renderer11 *renderer,
const gl::State &state,
const std::vector<const TranslatedAttribute *> ¤tAttributes,
@@ -181,8 +182,8 @@
angle::TrimCache(mLayoutCache.max_size() / 2, kGCLimit, "input layout", &mLayoutCache);
d3d11::InputLayout newInputLayout;
- ANGLE_TRY(createInputLayout(renderer, sortedSemanticIndices, currentAttributes, program,
- drawCallParams, &newInputLayout));
+ ANGLE_TRY(createInputLayout(context, renderer, sortedSemanticIndices, currentAttributes,
+ program, drawCallParams, &newInputLayout));
auto insertIt = mLayoutCache.Put(layout, std::move(newInputLayout));
*inputLayoutOut = &insertIt->second;
@@ -193,6 +194,7 @@
}
gl::Error InputLayoutCache::createInputLayout(
+ const gl::Context *context,
Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
const std::vector<const TranslatedAttribute *> ¤tAttributes,
@@ -291,7 +293,7 @@
}
ShaderExecutableD3D *shader = nullptr;
- ANGLE_TRY(programD3D->getVertexExecutableForCachedInputLayout(&shader, nullptr));
+ ANGLE_TRY(programD3D->getVertexExecutableForCachedInputLayout(context, &shader, nullptr));
ShaderExecutableD3D *shader11 = GetAs<ShaderExecutable11>(shader);
diff --git a/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.h b/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.h
index 73402c6..02c3b1c 100644
--- a/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.h
+++ b/src/libANGLE/renderer/d3d/d3d11/InputLayoutCache.h
@@ -88,7 +88,8 @@
// Useful for testing
void setCacheSize(size_t newCacheSize);
- gl::Error getInputLayout(Renderer11 *renderer,
+ gl::Error getInputLayout(const gl::Context *context,
+ Renderer11 *renderer,
const gl::State &state,
const std::vector<const TranslatedAttribute *> ¤tAttributes,
const AttribIndexArray &sortedSemanticIndices,
@@ -96,7 +97,8 @@
const d3d11::InputLayout **inputLayoutOut);
private:
- gl::Error createInputLayout(Renderer11 *renderer,
+ gl::Error createInputLayout(const gl::Context *context,
+ Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
const std::vector<const TranslatedAttribute *> ¤tAttributes,
gl::Program *program,
diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
index 70a823b..62e428e 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
@@ -867,13 +867,6 @@
ASSERT(!mPixelTransfer);
mPixelTransfer = new PixelTransfer11(this);
- const gl::Caps &rendererCaps = getNativeCaps();
-
- if (mStateManager.initialize(rendererCaps, getNativeExtensions()).isError())
- {
- return egl::EglBadAlloc() << "Error initializing state manager.";
- }
-
// Gather stats on DXGI and D3D feature level
ANGLE_HISTOGRAM_BOOLEAN("GPU.ANGLE.SupportsDXGI1_2", mRenderer11DeviceCaps.supportsDXGI1_2);
@@ -1427,7 +1420,7 @@
}
rx::ShaderExecutableD3D *pixelExe = nullptr;
- ANGLE_TRY(programD3D->getPixelExecutableForCachedOutputLayout(&pixelExe, nullptr));
+ ANGLE_TRY(programD3D->getPixelExecutableForCachedOutputLayout(context, &pixelExe, nullptr));
// Skip the draw call if rasterizer discard is enabled (or no fragment shader).
if (!pixelExe || glState.getRasterizerState().rasterizerDiscard)
@@ -1513,7 +1506,7 @@
for (GLsizei i = 0; i < params.instances(); i++)
{
ANGLE_TRY(mStateManager.updateVertexOffsetsForPointSpritesEmulation(
- params.baseVertex(), i));
+ context, params.baseVertex(), i));
mDeviceContext->DrawIndexedInstanced(6, clampedVertexCount, 0, 0, 0);
}
@@ -1614,7 +1607,8 @@
// Each instance being rendered requires the inputlayout cache to reapply buffers and offsets.
for (GLsizei i = 0; i < params.instances(); i++)
{
- ANGLE_TRY(mStateManager.updateVertexOffsetsForPointSpritesEmulation(startVertex, i));
+ ANGLE_TRY(
+ mStateManager.updateVertexOffsetsForPointSpritesEmulation(context, startVertex, i));
mDeviceContext->DrawIndexedInstanced(6, clampedVertexCount, 0, 0, 0);
}
mStateManager.invalidateVertexBuffer();
@@ -1694,13 +1688,8 @@
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBufferInterface(this);
- gl::Error error =
- mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
- if (error.isError())
- {
- SafeDelete(mLineLoopIB);
- return error;
- }
+ ANGLE_TRY(
+ mLineLoopIB->reserveBufferSpace(context, INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT));
}
// Checked by Renderer11::applyPrimitiveType
@@ -1716,17 +1705,17 @@
unsigned int spaceNeeded =
static_cast<unsigned int>(sizeof(GLuint) * mScratchIndexDataBuffer.size());
- ANGLE_TRY(mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT));
+ ANGLE_TRY(mLineLoopIB->reserveBufferSpace(context, spaceNeeded, GL_UNSIGNED_INT));
void *mappedMemory = nullptr;
unsigned int offset;
- ANGLE_TRY(mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset));
+ ANGLE_TRY(mLineLoopIB->mapBuffer(context, spaceNeeded, &mappedMemory, &offset));
// Copy over the converted index data.
memcpy(mappedMemory, &mScratchIndexDataBuffer[0],
sizeof(GLuint) * mScratchIndexDataBuffer.size());
- ANGLE_TRY(mLineLoopIB->unmapBuffer());
+ ANGLE_TRY(mLineLoopIB->unmapBuffer(context));
IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(mLineLoopIB->getIndexBuffer());
const d3d11::Buffer &d3dIndexBuffer = indexBuffer->getBuffer();
@@ -1776,13 +1765,8 @@
if (!mTriangleFanIB)
{
mTriangleFanIB = new StreamingIndexBufferInterface(this);
- gl::Error error =
- mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
- if (error.isError())
- {
- SafeDelete(mTriangleFanIB);
- return error;
- }
+ ANGLE_TRY(mTriangleFanIB->reserveBufferSpace(context, INITIAL_INDEX_BUFFER_SIZE,
+ GL_UNSIGNED_INT));
}
// Checked by Renderer11::applyPrimitiveType
@@ -1801,15 +1785,15 @@
const unsigned int spaceNeeded =
static_cast<unsigned int>(mScratchIndexDataBuffer.size() * sizeof(unsigned int));
- ANGLE_TRY(mTriangleFanIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT));
+ ANGLE_TRY(mTriangleFanIB->reserveBufferSpace(context, spaceNeeded, GL_UNSIGNED_INT));
void *mappedMemory = nullptr;
unsigned int offset;
- ANGLE_TRY(mTriangleFanIB->mapBuffer(spaceNeeded, &mappedMemory, &offset));
+ ANGLE_TRY(mTriangleFanIB->mapBuffer(context, spaceNeeded, &mappedMemory, &offset));
memcpy(mappedMemory, &mScratchIndexDataBuffer[0], spaceNeeded);
- ANGLE_TRY(mTriangleFanIB->unmapBuffer());
+ ANGLE_TRY(mTriangleFanIB->unmapBuffer(context));
IndexBuffer11 *indexBuffer = GetAs<IndexBuffer11>(mTriangleFanIB->getIndexBuffer());
const d3d11::Buffer &d3dIndexBuffer = indexBuffer->getBuffer();
@@ -2481,7 +2465,8 @@
return gl::NoError();
}
-gl::Error Renderer11::createRenderTarget(int width,
+gl::Error Renderer11::createRenderTarget(const gl::Context *context,
+ int width,
int height,
GLenum format,
GLsizei samples,
@@ -2619,12 +2604,14 @@
return gl::NoError();
}
-gl::Error Renderer11::createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT)
+gl::Error Renderer11::createRenderTargetCopy(const gl::Context *context,
+ RenderTargetD3D *source,
+ RenderTargetD3D **outRT)
{
ASSERT(source != nullptr);
RenderTargetD3D *newRT = nullptr;
- ANGLE_TRY(createRenderTarget(source->getWidth(), source->getHeight(),
+ ANGLE_TRY(createRenderTarget(context, source->getWidth(), source->getHeight(),
source->getInternalFormat(), source->getSamples(), &newRT));
RenderTarget11 *source11 = GetAs<RenderTarget11>(source);
@@ -2637,7 +2624,8 @@
return gl::NoError();
}
-gl::Error Renderer11::loadExecutable(const uint8_t *function,
+gl::Error Renderer11::loadExecutable(const gl::Context *context,
+ const uint8_t *function,
size_t length,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
@@ -2708,7 +2696,8 @@
return gl::NoError();
}
-gl::Error Renderer11::compileToExecutable(gl::InfoLog &infoLog,
+gl::Error Renderer11::compileToExecutable(const gl::Context *context,
+ gl::InfoLog &infoLog,
const std::string &shaderHLSL,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
@@ -2777,8 +2766,8 @@
// TODO(jmadill): Use ComPtr?
ID3DBlob *binary = nullptr;
std::string debugInfo;
- ANGLE_TRY(mCompiler.compileToBinary(infoLog, shaderHLSL, profile, configs, loopMacros, &binary,
- &debugInfo));
+ ANGLE_TRY(mCompiler.compileToBinary(context, infoLog, shaderHLSL, profile, configs, loopMacros,
+ &binary, &debugInfo));
// It's possible that binary is NULL if the compiler failed in all configurations. Set the
// executable to NULL and return GL_NO_ERROR to signify that there was a link error but the
@@ -2789,9 +2778,9 @@
return gl::NoError();
}
- gl::Error error = loadExecutable(static_cast<const uint8_t *>(binary->GetBufferPointer()),
- binary->GetBufferSize(), type, streamOutVaryings,
- separatedOutputBuffers, outExectuable);
+ gl::Error error = loadExecutable(
+ context, static_cast<const uint8_t *>(binary->GetBufferPointer()), binary->GetBufferSize(),
+ type, streamOutVaryings, separatedOutputBuffers, outExectuable);
SafeRelease(binary);
if (error.isError())
@@ -2807,9 +2796,9 @@
return gl::NoError();
}
-gl::Error Renderer11::ensureHLSLCompilerInitialized()
+gl::Error Renderer11::ensureHLSLCompilerInitialized(const gl::Context *context)
{
- return mCompiler.ensureInitialized();
+ return mCompiler.ensureInitialized(context);
}
UniformStorageD3D *Renderer11::createUniformStorage(size_t storageSize)
@@ -3121,7 +3110,7 @@
if (!invertTexture)
{
PackPixelsParams packParams(safeArea, angleFormat, outputPitch, pack, packBuffer, 0);
- return packPixels(stagingHelper, packParams, pixelsOut);
+ return packPixels(context, stagingHelper, packParams, pixelsOut);
}
// Create a new PixelPackState with reversed row order. Note that we can't just assign
@@ -3134,19 +3123,18 @@
PackPixelsParams packParams(safeArea, angleFormat, outputPitch, invertTexturePack, packBuffer,
0);
- gl::Error error = packPixels(stagingHelper, packParams, pixelsOut);
- ANGLE_TRY(error);
- return gl::NoError();
+ return packPixels(context, stagingHelper, packParams, pixelsOut);
}
-gl::Error Renderer11::packPixels(const TextureHelper11 &textureHelper,
+gl::Error Renderer11::packPixels(const gl::Context *context,
+ const TextureHelper11 &textureHelper,
const PackPixelsParams ¶ms,
uint8_t *pixelsOut)
{
ID3D11Resource *readResource = textureHelper.get();
D3D11_MAPPED_SUBRESOURCE mapping;
- ANGLE_TRY(mapResource(readResource, 0, D3D11_MAP_READ, 0, &mapping));
+ ANGLE_TRY(mapResource(context, readResource, 0, D3D11_MAP_READ, 0, &mapping));
uint8_t *source = static_cast<uint8_t *>(mapping.pData);
int inputPitch = static_cast<int>(mapping.RowPitch);
@@ -3576,6 +3564,7 @@
}
gl::ErrorOrResult<unsigned int> Renderer11::getVertexSpaceRequired(
+ const gl::Context *context,
const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
@@ -3663,7 +3652,7 @@
gl::Error Renderer11::applyComputeShader(const gl::Context *context)
{
- ANGLE_TRY(ensureHLSLCompilerInitialized());
+ ANGLE_TRY(ensureHLSLCompilerInitialized(context));
const auto &glState = context->getGLState();
ProgramD3D *programD3D = GetImplAs<ProgramD3D>(glState.getProgram());
@@ -3673,7 +3662,7 @@
ASSERT(computeExe != nullptr);
mStateManager.setComputeShader(&GetAs<ShaderExecutable11>(computeExe)->getComputeShader());
- ANGLE_TRY(mStateManager.applyComputeUniforms(programD3D));
+ ANGLE_TRY(mStateManager.applyComputeUniforms(context, programD3D));
return gl::NoError();
}
@@ -3784,7 +3773,8 @@
return mStateCache.getSamplerState(this, samplerState, outSamplerState);
}
-gl::Error Renderer11::clearRenderTarget(RenderTargetD3D *renderTarget,
+gl::Error Renderer11::clearRenderTarget(const gl::Context *context,
+ RenderTargetD3D *renderTarget,
const gl::ColorF &clearColorValue,
const float clearDepthValue,
const unsigned int clearStencilValue)
@@ -3831,7 +3821,8 @@
getRenderer11DeviceCaps().supportsVpRtIndexWriteFromVertexShader;
}
-gl::Error Renderer11::mapResource(ID3D11Resource *resource,
+gl::Error Renderer11::mapResource(const gl::Context *context,
+ ID3D11Resource *resource,
UINT subResource,
D3D11_MAP mapType,
UINT mapFlags,
diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.h b/src/libANGLE/renderer/d3d/d3d11/Renderer11.h
index 617fa26..941dcfb 100644
--- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.h
@@ -216,28 +216,33 @@
GLint destLevel) override;
// RenderTarget creation
- gl::Error createRenderTarget(int width,
+ gl::Error createRenderTarget(const gl::Context *context,
+ int width,
int height,
GLenum format,
GLsizei samples,
RenderTargetD3D **outRT) override;
- gl::Error createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT) override;
+ gl::Error createRenderTargetCopy(const gl::Context *context,
+ RenderTargetD3D *source,
+ RenderTargetD3D **outRT) override;
// Shader operations
- gl::Error loadExecutable(const uint8_t *function,
+ gl::Error loadExecutable(const gl::Context *context,
+ const uint8_t *function,
size_t length,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
bool separatedOutputBuffers,
ShaderExecutableD3D **outExecutable) override;
- gl::Error compileToExecutable(gl::InfoLog &infoLog,
+ gl::Error compileToExecutable(const gl::Context *context,
+ gl::InfoLog &infoLog,
const std::string &shaderHLSL,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
bool separatedOutputBuffers,
const angle::CompilerWorkaroundsD3D &workarounds,
ShaderExecutableD3D **outExectuable) override;
- gl::Error ensureHLSLCompilerInitialized() override;
+ gl::Error ensureHLSLCompilerInitialized(const gl::Context *context) override;
UniformStorageD3D *createUniformStorage(size_t storageSize) override;
@@ -329,7 +334,8 @@
GLenum sourcePixelsType,
const gl::Box &destArea) override;
- gl::Error packPixels(const TextureHelper11 &textureHelper,
+ gl::Error packPixels(const gl::Context *context,
+ const TextureHelper11 &textureHelper,
const PackPixelsParams ¶ms,
uint8_t *pixelsOut);
@@ -340,7 +346,8 @@
// Warning: you should ensure binding really matches attrib.bindingIndex before using this
// function.
- gl::ErrorOrResult<unsigned int> getVertexSpaceRequired(const gl::VertexAttribute &attrib,
+ gl::ErrorOrResult<unsigned int> getVertexSpaceRequired(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances) const override;
@@ -437,7 +444,8 @@
const D3D11_SUBRESOURCE_DATA *initData,
TextureHelper11 *textureOut);
- gl::Error clearRenderTarget(RenderTargetD3D *renderTarget,
+ gl::Error clearRenderTarget(const gl::Context *context,
+ RenderTargetD3D *renderTarget,
const gl::ColorF &clearColorValue,
const float clearDepthValue,
const unsigned int clearStencilValue) override;
@@ -446,7 +454,8 @@
void onDirtyUniformBlockBinding(GLuint uniformBlockIndex) override;
- gl::Error mapResource(ID3D11Resource *resource,
+ gl::Error mapResource(const gl::Context *context,
+ ID3D11Resource *resource,
UINT subResource,
D3D11_MAP mapType,
UINT mapFlags,
diff --git a/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp b/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp
index 550312c..c9af21f 100644
--- a/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/StateManager11.cpp
@@ -470,7 +470,8 @@
}
}
-gl::Error ShaderConstants11::updateBuffer(Renderer11 *renderer,
+gl::Error ShaderConstants11::updateBuffer(const gl::Context *context,
+ Renderer11 *renderer,
gl::ShaderType shaderType,
const ProgramD3D &programD3D,
const d3d11::Buffer &driverConstantBuffer)
@@ -514,8 +515,8 @@
// Previous buffer contents are discarded, so we need to refresh the whole buffer.
D3D11_MAPPED_SUBRESOURCE mapping = {0};
- ANGLE_TRY(
- renderer->mapResource(driverConstantBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapping));
+ ANGLE_TRY(renderer->mapResource(context, driverConstantBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD,
+ 0, &mapping));
memcpy(mapping.pData, data, dataSize);
memcpy(static_cast<uint8_t *>(mapping.pData) + dataSize, samplerData,
@@ -1110,8 +1111,10 @@
return gl::NoError();
}
-gl::Error StateManager11::syncDepthStencilState(const gl::State &glState)
+gl::Error StateManager11::syncDepthStencilState(const gl::Context *context)
{
+ const gl::State &glState = context->getGLState();
+
mCurDepthStencilState = glState.getDepthStencilState();
mCurStencilRef = glState.getStencilRef();
mCurStencilBackRef = glState.getStencilBackRef();
@@ -1549,6 +1552,8 @@
gl::Error StateManager11::onMakeCurrent(const gl::Context *context)
{
+ ANGLE_TRY(ensureInitialized(context));
+
const gl::State &state = context->getGLState();
for (Query11 *query : mCurrentQueries)
@@ -1696,8 +1701,13 @@
}
}
-gl::Error StateManager11::initialize(const gl::Caps &caps, const gl::Extensions &extensions)
+gl::Error StateManager11::ensureInitialized(const gl::Context *context)
{
+ Renderer11 *renderer = GetImplAs<Context11>(context)->getRenderer();
+
+ const gl::Caps &caps = renderer->getNativeCaps();
+ const gl::Extensions &extensions = renderer->getNativeExtensions();
+
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
const GLuint maxShaderTextureImageUnits = caps.maxShaderTextureImageUnits[shaderType];
@@ -1721,7 +1731,7 @@
mIsMultiviewEnabled = extensions.multiview;
mViewportOffsets.resize(1u);
- ANGLE_TRY(mVertexDataManager.initialize());
+ ANGLE_TRY(mVertexDataManager.initialize(context));
mCurrentAttributes.reserve(gl::MAX_VERTEX_ATTRIBS);
@@ -1832,6 +1842,7 @@
}
gl::Error StateManager11::syncCurrentValueAttribs(
+ const gl::Context *context,
const std::vector<gl::VertexAttribCurrentValueData> ¤tValues)
{
const auto &activeAttribsMask = mProgramD3D->getState().getActiveAttribLocationsMask();
@@ -1860,7 +1871,7 @@
mDirtyVertexBufferRange.extend(static_cast<unsigned int>(attribIndex));
- ANGLE_TRY(mVertexDataManager.storeCurrentValue(currentValue, currentValueAttrib,
+ ANGLE_TRY(mVertexDataManager.storeCurrentValue(context, currentValue, currentValueAttrib,
static_cast<size_t>(attribIndex)));
}
@@ -2042,18 +2053,18 @@
sampleMask));
break;
case DIRTY_BIT_DEPTH_STENCIL_STATE:
- ANGLE_TRY(syncDepthStencilState(glState));
+ ANGLE_TRY(syncDepthStencilState(context));
break;
case DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE:
// TODO(jmadill): More fine-grained update.
ANGLE_TRY(syncTextures(context));
break;
case DIRTY_BIT_PROGRAM_UNIFORMS:
- ANGLE_TRY(applyUniforms());
+ ANGLE_TRY(applyUniforms(context));
break;
case DIRTY_BIT_DRIVER_UNIFORMS:
// This must happen after viewport sync; the viewport affects builtin uniforms.
- ANGLE_TRY(applyDriverUniforms());
+ ANGLE_TRY(applyDriverUniforms(context));
break;
case DIRTY_BIT_PROGRAM_UNIFORM_BUFFERS:
ANGLE_TRY(syncUniformBuffers(context));
@@ -2062,7 +2073,7 @@
ANGLE_TRY(syncProgram(context, drawCallParams.mode()));
break;
case DIRTY_BIT_CURRENT_VALUE_ATTRIBS:
- ANGLE_TRY(syncCurrentValueAttribs(glState.getVertexAttribCurrentValues()));
+ ANGLE_TRY(syncCurrentValueAttribs(context, glState.getVertexAttribCurrentValues()));
break;
case DIRTY_BIT_TRANSFORM_FEEDBACK:
ANGLE_TRY(syncTransformFeedbackBuffers(context));
@@ -2615,10 +2626,10 @@
ASSERT(mProgramD3D->hasPixelExecutableForCachedOutputLayout());
ShaderExecutableD3D *vertexExe = nullptr;
- ANGLE_TRY(mProgramD3D->getVertexExecutableForCachedInputLayout(&vertexExe, nullptr));
+ ANGLE_TRY(mProgramD3D->getVertexExecutableForCachedInputLayout(context, &vertexExe, nullptr));
ShaderExecutableD3D *pixelExe = nullptr;
- ANGLE_TRY(mProgramD3D->getPixelExecutableForCachedOutputLayout(&pixelExe, nullptr));
+ ANGLE_TRY(mProgramD3D->getPixelExecutableForCachedOutputLayout(context, &pixelExe, nullptr));
ShaderExecutableD3D *geometryExe = nullptr;
ANGLE_TRY(mProgramD3D->getGeometryExecutableForPrimitiveType(context, drawMode, &geometryExe,
@@ -2684,8 +2695,9 @@
// Update the applied input layout by querying the cache.
const gl::State &state = context->getGLState();
const d3d11::InputLayout *inputLayout = nullptr;
- ANGLE_TRY(mInputLayoutCache.getInputLayout(
- mRenderer, state, mCurrentAttributes, sortedSemanticIndices, drawCallParams, &inputLayout));
+ ANGLE_TRY(mInputLayoutCache.getInputLayout(context, mRenderer, state, mCurrentAttributes,
+ sortedSemanticIndices, drawCallParams,
+ &inputLayout));
setInputLayoutInternal(inputLayout);
// Update the applied vertex buffers.
@@ -2909,7 +2921,8 @@
}
// Vertex buffer is invalidated outside this function.
-gl::Error StateManager11::updateVertexOffsetsForPointSpritesEmulation(GLint startVertex,
+gl::Error StateManager11::updateVertexOffsetsForPointSpritesEmulation(const gl::Context *context,
+ GLint startVertex,
GLsizei emulatedInstanceId)
{
size_t reservedBuffers = GetReservedBufferCount(true);
@@ -2989,7 +3002,8 @@
return gl::NoError();
}
-gl::Error StateManager11::applyUniformsForShader(gl::ShaderType shaderType)
+gl::Error StateManager11::applyUniformsForShader(const gl::Context *context,
+ gl::ShaderType shaderType)
{
UniformStorage11 *shaderUniformStorage =
GetAs<UniformStorage11>(mProgramD3D->getShaderUniformStorage(shaderType));
@@ -3042,13 +3056,13 @@
return gl::NoError();
}
-gl::Error StateManager11::applyUniforms()
+gl::Error StateManager11::applyUniforms(const gl::Context *context)
{
- ANGLE_TRY(applyUniformsForShader(gl::ShaderType::Vertex));
- ANGLE_TRY(applyUniformsForShader(gl::ShaderType::Fragment));
+ ANGLE_TRY(applyUniformsForShader(context, gl::ShaderType::Vertex));
+ ANGLE_TRY(applyUniformsForShader(context, gl::ShaderType::Fragment));
if (mProgramD3D->hasShaderStage(gl::ShaderType::Geometry))
{
- ANGLE_TRY(applyUniformsForShader(gl::ShaderType::Geometry));
+ ANGLE_TRY(applyUniformsForShader(context, gl::ShaderType::Geometry));
}
mProgramD3D->markUniformsClean();
@@ -3056,7 +3070,8 @@
return gl::NoError();
}
-gl::Error StateManager11::applyDriverUniformsForShader(gl::ShaderType shaderType)
+gl::Error StateManager11::applyDriverUniformsForShader(const gl::Context *context,
+ gl::ShaderType shaderType)
{
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
@@ -3096,21 +3111,21 @@
// Sampler metadata and driver constants need to coexist in the same constant buffer to
// conserve constant buffer slots. We update both in the constant buffer if needed.
- ANGLE_TRY(mShaderConstants.updateBuffer(mRenderer, shaderType, *mProgramD3D,
+ ANGLE_TRY(mShaderConstants.updateBuffer(context, mRenderer, shaderType, *mProgramD3D,
shaderDriverConstantBuffer));
return gl::NoError();
}
-gl::Error StateManager11::applyDriverUniforms()
+gl::Error StateManager11::applyDriverUniforms(const gl::Context *context)
{
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
- ANGLE_TRY(applyDriverUniformsForShader(gl::ShaderType::Vertex));
- ANGLE_TRY(applyDriverUniformsForShader(gl::ShaderType::Fragment));
+ ANGLE_TRY(applyDriverUniformsForShader(context, gl::ShaderType::Vertex));
+ ANGLE_TRY(applyDriverUniformsForShader(context, gl::ShaderType::Fragment));
if (mProgramD3D->hasShaderStage(gl::ShaderType::Geometry))
{
- ANGLE_TRY(applyDriverUniformsForShader(gl::ShaderType::Geometry));
+ ANGLE_TRY(applyDriverUniformsForShader(context, gl::ShaderType::Geometry));
}
// needed for the point sprite geometry shader
@@ -3130,7 +3145,7 @@
return gl::NoError();
}
-gl::Error StateManager11::applyComputeUniforms(ProgramD3D *programD3D)
+gl::Error StateManager11::applyComputeUniforms(const gl::Context *context, ProgramD3D *programD3D)
{
UniformStorage11 *computeUniformStorage =
GetAs<UniformStorage11>(programD3D->getShaderUniformStorage(gl::ShaderType::Compute));
@@ -3169,7 +3184,8 @@
&buffer);
}
- ANGLE_TRY(mShaderConstants.updateBuffer(mRenderer, gl::ShaderType::Compute, *programD3D,
+ ANGLE_TRY(mShaderConstants.updateBuffer(context, mRenderer, gl::ShaderType::Compute,
+ *programD3D,
mShaderDriverConstantBuffers[gl::ShaderType::Compute]));
return gl::NoError();
diff --git a/src/libANGLE/renderer/d3d/d3d11/StateManager11.h b/src/libANGLE/renderer/d3d/d3d11/StateManager11.h
index 5cab0b6..e192cb6 100644
--- a/src/libANGLE/renderer/d3d/d3d11/StateManager11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/StateManager11.h
@@ -48,7 +48,8 @@
unsigned int samplerIndex,
const gl::Texture &texture);
- gl::Error updateBuffer(Renderer11 *renderer,
+ gl::Error updateBuffer(const gl::Context *context,
+ Renderer11 *renderer,
gl::ShaderType shaderType,
const ProgramD3D &programD3D,
const d3d11::Buffer &driverConstantBuffer);
@@ -144,7 +145,6 @@
StateManager11(Renderer11 *renderer);
~StateManager11();
- gl::Error initialize(const gl::Caps &caps, const gl::Extensions &extensions);
void deinitialize();
void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits);
@@ -234,11 +234,12 @@
void setIndexBuffer(ID3D11Buffer *buffer, DXGI_FORMAT indexFormat, unsigned int offset);
- gl::Error updateVertexOffsetsForPointSpritesEmulation(GLint startVertex,
+ gl::Error updateVertexOffsetsForPointSpritesEmulation(const gl::Context *context,
+ GLint startVertex,
GLsizei emulatedInstanceId);
// TODO(jmadill): Should be private.
- gl::Error applyComputeUniforms(ProgramD3D *programD3D);
+ gl::Error applyComputeUniforms(const gl::Context *context, ProgramD3D *programD3D);
// Only used in testing.
InputLayoutCache *getInputLayoutCache() { return &mInputLayoutCache; }
@@ -249,6 +250,8 @@
ProgramD3D *getProgramD3D() const { return mProgramD3D; }
private:
+ gl::Error ensureInitialized(const gl::Context *context);
+
template <typename SRVType>
void setShaderResourceInternal(gl::ShaderType shaderType,
UINT resourceSlot,
@@ -270,7 +273,7 @@
const gl::ColorF &blendColor,
unsigned int sampleMask);
- gl::Error syncDepthStencilState(const gl::State &glState);
+ gl::Error syncDepthStencilState(const gl::Context *context);
gl::Error syncRasterizerState(const gl::Context *context,
const gl::DrawCallParams &drawCallParams);
@@ -309,16 +312,17 @@
void handleMultiviewDrawFramebufferChange(const gl::Context *context);
gl::Error syncCurrentValueAttribs(
+ const gl::Context *context,
const std::vector<gl::VertexAttribCurrentValueData> ¤tValues);
gl::Error generateSwizzle(const gl::Context *context, gl::Texture *texture);
gl::Error generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type);
gl::Error generateSwizzles(const gl::Context *context);
- gl::Error applyDriverUniforms();
- gl::Error applyDriverUniformsForShader(gl::ShaderType shaderType);
- gl::Error applyUniforms();
- gl::Error applyUniformsForShader(gl::ShaderType shaderType);
+ gl::Error applyDriverUniforms(const gl::Context *context);
+ gl::Error applyDriverUniformsForShader(const gl::Context *context, gl::ShaderType shaderType);
+ gl::Error applyUniforms(const gl::Context *context);
+ gl::Error applyUniformsForShader(const gl::Context *context, gl::ShaderType shaderType);
gl::Error syncUniformBuffers(const gl::Context *context);
gl::Error syncUniformBuffersForShader(const gl::Context *context, gl::ShaderType shaderType);
diff --git a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
index 15b10c5..aeb6a54 100644
--- a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
@@ -955,7 +955,7 @@
{
if (!mUseLevelZeroTexture && mTexture.valid())
{
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
// Pull data back from the mipped texture if necessary.
ASSERT(mLevelZeroTexture.valid());
@@ -970,7 +970,7 @@
{
if (mUseLevelZeroTexture && mLevelZeroTexture.valid())
{
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ ANGLE_TRY(ensureTextureExists(context, mMipLevels));
// Pull data back from the level zero texture if necessary.
ASSERT(mTexture.valid());
@@ -1055,13 +1055,13 @@
{
if (mUseLevelZeroTexture && mMipLevels > 1)
{
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
*outResource = &mLevelZeroTexture;
return gl::NoError();
}
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ ANGLE_TRY(ensureTextureExists(context, mMipLevels));
*outResource = &mTexture;
return gl::NoError();
@@ -1073,13 +1073,13 @@
// This shouldn't be called unless the zero max LOD workaround is active.
ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround);
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ ANGLE_TRY(ensureTextureExists(context, mMipLevels));
*outResource = &mTexture;
return gl::NoError();
}
-gl::Error TextureStorage11_2D::ensureTextureExists(int mipLevels)
+gl::Error TextureStorage11_2D::ensureTextureExists(const gl::Context *context, int mipLevels)
{
// If mMipLevels = 1 then always use mTexture rather than mLevelZeroTexture.
bool useLevelZeroTexture = mRenderer->getWorkarounds().zeroMaxLodWorkaround
@@ -1250,7 +1250,7 @@
if (mipLevels == 1 && mMipLevels > 1)
{
// We must use a SRV on the level-zero-only texture.
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
srvTexture = &mLevelZeroTexture;
}
else
@@ -1944,7 +1944,7 @@
{
if (!mUseLevelZeroTexture && mTexture.valid())
{
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
// Pull data back from the mipped texture if necessary.
ASSERT(mLevelZeroTexture.valid());
@@ -1964,7 +1964,7 @@
{
if (mUseLevelZeroTexture && mLevelZeroTexture.valid())
{
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ ANGLE_TRY(ensureTextureExists(context, mMipLevels));
// Pull data back from the level zero texture if necessary.
ASSERT(mTexture.valid());
@@ -2065,13 +2065,13 @@
{
if (mUseLevelZeroTexture && mMipLevels > 1)
{
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
*outResource = &mLevelZeroTexture;
return gl::NoError();
}
else
{
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ ANGLE_TRY(ensureTextureExists(context, mMipLevels));
*outResource = &mTexture;
return gl::NoError();
}
@@ -2083,12 +2083,12 @@
// This shouldn't be called unless the zero max LOD workaround is active.
ASSERT(mRenderer->getWorkarounds().zeroMaxLodWorkaround);
- ANGLE_TRY(ensureTextureExists(mMipLevels));
+ ANGLE_TRY(ensureTextureExists(context, mMipLevels));
*outResource = &mTexture;
return gl::NoError();
}
-gl::Error TextureStorage11_Cube::ensureTextureExists(int mipLevels)
+gl::Error TextureStorage11_Cube::ensureTextureExists(const gl::Context *context, int mipLevels)
{
// If mMipLevels = 1 then always use mTexture rather than mLevelZeroTexture.
bool useLevelZeroTexture = mRenderer->getWorkarounds().zeroMaxLodWorkaround
@@ -2122,7 +2122,8 @@
return gl::NoError();
}
-gl::Error TextureStorage11_Cube::createRenderTargetSRV(const TextureHelper11 &texture,
+gl::Error TextureStorage11_Cube::createRenderTargetSRV(const gl::Context *context,
+ const TextureHelper11 &texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
d3d11::SharedSRV *srv) const
@@ -2195,11 +2196,12 @@
}
d3d11::SharedSRV srv;
- ANGLE_TRY(createRenderTargetSRV(*texture, index, mFormatInfo.srvFormat, &srv));
+ ANGLE_TRY(createRenderTargetSRV(context, *texture, index, mFormatInfo.srvFormat, &srv));
d3d11::SharedSRV blitSRV;
if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat)
{
- ANGLE_TRY(createRenderTargetSRV(*texture, index, mFormatInfo.blitSRVFormat, &blitSRV));
+ ANGLE_TRY(createRenderTargetSRV(context, *texture, index, mFormatInfo.blitSRVFormat,
+ &blitSRV));
}
else
{
@@ -2296,7 +2298,7 @@
if (mipLevels == 1 && mMipLevels > 1)
{
// We must use a SRV on the level-zero-only texture.
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
srvTexture = &mLevelZeroTexture;
}
else
@@ -3004,7 +3006,8 @@
return gl::NoError();
}
-gl::Error TextureStorage11_2DArray::createRenderTargetSRV(const TextureHelper11 &texture,
+gl::Error TextureStorage11_2DArray::createRenderTargetSRV(const gl::Context *context,
+ const TextureHelper11 &texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
d3d11::SharedSRV *srv) const
@@ -3040,11 +3043,12 @@
const TextureHelper11 *texture = nullptr;
ANGLE_TRY(getResource(context, &texture));
d3d11::SharedSRV srv;
- ANGLE_TRY(createRenderTargetSRV(*texture, index, mFormatInfo.srvFormat, &srv));
+ ANGLE_TRY(createRenderTargetSRV(context, *texture, index, mFormatInfo.srvFormat, &srv));
d3d11::SharedSRV blitSRV;
if (mFormatInfo.blitSRVFormat != mFormatInfo.srvFormat)
{
- ANGLE_TRY(createRenderTargetSRV(*texture, index, mFormatInfo.blitSRVFormat, &blitSRV));
+ ANGLE_TRY(createRenderTargetSRV(context, *texture, index, mFormatInfo.blitSRVFormat,
+ &blitSRV));
}
else
{
@@ -3256,13 +3260,14 @@
gl::Error TextureStorage11_2DMultisample::getResource(const gl::Context *context,
const TextureHelper11 **outResource)
{
- ANGLE_TRY(ensureTextureExists(1));
+ ANGLE_TRY(ensureTextureExists(context, 1));
*outResource = &mTexture;
return gl::NoError();
}
-gl::Error TextureStorage11_2DMultisample::ensureTextureExists(int mipLevels)
+gl::Error TextureStorage11_2DMultisample::ensureTextureExists(const gl::Context *context,
+ int mipLevels)
{
// For Multisampled textures, mipLevels always equals 1.
ASSERT(mipLevels == 1);
diff --git a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h
index 2d31a51..a54830f 100644
--- a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h
@@ -273,7 +273,7 @@
gl::Error ensureDropStencilTexture(const gl::Context *context,
DropStencil *dropStencilOut) override;
- gl::Error ensureTextureExists(int mipLevels);
+ gl::Error ensureTextureExists(const gl::Context *context, int mipLevels);
private:
gl::Error createSRVForSampler(const gl::Context *context,
@@ -490,7 +490,7 @@
gl::Error ensureDropStencilTexture(const gl::Context *context,
DropStencil *dropStencilOut) override;
- gl::Error ensureTextureExists(int mipLevels);
+ gl::Error ensureTextureExists(const gl::Context *context, int mipLevels);
private:
gl::Error createSRVForSampler(const gl::Context *context,
@@ -509,7 +509,8 @@
DXGI_FORMAT format,
const TextureHelper11 &texture,
d3d11::SharedUAV *outUAV) override;
- gl::Error createRenderTargetSRV(const TextureHelper11 &texture,
+ gl::Error createRenderTargetSRV(const gl::Context *context,
+ const TextureHelper11 &texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
d3d11::SharedSRV *srv) const;
@@ -671,7 +672,8 @@
DXGI_FORMAT format,
const TextureHelper11 &texture,
d3d11::SharedUAV *outUAV) override;
- gl::Error createRenderTargetSRV(const TextureHelper11 &texture,
+ gl::Error createRenderTargetSRV(const gl::Context *context,
+ const TextureHelper11 &texture,
const gl::ImageIndex &index,
DXGI_FORMAT resourceFormat,
d3d11::SharedSRV *srv) const;
@@ -725,7 +727,7 @@
gl::Error ensureDropStencilTexture(const gl::Context *context,
DropStencil *dropStencilOut) override;
- gl::Error ensureTextureExists(int mipLevels);
+ gl::Error ensureTextureExists(const gl::Context *context, int mipLevels);
private:
gl::Error createSRVForSampler(const gl::Context *context,
diff --git a/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp b/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp
index 83b1672..38589bb 100644
--- a/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/VertexArray11.cpp
@@ -112,7 +112,7 @@
for (size_t attribIndex : attributesToUpdate)
{
- updateVertexAttribStorage(stateManager, attribIndex);
+ updateVertexAttribStorage(context, stateManager, attribIndex);
}
if (invalidateVertexBuffer)
@@ -205,12 +205,14 @@
return gl::NoError();
}
-void VertexArray11::updateVertexAttribStorage(StateManager11 *stateManager, size_t attribIndex)
+void VertexArray11::updateVertexAttribStorage(const gl::Context *context,
+ StateManager11 *stateManager,
+ size_t attribIndex)
{
const gl::VertexAttribute &attrib = mState.getVertexAttribute(attribIndex);
const gl::VertexBinding &binding = mState.getBindingFromAttribIndex(attribIndex);
- VertexStorageType newStorageType = ClassifyAttributeStorage(attrib, binding);
+ VertexStorageType newStorageType = ClassifyAttributeStorage(context, attrib, binding);
// Note: having an unchanged storage type doesn't mean the attribute is clean.
mAttribsToTranslate.set(attribIndex, newStorageType != VertexStorageType::DYNAMIC);
@@ -259,7 +261,7 @@
switch (mAttributeStorageTypes[dirtyAttribIndex])
{
case VertexStorageType::DIRECT:
- VertexDataManager::StoreDirectAttrib(translatedAttrib);
+ VertexDataManager::StoreDirectAttrib(context, translatedAttrib);
break;
case VertexStorageType::STATIC:
{
diff --git a/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h b/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h
index aa81c7e..2773c3a 100644
--- a/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/VertexArray11.h
@@ -59,7 +59,8 @@
GLenum getCachedDestinationIndexType() const;
private:
- void updateVertexAttribStorage(StateManager11 *stateManager,
+ void updateVertexAttribStorage(const gl::Context *context,
+ StateManager11 *stateManager,
size_t attribIndex);
gl::Error updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs);
diff --git a/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp b/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp
index 441baa1..a373195 100644
--- a/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.cpp
@@ -33,7 +33,9 @@
ASSERT(mMappedResourceData == nullptr);
}
-gl::Error VertexBuffer11::initialize(unsigned int size, bool dynamicUsage)
+gl::Error VertexBuffer11::initialize(const gl::Context *context,
+ unsigned int size,
+ bool dynamicUsage)
{
mBuffer.reset();
updateSerial();
@@ -66,13 +68,13 @@
return gl::NoError();
}
-gl::Error VertexBuffer11::mapResource()
+gl::Error VertexBuffer11::mapResource(const gl::Context *context)
{
if (mMappedResourceData == nullptr)
{
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(mRenderer->mapResource(mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0,
+ ANGLE_TRY(mRenderer->mapResource(context, mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0,
&mappedResource));
mMappedResourceData = static_cast<uint8_t *>(mappedResource.pData);
@@ -92,7 +94,8 @@
}
}
-gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib,
+gl::Error VertexBuffer11::storeVertexAttributes(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -109,7 +112,7 @@
int inputStride = static_cast<int>(ComputeVertexAttributeStride(attrib, binding));
// This will map the resource if it isn't already mapped.
- ANGLE_TRY(mapResource());
+ ANGLE_TRY(mapResource(context));
uint8_t *output = mMappedResourceData + offset;
@@ -135,11 +138,11 @@
return mBufferSize;
}
-gl::Error VertexBuffer11::setBufferSize(unsigned int size)
+gl::Error VertexBuffer11::setBufferSize(const gl::Context *context, unsigned int size)
{
if (size > mBufferSize)
{
- return initialize(size, mDynamicUsage);
+ return initialize(context, size, mDynamicUsage);
}
else
{
@@ -147,7 +150,7 @@
}
}
-gl::Error VertexBuffer11::discard()
+gl::Error VertexBuffer11::discard(const gl::Context *context)
{
if (!mBuffer.valid())
{
@@ -155,8 +158,8 @@
}
D3D11_MAPPED_SUBRESOURCE mappedResource;
- ANGLE_TRY(
- mRenderer->mapResource(mBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource));
+ ANGLE_TRY(mRenderer->mapResource(context, mBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0,
+ &mappedResource));
mRenderer->getDeviceContext()->Unmap(mBuffer.get(), 0);
diff --git a/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.h b/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.h
index 7778c31..e5d7f26 100644
--- a/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/VertexBuffer11.h
@@ -23,11 +23,12 @@
public:
explicit VertexBuffer11(Renderer11 *const renderer);
- gl::Error initialize(unsigned int size, bool dynamicUsage) override;
+ gl::Error initialize(const gl::Context *context, unsigned int size, bool dynamicUsage) override;
// Warning: you should ensure binding really matches attrib.bindingIndex before using this
// function.
- gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
+ gl::Error storeVertexAttributes(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -37,8 +38,8 @@
const uint8_t *sourceData) override;
unsigned int getBufferSize() const override;
- gl::Error setBufferSize(unsigned int size) override;
- gl::Error discard() override;
+ gl::Error setBufferSize(const gl::Context *context, unsigned int size) override;
+ gl::Error discard(const gl::Context *context) override;
void hintUnmapResource() override;
@@ -46,7 +47,7 @@
private:
~VertexBuffer11() override;
- gl::Error mapResource();
+ gl::Error mapResource(const gl::Context *context);
Renderer11 *const mRenderer;
diff --git a/src/libANGLE/renderer/d3d/d3d9/Context9.cpp b/src/libANGLE/renderer/d3d/d3d9/Context9.cpp
index 322869f..d3755bb 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Context9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Context9.cpp
@@ -278,7 +278,7 @@
gl::Error Context9::onMakeCurrent(const gl::Context *context)
{
- return gl::NoError();
+ return mRenderer->ensureVertexDataManagerInitialized(context);
}
gl::Caps Context9::getNativeCaps() const
diff --git a/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp b/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp
index df86331..f1928fe 100644
--- a/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.cpp
@@ -25,7 +25,10 @@
SafeRelease(mIndexBuffer);
}
-gl::Error IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic)
+gl::Error IndexBuffer9::initialize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType,
+ bool dynamic)
{
SafeRelease(mIndexBuffer);
@@ -66,7 +69,10 @@
return gl::NoError();
}
-gl::Error IndexBuffer9::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory)
+gl::Error IndexBuffer9::mapBuffer(const gl::Context *context,
+ unsigned int offset,
+ unsigned int size,
+ void **outMappedMemory)
{
if (!mIndexBuffer)
{
@@ -86,7 +92,7 @@
return gl::NoError();
}
-gl::Error IndexBuffer9::unmapBuffer()
+gl::Error IndexBuffer9::unmapBuffer(const gl::Context *context)
{
if (!mIndexBuffer)
{
@@ -112,11 +118,13 @@
return mBufferSize;
}
-gl::Error IndexBuffer9::setSize(unsigned int bufferSize, GLenum indexType)
+gl::Error IndexBuffer9::setSize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType)
{
if (bufferSize > mBufferSize || indexType != mIndexType)
{
- return initialize(bufferSize, indexType, mDynamic);
+ return initialize(context, bufferSize, indexType, mDynamic);
}
else
{
@@ -124,7 +132,7 @@
}
}
-gl::Error IndexBuffer9::discard()
+gl::Error IndexBuffer9::discard(const gl::Context *context)
{
if (!mIndexBuffer)
{
diff --git a/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.h b/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.h
index 5921d2a..0f75949 100644
--- a/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.h
+++ b/src/libANGLE/renderer/d3d/d3d9/IndexBuffer9.h
@@ -21,16 +21,24 @@
explicit IndexBuffer9(Renderer9 *const renderer);
~IndexBuffer9() override;
- gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) override;
+ gl::Error initialize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType,
+ bool dynamic) override;
- gl::Error mapBuffer(unsigned int offset, unsigned int size, void **outMappedMemory) override;
- gl::Error unmapBuffer() override;
+ gl::Error mapBuffer(const gl::Context *context,
+ unsigned int offset,
+ unsigned int size,
+ void **outMappedMemory) override;
+ gl::Error unmapBuffer(const gl::Context *context) override;
GLenum getIndexType() const override;
unsigned int getBufferSize() const override;
- gl::Error setSize(unsigned int bufferSize, GLenum indexType) override;
+ gl::Error setSize(const gl::Context *context,
+ unsigned int bufferSize,
+ GLenum indexType) override;
- gl::Error discard() override;
+ gl::Error discard(const gl::Context *context) override;
D3DFORMAT getIndexFormat() const;
IDirect3DIndexBuffer9 *getBuffer() const;
diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
index a22761e..ed6ab1b 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
@@ -375,14 +375,8 @@
ANGLE_TRY(mBlit->initialize());
ASSERT(!mVertexDataManager && !mIndexDataManager);
- mVertexDataManager = new VertexDataManager(this);
mIndexDataManager = new IndexDataManager(this);
- if (mVertexDataManager->initialize().isError())
- {
- return egl::EglBadAlloc() << "Error initializing VertexDataManager";
- }
-
mTranslatedAttribCache.resize(getNativeCaps().maxVertexAttributes);
mStateManager.initialize();
@@ -1191,7 +1185,7 @@
}
RenderTargetD3D *nullRenderTarget = nullptr;
- ANGLE_TRY(createRenderTarget(size.width, size.height, GL_NONE, 0, &nullRenderTarget));
+ ANGLE_TRY(createRenderTarget(context, size.width, size.height, GL_NONE, 0, &nullRenderTarget));
// add nullbuffer to the cache
NullRenderTargetCacheEntry *oldest = &mNullRenderTargetCache[0];
@@ -1363,14 +1357,11 @@
{
return drawLineLoop(context, count, GL_NONE, nullptr, 0, nullptr);
}
- else if (instances > 0)
+
+ if (instances > 0)
{
StaticIndexBufferInterface *countingIB = nullptr;
- gl::Error error = getCountingIB(count, &countingIB);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(getCountingIB(context, count, &countingIB));
if (mAppliedIBSerial != countingIB->getSerial())
{
@@ -1387,11 +1378,10 @@
return gl::NoError();
}
- else // Regular case
- {
- mDevice->DrawPrimitive(mPrimitiveType, 0, mPrimitiveCount);
- return gl::NoError();
- }
+
+ // Regular case
+ mDevice->DrawPrimitive(mPrimitiveType, 0, mPrimitiveCount);
+ return gl::NoError();
}
gl::Error Renderer9::drawElementsImpl(const gl::Context *context,
@@ -1453,11 +1443,7 @@
BufferD3D *storage = GetImplAs<BufferD3D>(elementArrayBuffer);
intptr_t offset = reinterpret_cast<intptr_t>(indices);
const uint8_t *bufferData = nullptr;
- gl::Error error = storage->getData(context, &bufferData);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(storage->getData(context, &bufferData));
indices = bufferData + offset;
}
@@ -1468,13 +1454,8 @@
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBufferInterface(this);
- gl::Error error =
- mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
- if (error.isError())
- {
- SafeDelete(mLineLoopIB);
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->reserveBufferSpace(context, INITIAL_INDEX_BUFFER_SIZE,
+ GL_UNSIGNED_INT));
}
// Checked by Renderer9::applyPrimitiveType
@@ -1489,19 +1470,11 @@
const unsigned int spaceNeeded =
(static_cast<unsigned int>(count) + 1) * sizeof(unsigned int);
- gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->reserveBufferSpace(context, spaceNeeded, GL_UNSIGNED_INT));
void *mappedMemory = nullptr;
unsigned int offset = 0;
- error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->mapBuffer(context, spaceNeeded, &mappedMemory, &offset));
startIndex = static_cast<unsigned int>(offset) / 4;
unsigned int *data = static_cast<unsigned int *>(mappedMemory);
@@ -1540,24 +1513,15 @@
UNREACHABLE();
}
- error = mLineLoopIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->unmapBuffer(context));
}
else
{
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBufferInterface(this);
- gl::Error error =
- mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT);
- if (error.isError())
- {
- SafeDelete(mLineLoopIB);
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->reserveBufferSpace(context, INITIAL_INDEX_BUFFER_SIZE,
+ GL_UNSIGNED_SHORT));
}
// Checked by Renderer9::applyPrimitiveType
@@ -1572,19 +1536,11 @@
const unsigned int spaceNeeded =
(static_cast<unsigned int>(count) + 1) * sizeof(unsigned short);
- gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->reserveBufferSpace(context, spaceNeeded, GL_UNSIGNED_SHORT));
void *mappedMemory = nullptr;
unsigned int offset;
- error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->mapBuffer(context, spaceNeeded, &mappedMemory, &offset));
startIndex = static_cast<unsigned int>(offset) / 2;
unsigned short *data = static_cast<unsigned short *>(mappedMemory);
@@ -1623,11 +1579,7 @@
UNREACHABLE();
}
- error = mLineLoopIB->unmapBuffer();
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(mLineLoopIB->unmapBuffer(context));
}
if (mAppliedIBSerial != mLineLoopIB->getSerial())
@@ -1698,7 +1650,9 @@
}
}
-gl::Error Renderer9::getCountingIB(size_t count, StaticIndexBufferInterface **outIB)
+gl::Error Renderer9::getCountingIB(const gl::Context *context,
+ size_t count,
+ StaticIndexBufferInterface **outIB)
{
// Update the counting index buffer if it is not large enough or has not been created yet.
if (count <= 65536) // 16-bit indices
@@ -1709,10 +1663,10 @@
{
SafeDelete(mCountingIB);
mCountingIB = new StaticIndexBufferInterface(this);
- ANGLE_TRY(mCountingIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT));
+ ANGLE_TRY(mCountingIB->reserveBufferSpace(context, spaceNeeded, GL_UNSIGNED_SHORT));
void *mappedMemory = nullptr;
- ANGLE_TRY(mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, nullptr));
+ ANGLE_TRY(mCountingIB->mapBuffer(context, spaceNeeded, &mappedMemory, nullptr));
unsigned short *data = static_cast<unsigned short *>(mappedMemory);
for (size_t i = 0; i < count; i++)
@@ -1720,7 +1674,7 @@
data[i] = static_cast<unsigned short>(i);
}
- ANGLE_TRY(mCountingIB->unmapBuffer());
+ ANGLE_TRY(mCountingIB->unmapBuffer(context));
}
}
else if (getNativeExtensions().elementIndexUint)
@@ -1731,10 +1685,10 @@
{
SafeDelete(mCountingIB);
mCountingIB = new StaticIndexBufferInterface(this);
- ANGLE_TRY(mCountingIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT));
+ ANGLE_TRY(mCountingIB->reserveBufferSpace(context, spaceNeeded, GL_UNSIGNED_INT));
void *mappedMemory = nullptr;
- ANGLE_TRY(mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, nullptr));
+ ANGLE_TRY(mCountingIB->mapBuffer(context, spaceNeeded, &mappedMemory, nullptr));
unsigned int *data = static_cast<unsigned int *>(mappedMemory);
for (unsigned int i = 0; i < count; i++)
@@ -1742,7 +1696,7 @@
data[i] = i;
}
- ANGLE_TRY(mCountingIB->unmapBuffer());
+ ANGLE_TRY(mCountingIB->unmapBuffer(context));
}
}
else
@@ -1759,20 +1713,20 @@
{
const gl::State &state = context->getContextState().getState();
// This method is called single-threaded.
- ANGLE_TRY(ensureHLSLCompilerInitialized());
+ ANGLE_TRY(ensureHLSLCompilerInitialized(context));
ProgramD3D *programD3D = GetImplAs<ProgramD3D>(state.getProgram());
VertexArray9 *vao = GetImplAs<VertexArray9>(state.getVertexArray());
programD3D->updateCachedInputLayout(vao->getCurrentStateSerial(), state);
ShaderExecutableD3D *vertexExe = nullptr;
- ANGLE_TRY(programD3D->getVertexExecutableForCachedInputLayout(&vertexExe, nullptr));
+ ANGLE_TRY(programD3D->getVertexExecutableForCachedInputLayout(context, &vertexExe, nullptr));
const gl::Framebuffer *drawFramebuffer = state.getDrawFramebuffer();
programD3D->updateCachedOutputLayout(context, drawFramebuffer);
ShaderExecutableD3D *pixelExe = nullptr;
- ANGLE_TRY(programD3D->getPixelExecutableForCachedOutputLayout(&pixelExe, nullptr));
+ ANGLE_TRY(programD3D->getPixelExecutableForCachedOutputLayout(context, &pixelExe, nullptr));
IDirect3DVertexShader9 *vertexShader =
(vertexExe ? GetAs<ShaderExecutable9>(vertexExe)->getVertexShader() : nullptr);
@@ -2557,7 +2511,8 @@
return gl::InternalError();
}
-gl::Error Renderer9::createRenderTarget(int width,
+gl::Error Renderer9::createRenderTarget(const gl::Context *context,
+ int width,
int height,
GLenum format,
GLsizei samples,
@@ -2627,17 +2582,15 @@
return gl::NoError();
}
-gl::Error Renderer9::createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT)
+gl::Error Renderer9::createRenderTargetCopy(const gl::Context *context,
+ RenderTargetD3D *source,
+ RenderTargetD3D **outRT)
{
ASSERT(source != nullptr);
RenderTargetD3D *newRT = nullptr;
- gl::Error error = createRenderTarget(source->getWidth(), source->getHeight(),
- source->getInternalFormat(), source->getSamples(), &newRT);
- if (error.isError())
- {
- return error;
- }
+ ANGLE_TRY(createRenderTarget(context, source->getWidth(), source->getHeight(),
+ source->getInternalFormat(), source->getSamples(), &newRT));
RenderTarget9 *source9 = GetAs<RenderTarget9>(source);
RenderTarget9 *dest9 = GetAs<RenderTarget9>(newRT);
@@ -2654,7 +2607,8 @@
return gl::NoError();
}
-gl::Error Renderer9::loadExecutable(const uint8_t *function,
+gl::Error Renderer9::loadExecutable(const gl::Context *context,
+ const uint8_t *function,
size_t length,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
@@ -2696,7 +2650,8 @@
return gl::NoError();
}
-gl::Error Renderer9::compileToExecutable(gl::InfoLog &infoLog,
+gl::Error Renderer9::compileToExecutable(const gl::Context *context,
+ gl::InfoLog &infoLog,
const std::string &shaderHLSL,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
@@ -2758,8 +2713,8 @@
ID3DBlob *binary = nullptr;
std::string debugInfo;
- gl::Error error = mCompiler.compileToBinary(infoLog, shaderHLSL, profile, configs, nullptr,
- &binary, &debugInfo);
+ gl::Error error = mCompiler.compileToBinary(context, infoLog, shaderHLSL, profile, configs,
+ nullptr, &binary, &debugInfo);
if (error.isError())
{
return error;
@@ -2774,7 +2729,7 @@
return gl::NoError();
}
- error = loadExecutable(reinterpret_cast<const uint8_t *>(binary->GetBufferPointer()),
+ error = loadExecutable(context, reinterpret_cast<const uint8_t *>(binary->GetBufferPointer()),
binary->GetBufferSize(), type, streamOutVaryings, separatedOutputBuffers,
outExectuable);
@@ -2792,9 +2747,9 @@
return gl::NoError();
}
-gl::Error Renderer9::ensureHLSLCompilerInitialized()
+gl::Error Renderer9::ensureHLSLCompilerInitialized(const gl::Context *context)
{
- return mCompiler.ensureInitialized();
+ return mCompiler.ensureInitialized(context);
}
UniformStorageD3D *Renderer9::createUniformStorage(size_t storageSize)
@@ -3006,7 +2961,8 @@
return d3d9::GetVertexFormatInfo(getCapsDeclTypes(), vertexFormatType).componentType;
}
-gl::ErrorOrResult<unsigned int> Renderer9::getVertexSpaceRequired(const gl::VertexAttribute &attrib,
+gl::ErrorOrResult<unsigned int> Renderer9::getVertexSpaceRequired(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances) const
@@ -3137,7 +3093,8 @@
return gl::Version(2, 0);
}
-gl::Error Renderer9::clearRenderTarget(RenderTargetD3D *renderTarget,
+gl::Error Renderer9::clearRenderTarget(const gl::Context *context,
+ RenderTargetD3D *renderTarget,
const gl::ColorF &clearColorValue,
const float clearDepthValue,
const unsigned int clearStencilValue)
@@ -3271,4 +3228,15 @@
{
return GetImplAs<Context9>(context)->getIncompleteTexture(context, type, textureOut);
}
+
+gl::Error Renderer9::ensureVertexDataManagerInitialized(const gl::Context *context)
+{
+ if (!mVertexDataManager)
+ {
+ mVertexDataManager = new VertexDataManager(this);
+ ANGLE_TRY(mVertexDataManager->initialize(context));
+ }
+
+ return gl::NoError();
+}
} // namespace rx
diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.h b/src/libANGLE/renderer/d3d/d3d9/Renderer9.h
index c0ced99..dc27721 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.h
+++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.h
@@ -240,28 +240,33 @@
GLint destLevel) override;
// RenderTarget creation
- gl::Error createRenderTarget(int width,
+ gl::Error createRenderTarget(const gl::Context *context,
+ int width,
int height,
GLenum format,
GLsizei samples,
RenderTargetD3D **outRT) override;
- gl::Error createRenderTargetCopy(RenderTargetD3D *source, RenderTargetD3D **outRT) override;
+ gl::Error createRenderTargetCopy(const gl::Context *context,
+ RenderTargetD3D *source,
+ RenderTargetD3D **outRT) override;
// Shader operations
- gl::Error loadExecutable(const uint8_t *function,
+ gl::Error loadExecutable(const gl::Context *context,
+ const uint8_t *function,
size_t length,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
bool separatedOutputBuffers,
ShaderExecutableD3D **outExecutable) override;
- gl::Error compileToExecutable(gl::InfoLog &infoLog,
+ gl::Error compileToExecutable(const gl::Context *context,
+ gl::InfoLog &infoLog,
const std::string &shaderHLSL,
gl::ShaderType type,
const std::vector<D3DVarying> &streamOutVaryings,
bool separatedOutputBuffers,
const angle::CompilerWorkaroundsD3D &workarounds,
ShaderExecutableD3D **outExectuable) override;
- gl::Error ensureHLSLCompilerInitialized() override;
+ gl::Error ensureHLSLCompilerInitialized(const gl::Context *context) override;
UniformStorageD3D *createUniformStorage(size_t storageSize) override;
@@ -346,7 +351,8 @@
// Warning: you should ensure binding really matches attrib.bindingIndex before using this
// function.
- gl::ErrorOrResult<unsigned int> getVertexSpaceRequired(const gl::VertexAttribute &attrib,
+ gl::ErrorOrResult<unsigned int> getVertexSpaceRequired(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t count,
GLsizei instances) const override;
@@ -383,7 +389,8 @@
gl::Version getMaxSupportedESVersion() const override;
- gl::Error clearRenderTarget(RenderTargetD3D *renderTarget,
+ gl::Error clearRenderTarget(const gl::Context *context,
+ RenderTargetD3D *renderTarget,
const gl::ColorF &clearColorValue,
const float clearDepthValue,
const unsigned int clearStencilValue) override;
@@ -394,6 +401,8 @@
gl::TextureType type,
gl::Texture **textureOut) override;
+ gl::Error ensureVertexDataManagerInitialized(const gl::Context *context);
+
private:
gl::Error drawArraysImpl(const gl::Context *context,
gl::PrimitiveMode mode,
@@ -440,7 +449,9 @@
int minIndex,
gl::Buffer *elementArrayBuffer);
- gl::Error getCountingIB(size_t count, StaticIndexBufferInterface **outIB);
+ gl::Error getCountingIB(const gl::Context *context,
+ size_t count,
+ StaticIndexBufferInterface **outIB);
gl::Error getNullColorRenderTarget(const gl::Context *context,
const RenderTarget9 *depthRenderTarget,
diff --git a/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.cpp b/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.cpp
index 51af37a..e56e4d6 100644
--- a/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.cpp
@@ -29,7 +29,9 @@
SafeRelease(mVertexBuffer);
}
-gl::Error VertexBuffer9::initialize(unsigned int size, bool dynamicUsage)
+gl::Error VertexBuffer9::initialize(const gl::Context *context,
+ unsigned int size,
+ bool dynamicUsage)
{
SafeRelease(mVertexBuffer);
@@ -57,7 +59,8 @@
return gl::NoError();
}
-gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib,
+gl::Error VertexBuffer9::storeVertexAttributes(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -78,7 +81,8 @@
uint8_t *mapPtr = nullptr;
- auto errorOrMapSize = mRenderer->getVertexSpaceRequired(attrib, binding, count, instances);
+ auto errorOrMapSize =
+ mRenderer->getVertexSpaceRequired(context, attrib, binding, count, instances);
if (errorOrMapSize.isError())
{
return errorOrMapSize.getError();
@@ -123,11 +127,11 @@
return mBufferSize;
}
-gl::Error VertexBuffer9::setBufferSize(unsigned int size)
+gl::Error VertexBuffer9::setBufferSize(const gl::Context *context, unsigned int size)
{
if (size > mBufferSize)
{
- return initialize(size, mDynamicUsage);
+ return initialize(context, size, mDynamicUsage);
}
else
{
@@ -135,7 +139,7 @@
}
}
-gl::Error VertexBuffer9::discard()
+gl::Error VertexBuffer9::discard(const gl::Context *context)
{
if (!mVertexBuffer)
{
diff --git a/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.h b/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.h
index 90defb3..f6813a1 100644
--- a/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.h
+++ b/src/libANGLE/renderer/d3d/d3d9/VertexBuffer9.h
@@ -20,11 +20,12 @@
public:
explicit VertexBuffer9(Renderer9 *renderer);
- gl::Error initialize(unsigned int size, bool dynamicUsage) override;
+ gl::Error initialize(const gl::Context *context, unsigned int size, bool dynamicUsage) override;
// Warning: you should ensure binding really matches attrib.bindingIndex before using this
// function.
- gl::Error storeVertexAttributes(const gl::VertexAttribute &attrib,
+ gl::Error storeVertexAttributes(const gl::Context *context,
+ const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
GLenum currentValueType,
GLint start,
@@ -34,8 +35,8 @@
const uint8_t *sourceData) override;
unsigned int getBufferSize() const override;
- gl::Error setBufferSize(unsigned int size) override;
- gl::Error discard() override;
+ gl::Error setBufferSize(const gl::Context *context, unsigned int size) override;
+ gl::Error discard(const gl::Context *context) override;
IDirect3DVertexBuffer9 *getBuffer() const;
diff --git a/src/tests/perf_tests/IndexDataManagerTest.cpp b/src/tests/perf_tests/IndexDataManagerTest.cpp
index 80e1b8f..a85d212 100644
--- a/src/tests/perf_tests/IndexDataManagerTest.cpp
+++ b/src/tests/perf_tests/IndexDataManagerTest.cpp
@@ -29,11 +29,11 @@
{
}
- MOCK_METHOD3(initialize, gl::Error(unsigned int, GLenum, bool));
- MOCK_METHOD3(mapBuffer, gl::Error(unsigned int, unsigned int, void **));
- MOCK_METHOD0(unmapBuffer, gl::Error());
- MOCK_METHOD0(discard, gl::Error());
- MOCK_METHOD2(setSize, gl::Error(unsigned int, GLenum));
+ MOCK_METHOD4(initialize, gl::Error(const gl::Context *, unsigned int, GLenum, bool));
+ MOCK_METHOD4(mapBuffer, gl::Error(const gl::Context *, unsigned int, unsigned int, void **));
+ MOCK_METHOD1(unmapBuffer, gl::Error(const gl::Context *));
+ MOCK_METHOD1(discard, gl::Error(const gl::Context *));
+ MOCK_METHOD3(setSize, gl::Error(const gl::Context *, unsigned int, GLenum));
// inlined for speed
GLenum getIndexType() const override { return mIndexType; }
@@ -55,8 +55,9 @@
MOCK_METHOD0(createVertexBuffer, rx::VertexBuffer *());
MOCK_CONST_METHOD1(getVertexConversionType, rx::VertexConversionType(gl::VertexFormatType));
MOCK_CONST_METHOD1(getVertexComponentType, GLenum(gl::VertexFormatType));
- MOCK_CONST_METHOD4(getVertexSpaceRequired,
- gl::ErrorOrResult<unsigned int>(const gl::VertexAttribute &,
+ MOCK_CONST_METHOD5(getVertexSpaceRequired,
+ gl::ErrorOrResult<unsigned int>(const gl::Context *,
+ const gl::VertexAttribute &,
const gl::VertexBinding &,
size_t,
GLsizei));