本文整理汇总了C++中GrPipeline类的典型用法代码示例。如果您正苦于以下问题:C++ GrPipeline类的具体用法?C++ GrPipeline怎么用?C++ GrPipeline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GrPipeline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isEqual
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;
}
示例2: setData
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);
}
示例3: setRenderTargetState
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());
}
}
示例4: b
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);
}
示例5: setData
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);
}
示例6: generateMipmaps
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());
}
}
示例7: setAndBindUniforms
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());
}
}
}
示例8: setFragmentData
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);
}
}
示例9: setRenderTargetState
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);
}
示例10: setData
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);
}
}
}
示例11: generateMipmaps
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());
}
}
示例12: set_dynamic_scissor_state
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);
}
示例13: SetDynamicState
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);
}
示例14: AreEqual
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;
}
示例15: setData
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);
}
}