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(); }
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(); }
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); }
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; }
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(); }
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(); }
// 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(); }
// 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(); }
gl::Error Image11::copyWithoutConversion(const gl::Offset &destOffset, const gl::Box &sourceArea, const TextureHelper11 &textureHelper, UINT sourceSubResource) { // No conversion needed-- use copyback fastpath const TextureHelper11 *stagingTexture = nullptr; unsigned int stagingSubresourceIndex = 0; ANGLE_TRY(getStagingTexture(&stagingTexture, &stagingSubresourceIndex)); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); const gl::Extents &extents = textureHelper.getExtents(); D3D11_BOX srcBox; srcBox.left = sourceArea.x; srcBox.right = sourceArea.x + sourceArea.width; srcBox.top = sourceArea.y; srcBox.bottom = sourceArea.y + sourceArea.height; srcBox.front = sourceArea.z; srcBox.back = sourceArea.z + sourceArea.depth; if (textureHelper.is2D() && textureHelper.getSampleCount() > 1) { D3D11_TEXTURE2D_DESC resolveDesc; resolveDesc.Width = extents.width; resolveDesc.Height = extents.height; resolveDesc.MipLevels = 1; resolveDesc.ArraySize = 1; resolveDesc.Format = textureHelper.getFormat(); resolveDesc.SampleDesc.Count = 1; resolveDesc.SampleDesc.Quality = 0; resolveDesc.Usage = D3D11_USAGE_DEFAULT; resolveDesc.BindFlags = 0; resolveDesc.CPUAccessFlags = 0; resolveDesc.MiscFlags = 0; d3d11::Texture2D resolveTex; ANGLE_TRY(mRenderer->allocateResource(resolveDesc, &resolveTex)); deviceContext->ResolveSubresource(resolveTex.get(), 0, textureHelper.get(), sourceSubResource, textureHelper.getFormat()); deviceContext->CopySubresourceRegion(stagingTexture->get(), stagingSubresourceIndex, destOffset.x, destOffset.y, destOffset.z, resolveTex.get(), 0, &srcBox); } else { deviceContext->CopySubresourceRegion(stagingTexture->get(), stagingSubresourceIndex, destOffset.x, destOffset.y, destOffset.z, textureHelper.get(), sourceSubResource, &srcBox); } mDirty = true; return gl::NoError(); }
angle::Result VertexDataManager::storeDynamicAttrib(const gl::Context *context, TranslatedAttribute *translated, GLint start, size_t count, GLsizei instances) { ASSERT(translated->attribute && translated->binding); const auto &attrib = *translated->attribute; const auto &binding = *translated->binding; gl::Buffer *buffer = binding.getBuffer().get(); ASSERT(buffer || attrib.pointer); ASSERT(attrib.enabled); BufferD3D *storage = buffer ? GetImplAs<BufferD3D>(buffer) : nullptr; // Instanced vertices do not apply the 'start' offset GLint firstVertexIndex = (binding.getDivisor() > 0 ? 0 : start); // Compute source data pointer const uint8_t *sourceData = nullptr; if (buffer) { ANGLE_TRY(storage->getData(context, &sourceData)); sourceData += static_cast<int>(ComputeVertexAttributeOffset(attrib, binding)); } else { // Attributes using client memory ignore the VERTEX_ATTRIB_BINDING state. // https://www.opengl.org/registry/specs/ARB/vertex_attrib_binding.txt sourceData = static_cast<const uint8_t*>(attrib.pointer); } unsigned int streamOffset = 0; translated->storage = nullptr; ANGLE_TRY( 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( context, attrib, binding, translated->currentValueType, firstVertexIndex, static_cast<GLsizei>(totalCount), instances, &streamOffset, sourceData)); VertexBuffer *vertexBuffer = mStreamingBuffer.getVertexBuffer(); translated->vertexBuffer.set(vertexBuffer); translated->serial = vertexBuffer->getSerial(); translated->baseOffset = streamOffset; translated->usesFirstVertexOffset = false; return angle::Result::Continue(); }
Error Renderbuffer::onDestroy(const Context *context) { ANGLE_TRY(orphanImages(context)); if (mImplementation) { ANGLE_TRY(mImplementation->onDestroy(context)); } return NoError(); }
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(); }
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); }
Error Renderbuffer::setStorageEGLImageTarget(const Context *context, egl::Image *image) { ANGLE_TRY(orphanImages(context)); ANGLE_TRY(mImplementation->setStorageEGLImageTarget(context, image)); setTargetImage(context, image); mState.update(static_cast<GLsizei>(image->getWidth()), static_cast<GLsizei>(image->getHeight()), Format(image->getFormat()), 0, image->sourceInitState()); mDirtyChannel.signal(mState.mInitState); return NoError(); }
Error Renderbuffer::setStorage(const Context *context, GLenum internalformat, size_t width, size_t height) { ANGLE_TRY(orphanImages(context)); ANGLE_TRY(mImplementation->setStorage(context, internalformat, width, height)); mState.update(static_cast<GLsizei>(width), static_cast<GLsizei>(height), Format(internalformat), 0, InitState::MayNeedInit); mDirtyChannel.signal(mState.mInitState); return NoError(); }
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; }
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(); }
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(); }
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; }
ANGLE_INLINE angle::Result ContextGL::setDrawElementsState(const gl::Context *context, GLsizei count, gl::DrawElementsType type, const void *indices, GLsizei instanceCount, const void **outIndices) { const gl::State &glState = context->getState(); const gl::Program *program = glState.getProgram(); const gl::VertexArray *vao = glState.getVertexArray(); const gl::StateCache &stateCache = context->getStateCache(); if (stateCache.hasAnyActiveClientAttrib() || vao->getElementArrayBuffer() == nullptr) { const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao); ANGLE_TRY(vaoGL->syncDrawElementsState(context, program->getActiveAttribLocationsMask(), count, type, indices, instanceCount, glState.isPrimitiveRestartEnabled(), outIndices)); } else { *outIndices = indices; } return angle::Result::Continue; }
Error FramebufferAttachment::initializeContents(const Context *context) { ASSERT(mResource); ANGLE_TRY(mResource->initializeContents(context, mTarget.textureIndex())); setInitState(InitState::Initialized); return NoError(); }
gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attrib, GLenum currentValueType, GLint start, GLsizei count, GLsizei instances, unsigned int offset, const uint8_t *sourceData) { if (!mBuffer) { return gl::Error(GL_OUT_OF_MEMORY, "Internal vertex buffer is not initialized."); } int inputStride = static_cast<int>(ComputeVertexAttributeStride(attrib)); // This will map the resource if it isn't already mapped. ANGLE_TRY(mapResource()); uint8_t *output = mMappedResourceData + offset; const uint8_t *input = sourceData; if (instances == 0 || attrib.divisor == 0) { input += inputStride * start; } gl::VertexFormatType vertexFormatType = gl::GetVertexFormatType(attrib, currentValueType); const D3D_FEATURE_LEVEL featureLevel = mRenderer->getRenderer11DeviceCaps().featureLevel; const d3d11::VertexFormat &vertexFormatInfo = d3d11::GetVertexFormatInfo(vertexFormatType, featureLevel); ASSERT(vertexFormatInfo.copyFunction != NULL); vertexFormatInfo.copyFunction(input, inputStride, count, output); return gl::NoError(); }
egl::Error DisplayD3D::initialize(egl::Display *display) { ASSERT(mRenderer == nullptr && display != nullptr); mDisplay = display; ANGLE_TRY(CreateRendererD3D(display, &mRenderer)); return egl::Error(EGL_SUCCESS); }
Error Surface::initialize(const Display *display) { ANGLE_TRY(mImplementation->initialize(display)); // Initialized here since impl is nullptr in the constructor. // Must happen after implementation initialize for Android. mSwapBehavior = mImplementation->getSwapBehavior(); if (mBuftype == EGL_IOSURFACE_ANGLE) { GLenum internalFormat = static_cast<GLenum>(mState.attributes.get(EGL_TEXTURE_INTERNAL_FORMAT_ANGLE)); GLenum type = static_cast<GLenum>(mState.attributes.get(EGL_TEXTURE_TYPE_ANGLE)); mColorFormat = gl::Format(internalFormat, type); } if (mBuftype == EGL_D3D_TEXTURE_ANGLE) { const angle::Format *colorFormat = mImplementation->getD3DTextureColorFormat(); ASSERT(colorFormat != nullptr); GLenum internalFormat = colorFormat->fboImplementationInternalFormat; mColorFormat = gl::Format(internalFormat, colorFormat->componentType); mGLColorspace = EGL_GL_COLORSPACE_LINEAR; if (mColorFormat.info->colorEncoding == GL_SRGB) { mGLColorspace = EGL_GL_COLORSPACE_SRGB; } } return NoError(); }
ANGLE_INLINE angle::Result ContextGL::setDrawArraysState(const gl::Context *context, GLint first, GLsizei count, GLsizei instanceCount) { if (context->getStateCache().hasAnyActiveClientAttrib()) { const gl::State &glState = context->getState(); const gl::Program *program = glState.getProgram(); const gl::VertexArray *vao = glState.getVertexArray(); const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao); ANGLE_TRY(vaoGL->syncClientSideData(context, program->getActiveAttribLocationsMask(), first, count, instanceCount)); } if (context->getExtensions().webglCompatibility) { const gl::State &glState = context->getState(); FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(glState.getDrawFramebuffer()); framebufferGL->maskOutInactiveOutputDrawBuffers(context); } return angle::Result::Continue; }
Error Surface::destroyImpl(const Display *display) { if (mState.defaultFramebuffer) { mState.defaultFramebuffer->destroyDefault(display); } if (mImplementation) { mImplementation->destroy(display); } if (mTexture.get()) { if (mImplementation) { ANGLE_TRY(mImplementation->releaseTexImage(EGL_BACK_BUFFER)); } auto glErr = mTexture->releaseTexImageFromSurface(display->getProxyContext()); if (glErr.isError()) { return Error(EGL_BAD_SURFACE); } mTexture.set(nullptr, nullptr); } if (mState.defaultFramebuffer) { mState.defaultFramebuffer->onDestroy(display->getProxyContext()); } SafeDelete(mState.defaultFramebuffer); SafeDelete(mImplementation); delete this; return NoError(); }
vk::Error ProgramVk::updateUniforms(ContextVk *contextVk) { if (!mDefaultUniformBlocks[VertexShader].uniformsDirty && !mDefaultUniformBlocks[FragmentShader].uniformsDirty) { return vk::NoError(); } ASSERT(mDescriptorSetOffset == 0); VkDevice device = contextVk->getDevice(); // Update buffer memory by immediate mapping. This immediate update only works once. // TODO(jmadill): Handle inserting updates into the command stream, or use dynamic buffers. for (auto &uniformBlock : mDefaultUniformBlocks) { if (uniformBlock.uniformsDirty) { ANGLE_TRY(SyncDefaultUniformBlock(device, &uniformBlock.storage.memory, uniformBlock.uniformData)); uniformBlock.uniformsDirty = false; } } return vk::NoError(); }
egl::Error DisplayD3D::restoreLostDevice(const egl::Display *display) { // Release surface resources to make the Reset() succeed for (egl::Surface *surface : mState.surfaceSet) { ASSERT(!surface->getBoundTexture()); SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface); surfaceD3D->releaseSwapChain(); } if (!mRenderer->resetDevice()) { return egl::EglBadAlloc(); } // Restore any surfaces that may have been lost for (const egl::Surface *surface : mState.surfaceSet) { SurfaceD3D *surfaceD3D = GetImplAs<SurfaceD3D>(surface); ANGLE_TRY(surfaceD3D->resetSwapChain(display)); } return egl::NoError(); }
gl::Error RendererGL::drawRangeElements(const gl::Context *context, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices) { const gl::Program *program = context->getGLState().getProgram(); const bool usesMultiview = program->usesMultiview(); const GLsizei instanceCount = usesMultiview ? program->getNumViews() : 0; const void *drawIndexPointer = nullptr; ANGLE_TRY(mStateManager->setDrawElementsState(context, count, type, indices, instanceCount, &drawIndexPointer)); if (!mSkipDrawCalls) { if (!usesMultiview) { mFunctions->drawRangeElements(mode, start, end, count, type, drawIndexPointer); } else { mFunctions->drawElementsInstanced(mode, count, type, drawIndexPointer, instanceCount); } } return gl::NoError(); }
egl::Error DisplayVk::initialize(egl::Display *display) { ASSERT(mRenderer != nullptr && display != nullptr); angle::Result result = mRenderer->initialize(this, display, getWSIName()); ANGLE_TRY(angle::ToEGL(result, this, EGL_NOT_INITIALIZED)); return egl::NoError(); }