bool GrPipeline::isEqual(const GrPipeline& that) const { if (this->getRenderTarget() != that.getRenderTarget() || this->fFragmentStages.count() != that.fFragmentStages.count() || this->fNumColorStages != that.fNumColorStages || this->fScissorState != that.fScissorState || this->fFlags != that.fFlags || this->fStencilSettings != that.fStencilSettings || this->fDrawFace != that.fDrawFace) { return false; } if (!this->getXferProcessor()->isEqual(*that.getXferProcessor())) { return false; } // The program desc comparison should have already assured that the stage counts match. SkASSERT(this->numFragmentStages() == that.numFragmentStages()); for (int i = 0; i < this->numFragmentStages(); i++) { if (this->getFragmentStage(i) != that.getFragmentStage(i)) { return false; } } return true; }
void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { this->setRenderTargetState(primProc, pipeline.proxy()); // we set the textures, and uniforms for installed processors in a generic way, but subclasses // of GLProgram determine how to set coord transforms // We must bind to texture units in the same order in which we set the uniforms in // GrGLProgramDataManager. That is first all texture samplers and then texel buffers. // Within each group we will bind them in primProc, fragProcs, XP order. int nextTexSamplerIdx = 0; int nextTexelBufferIdx = fNumTextureSamplers; fGeometryProcessor->setData(fProgramDataManager, primProc, GrFragmentProcessor::CoordTransformIter(pipeline)); this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextTexSamplerIdx, &nextTexelBufferIdx); this->setFragmentData(primProc, pipeline, &nextTexSamplerIdx, &nextTexelBufferIdx); const GrXferProcessor& xp = pipeline.getXferProcessor(); SkIPoint offset; GrTexture* dstTexture = pipeline.peekDstTexture(&offset); fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset); if (dstTexture) { fGpu->bindTexture(nextTexSamplerIdx++, GrSamplerState::ClampNearest(), true, static_cast<GrGLTexture*>(dstTexture), pipeline.dstTextureProxy()->origin()); } SkASSERT(nextTexSamplerIdx == fNumTextureSamplers); SkASSERT(nextTexelBufferIdx == fNumTextureSamplers + fNumTexelBuffers); }
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { // Load the RT height uniform if it is needed to y-flip gl_FragCoord. if (fBuiltinUniformHandles.fRTHeightUni.isValid() && fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget()->height()) { fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, SkIntToScalar(pipeline.getRenderTarget()->height())); } // set RT adjustment const GrRenderTarget* rt = pipeline.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); if (!primProc.isPathRendering()) { if (fRenderTargetState.fRenderTargetOrigin != rt->origin() || fRenderTargetState.fRenderTargetSize != size) { fRenderTargetState.fRenderTargetSize = size; fRenderTargetState.fRenderTargetOrigin = rt->origin(); float rtAdjustmentVec[4]; fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); } } else { SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport()); const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(), size, rt->origin()); } }
void GrVkPipelineState::BuildStateKey(const GrPipeline& pipeline, GrPrimitiveType primitiveType, SkTArray<uint8_t, true>* key) { // Save room for the key length and key header key->reset(); key->push_back_n(kData_StateKeyOffset); GrProcessorKeyBuilder b(key); GrVkRenderTarget* vkRT = (GrVkRenderTarget*)pipeline.getRenderTarget(); vkRT->simpleRenderPass()->genKey(&b); pipeline.getStencil().genKey(&b); SkASSERT(sizeof(GrPipelineBuilder::DrawFace) <= sizeof(uint32_t)); b.add32(pipeline.getDrawFace()); b.add32(get_blend_info_key(pipeline)); b.add32(primitiveType); // Set key length int keyLength = key->count(); SkASSERT(0 == (keyLength % 4)); *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); }
void GrVkProgram::setData(const GrVkGpu* gpu, const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { // This is here to protect against someone calling setData multiple times in a row without // freeing the tempData between calls. this->freeTempResources(gpu); this->setRenderTargetState(pipeline); SkSTArray<8, const GrTextureAccess*> textureBindings; fGeometryProcessor->setData(fProgramDataManager, primProc); append_texture_bindings(primProc, &textureBindings); for (int i = 0; i < fFragmentProcessors.count(); ++i) { const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); fFragmentProcessors[i]->setData(fProgramDataManager, processor); fGeometryProcessor->setTransformData(primProc, fProgramDataManager, i, processor.coordTransforms()); append_texture_bindings(processor, &textureBindings); } fXferProcessor->setData(fProgramDataManager, pipeline.getXferProcessor()); append_texture_bindings(pipeline.getXferProcessor(), &textureBindings); this->writeUniformBuffers(gpu); this->writeSamplers(gpu, textureBindings); }
void GrGLProgram::generateMipmaps(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { this->generateMipmaps(primProc, pipeline.getAllowSRGBInputs()); GrFragmentProcessor::Iter iter(pipeline); while (const GrFragmentProcessor* fp = iter.next()) { this->generateMipmaps(*fp, pipeline.getAllowSRGBInputs()); } }
void GrVkPipelineState::setAndBindUniforms(GrVkGpu* gpu, const GrRenderTarget* renderTarget, GrSurfaceOrigin origin, const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline, GrVkCommandBuffer* commandBuffer) { this->setRenderTargetState(renderTarget, origin); fGeometryProcessor->setData(fDataManager, primProc, GrFragmentProcessor::CoordTransformIter(pipeline)); GrFragmentProcessor::Iter iter(pipeline); GrGLSLFragmentProcessor::Iter glslIter(fFragmentProcessors.get(), fFragmentProcessorCnt); const GrFragmentProcessor* fp = iter.next(); GrGLSLFragmentProcessor* glslFP = glslIter.next(); while (fp && glslFP) { glslFP->setData(fDataManager, *fp); fp = iter.next(); glslFP = glslIter.next(); } SkASSERT(!fp && !glslFP); { SkIPoint offset; GrTexture* dstTexture = pipeline.peekDstTexture(&offset); fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset); } // Get new descriptor set if (fGeometryUniformBuffer || fFragmentUniformBuffer) { int uniformDSIdx = GrVkUniformHandler::kUniformBufferDescSet; if (fDataManager.uploadUniformBuffers( gpu, fGeometryUniformBuffer.get(), fFragmentUniformBuffer.get()) || !fUniformDescriptorSet) { if (fUniformDescriptorSet) { fUniformDescriptorSet->recycle(gpu); } fUniformDescriptorSet = gpu->resourceProvider().getUniformDescriptorSet(); fDescriptorSets[uniformDSIdx] = fUniformDescriptorSet->descriptorSet(); this->writeUniformBuffers(gpu); } commandBuffer->bindDescriptorSets(gpu, this, fPipelineLayout, uniformDSIdx, 1, &fDescriptorSets[uniformDSIdx], 0, nullptr); if (fUniformDescriptorSet) { commandBuffer->addRecycledResource(fUniformDescriptorSet); } if (fGeometryUniformBuffer) { commandBuffer->addRecycledResource(fGeometryUniformBuffer->resource()); } if (fFragmentUniformBuffer) { commandBuffer->addRecycledResource(fFragmentUniformBuffer->resource()); } } }
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline, int* nextSamplerIdx) { int numProcessors = fFragmentProcessors.count(); for (int i = 0; i < numProcessors; ++i) { const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); fFragmentProcessors[i]->setData(fProgramDataManager, processor); this->setTransformData(primProc, processor, i); this->bindTextures(processor, pipeline.getAllowSRGBInputs(), nextSamplerIdx); } }
void GrGLProgram::setRenderTargetState(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { // Load the RT height uniform if it is needed to y-flip gl_FragCoord. if (fBuiltinUniformHandles.fRTHeightUni.isValid() && fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget()->height()) { fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, SkIntToScalar(pipeline.getRenderTarget()->height())); } // call subclasses to set the actual view matrix this->onSetRenderTargetState(primProc, pipeline); }
void GrVkPipelineState::setData(GrVkGpu* gpu, const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { // This is here to protect against someone calling setData multiple times in a row without // freeing the tempData between calls. this->freeTempResources(gpu); this->setRenderTargetState(pipeline); SkSTArray<8, const GrTextureAccess*> textureBindings; fGeometryProcessor->setData(fDataManager, primProc); append_texture_bindings(primProc, &textureBindings); for (int i = 0; i < fFragmentProcessors.count(); ++i) { const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); fFragmentProcessors[i]->setData(fDataManager, processor); fGeometryProcessor->setTransformData(primProc, fDataManager, i, processor.coordTransforms()); append_texture_bindings(processor, &textureBindings); } fXferProcessor->setData(fDataManager, pipeline.getXferProcessor()); append_texture_bindings(pipeline.getXferProcessor(), &textureBindings); // Get new descriptor sets if (fNumSamplers) { fSamplerPoolManager.getNewDescriptorSet(gpu, &fDescriptorSets[GrVkUniformHandler::kSamplerDescSet]); this->writeSamplers(gpu, textureBindings, pipeline.getAllowSRGBInputs()); } if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) { if (fDataManager.uploadUniformBuffers(gpu, fVertexUniformBuffer, fFragmentUniformBuffer) || VK_NULL_HANDLE == fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet]) { const GrVkDescriptorPool* pool; int uniformDSIdx = GrVkUniformHandler::kUniformBufferDescSet; gpu->resourceProvider().getUniformDescriptorSet(&fDescriptorSets[uniformDSIdx], &pool); if (pool != fCurrentUniformDescPool) { if (fCurrentUniformDescPool) { fCurrentUniformDescPool->unref(gpu); } fCurrentUniformDescPool = pool; fCurrentUniformDescPool->ref(); } this->writeUniformBuffers(gpu); } } }
void GrGLProgram::generateMipmaps(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { this->generateMipmaps(primProc, pipeline.getAllowSRGBInputs()); GrFragmentProcessor::Iter iter(pipeline); while (const GrFragmentProcessor* fp = iter.next()) { this->generateMipmaps(*fp, pipeline.getAllowSRGBInputs()); } if (primProc.getPixelLocalStorageState() != GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) { const GrXferProcessor& xp = pipeline.getXferProcessor(); this->generateMipmaps(xp, pipeline.getAllowSRGBInputs()); } }
void set_dynamic_scissor_state(GrVkGpu* gpu, GrVkCommandBuffer* cmdBuffer, const GrPipeline& pipeline, const GrRenderTarget& target) { // We always use one scissor and if it is disabled we just make it the size of the RT const GrScissorState& scissorState = pipeline.getScissorState(); VkRect2D scissor; if (scissorState.enabled() && !scissorState.rect().contains(0, 0, target.width(), target.height())) { // This all assumes the scissorState has previously been clipped to the device space render // target. scissor.offset.x = scissorState.rect().fLeft; scissor.extent.width = scissorState.rect().width(); if (kTopLeft_GrSurfaceOrigin == target.origin()) { scissor.offset.y = scissorState.rect().fTop; } else { SkASSERT(kBottomLeft_GrSurfaceOrigin == target.origin()); scissor.offset.y = target.height() - scissorState.rect().fBottom; } scissor.extent.height = scissorState.rect().height(); SkASSERT(scissor.offset.x >= 0); SkASSERT(scissor.offset.x + scissor.extent.width <= (uint32_t)target.width()); SkASSERT(scissor.offset.y >= 0); SkASSERT(scissor.offset.y + scissor.extent.height <= (uint32_t)target.height()); } else { scissor.extent.width = target.width(); scissor.extent.height = target.height(); scissor.offset.x = 0; scissor.offset.y = 0; } cmdBuffer->setScissor(gpu, 0, 1, &scissor); }
void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, GrVkCommandBuffer* cmdBuffer, const GrPipeline& pipeline) { const GrRenderTarget& target = *pipeline.getRenderTarget(); set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); set_dynamic_viewport_state(gpu, cmdBuffer, target); set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); }
bool GrPipeline::AreEqual(const GrPipeline& a, const GrPipeline& b, bool ignoreCoordTransforms) { SkASSERT(&a != &b); if (a.getRenderTarget() != b.getRenderTarget() || a.fFragmentProcessors.count() != b.fFragmentProcessors.count() || a.fNumColorProcessors != b.fNumColorProcessors || a.fScissorState != b.fScissorState || a.fFlags != b.fFlags || a.fStencilSettings != b.fStencilSettings || a.fDrawFace != b.fDrawFace) { return false; } // Most of the time both are nullptr if (a.fXferProcessor.get() || b.fXferProcessor.get()) { if (!a.getXferProcessor().isEqual(b.getXferProcessor())) { return false; } } for (int i = 0; i < a.numFragmentProcessors(); i++) { if (!a.getFragmentProcessor(i).isEqual(b.getFragmentProcessor(i), ignoreCoordTransforms)) { return false; } } return true; }
void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { this->setRenderTargetState(primProc, pipeline); // we set the textures, and uniforms for installed processors in a generic way, but subclasses // of GLProgram determine how to set coord transforms int nextSamplerIdx = 0; fGeometryProcessor->setData(fProgramDataManager, primProc); this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextSamplerIdx); this->setFragmentData(primProc, pipeline, &nextSamplerIdx); if (primProc.getPixelLocalStorageState() != GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) { const GrXferProcessor& xp = pipeline.getXferProcessor(); fXferProcessor->setData(fProgramDataManager, xp); this->bindTextures(xp, pipeline.getAllowSRGBInputs(), &nextSamplerIdx); } }
void GrGLPathProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0); const GrRenderTarget* rt = pipeline.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(), size, rt->origin()); }
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline, SkTArray<const GrTextureAccess*>* textureBindings) { int numProcessors = fFragmentProcessors.count(); for (int i = 0; i < numProcessors; ++i) { const GrFragmentProcessor& processor = pipeline.getFragmentProcessor(i); fFragmentProcessors[i]->setData(fProgramDataManager, processor); this->setTransformData(primProc, processor, i); append_texture_bindings(processor, textureBindings); } }
void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { this->setRenderTargetState(primProc, pipeline.getRenderTarget()); // we set the textures, and uniforms for installed processors in a generic way, but subclasses // of GLProgram determine how to set coord transforms int nextSamplerIdx = 0; fGeometryProcessor->setData(fProgramDataManager, primProc, GrFragmentProcessor::CoordTransformIter(pipeline)); this->bindTextures(primProc, pipeline.getAllowSRGBInputs(), &nextSamplerIdx); this->setFragmentData(primProc, pipeline, &nextSamplerIdx); const GrXferProcessor& xp = pipeline.getXferProcessor(); SkIPoint offset; GrTexture* dstTexture = pipeline.dstTexture(&offset); fXferProcessor->setData(fProgramDataManager, xp, dstTexture, offset); if (dstTexture) { fGpu->bindTexture(nextSamplerIdx++, GrSamplerParams::ClampNoFilter(), true, static_cast<GrGLTexture*>(dstTexture)); } }
void setup_viewport_scissor_state(const GrVkGpu* gpu, const GrPipeline& pipeline, const GrVkRenderTarget* vkRT, VkPipelineViewportStateCreateInfo* viewportInfo, VkViewport* viewport, VkRect2D* scissor) { memset(viewportInfo, 0, sizeof(VkPipelineViewportStateCreateInfo)); viewportInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewportInfo->pNext = nullptr; viewportInfo->flags = 0; viewport->x = 0.0f; viewport->y = 0.0f; viewport->width = SkIntToScalar(vkRT->width()); viewport->height = SkIntToScalar(vkRT->height()); viewport->minDepth = 0.0f; viewport->maxDepth = 1.0f; viewportInfo->viewportCount = 1; viewportInfo->pViewports = viewport; const GrScissorState& scissorState = pipeline.getScissorState(); if (scissorState.enabled() && !scissorState.rect().contains(0, 0, vkRT->width(), vkRT->height())) { // This all assumes the scissorState has previously been clipped to the device space render // target. scissor->offset.x = scissorState.rect().fLeft; scissor->extent.width = scissorState.rect().width(); if (kTopLeft_GrSurfaceOrigin == vkRT->origin()) { scissor->offset.y = scissorState.rect().fTop; } else { SkASSERT(kBottomLeft_GrSurfaceOrigin == vkRT->origin()); scissor->offset.y = vkRT->height() - scissorState.rect().fBottom; } scissor->extent.height = scissorState.rect().height(); viewportInfo->scissorCount = 1; viewportInfo->pScissors = scissor; SkASSERT(scissor->offset.x >= 0); SkASSERT(scissor->offset.x + scissor->extent.width <= (uint32_t)vkRT->width()); SkASSERT(scissor->offset.y >= 0); SkASSERT(scissor->offset.y + scissor->extent.height <= (uint32_t)vkRT->height()); } else { scissor->extent.width = vkRT->width(); scissor->extent.height = vkRT->height(); scissor->offset.x = 0; scissor->offset.y = 0; viewportInfo->scissorCount = 1; viewportInfo->pScissors = scissor; } SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount); }
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline) { int numProcessors = fFragmentProcessors->fProcs.count(); for (int e = 0; e < numProcessors; ++e) { const GrPendingFragmentStage& stage = pipeline.getFragmentStage(e); const GrProcessor& processor = *stage.processor(); fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, processor); this->setTransformData(primProc, stage, e, fFragmentProcessors->fProcs[e]); this->bindTextures(fFragmentProcessors->fProcs[e], processor); } }
void GrVkProgram::setRenderTargetState(const GrPipeline& pipeline) { // Load the RT height uniform if it is needed to y-flip gl_FragCoord. if (fBuiltinUniformHandles.fRTHeightUni.isValid() && fRenderTargetState.fRenderTargetSize.fHeight != pipeline.getRenderTarget()->height()) { fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni, SkIntToScalar(pipeline.getRenderTarget()->height())); } // set RT adjustment const GrRenderTarget* rt = pipeline.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); SkASSERT(fBuiltinUniformHandles.fRTAdjustmentUni.isValid()); if (fRenderTargetState.fRenderTargetOrigin != rt->origin() || fRenderTargetState.fRenderTargetSize != size) { fRenderTargetState.fRenderTargetSize = size; fRenderTargetState.fRenderTargetOrigin = rt->origin(); float rtAdjustmentVec[4]; fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); } }
void GrGLProgram::onSetRenderTargetState(const GrPrimitiveProcessor&, const GrPipeline& pipeline) { const GrRenderTarget* rt = pipeline.getRenderTarget(); SkISize size; size.set(rt->width(), rt->height()); if (fRenderTargetState.fRenderTargetOrigin != rt->origin() || fRenderTargetState.fRenderTargetSize != size) { fRenderTargetState.fRenderTargetSize = size; fRenderTargetState.fRenderTargetOrigin = rt->origin(); GrGLfloat rtAdjustmentVec[4]; fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, rtAdjustmentVec); } }
void set_dynamic_blend_constant_state(GrVkGpu* gpu, GrVkCommandBuffer* cmdBuffer, const GrPipeline& pipeline) { GrXferProcessor::BlendInfo blendInfo; pipeline.getXferProcessor().getBlendInfo(&blendInfo); GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; GrBlendCoeff dstCoeff = blendInfo.fDstBlend; float floatColors[4]; if (blend_coeff_refs_constant(srcCoeff) || blend_coeff_refs_constant(dstCoeff)) { GrColorToRGBAFloat(blendInfo.fBlendConstant, floatColors); } else { memset(floatColors, 0, 4 * sizeof(float)); } cmdBuffer->setBlendConstants(gpu, floatColors); }
void setup_multisample_state(const GrPipeline& pipeline, VkPipelineMultisampleStateCreateInfo* multisampleInfo) { memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo)); multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisampleInfo->pNext = nullptr; multisampleInfo->flags = 0; int numSamples = pipeline.getRenderTarget()->numColorSamples(); SkAssertResult(GrSampleCountToVkSampleCount(numSamples, &multisampleInfo->rasterizationSamples)); multisampleInfo->sampleShadingEnable = VK_FALSE; multisampleInfo->minSampleShading = 0; multisampleInfo->pSampleMask = nullptr; multisampleInfo->alphaToCoverageEnable = VK_FALSE; multisampleInfo->alphaToOneEnable = VK_FALSE; }
void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch, const PipelineInfo& pipelineInfo) { SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage; bool shouldDraw = this->setupPipelineAndShouldDraw(pipelineStorage.get(), pipelineInfo); GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get()); if (!shouldDraw) { pipeline->~GrPipeline(); return; } batch->initBatchTracker(pipeline->infoForPrimitiveProcessor()); fBatchTarget.resetNumberOfDraws(); batch->generateGeometry(&fBatchTarget, pipeline); batch->setNumberOfDraws(fBatchTarget.numberOfDraws()); fBatchTarget.preFlush(); fBatchTarget.flushNext(batch->numberOfDraws()); fBatchTarget.postFlush(); pipeline->~GrPipeline(); }
void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline, int* nextSamplerIdx) { GrFragmentProcessor::Iter iter(pipeline); GrGLSLFragmentProcessor::Iter glslIter(fFragmentProcessors.begin(), fFragmentProcessors.count()); const GrFragmentProcessor* fp = iter.next(); GrGLSLFragmentProcessor* glslFP = glslIter.next(); while (fp && glslFP) { glslFP->setData(fProgramDataManager, *fp); this->bindTextures(*fp, pipeline.getAllowSRGBInputs(), nextSamplerIdx); fp = iter.next(); glslFP = glslIter.next(); } SkASSERT(!fp && !glslFP); }
uint32_t get_blend_info_key(const GrPipeline& pipeline) { GrXferProcessor::BlendInfo blendInfo; pipeline.getXferProcessor().getBlendInfo(&blendInfo); static const uint32_t kBlendWriteShift = 1; static const uint32_t kBlendCoeffShift = 5; GR_STATIC_ASSERT(kLast_GrBlendCoeff < (1 << kBlendCoeffShift)); GR_STATIC_ASSERT(kFirstAdvancedGrBlendEquation - 1 < 4); uint32_t key = blendInfo.fWriteColor; key |= (blendInfo.fSrcBlend << kBlendWriteShift); key |= (blendInfo.fDstBlend << (kBlendWriteShift + kBlendCoeffShift)); key |= (blendInfo.fEquation << (kBlendWriteShift + 2 * kBlendCoeffShift)); return key; }
void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline& pipeline, const GrBatchTracker& batchTracker) { this->setRenderTargetState(primProc, pipeline); // we set the textures, and uniforms for installed processors in a generic way, but subclasses // of GLProgram determine how to set coord transforms fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, batchTracker); this->bindTextures(fGeometryProcessor.get(), primProc); const GrXferProcessor& xp = *pipeline.getXferProcessor(); fXferProcessor->fGLProc->setData(fProgramDataManager, xp); this->bindTextures(fXferProcessor.get(), xp); this->setFragmentData(primProc, pipeline); // Some of GrGLProgram subclasses need to update state here this->didSetData(); }
void setup_raster_state(const GrVkGpu* gpu, const GrPipeline& pipeline, VkPipelineRasterizationStateCreateInfo* rasterInfo) { memset(rasterInfo, 0, sizeof(VkPipelineRasterizationStateCreateInfo)); rasterInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterInfo->pNext = nullptr; rasterInfo->flags = 0; rasterInfo->depthClampEnable = VK_FALSE; rasterInfo->rasterizerDiscardEnable = VK_FALSE; rasterInfo->polygonMode = VK_POLYGON_MODE_FILL; rasterInfo->cullMode = draw_face_to_vk_cull_mode(pipeline.getDrawFace()); rasterInfo->frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; rasterInfo->depthBiasEnable = VK_FALSE; rasterInfo->depthBiasConstantFactor = 0.0f; rasterInfo->depthBiasClamp = 0.0f; rasterInfo->depthBiasSlopeFactor = 0.0f; rasterInfo->lineWidth = 1.0f; }
void setup_multisample_state(const GrPipeline& pipeline, const GrPrimitiveProcessor& primProc, const GrCaps* caps, VkPipelineMultisampleStateCreateInfo* multisampleInfo) { memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo)); multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisampleInfo->pNext = nullptr; multisampleInfo->flags = 0; int numSamples = pipeline.getRenderTarget()->numColorSamples(); SkAssertResult(GrSampleCountToVkSampleCount(numSamples, &multisampleInfo->rasterizationSamples)); float sampleShading = primProc.getSampleShading(); SkASSERT(sampleShading == 0.0f || caps->sampleShadingSupport()); multisampleInfo->sampleShadingEnable = sampleShading > 0.0f; multisampleInfo->minSampleShading = sampleShading; multisampleInfo->pSampleMask = nullptr; multisampleInfo->alphaToCoverageEnable = VK_FALSE; multisampleInfo->alphaToOneEnable = VK_FALSE; }