Commit 306b6c16 by Jamie Madill Committed by Commit Bot

D3D11: Use angle::Result error pattern. 1/3

This CL improves performance on the draw call microbenchmark by 10% when no-oping driver calls. Bug: angleproject:2738 Change-Id: I4f5c11db90d9056ce4557b2a4432bc55b42b5bba Reviewed-on: https://chromium-review.googlesource.com/1150093 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent c0b61500
......@@ -311,4 +311,10 @@ std::ostream &FmtHex(std::ostream &os, T value)
ANGLE_EMPTY_STATEMENT
#endif // defined(ANGLE_TRACE_ENABLED) || defined(ANGLE_ENABLE_ASSERTS)
#if defined(ANGLE_PLATFORM_WINDOWS)
#define ANGLE_FUNCTION __FUNCTION__
#else
#define ANGLE_FUNCTION __func__
#endif
#endif // COMMON_DEBUG_H_
......@@ -2545,7 +2545,7 @@ void Context::getProgramInterfaceivRobust(GLuint program,
UNIMPLEMENTED();
}
void Context::handleError(const Error &error)
void Context::handleError(const Error &error) const
{
mErrors.handleError(error);
}
......@@ -7538,7 +7538,7 @@ ErrorSet::ErrorSet(Context *context) : mContext(context)
ErrorSet::~ErrorSet() = default;
void ErrorSet::handleError(const Error &error)
void ErrorSet::handleError(const Error &error) const
{
// This internal enum is used to filter internal errors that are already handled.
// TODO(jmadill): Remove this when refactor is done. http://anglebug.com/2491
......
......@@ -69,13 +69,16 @@ class ErrorSet : angle::NonCopyable
explicit ErrorSet(Context *context);
~ErrorSet();
void handleError(const Error &error);
// TODO(jmadill): Remove const. http://anglebug.com/2378
void handleError(const Error &error) const;
bool empty() const;
GLenum popError();
private:
Context *mContext;
std::set<GLenum> mErrors;
// TODO(jmadill): Remove mutable. http://anglebug.com/2378
mutable std::set<GLenum> mErrors;
};
class Context final : public egl::LabeledObject, angle::NonCopyable
......@@ -1395,7 +1398,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable
void framebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level);
// Consumes the error.
void handleError(const Error &error);
// TODO(jmadill): Remove const. http://anglebug.com/2378
void handleError(const Error &error) const;
GLenum getError();
void markContextLost();
......
......@@ -236,6 +236,19 @@ inline Error NoError()
#define ANGLE_RETURN(X) return X;
#define ANGLE_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_RETURN);
// TODO(jmadill): Remove this once refactor is complete. http://anglebug.com/2738
#define ANGLE_TRY_HANDLE(CONTEXT, EXPR) \
\
{ \
auto ANGLE_LOCAL_VAR = (EXPR); \
if (ANGLE_LOCAL_VAR.isError()) \
{ \
CONTEXT->handleError(ANGLE_LOCAL_VAR); \
return angle::Result::Stop(); \
} \
\
}
#define ANGLE_TRY_RESULT(EXPR, RESULT) \
{ \
auto ANGLE_LOCAL_VAR = EXPR; \
......@@ -285,6 +298,10 @@ class ANGLE_NO_DISCARD Result
return operator gl::Error();
}
bool operator==(Result other) const { return mStop == other.mStop; }
bool operator!=(Result other) const { return mStop != other.mStop; }
private:
Result(bool stop) : mStop(stop) {}
bool mStop;
......
......@@ -73,6 +73,32 @@ enum RendererClass
RENDERER_D3D9
};
// ANGLE_TRY for HRESULT errors.
#define ANGLE_TRY_HR(CONTEXT, EXPR, MESSAGE) \
\
{ \
auto ANGLE_LOCAL_VAR = (EXPR); \
if (ANGLE_UNLIKELY(FAILED(ANGLE_LOCAL_VAR))) \
{ \
CONTEXT->handleError(ANGLE_LOCAL_VAR, MESSAGE, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop(); \
} \
\
}
#define ANGLE_CHECK_HR(CONTEXT, EXPR, MESSAGE, ERROR) \
\
{ \
if (ANGLE_UNLIKELY(!(EXPR))) \
{ \
CONTEXT->handleError(ERROR, MESSAGE, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop(); \
} \
}
#define ANGLE_CHECK_HR_ALLOC(context, result) \
ANGLE_CHECK_HR(context, result, "Failed to allocate host memory", E_OUTOFMEMORY)
// Check if the device is lost every 10 failures to get the query data
constexpr unsigned int kPollingD3DDeviceLostCheckFrequency = 10;
......
......@@ -53,25 +53,27 @@ class Buffer11 : public BufferD3D
Buffer11(const gl::BufferState &state, Renderer11 *renderer);
~Buffer11() override;
gl::Error getBuffer(const gl::Context *context, BufferUsage usage, ID3D11Buffer **bufferOut);
gl::Error getEmulatedIndexedBuffer(const gl::Context *context,
SourceIndexData *indexInfo,
const TranslatedAttribute &attribute,
GLint startVertex,
ID3D11Buffer **bufferOut);
gl::Error getConstantBufferRange(const gl::Context *context,
GLintptr offset,
GLsizeiptr size,
const d3d11::Buffer **bufferOut,
UINT *firstConstantOut,
UINT *numConstantsOut);
gl::Error getSRV(const gl::Context *context,
DXGI_FORMAT srvFormat,
const d3d11::ShaderResourceView **srvOut);
angle::Result getBuffer(const gl::Context *context,
BufferUsage usage,
ID3D11Buffer **bufferOut);
angle::Result getEmulatedIndexedBuffer(const gl::Context *context,
SourceIndexData *indexInfo,
const TranslatedAttribute &attribute,
GLint startVertex,
ID3D11Buffer **bufferOut);
angle::Result getConstantBufferRange(const gl::Context *context,
GLintptr offset,
GLsizeiptr size,
const d3d11::Buffer **bufferOut,
UINT *firstConstantOut,
UINT *numConstantsOut);
angle::Result getSRV(const gl::Context *context,
DXGI_FORMAT srvFormat,
const d3d11::ShaderResourceView **srvOut);
bool isMapped() const { return mMappedStorage != nullptr; }
gl::Error packPixels(const gl::Context *context,
const gl::FramebufferAttachment &readAttachment,
const PackPixelsParams &params);
angle::Result packPixels(const gl::Context *context,
const gl::FramebufferAttachment &readAttachment,
const PackPixelsParams &params);
size_t getTotalCPUBufferMemoryBytes() const;
// BufferD3D implementation
......@@ -122,33 +124,34 @@ class Buffer11 : public BufferD3D
};
void markBufferUsage(BufferUsage usage);
gl::Error garbageCollection(const gl::Context *context, BufferUsage currentUsage);
angle::Result garbageCollection(const gl::Context *context, BufferUsage currentUsage);
gl::Error updateBufferStorage(const gl::Context *context,
BufferStorage *storage,
size_t sourceOffset,
size_t storageSize);
angle::Result updateBufferStorage(const gl::Context *context,
BufferStorage *storage,
size_t sourceOffset,
size_t storageSize);
template <typename StorageOutT>
gl::Error getBufferStorage(const gl::Context *context,
BufferUsage usage,
StorageOutT **storageOut);
angle::Result getBufferStorage(const gl::Context *context,
BufferUsage usage,
StorageOutT **storageOut);
template <typename StorageOutT>
gl::Error getStagingStorage(const gl::Context *context, StorageOutT **storageOut);
angle::Result getStagingStorage(const gl::Context *context, StorageOutT **storageOut);
gl::Error getLatestBufferStorage(const gl::Context *context, BufferStorage **storageOut) const;
angle::Result getLatestBufferStorage(const gl::Context *context,
BufferStorage **storageOut) const;
gl::Error getConstantBufferRangeStorage(const gl::Context *context,
GLintptr offset,
GLsizeiptr size,
NativeStorage **storageOut);
angle::Result getConstantBufferRangeStorage(const gl::Context *context,
GLintptr offset,
GLsizeiptr size,
NativeStorage **storageOut);
BufferStorage *allocateStorage(BufferUsage usage);
void updateDeallocThreshold(BufferUsage usage);
// Free the storage if we decide it isn't being used very often.
gl::Error checkForDeallocation(const gl::Context *context, BufferUsage usage);
angle::Result checkForDeallocation(const gl::Context *context, BufferUsage usage);
// For some cases of uniform buffer storage, we can't deallocate system memory storage.
bool canDeallocateSystemMemory() const;
......
......@@ -38,9 +38,9 @@ class Clear11 : angle::NonCopyable
~Clear11();
// Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
gl::Error clearFramebuffer(const gl::Context *context,
const ClearParameters &clearParams,
const gl::FramebufferState &fboData);
angle::Result clearFramebuffer(const gl::Context *context,
const ClearParameters &clearParams,
const gl::FramebufferState &fboData);
private:
class ShaderManager final : angle::NonCopyable
......@@ -48,14 +48,15 @@ class Clear11 : angle::NonCopyable
public:
ShaderManager();
~ShaderManager();
gl::Error getShadersAndLayout(Renderer11 *renderer,
const INT clearType,
const uint32_t numRTs,
const bool hasLayeredLayout,
const d3d11::InputLayout **il,
const d3d11::VertexShader **vs,
const d3d11::GeometryShader **gs,
const d3d11::PixelShader **ps);
angle::Result getShadersAndLayout(const gl::Context *context,
Renderer11 *renderer,
const INT clearType,
const uint32_t numRTs,
const bool hasLayeredLayout,
const d3d11::InputLayout **il,
const d3d11::VertexShader **vs,
const d3d11::GeometryShader **gs,
const d3d11::PixelShader **ps);
private:
constexpr static size_t kNumShaders = D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT;
......@@ -73,9 +74,9 @@ class Clear11 : angle::NonCopyable
};
bool useVertexBuffer() const;
gl::Error ensureConstantBufferCreated();
gl::Error ensureVertexBufferCreated();
gl::Error ensureResourcesInitialized();
angle::Result ensureConstantBufferCreated(const gl::Context *context);
angle::Result ensureVertexBufferCreated(const gl::Context *context);
angle::Result ensureResourcesInitialized(const gl::Context *context);
Renderer11 *mRenderer;
bool mResourcesInitialized;
......
......@@ -106,6 +106,16 @@ gl::Error ReadbackIndirectBuffer(const gl::Context *context,
return gl::NoError();
}
GLenum DefaultGLErrorCode(HRESULT hr)
{
switch (hr)
{
case E_OUTOFMEMORY:
return GL_OUT_OF_MEMORY;
default:
return GL_INVALID_OPERATION;
}
}
} // anonymous namespace
Context11::Context11(const gl::ContextState &state, Renderer11 *renderer)
......@@ -485,8 +495,8 @@ gl::Error Context11::dispatchComputeIndirect(const gl::Context *context, GLintpt
return gl::InternalError();
}
gl::Error Context11::triggerDrawCallProgramRecompilation(const gl::Context *context,
gl::PrimitiveMode drawMode)
angle::Result Context11::triggerDrawCallProgramRecompilation(const gl::Context *context,
gl::PrimitiveMode drawMode)
{
const auto &glState = context->getGLState();
const auto *va11 = GetImplAs<VertexArray11>(glState.getVertexArray());
......@@ -503,53 +513,50 @@ gl::Error Context11::triggerDrawCallProgramRecompilation(const gl::Context *cont
if (!recompileVS && !recompileGS && !recompilePS)
{
return gl::NoError();
return angle::Result::Continue();
}
// Load the compiler if necessary and recompile the programs.
ANGLE_TRY(mRenderer->ensureHLSLCompilerInitialized(context));
ANGLE_TRY_HANDLE(context, mRenderer->ensureHLSLCompilerInitialized(context));
gl::InfoLog infoLog;
if (recompileVS)
{
ShaderExecutableD3D *vertexExe = nullptr;
ANGLE_TRY(
programD3D->getVertexExecutableForCachedInputLayout(context, &vertexExe, &infoLog));
ANGLE_TRY_HANDLE(context, programD3D->getVertexExecutableForCachedInputLayout(
context, &vertexExe, &infoLog));
if (!programD3D->hasVertexExecutableForCachedInputLayout())
{
ASSERT(infoLog.getLength() > 0);
ERR() << "Dynamic recompilation error log: " << infoLog.str();
return gl::InternalError()
<< "Error compiling dynamic vertex executable:" << infoLog.str();
ERR() << "Error compiling dynamic vertex executable: " << infoLog.str();
ANGLE_TRY_HR(this, E_FAIL, "Error compiling dynamic vertex executable");
}
}
if (recompileGS)
{
ShaderExecutableD3D *geometryExe = nullptr;
ANGLE_TRY(programD3D->getGeometryExecutableForPrimitiveType(context, drawMode, &geometryExe,
&infoLog));
ANGLE_TRY_HANDLE(context, programD3D->getGeometryExecutableForPrimitiveType(
context, drawMode, &geometryExe, &infoLog));
if (!programD3D->hasGeometryExecutableForPrimitiveType(drawMode))
{
ASSERT(infoLog.getLength() > 0);
ERR() << "Dynamic recompilation error log: " << infoLog.str();
return gl::InternalError()
<< "Error compiling dynamic geometry executable:" << infoLog.str();
ERR() << "Error compiling dynamic geometry executable: " << infoLog.str();
ANGLE_TRY_HR(this, E_FAIL, "Error compiling dynamic geometry executable");
}
}
if (recompilePS)
{
ShaderExecutableD3D *pixelExe = nullptr;
ANGLE_TRY(
programD3D->getPixelExecutableForCachedOutputLayout(context, &pixelExe, &infoLog));
ANGLE_TRY_HANDLE(context, programD3D->getPixelExecutableForCachedOutputLayout(
context, &pixelExe, &infoLog));
if (!programD3D->hasPixelExecutableForCachedOutputLayout())
{
ASSERT(infoLog.getLength() > 0);
ERR() << "Dynamic recompilation error log: " << infoLog.str();
return gl::InternalError()
<< "Error compiling dynamic pixel executable:" << infoLog.str();
ERR() << "Error compiling dynamic pixel executable: " << infoLog.str();
ANGLE_TRY_HR(this, E_FAIL, "Error compiling dynamic pixel executable");
}
}
......@@ -559,14 +566,14 @@ gl::Error Context11::triggerDrawCallProgramRecompilation(const gl::Context *cont
mMemoryProgramCache->updateProgram(context, program);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Context11::prepareForDrawCall(const gl::Context *context,
const gl::DrawCallParams &drawCallParams)
angle::Result Context11::prepareForDrawCall(const gl::Context *context,
const gl::DrawCallParams &drawCallParams)
{
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, drawCallParams));
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Context11::memoryBarrier(const gl::Context *context, GLbitfield barriers)
......@@ -597,4 +604,32 @@ gl::Error Context11::initializeMultisampleTextureToBlack(const gl::Context *cont
return mRenderer->clearRenderTarget(context, renderTarget, gl::ColorF(0.0f, 0.0f, 0.0f, 1.0f),
1.0f, 0);
}
void Context11::handleError(HRESULT hr,
const char *message,
const char *file,
const char *function,
unsigned int line)
{
ASSERT(FAILED(hr));
if (d3d11::isDeviceLostError(hr))
{
mRenderer->notifyDeviceLost();
}
GLenum glErrorCode = DefaultGLErrorCode(hr);
std::stringstream errorStream;
errorStream << "Internal D3D11 error: " << gl::FmtHR(hr) << ", in " << file << ", " << function
<< ":" << line << ". " << message;
mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str()));
}
// TODO(jmadill): Remove this once refactor is complete. http://anglebug.com/2738
void Context11::handleError(const gl::Error &error)
{
mErrors->handleError(error);
}
} // namespace rx
......@@ -147,8 +147,8 @@ class Context11 : public ContextImpl, public MultisampleTextureInitializer
gl::Error memoryBarrier(const gl::Context *context, GLbitfield barriers) override;
gl::Error memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
gl::Error triggerDrawCallProgramRecompilation(const gl::Context *context,
gl::PrimitiveMode drawMode);
angle::Result triggerDrawCallProgramRecompilation(const gl::Context *context,
gl::PrimitiveMode drawMode);
gl::Error getIncompleteTexture(const gl::Context *context,
gl::TextureType type,
......@@ -157,9 +157,18 @@ class Context11 : public ContextImpl, public MultisampleTextureInitializer
gl::Error initializeMultisampleTextureToBlack(const gl::Context *context,
gl::Texture *glTexture) override;
void handleError(HRESULT hr,
const char *message,
const char *file,
const char *function,
unsigned int line);
// TODO(jmadill): Remove this once refactor is complete. http://anglebug.com/2738
void handleError(const gl::Error &error);
private:
gl::Error prepareForDrawCall(const gl::Context *context,
const gl::DrawCallParams &drawCallParams);
angle::Result prepareForDrawCall(const gl::Context *context,
const gl::DrawCallParams &drawCallParams);
Renderer11 *mRenderer;
IncompleteTextureSet mIncompleteTextures;
......
......@@ -8,9 +8,11 @@
// rx::FenceNVImpl and rx::SyncImpl.
#include "libANGLE/renderer/d3d/d3d11/Fence11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/d3d/d3d11/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
namespace rx
{
......@@ -20,7 +22,7 @@ namespace rx
//
template <class FenceClass>
gl::Error FenceSetHelper(FenceClass *fence)
angle::Result FenceSetHelper(const gl::Context *context, FenceClass *fence)
{
if (!fence->mQuery)
{
......@@ -28,34 +30,33 @@ gl::Error FenceSetHelper(FenceClass *fence)
queryDesc.Query = D3D11_QUERY_EVENT;
queryDesc.MiscFlags = 0;
Context11 *context11 = GetImplAs<Context11>(context);
HRESULT result = fence->mRenderer->getDevice()->CreateQuery(&queryDesc, &fence->mQuery);
if (FAILED(result))
{
return gl::OutOfMemory() << "Failed to create event query, " << gl::FmtHR(result);
}
ANGLE_TRY_HR(context11, result, "Failed to create event query");
}
fence->mRenderer->getDeviceContext()->End(fence->mQuery);
return gl::NoError();
return angle::Result::Continue();
}
template <class FenceClass>
gl::Error FenceTestHelper(FenceClass *fence, bool flushCommandBuffer, GLboolean *outFinished)
angle::Result FenceTestHelper(const gl::Context *context,
FenceClass *fence,
bool flushCommandBuffer,
GLboolean *outFinished)
{
ASSERT(fence->mQuery);
UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
Context11 *context11 = GetImplAs<Context11>(context);
HRESULT result =
fence->mRenderer->getDeviceContext()->GetData(fence->mQuery, nullptr, 0, getDataFlags);
if (FAILED(result))
{
return gl::OutOfMemory() << "Failed to get query data, " << gl::FmtHR(result);
}
ANGLE_TRY_HR(context11, result, "Failed to get query data");
ASSERT(result == S_OK || result == S_FALSE);
*outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE);
return gl::NoError();
return angle::Result::Continue();
}
//
......@@ -73,12 +74,12 @@ FenceNV11::~FenceNV11()
gl::Error FenceNV11::set(const gl::Context *context, GLenum condition)
{
return FenceSetHelper(this);
return FenceSetHelper(context, this);
}
gl::Error FenceNV11::test(const gl::Context *context, GLboolean *outFinished)
{
return FenceTestHelper(this, true, outFinished);
return FenceTestHelper(context, this, true, outFinished);
}
gl::Error FenceNV11::finish(const gl::Context *context)
......@@ -89,7 +90,7 @@ gl::Error FenceNV11::finish(const gl::Context *context)
while (finished != GL_TRUE)
{
loopCount++;
ANGLE_TRY(FenceTestHelper(this, true, &finished));
ANGLE_TRY(FenceTestHelper(context, this, true, &finished));
bool checkDeviceLost = (loopCount % kPollingD3DDeviceLostCheckFrequency) == 0;
if (checkDeviceLost && mRenderer->testDeviceLost())
......@@ -135,7 +136,7 @@ Sync11::~Sync11()
gl::Error Sync11::set(const gl::Context *context, GLenum condition, GLbitfield flags)
{
ASSERT(condition == GL_SYNC_GPU_COMMANDS_COMPLETE && flags == 0);
return FenceSetHelper(this);
return FenceSetHelper(context, this);
}
gl::Error Sync11::clientWait(const gl::Context *context,
......@@ -148,7 +149,7 @@ gl::Error Sync11::clientWait(const gl::Context *context,
bool flushCommandBuffer = ((flags & GL_SYNC_FLUSH_COMMANDS_BIT) != 0);
GLboolean result = GL_FALSE;
gl::Error error = FenceTestHelper(this, flushCommandBuffer, &result);
gl::Error error = FenceTestHelper(context, this, flushCommandBuffer, &result);
if (error.isError())
{
*outResult = GL_WAIT_FAILED;
......@@ -188,7 +189,7 @@ gl::Error Sync11::clientWait(const gl::Context *context,
success = QueryPerformanceCounter(&currentCounter);
ASSERT(success);
error = FenceTestHelper(this, flushCommandBuffer, &result);
error = FenceTestHelper(context, this, flushCommandBuffer, &result);
if (error.isError())
{
*outResult = GL_WAIT_FAILED;
......@@ -226,8 +227,8 @@ gl::Error Sync11::serverWait(const gl::Context *context, GLbitfield flags, GLuin
gl::Error Sync11::getStatus(const gl::Context *context, GLint *outResult)
{
GLboolean result = GL_FALSE;
gl::Error error = FenceTestHelper(this, false, &result);
if (error.isError())
angle::Result error = FenceTestHelper(context, this, false, &result);
if (error == angle::Result::Stop())
{
// The spec does not specify any way to report errors during the status test (e.g. device
// lost) so we report the fence is unblocked in case of error or signaled.
......
......@@ -28,8 +28,13 @@ class FenceNV11 : public FenceNVImpl
gl::Error finish(const gl::Context *context) override;
private:
template<class T> friend gl::Error FenceSetHelper(T *fence);
template<class T> friend gl::Error FenceTestHelper(T *fence, bool flushCommandBuffer, GLboolean *outFinished);
template <class T>
friend angle::Result FenceSetHelper(const gl::Context *context, T *fence);
template <class T>
friend angle::Result FenceTestHelper(const gl::Context *context,
T *fence,
bool flushCommandBuffer,
GLboolean *outFinished);
Renderer11 *mRenderer;
ID3D11Query *mQuery;
......@@ -50,8 +55,13 @@ class Sync11 : public SyncImpl
gl::Error getStatus(const gl::Context *context, GLint *outResult) override;
private:
template<class T> friend gl::Error FenceSetHelper(T *fence);
template<class T> friend gl::Error FenceTestHelper(T *fence, bool flushCommandBuffer, GLboolean *outFinished);
template <class T>
friend angle::Result FenceSetHelper(const gl::Context *context, T *fence);
template <class T>
friend angle::Result FenceTestHelper(const gl::Context *context,
T *fence,
bool flushCommandBuffer,
GLboolean *outFinished);
Renderer11 *mRenderer;
ID3D11Query *mQuery;
......
......@@ -30,8 +30,8 @@ namespace rx
namespace
{
gl::Error MarkAttachmentsDirty(const gl::Context *context,
const gl::FramebufferAttachment *attachment)
angle::Result MarkAttachmentsDirty(const gl::Context *context,
const gl::FramebufferAttachment *attachment)
{
if (attachment->type() == GL_TEXTURE)
{
......@@ -40,7 +40,7 @@ gl::Error MarkAttachmentsDirty(const gl::Context *context,
TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture);
TextureStorage *texStorage = nullptr;
ANGLE_TRY(textureD3D->getNativeTexture(context, &texStorage));
ANGLE_TRY_HANDLE(context, textureD3D->getNativeTexture(context, &texStorage));
if (texStorage)
{
......@@ -51,7 +51,7 @@ gl::Error MarkAttachmentsDirty(const gl::Context *context,
}
}
return gl::NoError();
return angle::Result::Continue();
}
} // anonymous namespace
......@@ -65,7 +65,7 @@ Framebuffer11::~Framebuffer11()
{
}
gl::Error Framebuffer11::markAttachmentsDirty(const gl::Context *context) const
angle::Result Framebuffer11::markAttachmentsDirty(const gl::Context *context) const
{
const auto &colorAttachments = mState.getColorAttachments();
for (size_t drawBuffer : mState.getEnabledDrawBuffers())
......@@ -81,7 +81,7 @@ gl::Error Framebuffer11::markAttachmentsDirty(const gl::Context *context) const
ANGLE_TRY(MarkAttachmentsDirty(context, dsAttachment));
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Framebuffer11::clearImpl(const gl::Context *context, const ClearParameters &clearParams)
......
......@@ -34,7 +34,7 @@ class Framebuffer11 : public FramebufferD3D
const gl::Rectangle &area) override;
// Invalidate the cached swizzles of all bound texture attachments.
gl::Error markAttachmentsDirty(const gl::Context *context) const;
angle::Result markAttachmentsDirty(const gl::Context *context) const;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
......
......@@ -20,6 +20,12 @@ namespace gl
class Framebuffer;
}
namespace d3d11
{
template <typename T>
class ScopedUnmapper;
} // namespace d3d11
namespace rx
{
class Renderer11;
......@@ -33,19 +39,19 @@ class Image11 : public ImageD3D
Image11(Renderer11 *renderer);
~Image11() override;
static gl::Error GenerateMipmap(const gl::Context *context,
Image11 *dest,
Image11 *src,
const Renderer11DeviceCaps &rendererCaps);
static gl::Error CopyImage(const gl::Context *context,
Image11 *dest,
Image11 *source,
const gl::Rectangle &sourceRect,
const gl::Offset &destOffset,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
const Renderer11DeviceCaps &rendererCaps);
static angle::Result GenerateMipmap(const gl::Context *context,
Image11 *dest,
Image11 *src,
const Renderer11DeviceCaps &rendererCaps);
static angle::Result CopyImage(const gl::Context *context,
Image11 *dest,
Image11 *source,
const gl::Rectangle &sourceRect,
const gl::Offset &destOffset,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
const Renderer11DeviceCaps &rendererCaps);
bool isDirty() const override;
......@@ -79,25 +85,27 @@ class Image11 : public ImageD3D
const gl::Rectangle &sourceArea,
const gl::Framebuffer *source) override;
gl::Error recoverFromAssociatedStorage(const gl::Context *context);
angle::Result recoverFromAssociatedStorage(const gl::Context *context);
void verifyAssociatedStorageValid(TextureStorage11 *textureStorage) const;
void disassociateStorage();
protected:
gl::Error map(const gl::Context *context, D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map);
template <typename T>
friend class d3d11::ScopedUnmapper;
angle::Result map(const gl::Context *context, D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map);
void unmap();
private:
gl::Error copyWithoutConversion(const gl::Context *context,
const gl::Offset &destOffset,
const gl::Box &sourceArea,
const TextureHelper11 &textureHelper,
UINT sourceSubResource);
gl::Error getStagingTexture(const gl::Context *context,
const TextureHelper11 **outStagingTexture,
unsigned int *outSubresourceIndex);
gl::Error createStagingTexture(const gl::Context *context);
angle::Result copyWithoutConversion(const gl::Context *context,
const gl::Offset &destOffset,
const gl::Box &sourceArea,
const TextureHelper11 &textureHelper,
UINT sourceSubResource);
angle::Result getStagingTexture(const gl::Context *context,
const TextureHelper11 **outStagingTexture,
unsigned int *outSubresourceIndex);
angle::Result createStagingTexture(const gl::Context *context);
void releaseStagingTexture();
Renderer11 *mRenderer;
......
......@@ -113,7 +113,7 @@ void InputLayoutCache::clear()
mLayoutCache.Clear();
}
gl::Error InputLayoutCache::getInputLayout(
angle::Result InputLayoutCache::getInputLayout(
const gl::Context *context,
Renderer11 *renderer,
const gl::State &state,
......@@ -190,10 +190,10 @@ gl::Error InputLayoutCache::getInputLayout(
}
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error InputLayoutCache::createInputLayout(
angle::Result InputLayoutCache::createInputLayout(
const gl::Context *context,
Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
......@@ -293,15 +293,17 @@ gl::Error InputLayoutCache::createInputLayout(
}
ShaderExecutableD3D *shader = nullptr;
ANGLE_TRY(programD3D->getVertexExecutableForCachedInputLayout(context, &shader, nullptr));
ANGLE_TRY_HANDLE(
context, programD3D->getVertexExecutableForCachedInputLayout(context, &shader, nullptr));
ShaderExecutableD3D *shader11 = GetAs<ShaderExecutable11>(shader);
InputElementArray inputElementArray(inputElements.data(), inputElementCount);
ShaderData vertexShaderData(shader11->getFunction(), shader11->getLength());
ANGLE_TRY(renderer->allocateResource(inputElementArray, &vertexShaderData, inputLayoutOut));
return gl::NoError();
ANGLE_TRY_HANDLE(
context, renderer->allocateResource(inputElementArray, &vertexShaderData, inputLayoutOut));
return angle::Result::Continue();
}
void InputLayoutCache::setCacheSize(size_t newCacheSize)
......
......@@ -88,22 +88,23 @@ class InputLayoutCache : angle::NonCopyable
// Useful for testing
void setCacheSize(size_t newCacheSize);
gl::Error getInputLayout(const gl::Context *context,
Renderer11 *renderer,
const gl::State &state,
const std::vector<const TranslatedAttribute *> &currentAttributes,
const AttribIndexArray &sortedSemanticIndices,
const gl::DrawCallParams &drawCallParams,
const d3d11::InputLayout **inputLayoutOut);
angle::Result getInputLayout(const gl::Context *context,
Renderer11 *renderer,
const gl::State &state,
const std::vector<const TranslatedAttribute *> &currentAttributes,
const AttribIndexArray &sortedSemanticIndices,
const gl::DrawCallParams &drawCallParams,
const d3d11::InputLayout **inputLayoutOut);
private:
gl::Error createInputLayout(const gl::Context *context,
Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
const std::vector<const TranslatedAttribute *> &currentAttributes,
gl::Program *program,
const gl::DrawCallParams &drawCallParams,
d3d11::InputLayout *inputLayoutOut);
angle::Result createInputLayout(
const gl::Context *context,
Renderer11 *renderer,
const AttribIndexArray &sortedSemanticIndices,
const std::vector<const TranslatedAttribute *> &currentAttributes,
gl::Program *program,
const gl::DrawCallParams &drawCallParams,
d3d11::InputLayout *inputLayoutOut);
// Starting cache size.
static constexpr size_t kDefaultCacheSize = 1024;
......
......@@ -48,11 +48,11 @@ PixelTransfer11::~PixelTransfer11()
{
}
gl::Error PixelTransfer11::loadResources()
angle::Result PixelTransfer11::loadResources(const gl::Context *context)
{
if (mResourcesLoaded)
{
return gl::NoError();
return angle::Result::Continue();
}
D3D11_RASTERIZER_DESC rasterDesc;
......@@ -67,7 +67,7 @@ gl::Error PixelTransfer11::loadResources()
rasterDesc.MultisampleEnable = FALSE;
rasterDesc.AntialiasedLineEnable = FALSE;
ANGLE_TRY(mRenderer->allocateResource(rasterDesc, &mCopyRasterizerState));
ANGLE_TRY_HANDLE(context, mRenderer->allocateResource(rasterDesc, &mCopyRasterizerState));
D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
depthStencilDesc.DepthEnable = true;
......@@ -85,7 +85,8 @@ gl::Error PixelTransfer11::loadResources()
depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
ANGLE_TRY(mRenderer->allocateResource(depthStencilDesc, &mCopyDepthStencilState));
ANGLE_TRY_HANDLE(context,
mRenderer->allocateResource(depthStencilDesc, &mCopyDepthStencilState));
D3D11_BUFFER_DESC constantBufferDesc = { 0 };
constantBufferDesc.ByteWidth = roundUp<UINT>(sizeof(CopyShaderParams), 32u);
......@@ -95,23 +96,26 @@ gl::Error PixelTransfer11::loadResources()
constantBufferDesc.MiscFlags = 0;
constantBufferDesc.StructureByteStride = 0;
ANGLE_TRY(mRenderer->allocateResource(constantBufferDesc, &mParamsConstantBuffer));
ANGLE_TRY_HANDLE(context,
mRenderer->allocateResource(constantBufferDesc, &mParamsConstantBuffer));
mParamsConstantBuffer.setDebugName("PixelTransfer11 constant buffer");
// init shaders
ANGLE_TRY(mRenderer->allocateResource(ShaderData(g_VS_BufferToTexture), &mBufferToTextureVS));
ANGLE_TRY_HANDLE(context, mRenderer->allocateResource(ShaderData(g_VS_BufferToTexture),
&mBufferToTextureVS));
mBufferToTextureVS.setDebugName("BufferToTexture VS");
ANGLE_TRY(mRenderer->allocateResource(ShaderData(g_GS_BufferToTexture), &mBufferToTextureGS));
ANGLE_TRY_HANDLE(context, mRenderer->allocateResource(ShaderData(g_GS_BufferToTexture),
&mBufferToTextureGS));
mBufferToTextureGS.setDebugName("BufferToTexture GS");
ANGLE_TRY(buildShaderMap());
ANGLE_TRY(buildShaderMap(context));
StructZero(&mParamsData);
mResourcesLoaded = true;
return gl::NoError();
return angle::Result::Continue();
}
void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
......@@ -137,15 +141,15 @@ void PixelTransfer11::setBufferToTextureCopyParams(const gl::Box &destArea, cons
parametersOut->FirstSlice = destArea.z;
}
gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context,
const gl::PixelUnpackState &unpack,
unsigned int offset,
RenderTargetD3D *destRenderTarget,
GLenum destinationFormat,
GLenum sourcePixelsType,
const gl::Box &destArea)
angle::Result PixelTransfer11::copyBufferToTexture(const gl::Context *context,
const gl::PixelUnpackState &unpack,
unsigned int offset,
RenderTargetD3D *destRenderTarget,
GLenum destinationFormat,
GLenum sourcePixelsType,
const gl::Box &destArea)
{
ANGLE_TRY(loadResources());
ANGLE_TRY(loadResources(context));
gl::Extents destSize = destRenderTarget->getExtents();
......@@ -216,21 +220,21 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context,
UINT numPixels = (destArea.width * destArea.height * destArea.depth);
deviceContext->Draw(numPixels, 0);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error PixelTransfer11::buildShaderMap()
angle::Result PixelTransfer11::buildShaderMap(const gl::Context *context)
{
d3d11::PixelShader bufferToTextureFloat;
d3d11::PixelShader bufferToTextureInt;
d3d11::PixelShader bufferToTextureUint;
ANGLE_TRY(
mRenderer->allocateResource(ShaderData(g_PS_BufferToTexture_4F), &bufferToTextureFloat));
ANGLE_TRY(
mRenderer->allocateResource(ShaderData(g_PS_BufferToTexture_4I), &bufferToTextureInt));
ANGLE_TRY(
mRenderer->allocateResource(ShaderData(g_PS_BufferToTexture_4UI), &bufferToTextureUint));
ANGLE_TRY_HANDLE(context, mRenderer->allocateResource(ShaderData(g_PS_BufferToTexture_4F),
&bufferToTextureFloat));
ANGLE_TRY_HANDLE(context, mRenderer->allocateResource(ShaderData(g_PS_BufferToTexture_4I),
&bufferToTextureInt));
ANGLE_TRY_HANDLE(context, mRenderer->allocateResource(ShaderData(g_PS_BufferToTexture_4UI),
&bufferToTextureUint));
bufferToTextureFloat.setDebugName("BufferToTexture RGBA ps");
bufferToTextureInt.setDebugName("BufferToTexture RGBA-I ps");
......@@ -240,7 +244,7 @@ gl::Error PixelTransfer11::buildShaderMap()
mBufferToTexturePSMap[GL_INT] = std::move(bufferToTextureInt);
mBufferToTexturePSMap[GL_UNSIGNED_INT] = std::move(bufferToTextureUint);
return gl::NoError();
return angle::Result::Continue();
}
const d3d11::PixelShader *PixelTransfer11::findBufferToTexturePS(GLenum internalFormat) const
......
......@@ -45,13 +45,13 @@ class PixelTransfer11
// destRenderTarget: individual slice/layer of a target texture
// destinationFormat/sourcePixelsType: determines shaders + shader parameters
// destArea: the sub-section of destRenderTarget to copy to
gl::Error copyBufferToTexture(const gl::Context *context,
const gl::PixelUnpackState &unpack,
unsigned int offset,
RenderTargetD3D *destRenderTarget,
GLenum destinationFormat,
GLenum sourcePixelsType,
const gl::Box &destArea);
angle::Result copyBufferToTexture(const gl::Context *context,
const gl::PixelUnpackState &unpack,
unsigned int offset,
RenderTargetD3D *destRenderTarget,
GLenum destinationFormat,
GLenum sourcePixelsType,
const gl::Box &destArea);
private:
......@@ -71,8 +71,8 @@ class PixelTransfer11
static void setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat,
const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut);
gl::Error loadResources();
gl::Error buildShaderMap();
angle::Result loadResources(const gl::Context *context);
angle::Result buildShaderMap(const gl::Context *context);
const d3d11::PixelShader *findBufferToTexturePS(GLenum internalFormat) const;
Renderer11 *mRenderer;
......
......@@ -11,6 +11,8 @@
#include <GLES2/gl2ext.h>
#include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/d3d/d3d11/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
......@@ -72,12 +74,12 @@ gl::Error Query11::begin(const gl::Context *context)
{
mResultSum = 0;
mRenderer->getStateManager()->onBeginQuery(this);
return resume();
return resume(GetImplAs<Context11>(context));
}
gl::Error Query11::end(const gl::Context *context)
{
return pause();
return pause(GetImplAs<Context11>(context));
}
gl::Error Query11::queryCounter(const gl::Context *context)
......@@ -90,45 +92,45 @@ gl::Error Query11::queryCounter(const gl::Context *context)
}
template <typename T>
gl::Error Query11::getResultBase(T *params)
angle::Result Query11::getResultBase(Context11 *context11, T *params)
{
ASSERT(!mActiveQuery->query.valid());
ANGLE_TRY(flush(true));
ANGLE_TRY(flush(context11, true));
ASSERT(mPendingQueries.empty());
*params = static_cast<T>(mResultSum);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Query11::getResult(const gl::Context *context, GLint *params)
{
return getResultBase(params);
return getResultBase(GetImplAs<Context11>(context), params);
}
gl::Error Query11::getResult(const gl::Context *context, GLuint *params)
{
return getResultBase(params);
return getResultBase(GetImplAs<Context11>(context), params);
}
gl::Error Query11::getResult(const gl::Context *context, GLint64 *params)
{
return getResultBase(params);
return getResultBase(GetImplAs<Context11>(context), params);
}
gl::Error Query11::getResult(const gl::Context *context, GLuint64 *params)
{
return getResultBase(params);
return getResultBase(GetImplAs<Context11>(context), params);
}
gl::Error Query11::isResultAvailable(const gl::Context *context, bool *available)
{
ANGLE_TRY(flush(false));
ANGLE_TRY(flush(GetImplAs<Context11>(context), false));
*available = mPendingQueries.empty();
return gl::NoError();
}
gl::Error Query11::pause()
angle::Result Query11::pause(Context11 *context11)
{
if (mActiveQuery->query.valid())
{
......@@ -147,14 +149,14 @@ gl::Error Query11::pause()
mActiveQuery = std::unique_ptr<QueryState>(new QueryState());
}
return flush(false);
return flush(context11, false);
}
gl::Error Query11::resume()
angle::Result Query11::resume(Context11 *context11)
{
if (!mActiveQuery->query.valid())
{
ANGLE_TRY(flush(false));
ANGLE_TRY(flush(context11, false));
gl::QueryType type = getType();
D3D11_QUERY d3dQueryType = gl_d3d11::ConvertQueryType(type);
......@@ -163,7 +165,7 @@ gl::Error Query11::resume()
queryDesc.Query = d3dQueryType;
queryDesc.MiscFlags = 0;
ANGLE_TRY(mRenderer->allocateResource(queryDesc, &mActiveQuery->query));
ANGLE_TRY_HANDLE(context11, mRenderer->allocateResource(queryDesc, &mActiveQuery->query));
// If we are doing time elapsed we also need a query to actually query the timestamp
if (type == gl::QueryType::TimeElapsed)
......@@ -172,8 +174,10 @@ gl::Error Query11::resume()
desc.Query = D3D11_QUERY_TIMESTAMP;
desc.MiscFlags = 0;
ANGLE_TRY(mRenderer->allocateResource(desc, &mActiveQuery->beginTimestamp));
ANGLE_TRY(mRenderer->allocateResource(desc, &mActiveQuery->endTimestamp));
ANGLE_TRY_HANDLE(context11,
mRenderer->allocateResource(desc, &mActiveQuery->beginTimestamp));
ANGLE_TRY_HANDLE(context11,
mRenderer->allocateResource(desc, &mActiveQuery->endTimestamp));
}
ID3D11DeviceContext *context = mRenderer->getDeviceContext();
......@@ -190,10 +194,10 @@ gl::Error Query11::resume()
}
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Query11::flush(bool force)
angle::Result Query11::flush(Context11 *context11, bool force)
{
while (!mPendingQueries.empty())
{
......@@ -201,10 +205,10 @@ gl::Error Query11::flush(bool force)
do
{
ANGLE_TRY(testQuery(query));
ANGLE_TRY(testQuery(context11, query));
if (!query->finished && !force)
{
return gl::NoError();
return angle::Result::Continue();
}
} while (!query->finished);
......@@ -212,10 +216,10 @@ gl::Error Query11::flush(bool force)
mPendingQueries.pop_front();
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Query11::testQuery(QueryState *queryState)
angle::Result Query11::testQuery(Context11 *context11, QueryState *queryState)
{
if (!queryState->finished)
{
......@@ -229,11 +233,7 @@ gl::Error Query11::testQuery(QueryState *queryState)
UINT64 numPixels = 0;
HRESULT result =
context->GetData(queryState->query.get(), &numPixels, sizeof(numPixels), 0);
if (FAILED(result))
{
return gl::OutOfMemory()
<< "Failed to get the data of an internal query, " << gl::FmtHR(result);
}
ANGLE_TRY_HR(context11, result, "Failed to get the data of an internal query");
if (result == S_OK)
{
......@@ -249,11 +249,7 @@ gl::Error Query11::testQuery(QueryState *queryState)
D3D11_QUERY_DATA_SO_STATISTICS soStats = {0};
HRESULT result =
context->GetData(queryState->query.get(), &soStats, sizeof(soStats), 0);
if (FAILED(result))
{
return gl::OutOfMemory()
<< "Failed to get the data of an internal query, " << gl::FmtHR(result);
}
ANGLE_TRY_HR(context11, result, "Failed to get the data of an internal query");
if (result == S_OK)
{
......@@ -271,30 +267,20 @@ gl::Error Query11::testQuery(QueryState *queryState)
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT timeStats = {0};
HRESULT result =
context->GetData(queryState->query.get(), &timeStats, sizeof(timeStats), 0);
if (FAILED(result))
{
return gl::OutOfMemory()
<< "Failed to get the data of an internal query, " << gl::FmtHR(result);
}
ANGLE_TRY_HR(context11, result, "Failed to get the data of an internal query");
if (result == S_OK)
{
UINT64 beginTime = 0;
HRESULT beginRes = context->GetData(queryState->beginTimestamp.get(),
&beginTime, sizeof(UINT64), 0);
if (FAILED(beginRes))
{
return gl::OutOfMemory() << "Failed to get the data of an internal query, "
<< gl::FmtHR(beginRes);
}
ANGLE_TRY_HR(context11, beginRes,
"Failed to get the data of an internal query");
UINT64 endTime = 0;
HRESULT endRes = context->GetData(queryState->endTimestamp.get(), &endTime,
sizeof(UINT64), 0);
if (FAILED(endRes))
{
return gl::OutOfMemory() << "Failed to get the data of an internal query, "
<< gl::FmtHR(endRes);
}
ANGLE_TRY_HR(context11, endRes, "Failed to get the data of an internal query");
if (beginRes == S_OK && endRes == S_OK)
{
......@@ -343,11 +329,7 @@ gl::Error Query11::testQuery(QueryState *queryState)
BOOL completed = 0;
HRESULT result =
context->GetData(queryState->query.get(), &completed, sizeof(completed), 0);
if (FAILED(result))
{
return gl::OutOfMemory()
<< "Failed to get the data of an internal query, " << gl::FmtHR(result);
}
ANGLE_TRY_HR(context11, result, "Failed to get the data of an internal query");
if (result == S_OK)
{
......@@ -369,11 +351,12 @@ gl::Error Query11::testQuery(QueryState *queryState)
if (!queryState->finished && checkDeviceLost && mRenderer->testDeviceLost())
{
mRenderer->notifyDeviceLost();
return gl::OutOfMemory() << "Failed to test get query result, device is lost.";
ANGLE_TRY_HR(context11, E_OUTOFMEMORY,
"Failed to test get query result, device is lost.");
}
}
return gl::NoError();
return angle::Result::Continue();
}
} // namespace rx
......@@ -16,6 +16,7 @@
namespace rx
{
class Context11;
class Renderer11;
class Query11 : public QueryImpl
......@@ -33,8 +34,8 @@ class Query11 : public QueryImpl
gl::Error getResult(const gl::Context *context, GLuint64 *params) override;
gl::Error isResultAvailable(const gl::Context *context, bool *available) override;
gl::Error pause();
gl::Error resume();
angle::Result pause(Context11 *context11);
angle::Result resume(Context11 *context11);
private:
struct QueryState final : private angle::NonCopyable
......@@ -50,11 +51,11 @@ class Query11 : public QueryImpl
bool finished;
};
gl::Error flush(bool force);
gl::Error testQuery(QueryState *queryState);
angle::Result flush(Context11 *context11, bool force);
angle::Result testQuery(Context11 *context11, QueryState *queryState);
template <typename T>
gl::Error getResultBase(T *params);
angle::Result getResultBase(Context11 *context11, T *params);
GLuint64 mResult;
GLuint64 mResultSum;
......
......@@ -12,6 +12,7 @@
#include <float.h>
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/d3d/d3d11/Framebuffer11.h"
......@@ -70,15 +71,16 @@ d3d11::BlendStateKey RenderStateCache::GetBlendStateKey(const gl::Context *conte
return key;
}
gl::Error RenderStateCache::getBlendState(Renderer11 *renderer,
const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState)
angle::Result RenderStateCache::getBlendState(const gl::Context *context,
Renderer11 *renderer,
const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState)
{
auto keyIter = mBlendStateCache.Get(key);
if (keyIter != mBlendStateCache.end())
{
*outBlendState = &keyIter->second;
return gl::NoError();
return angle::Result::Continue();
}
TrimCache(kMaxStates, kGCLimit, "blend state", &mBlendStateCache);
......@@ -113,18 +115,19 @@ gl::Error RenderStateCache::getBlendState(Renderer11 *renderer,
}
d3d11::BlendState d3dBlendState;
ANGLE_TRY(renderer->allocateResource(blendDesc, &d3dBlendState));
ANGLE_TRY_HANDLE(context, renderer->allocateResource(blendDesc, &d3dBlendState));
const auto &iter = mBlendStateCache.Put(key, std::move(d3dBlendState));
*outBlendState = &iter->second;
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RenderStateCache::getRasterizerState(Renderer11 *renderer,
const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState)
angle::Result RenderStateCache::getRasterizerState(const gl::Context *context,
Renderer11 *renderer,
const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState)
{
d3d11::RasterizerStateKey key;
key.rasterizerState = rasterState;
......@@ -134,7 +137,7 @@ gl::Error RenderStateCache::getRasterizerState(Renderer11 *renderer,
if (keyIter != mRasterizerStateCache.end())
{
*outRasterizerState = keyIter->second.get();
return gl::NoError();
return angle::Result::Continue();
}
TrimCache(kMaxStates, kGCLimit, "rasterizer state", &mRasterizerStateCache);
......@@ -171,22 +174,23 @@ gl::Error RenderStateCache::getRasterizerState(Renderer11 *renderer,
}
d3d11::RasterizerState dx11RasterizerState;
ANGLE_TRY(renderer->allocateResource(rasterDesc, &dx11RasterizerState));
ANGLE_TRY_HANDLE(context, renderer->allocateResource(rasterDesc, &dx11RasterizerState));
*outRasterizerState = dx11RasterizerState.get();
mRasterizerStateCache.Put(key, std::move(dx11RasterizerState));
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RenderStateCache::getDepthStencilState(Renderer11 *renderer,
const gl::DepthStencilState &glState,
const d3d11::DepthStencilState **outDSState)
angle::Result RenderStateCache::getDepthStencilState(const gl::Context *context,
Renderer11 *renderer,
const gl::DepthStencilState &glState,
const d3d11::DepthStencilState **outDSState)
{
auto keyIter = mDepthStencilStateCache.Get(glState);
if (keyIter != mDepthStencilStateCache.end())
{
*outDSState = &keyIter->second;
return gl::NoError();
return angle::Result::Continue();
}
TrimCache(kMaxStates, kGCLimit, "depth stencil state", &mDepthStencilStateCache);
......@@ -208,23 +212,24 @@ gl::Error RenderStateCache::getDepthStencilState(Renderer11 *renderer,
dsDesc.BackFace.StencilFunc = ConvertComparison(glState.stencilBackFunc);
d3d11::DepthStencilState dx11DepthStencilState;
ANGLE_TRY(renderer->allocateResource(dsDesc, &dx11DepthStencilState));
ANGLE_TRY_HANDLE(context, renderer->allocateResource(dsDesc, &dx11DepthStencilState));
const auto &iter = mDepthStencilStateCache.Put(glState, std::move(dx11DepthStencilState));
*outDSState = &iter->second;
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RenderStateCache::getSamplerState(Renderer11 *renderer,
const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState)
angle::Result RenderStateCache::getSamplerState(const gl::Context *context,
Renderer11 *renderer,
const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState)
{
auto keyIter = mSamplerStateCache.Get(samplerState);
if (keyIter != mSamplerStateCache.end())
{
*outSamplerState = keyIter->second.get();
return gl::NoError();
return angle::Result::Continue();
}
TrimCache(kMaxStates, kGCLimit, "sampler state", &mSamplerStateCache);
......@@ -262,11 +267,11 @@ gl::Error RenderStateCache::getSamplerState(Renderer11 *renderer,
}
d3d11::SamplerState dx11SamplerState;
ANGLE_TRY(renderer->allocateResource(samplerDesc, &dx11SamplerState));
ANGLE_TRY_HANDLE(context, renderer->allocateResource(samplerDesc, &dx11SamplerState));
*outSamplerState = dx11SamplerState.get();
mSamplerStateCache.Put(samplerState, std::move(dx11SamplerState));
return gl::NoError();
return angle::Result::Continue();
}
} // namespace rx
......@@ -70,19 +70,23 @@ class RenderStateCache : angle::NonCopyable
static d3d11::BlendStateKey GetBlendStateKey(const gl::Context *context,
Framebuffer11 *framebuffer11,
const gl::BlendState &blendState);
gl::Error getBlendState(Renderer11 *renderer,
const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState);
gl::Error getRasterizerState(Renderer11 *renderer,
const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState);
gl::Error getDepthStencilState(Renderer11 *renderer,
const gl::DepthStencilState &dsState,
const d3d11::DepthStencilState **outDSState);
gl::Error getSamplerState(Renderer11 *renderer,
const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState);
angle::Result getBlendState(const gl::Context *context,
Renderer11 *renderer,
const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState);
angle::Result getRasterizerState(const gl::Context *context,
Renderer11 *renderer,
const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState);
angle::Result getDepthStencilState(const gl::Context *context,
Renderer11 *renderer,
const gl::DepthStencilState &dsState,
const d3d11::DepthStencilState **outDSState);
angle::Result getSamplerState(const gl::Context *context,
Renderer11 *renderer,
const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState);
private:
// MSDN's documentation of ID3D11Device::CreateBlendState, ID3D11Device::CreateRasterizerState,
......
......@@ -3052,8 +3052,9 @@ gl::Error Renderer11::readFromAttachment(const gl::Context *context,
gl::Extents safeSize(safeArea.width, safeArea.height, 1);
TextureHelper11 stagingHelper;
ANGLE_TRY(createStagingTexture(textureHelper.getTextureType(), textureHelper.getFormatSet(),
safeSize, StagingAccess::READ, &stagingHelper));
ANGLE_TRY(createStagingTexture(context, textureHelper.getTextureType(),
textureHelper.getFormatSet(), safeSize, StagingAccess::READ,
&stagingHelper));
stagingHelper.setDebugName("readFromAttachment::stagingHelper");
TextureHelper11 resolvedTextureHelper;
......@@ -3126,10 +3127,10 @@ gl::Error Renderer11::readFromAttachment(const gl::Context *context,
return packPixels(context, stagingHelper, packParams, pixelsOut);
}
gl::Error Renderer11::packPixels(const gl::Context *context,
const TextureHelper11 &textureHelper,
const PackPixelsParams &params,
uint8_t *pixelsOut)
angle::Result Renderer11::packPixels(const gl::Context *context,
const TextureHelper11 &textureHelper,
const PackPixelsParams &params,
uint8_t *pixelsOut)
{
ID3D11Resource *readResource = textureHelper.get();
......@@ -3146,7 +3147,7 @@ gl::Error Renderer11::packPixels(const gl::Context *context,
mDeviceContext->Unmap(readResource, 0);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Renderer11::blitRenderbufferRect(const gl::Context *context,
......@@ -3682,11 +3683,12 @@ gl::Error Renderer11::dispatchCompute(const gl::Context *context,
return gl::NoError();
}
gl::Error Renderer11::createStagingTexture(ResourceType textureType,
const d3d11::Format &formatSet,
const gl::Extents &size,
StagingAccess readAndWriteAccess,
TextureHelper11 *textureOut)
angle::Result Renderer11::createStagingTexture(const gl::Context *context,
ResourceType textureType,
const d3d11::Format &formatSet,
const gl::Extents &size,
StagingAccess readAndWriteAccess,
TextureHelper11 *textureOut)
{
if (textureType == ResourceType::Texture2D)
{
......@@ -3708,8 +3710,8 @@ gl::Error Renderer11::createStagingTexture(ResourceType textureType,
stagingDesc.CPUAccessFlags |= D3D11_CPU_ACCESS_WRITE;
}
ANGLE_TRY(allocateTexture(stagingDesc, formatSet, textureOut));
return gl::NoError();
ANGLE_TRY_HANDLE(context, allocateTexture(stagingDesc, formatSet, textureOut));
return angle::Result::Continue();
}
ASSERT(textureType == ResourceType::Texture3D);
......@@ -3724,8 +3726,8 @@ gl::Error Renderer11::createStagingTexture(ResourceType textureType,
stagingDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
stagingDesc.MiscFlags = 0;
ANGLE_TRY(allocateTexture(stagingDesc, formatSet, textureOut));
return gl::NoError();
ANGLE_TRY_HANDLE(context, allocateTexture(stagingDesc, formatSet, textureOut));
return angle::Result::Continue();
}
gl::Error Renderer11::allocateTexture(const D3D11_TEXTURE2D_DESC &desc,
......@@ -3736,7 +3738,7 @@ gl::Error Renderer11::allocateTexture(const D3D11_TEXTURE2D_DESC &desc,
d3d11::Texture2D texture;
ANGLE_TRY(mResourceManager11.allocate(this, &desc, initData, &texture));
textureOut->init(std::move(texture), desc, format);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Renderer11::allocateTexture(const D3D11_TEXTURE3D_DESC &desc,
......@@ -3747,32 +3749,37 @@ gl::Error Renderer11::allocateTexture(const D3D11_TEXTURE3D_DESC &desc,
d3d11::Texture3D texture;
ANGLE_TRY(mResourceManager11.allocate(this, &desc, initData, &texture));
textureOut->init(std::move(texture), desc, format);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error Renderer11::getBlendState(const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState)
angle::Result Renderer11::getBlendState(const gl::Context *context,
const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState)
{
return mStateCache.getBlendState(this, key, outBlendState);
return mStateCache.getBlendState(context, this, key, outBlendState);
}
gl::Error Renderer11::getRasterizerState(const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState)
angle::Result Renderer11::getRasterizerState(const gl::Context *context,
const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState)
{
return mStateCache.getRasterizerState(this, rasterState, scissorEnabled, outRasterizerState);
return mStateCache.getRasterizerState(context, this, rasterState, scissorEnabled,
outRasterizerState);
}
gl::Error Renderer11::getDepthStencilState(const gl::DepthStencilState &dsState,
const d3d11::DepthStencilState **outDSState)
angle::Result Renderer11::getDepthStencilState(const gl::Context *context,
const gl::DepthStencilState &dsState,
const d3d11::DepthStencilState **outDSState)
{
return mStateCache.getDepthStencilState(this, dsState, outDSState);
return mStateCache.getDepthStencilState(context, this, dsState, outDSState);
}
gl::Error Renderer11::getSamplerState(const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState)
angle::Result Renderer11::getSamplerState(const gl::Context *context,
const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState)
{
return mStateCache.getSamplerState(this, samplerState, outSamplerState);
return mStateCache.getSamplerState(context, this, samplerState, outSamplerState);
}
gl::Error Renderer11::clearRenderTarget(const gl::Context *context,
......@@ -3823,28 +3830,16 @@ bool Renderer11::canSelectViewInVertexShader() const
getRenderer11DeviceCaps().supportsVpRtIndexWriteFromVertexShader;
}
gl::Error Renderer11::mapResource(const gl::Context *context,
ID3D11Resource *resource,
UINT subResource,
D3D11_MAP mapType,
UINT mapFlags,
D3D11_MAPPED_SUBRESOURCE *mappedResource)
angle::Result Renderer11::mapResource(const gl::Context *context,
ID3D11Resource *resource,
UINT subResource,
D3D11_MAP mapType,
UINT mapFlags,
D3D11_MAPPED_SUBRESOURCE *mappedResource)
{
HRESULT hr = mDeviceContext->Map(resource, subResource, mapType, mapFlags, mappedResource);
if (FAILED(hr))
{
if (d3d11::isDeviceLostError(hr))
{
this->notifyDeviceLost();
}
// Note: gl::OutOfMemory is used instead of gl::InternalError to avoid requiring
// additional context queries. This is needed as gl::InternalError corresponds to
// GL_INVALID_OPERATION, which does not uniquely identify a device reset error.
return gl::OutOfMemory() << "Failed to map D3D11 resource." << gl::FmtHR(hr);
}
return gl::NoError();
ANGLE_TRY_HR(GetImplAs<Context11>(context), hr, "Failed to map D3D11 resource.");
return angle::Result::Continue();
}
gl::Error Renderer11::markTransformFeedbackUsage(const gl::Context *context)
......
......@@ -310,15 +310,19 @@ class Renderer11 : public RendererD3D
ID3D11DeviceContext1 *getDeviceContext1IfSupported() { return mDeviceContext1; };
IDXGIFactory *getDxgiFactory() { return mDxgiFactory; };
gl::Error getBlendState(const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState);
gl::Error getRasterizerState(const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState);
gl::Error getDepthStencilState(const gl::DepthStencilState &dsState,
const d3d11::DepthStencilState **outDSState);
gl::Error getSamplerState(const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState);
angle::Result getBlendState(const gl::Context *context,
const d3d11::BlendStateKey &key,
const d3d11::BlendState **outBlendState);
angle::Result getRasterizerState(const gl::Context *context,
const gl::RasterizerState &rasterState,
bool scissorEnabled,
ID3D11RasterizerState **outRasterizerState);
angle::Result getDepthStencilState(const gl::Context *context,
const gl::DepthStencilState &dsState,
const d3d11::DepthStencilState **outDSState);
angle::Result getSamplerState(const gl::Context *context,
const gl::SamplerState &samplerState,
ID3D11SamplerState **outSamplerState);
Blit11 *getBlitter() { return mBlit; }
Clear11 *getClearer() { return mClear; }
......@@ -334,10 +338,10 @@ class Renderer11 : public RendererD3D
GLenum sourcePixelsType,
const gl::Box &destArea) override;
gl::Error packPixels(const gl::Context *context,
const TextureHelper11 &textureHelper,
const PackPixelsParams &params,
uint8_t *pixelsOut);
angle::Result packPixels(const gl::Context *context,
const TextureHelper11 &textureHelper,
const PackPixelsParams &params,
uint8_t *pixelsOut);
bool getLUID(LUID *adapterLuid) const override;
VertexConversionType getVertexConversionType(
......@@ -403,11 +407,12 @@ class Renderer11 : public RendererD3D
GLuint numGroupsZ);
gl::Error applyComputeShader(const gl::Context *context);
gl::Error createStagingTexture(ResourceType textureType,
const d3d11::Format &formatSet,
const gl::Extents &size,
StagingAccess readAndWriteAccess,
TextureHelper11 *textureOut);
angle::Result createStagingTexture(const gl::Context *context,
ResourceType textureType,
const d3d11::Format &formatSet,
const gl::Extents &size,
StagingAccess readAndWriteAccess,
TextureHelper11 *textureOut);
template <typename DescT, typename ResourceT>
gl::Error allocateResource(const DescT &desc, ResourceT *resourceOut)
......@@ -455,12 +460,12 @@ class Renderer11 : public RendererD3D
void onDirtyUniformBlockBinding(GLuint uniformBlockIndex) override;
gl::Error mapResource(const gl::Context *context,
ID3D11Resource *resource,
UINT subResource,
D3D11_MAP mapType,
UINT mapFlags,
D3D11_MAPPED_SUBRESOURCE *mappedResource);
angle::Result mapResource(const gl::Context *context,
ID3D11Resource *resource,
UINT subResource,
D3D11_MAP mapType,
UINT mapFlags,
D3D11_MAPPED_SUBRESOURCE *mappedResource);
gl::Error getIncompleteTexture(const gl::Context *context,
gl::TextureType type,
......
......@@ -308,7 +308,7 @@ class ResourceManager11 final : angle::NonCopyable
Resource11<T> res;
ANGLE_TRY(allocate(renderer, desc, initData, &res));
*sharedRes = std::move(res);
return gl::NoError();
return angle::Result::Continue();
}
template <typename T>
......
......@@ -8,6 +8,8 @@
// executable implementation details.
#include "libANGLE/renderer/d3d/d3d11/ShaderExecutable11.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
namespace rx
......@@ -100,7 +102,9 @@ UniformStorage11::~UniformStorage11()
{
}
gl::Error UniformStorage11::getConstantBuffer(Renderer11 *renderer, const d3d11::Buffer **bufferOut)
angle::Result UniformStorage11::getConstantBuffer(const gl::Context *context,
Renderer11 *renderer,
const d3d11::Buffer **bufferOut)
{
if (size() > 0 && !mConstantBuffer.valid())
{
......@@ -109,11 +113,11 @@ gl::Error UniformStorage11::getConstantBuffer(Renderer11 *renderer, const d3d11:
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
ANGLE_TRY(renderer->allocateResource(desc, &mConstantBuffer));
ANGLE_TRY_HANDLE(context, renderer->allocateResource(desc, &mConstantBuffer));
}
*bufferOut = &mConstantBuffer;
return gl::NoError();
return angle::Result::Continue();
}
} // namespace rx
......@@ -51,7 +51,9 @@ class UniformStorage11 : public UniformStorageD3D
UniformStorage11(size_t initialSize);
~UniformStorage11() override;
gl::Error getConstantBuffer(Renderer11 *renderer, const d3d11::Buffer **bufferOut);
angle::Result getConstantBuffer(const gl::Context *context,
Renderer11 *renderer,
const d3d11::Buffer **bufferOut);
private:
d3d11::Buffer mConstantBuffer;
......
......@@ -100,8 +100,8 @@ UINT TransformFeedback11::getNumSOBuffers() const
return static_cast<UINT>(mBuffers.size());
}
gl::Error TransformFeedback11::getSOBuffers(const gl::Context *context,
const std::vector<ID3D11Buffer *> **buffersOut)
angle::Result TransformFeedback11::getSOBuffers(const gl::Context *context,
const std::vector<ID3D11Buffer *> **buffersOut)
{
for (size_t bindingIdx = 0; bindingIdx < mBuffers.size(); bindingIdx++)
{
......@@ -115,7 +115,7 @@ gl::Error TransformFeedback11::getSOBuffers(const gl::Context *context,
}
*buffersOut = &mBuffers;
return gl::NoError();
return angle::Result::Continue();
}
const std::vector<UINT> &TransformFeedback11::getSOBufferOffsets() const
......
......@@ -41,8 +41,8 @@ class TransformFeedback11 : public TransformFeedbackImpl
bool isDirty() const;
UINT getNumSOBuffers() const;
gl::Error getSOBuffers(const gl::Context *context,
const std::vector<ID3D11Buffer *> **buffersOut);
angle::Result getSOBuffers(const gl::Context *context,
const std::vector<ID3D11Buffer *> **buffersOut);
const std::vector<UINT> &getSOBufferOffsets() const;
Serial getSerial() const;
......
......@@ -124,8 +124,8 @@ gl::Error VertexArray11::syncState(const gl::Context *context,
return gl::NoError();
}
gl::Error VertexArray11::syncStateForDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams)
angle::Result VertexArray11::syncStateForDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams)
{
Renderer11 *renderer = GetImplAs<Context11>(context)->getRenderer();
StateManager11 *stateManager = renderer->getStateManager();
......@@ -182,18 +182,19 @@ gl::Error VertexArray11::syncStateForDraw(const gl::Context *context,
}
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error VertexArray11::updateElementArrayStorage(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
bool restartEnabled)
angle::Result VertexArray11::updateElementArrayStorage(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
bool restartEnabled)
{
bool usePrimitiveRestartWorkaround =
UsePrimitiveRestartWorkaround(restartEnabled, drawCallParams.type());
ANGLE_TRY(GetIndexTranslationDestType(context, drawCallParams, usePrimitiveRestartWorkaround,
&mCachedDestinationIndexType));
ANGLE_TRY_HANDLE(
context, GetIndexTranslationDestType(context, drawCallParams, usePrimitiveRestartWorkaround,
&mCachedDestinationIndexType));
unsigned int offset =
static_cast<unsigned int>(reinterpret_cast<uintptr_t>(drawCallParams.indices()));
......@@ -202,7 +203,7 @@ gl::Error VertexArray11::updateElementArrayStorage(const gl::Context *context,
ClassifyIndexStorage(context->getGLState(), mState.getElementArrayBuffer().get(),
drawCallParams.type(), mCachedDestinationIndexType, offset);
return gl::NoError();
return angle::Result::Continue();
}
void VertexArray11::updateVertexAttribStorage(const gl::Context *context,
......@@ -237,8 +238,8 @@ bool VertexArray11::hasActiveDynamicAttrib(const gl::Context *context)
return activeDynamicAttribs.any();
}
gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs)
angle::Result VertexArray11::updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs)
{
const auto &glState = context->getGLState();
const auto &attribs = mState.getVertexAttributes();
......@@ -265,7 +266,8 @@ gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context,
break;
case VertexStorageType::STATIC:
{
ANGLE_TRY(VertexDataManager::StoreStaticAttrib(context, translatedAttrib));
ANGLE_TRY_HANDLE(context,
VertexDataManager::StoreStaticAttrib(context, translatedAttrib));
break;
}
case VertexStorageType::CURRENT_VALUE:
......@@ -277,19 +279,19 @@ gl::Error VertexArray11::updateDirtyAttribs(const gl::Context *context,
}
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error VertexArray11::updateDynamicAttribs(const gl::Context *context,
VertexDataManager *vertexDataManager,
const gl::DrawCallParams &drawCallParams,
const gl::AttributesMask &activeDynamicAttribs)
angle::Result VertexArray11::updateDynamicAttribs(const gl::Context *context,
VertexDataManager *vertexDataManager,
const gl::DrawCallParams &drawCallParams,
const gl::AttributesMask &activeDynamicAttribs)
{
const auto &glState = context->getGLState();
const auto &attribs = mState.getVertexAttributes();
const auto &bindings = mState.getVertexBindings();
ANGLE_TRY(drawCallParams.ensureIndexRangeResolved(context));
ANGLE_TRY_HANDLE(context, drawCallParams.ensureIndexRangeResolved(context));
for (size_t dynamicAttribIndex : activeDynamicAttribs)
{
......@@ -303,14 +305,15 @@ gl::Error VertexArray11::updateDynamicAttribs(const gl::Context *context,
dynamicAttrib->divisor = dynamicAttrib->binding->getDivisor() * mAppliedNumViewsToDivisor;
}
ANGLE_TRY(vertexDataManager->storeDynamicAttribs(
context, &mTranslatedAttribs, activeDynamicAttribs, drawCallParams.firstVertex(),
drawCallParams.vertexCount(), drawCallParams.instances()));
ANGLE_TRY_HANDLE(context, vertexDataManager->storeDynamicAttribs(
context, &mTranslatedAttribs, activeDynamicAttribs,
drawCallParams.firstVertex(), drawCallParams.vertexCount(),
drawCallParams.instances()));
VertexDataManager::PromoteDynamicAttribs(context, mTranslatedAttribs, activeDynamicAttribs,
drawCallParams.vertexCount());
return gl::NoError();
return angle::Result::Continue();
}
const std::vector<TranslatedAttribute> &VertexArray11::getTranslatedAttribs() const
......
......@@ -33,8 +33,8 @@ class VertexArray11 : public VertexArrayImpl
const gl::VertexArray::DirtyBindingBitsArray &bindingBits) override;
// Applied buffer pointers are updated here.
gl::Error syncStateForDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams);
angle::Result syncStateForDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams);
// This will check the dynamic attribs mask.
bool hasActiveDynamicAttrib(const gl::Context *context);
......@@ -47,11 +47,6 @@ class VertexArray11 : public VertexArrayImpl
// is adjusted.
void markAllAttributeDivisorsForAdjustment(int numViews);
// Returns true if the element array buffer needs to be translated.
gl::Error updateElementArrayStorage(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
bool restartEnabled);
const TranslatedIndexData &getCachedIndexInfo() const;
void updateCachedIndexInfo(const TranslatedIndexData &indexInfo);
bool isCachedIndexInfoValid() const;
......@@ -62,12 +57,16 @@ class VertexArray11 : public VertexArrayImpl
void updateVertexAttribStorage(const gl::Context *context,
StateManager11 *stateManager,
size_t attribIndex);
gl::Error updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs);
gl::Error updateDynamicAttribs(const gl::Context *context,
VertexDataManager *vertexDataManager,
const gl::DrawCallParams &drawCallParams,
const gl::AttributesMask &activeDynamicAttribs);
angle::Result updateDirtyAttribs(const gl::Context *context,
const gl::AttributesMask &activeDirtyAttribs);
angle::Result updateDynamicAttribs(const gl::Context *context,
VertexDataManager *vertexDataManager,
const gl::DrawCallParams &drawCallParams,
const gl::AttributesMask &activeDynamicAttribs);
angle::Result updateElementArrayStorage(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
bool restartEnabled);
std::vector<VertexStorageType> mAttributeStorageTypes;
std::vector<TranslatedAttribute> mTranslatedAttribs;
......
......@@ -21,6 +21,7 @@
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/BufferD3D.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/d3d11/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/dxgi_support_table.h"
......@@ -2030,14 +2031,15 @@ void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsi
}
}
gl::Error GenerateInitialTextureData(const gl::Context *context,
GLint internalFormat,
const Renderer11DeviceCaps &renderer11DeviceCaps,
GLuint width,
GLuint height,
GLuint depth,
GLuint mipLevels,
gl::TexLevelArray<D3D11_SUBRESOURCE_DATA> *outSubresourceData)
angle::Result GenerateInitialTextureData(
const gl::Context *context,
GLint internalFormat,
const Renderer11DeviceCaps &renderer11DeviceCaps,
GLuint width,
GLuint height,
GLuint depth,
GLuint mipLevels,
gl::TexLevelArray<D3D11_SUBRESOURCE_DATA> *outSubresourceData)
{
const d3d11::Format &d3dFormatInfo = d3d11::Format::Get(internalFormat, renderer11DeviceCaps);
ASSERT(d3dFormatInfo.dataInitializerFunction != nullptr);
......@@ -2050,7 +2052,8 @@ gl::Error GenerateInitialTextureData(const gl::Context *context,
unsigned int maxImageSize = depthPitch * depth;
angle::MemoryBuffer *scratchBuffer = nullptr;
ANGLE_TRY_ALLOCATION(context->getScratchBuffer(maxImageSize, &scratchBuffer));
ANGLE_CHECK_HR_ALLOC(GetImplAs<Context11>(context),
context->getScratchBuffer(maxImageSize, &scratchBuffer));
d3dFormatInfo.dataInitializerFunction(width, height, depth, scratchBuffer->data(), rowPitch,
depthPitch);
......@@ -2068,7 +2071,7 @@ gl::Error GenerateInitialTextureData(const gl::Context *context,
outSubresourceData->at(i).SysMemSlicePitch = mipDepthPitch;
}
return gl::NoError();
return angle::Result::Continue();
}
UINT GetPrimitiveRestartIndex()
......@@ -2177,7 +2180,7 @@ gl::Error LazyResource<ResourceT>::resolveImpl(Renderer11 *renderer,
ANGLE_TRY(renderer->allocateResource(desc, initData, &mResource));
mResource.setDebugName(name);
}
return gl::NoError();
return angle::Result::Continue();
}
template gl::Error LazyResource<ResourceType::BlendState>::resolveImpl(Renderer11 *renderer,
......
......@@ -97,14 +97,15 @@ ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device);
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
gl::Error GenerateInitialTextureData(const gl::Context *context,
GLint internalFormat,
const Renderer11DeviceCaps &renderer11DeviceCaps,
GLuint width,
GLuint height,
GLuint depth,
GLuint mipLevels,
gl::TexLevelArray<D3D11_SUBRESOURCE_DATA> *outSubresourceData);
angle::Result GenerateInitialTextureData(
const gl::Context *context,
GLint internalFormat,
const Renderer11DeviceCaps &renderer11DeviceCaps,
GLuint width,
GLuint height,
GLuint depth,
GLuint mipLevels,
gl::TexLevelArray<D3D11_SUBRESOURCE_DATA> *outSubresourceData);
UINT GetPrimitiveRestartIndex();
......@@ -303,6 +304,18 @@ enum ReservedConstantBufferSlot
};
void InitConstantBufferDesc(D3D11_BUFFER_DESC *constantBufferDescription, size_t byteWidth);
// Helper class for RAII patterning.
template <typename T>
class ScopedUnmapper final : angle::NonCopyable
{
public:
ScopedUnmapper(T *object) : mObject(object) {}
~ScopedUnmapper() { mObject->unmap(); }
private:
T *mObject;
};
} // namespace d3d11
struct GenericData
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment