本文整理汇总了C++中ANGLE_TRY函数的典型用法代码示例。如果您正苦于以下问题:C++ ANGLE_TRY函数的具体用法?C++ ANGLE_TRY怎么用?C++ ANGLE_TRY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ANGLE_TRY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ANGLE_TRY
gl::Error Image11::map(const gl::Context *context, D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
{
// We must recover from the TextureStorage if necessary, even for D3D11_MAP_WRITE.
ANGLE_TRY(recoverFromAssociatedStorage(context));
const TextureHelper11 *stagingTexture = nullptr;
unsigned int subresourceIndex = 0;
ANGLE_TRY(getStagingTexture(&stagingTexture, &subresourceIndex));
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
ASSERT(stagingTexture && stagingTexture->valid());
HRESULT result = deviceContext->Map(stagingTexture->get(), subresourceIndex, mapType, 0, map);
if (FAILED(result))
{
// this can fail if the device is removed (from TDR)
if (d3d11::isDeviceLostError(result))
{
mRenderer->notifyDeviceLost();
}
return gl::OutOfMemory() << "Failed to map staging texture, " << gl::FmtHR(result);
}
mDirty = true;
return gl::NoError();
}
示例2: ANGLE_TRY
egl::Error DisplayGLX::waitNative(const gl::Context *context, EGLint engine) const
{
// eglWaitNative is used to notice the driver of changes in X11 for the current surface, such as
// changes of the window size. We use this event to update the child window of WindowSurfaceGLX
// to match its parent window's size.
// Handling eglWaitNative this way helps the application control when resize happens. This is
// important because drivers have a tendency to clobber the back buffer when the windows are
// resized. See http://crbug.com/326995
egl::Surface *drawSurface = context->getCurrentDrawSurface();
egl::Surface *readSurface = context->getCurrentReadSurface();
if (drawSurface != nullptr)
{
SurfaceGLX *glxDrawSurface = GetImplAs<SurfaceGLX>(drawSurface);
ANGLE_TRY(glxDrawSurface->checkForResize());
}
if (readSurface != drawSurface && readSurface != nullptr)
{
SurfaceGLX *glxReadSurface = GetImplAs<SurfaceGLX>(readSurface);
ANGLE_TRY(glxReadSurface->checkForResize());
}
// We still need to forward the resizing of the child window to the driver.
mGLX.waitX();
return egl::NoError();
}
示例3: ValidateCreateStreamProducerD3DTextureNV12ANGLE
Error ValidateCreateStreamProducerD3DTextureNV12ANGLE(const Display *display,
const Stream *stream,
const AttributeMap &attribs)
{
ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.streamProducerD3DTextureNV12)
{
return Error(EGL_BAD_ACCESS, "Stream producer extension not active");
}
ANGLE_TRY(ValidateStream(display, stream));
if (!attribs.isEmpty())
{
return Error(EGL_BAD_ATTRIBUTE, "Invalid attribute");
}
if (stream->getState() != EGL_STREAM_STATE_CONNECTING_KHR)
{
return Error(EGL_BAD_STATE_KHR, "Stream not in connecting state");
}
if (stream->getConsumerType() != Stream::ConsumerType::GLTextureYUV ||
stream->getPlaneCount() != 2)
{
return Error(EGL_BAD_MATCH, "Incompatible stream consumer type");
}
return Error(EGL_SUCCESS);
}
示例4: GetVertexRangeInfo
angle::Result GetVertexRangeInfo(const gl::Context *context,
GLint firstVertex,
GLsizei vertexOrIndexCount,
gl::DrawElementsType indexTypeOrInvalid,
const void *indices,
GLint baseVertex,
GLint *startVertexOut,
size_t *vertexCountOut)
{
if (indexTypeOrInvalid != gl::DrawElementsType::InvalidEnum)
{
gl::IndexRange indexRange;
ANGLE_TRY(context->getState().getVertexArray()->getIndexRange(
context, indexTypeOrInvalid, vertexOrIndexCount, indices, &indexRange));
ANGLE_TRY(ComputeStartVertex(context->getImplementation(), indexRange, baseVertex,
startVertexOut));
*vertexCountOut = indexRange.vertexCount();
}
else
{
*startVertexOut = firstVertex;
*vertexCountOut = vertexOrIndexCount;
}
return angle::Result::Continue;
}
示例5: UsePresentPathFast
gl::Error Framebuffer11::clearImpl(const gl::Context *context, const ClearParameters &clearParams)
{
Clear11 *clearer = mRenderer->getClearer();
const gl::FramebufferAttachment *colorAttachment = mState.getFirstColorAttachment();
if (clearParams.scissorEnabled == true && colorAttachment != nullptr &&
UsePresentPathFast(mRenderer, colorAttachment))
{
// If the current framebuffer is using the default colorbuffer, and present path fast is
// active, and the scissor rect is enabled, then we should invert the scissor rect
// vertically
ClearParameters presentPathFastClearParams = clearParams;
gl::Extents framebufferSize = colorAttachment->getSize();
presentPathFastClearParams.scissor.y = framebufferSize.height -
presentPathFastClearParams.scissor.y -
presentPathFastClearParams.scissor.height;
ANGLE_TRY(clearer->clearFramebuffer(context, presentPathFastClearParams, mState));
}
else
{
ANGLE_TRY(clearer->clearFramebuffer(context, clearParams, mState));
}
ANGLE_TRY(markAttachmentsDirty(context));
return gl::NoError();
}
示例6: ANGLE_TRY
angle::Result PixelTransfer11::buildShaderMap(const gl::Context *context)
{
d3d11::PixelShader bufferToTextureFloat;
d3d11::PixelShader bufferToTextureInt;
d3d11::PixelShader bufferToTextureUint;
Context11 *context11 = GetImplAs<Context11>(context);
ANGLE_TRY(mRenderer->allocateResource(context11, ShaderData(g_PS_BufferToTexture_4F),
&bufferToTextureFloat));
ANGLE_TRY(mRenderer->allocateResource(context11, ShaderData(g_PS_BufferToTexture_4I),
&bufferToTextureInt));
ANGLE_TRY(mRenderer->allocateResource(context11, ShaderData(g_PS_BufferToTexture_4UI),
&bufferToTextureUint));
bufferToTextureFloat.setDebugName("BufferToTexture RGBA ps");
bufferToTextureInt.setDebugName("BufferToTexture RGBA-I ps");
bufferToTextureUint.setDebugName("BufferToTexture RGBA-UI ps");
mBufferToTexturePSMap[GL_FLOAT] = std::move(bufferToTextureFloat);
mBufferToTexturePSMap[GL_INT] = std::move(bufferToTextureInt);
mBufferToTexturePSMap[GL_UNSIGNED_INT] = std::move(bufferToTextureUint);
return angle::Result::Continue();
}
示例7: ASSERT
// static
angle::Result VertexDataManager::StoreStaticAttrib(const gl::Context *context,
TranslatedAttribute *translated)
{
ASSERT(translated->attribute && translated->binding);
const auto &attrib = *translated->attribute;
const auto &binding = *translated->binding;
gl::Buffer *buffer = binding.getBuffer().get();
ASSERT(buffer && attrib.enabled && !DirectStoragePossible(context, attrib, binding));
BufferD3D *bufferD3D = GetImplAs<BufferD3D>(buffer);
// Compute source data pointer
const uint8_t *sourceData = nullptr;
const int offset = static_cast<int>(ComputeVertexAttributeOffset(attrib, binding));
ANGLE_TRY(bufferD3D->getData(context, &sourceData));
sourceData += offset;
unsigned int streamOffset = 0;
translated->storage = nullptr;
ANGLE_TRY(bufferD3D->getFactory()->getVertexSpaceRequired(context, attrib, binding, 1, 0,
&translated->stride));
auto *staticBuffer = bufferD3D->getStaticVertexBuffer(attrib, binding);
ASSERT(staticBuffer);
if (staticBuffer->empty())
{
// Convert the entire buffer
int totalCount =
ElementsInBuffer(attrib, binding, static_cast<unsigned int>(bufferD3D->getSize()));
int startIndex = offset / static_cast<int>(ComputeVertexAttributeStride(attrib, binding));
ANGLE_TRY(staticBuffer->storeStaticAttribute(context, attrib, binding, -startIndex,
totalCount, 0, sourceData));
}
unsigned int firstElementOffset =
(static_cast<unsigned int>(offset) /
static_cast<unsigned int>(ComputeVertexAttributeStride(attrib, binding))) *
translated->stride;
VertexBuffer *vertexBuffer = staticBuffer->getVertexBuffer();
CheckedNumeric<unsigned int> checkedOffset(streamOffset);
checkedOffset += firstElementOffset;
ANGLE_CHECK_HR_MATH(GetImplAs<ContextD3D>(context), checkedOffset.IsValid());
translated->vertexBuffer.set(vertexBuffer);
translated->serial = vertexBuffer->getSerial();
translated->baseOffset = streamOffset + firstElementOffset;
// Instanced vertices do not apply the 'start' offset
translated->usesFirstVertexOffset = (binding.getDivisor() == 0);
return angle::Result::Continue();
}
示例8: ASSERT
// For each Direct3D sampler of either the pixel or vertex stage,
// looks up the corresponding OpenGL texture image unit and texture type,
// and sets the texture and its addressing/filtering state (or NULL when inactive).
// Sampler mapping needs to be up-to-date on the program object before this is called.
gl::Error RendererD3D::applyTextures(GLImplFactory *implFactory,
const gl::ContextState &data,
gl::SamplerType shaderType,
const FramebufferTextureArray &framebufferTextures,
size_t framebufferTextureCount)
{
ProgramD3D *programD3D = GetImplAs<ProgramD3D>(data.state->getProgram());
ASSERT(!programD3D->isSamplerMappingDirty());
unsigned int samplerRange = programD3D->getUsedSamplerRange(shaderType);
for (unsigned int samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
{
GLenum textureType = programD3D->getSamplerTextureType(shaderType, samplerIndex);
GLint textureUnit = programD3D->getSamplerMapping(shaderType, samplerIndex, *data.caps);
if (textureUnit != -1)
{
gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType);
ASSERT(texture);
gl::Sampler *samplerObject = data.state->getSampler(textureUnit);
const gl::SamplerState &samplerState =
samplerObject ? samplerObject->getSamplerState() : texture->getSamplerState();
// TODO: std::binary_search may become unavailable using older versions of GCC
if (texture->getTextureState().isSamplerComplete(samplerState, data) &&
!std::binary_search(framebufferTextures.begin(),
framebufferTextures.begin() + framebufferTextureCount, texture))
{
ANGLE_TRY(setSamplerState(shaderType, samplerIndex, texture, samplerState));
ANGLE_TRY(setTexture(shaderType, samplerIndex, texture));
}
else
{
// Texture is not sampler complete or it is in use by the framebuffer. Bind the incomplete texture.
gl::Texture *incompleteTexture = getIncompleteTexture(implFactory, textureType);
ANGLE_TRY(setSamplerState(shaderType, samplerIndex, incompleteTexture,
incompleteTexture->getSamplerState()));
ANGLE_TRY(setTexture(shaderType, samplerIndex, incompleteTexture));
}
}
else
{
// No texture bound to this slot even though it is used by the shader, bind a NULL texture
ANGLE_TRY(setTexture(shaderType, samplerIndex, nullptr));
}
}
// Set all the remaining textures to NULL
size_t samplerCount = (shaderType == gl::SAMPLER_PIXEL) ? data.caps->maxTextureImageUnits
: data.caps->maxVertexTextureImageUnits;
clearTextures(shaderType, samplerRange, samplerCount);
return gl::NoError();
}
示例9: ANGLE_TRY
Error Renderbuffer::onDestroy(const Context *context)
{
ANGLE_TRY(orphanImages(context));
if (mImplementation)
{
ANGLE_TRY(mImplementation->onDestroy(context));
}
return NoError();
}
示例10: getBoundFramebufferTextures
gl::Error RendererD3D::applyTextures(GLImplFactory *implFactory, const gl::ContextState &data)
{
FramebufferTextureArray framebufferTextures;
size_t framebufferSerialCount = getBoundFramebufferTextures(data, &framebufferTextures);
ANGLE_TRY(applyTextures(implFactory, data, gl::SAMPLER_VERTEX, framebufferTextures,
framebufferSerialCount));
ANGLE_TRY(applyTextures(implFactory, data, gl::SAMPLER_PIXEL, framebufferTextures,
framebufferSerialCount));
return gl::NoError();
}
示例11: ValidateStreamPostD3DTextureNV12ANGLE
Error ValidateStreamPostD3DTextureNV12ANGLE(const Display *display,
const Stream *stream,
void *texture,
const AttributeMap &attribs)
{
ANGLE_TRY(ValidateDisplay(display));
const DisplayExtensions &displayExtensions = display->getExtensions();
if (!displayExtensions.streamProducerD3DTextureNV12)
{
return Error(EGL_BAD_ACCESS, "Stream producer extension not active");
}
ANGLE_TRY(ValidateStream(display, stream));
for (auto &attributeIter : attribs)
{
EGLAttrib attribute = attributeIter.first;
EGLAttrib value = attributeIter.second;
switch (attribute)
{
case EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE:
if (value < 0)
{
return Error(EGL_BAD_PARAMETER, "Invalid subresource index");
}
break;
default:
return Error(EGL_BAD_ATTRIBUTE, "Invalid attribute");
}
}
if (stream->getState() != EGL_STREAM_STATE_EMPTY_KHR &&
stream->getState() != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR &&
stream->getState() != EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR)
{
return Error(EGL_BAD_STATE_KHR, "Stream not fully configured");
}
if (stream->getProducerType() != Stream::ProducerType::D3D11TextureNV12)
{
return Error(EGL_BAD_MATCH, "Incompatible stream producer");
}
if (texture == nullptr)
{
return egl::Error(EGL_BAD_PARAMETER, "Texture is null");
}
return stream->validateD3D11NV12Texture(texture);
}
示例12: reset
gl::LinkResult ProgramVk::link(const gl::Context *glContext,
const gl::ProgramLinkedResources &resources,
gl::InfoLog &infoLog)
{
ContextVk *contextVk = vk::GetImpl(glContext);
RendererVk *renderer = contextVk->getRenderer();
GlslangWrapper *glslangWrapper = renderer->getGlslangWrapper();
VkDevice device = renderer->getDevice();
reset(device);
std::vector<uint32_t> vertexCode;
std::vector<uint32_t> fragmentCode;
bool linkSuccess = false;
ANGLE_TRY_RESULT(
glslangWrapper->linkProgram(glContext, mState, resources, &vertexCode, &fragmentCode),
linkSuccess);
if (!linkSuccess)
{
return false;
}
{
VkShaderModuleCreateInfo vertexShaderInfo;
vertexShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
vertexShaderInfo.pNext = nullptr;
vertexShaderInfo.flags = 0;
vertexShaderInfo.codeSize = vertexCode.size() * sizeof(uint32_t);
vertexShaderInfo.pCode = vertexCode.data();
ANGLE_TRY(mLinkedVertexModule.init(device, vertexShaderInfo));
}
{
VkShaderModuleCreateInfo fragmentShaderInfo;
fragmentShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
fragmentShaderInfo.pNext = nullptr;
fragmentShaderInfo.flags = 0;
fragmentShaderInfo.codeSize = fragmentCode.size() * sizeof(uint32_t);
fragmentShaderInfo.pCode = fragmentCode.data();
ANGLE_TRY(mLinkedFragmentModule.init(device, fragmentShaderInfo));
}
ANGLE_TRY(initPipelineLayout(contextVk));
ANGLE_TRY(initDescriptorSets(contextVk));
ANGLE_TRY(initDefaultUniformBlocks(glContext));
return true;
}
示例13: ANGLE_TRY
gl::Error Framebuffer11::markAttachmentsDirty() const
{
for (const auto &colorAttachment : mState.getColorAttachments())
{
if (colorAttachment.isAttached())
{
ANGLE_TRY(MarkAttachmentsDirty(&colorAttachment));
}
}
ANGLE_TRY(MarkAttachmentsDirty(mState.getDepthAttachment()));
ANGLE_TRY(MarkAttachmentsDirty(mState.getStencilAttachment()));
return gl::NoError();
}
示例14: ANGLE_TRY
gl::Error HLSLCompiler::disassembleBinary(ID3DBlob *shaderBinary, std::string *disassemblyOut)
{
ANGLE_TRY(ensureInitialized());
// Retrieve disassembly
UINT flags = D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS | D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING;
ID3DBlob *disassembly = nullptr;
pD3DDisassemble disassembleFunc = reinterpret_cast<pD3DDisassemble>(mD3DDisassembleFunc);
LPCVOID buffer = shaderBinary->GetBufferPointer();
SIZE_T bufSize = shaderBinary->GetBufferSize();
HRESULT result = disassembleFunc(buffer, bufSize, flags, "", &disassembly);
if (SUCCEEDED(result))
{
*disassemblyOut = std::string(reinterpret_cast<const char*>(disassembly->GetBufferPointer()));
}
else
{
*disassemblyOut = "";
}
SafeRelease(disassembly);
return gl::NoError();
}
示例15: ANGLE_TRY
angle::Result ContextGL::drawRangeElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
gl::DrawElementsType type,
const void *indices)
{
const gl::Program *program = context->getState().getProgram();
const bool usesMultiview = program->usesMultiview();
const GLsizei instanceCount = usesMultiview ? program->getNumViews() : 0;
const void *drawIndexPointer = nullptr;
ANGLE_TRY(
setDrawElementsState(context, count, type, indices, instanceCount, &drawIndexPointer));
if (!usesMultiview)
{
getFunctions()->drawRangeElements(ToGLenum(mode), start, end, count, ToGLenum(type),
drawIndexPointer);
}
else
{
getFunctions()->drawElementsInstanced(ToGLenum(mode), count, ToGLenum(type),
drawIndexPointer, instanceCount);
}
return angle::Result::Continue;
}