Exemplo n.º 1
0
/******************************************************************************
* Returns a human-readable string describing the picked object,
* which will be displayed in the status bar by OVITO.
******************************************************************************/
QString ParticlePickInfo::infoString(ObjectNode* objectNode, quint32 subobjectId)
{
	QString str;
	for(DataObject* dataObj : pipelineState().objects()) {
		ParticlePropertyObject* property = dynamic_object_cast<ParticlePropertyObject>(dataObj);
		if(!property || property->size() <= subobjectId) continue;
		if(property->type() == ParticleProperty::SelectionProperty) continue;
		if(property->type() == ParticleProperty::ColorProperty) continue;
		if(property->dataType() != qMetaTypeId<int>() && property->dataType() != qMetaTypeId<FloatType>()) continue;
		if(!str.isEmpty()) str += QStringLiteral(" | ");
		str += property->name();
		str += QStringLiteral(" ");
		for(size_t component = 0; component < property->componentCount(); component++) {
			if(component != 0) str += QStringLiteral(", ");
			QString valueString;
			if(property->dataType() == qMetaTypeId<int>()) {
				str += QString::number(property->getIntComponent(subobjectId, component));
				ParticleTypeProperty* typeProperty = dynamic_object_cast<ParticleTypeProperty>(property);
				if(typeProperty && typeProperty->particleTypes().empty() == false) {
					if(ParticleType* ptype = typeProperty->particleType(property->getIntComponent(subobjectId, component)))
						str += QString(" (%1)").arg(ptype->name());
				}
			}
			else if(property->dataType() == qMetaTypeId<FloatType>())
				str += QString::number(property->getFloatComponent(subobjectId, component));
		}
	}
	return str;
}
Exemplo n.º 2
0
sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineState(
                                                               const GrPipeline& pipeline,
                                                               const GrPrimitiveProcessor& primProc,
                                                               GrPrimitiveType primitiveType,
                                                               const GrVkRenderPass& renderPass) {
#ifdef GR_PIPELINE_STATE_CACHE_STATS
    ++fTotalRequests;
#endif
    // Get GrVkProgramDesc
    GrVkPipelineState::Desc desc;
    if (!GrVkProgramDescBuilder::Build(&desc.fProgramDesc,
                                       primProc,
                                       pipeline,
                                       *fGpu->vkCaps().glslCaps())) {
        GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n");
        return false;
    }

    // Get vulkan specific descriptor key
    GrVkPipelineState::BuildStateKey(pipeline, primitiveType, &desc.fStateKey);
    // Get checksum of entire PipelineDesc
    int keyLength = desc.fStateKey.count();
    SkASSERT(0 == (keyLength % 4));
    // Seed the checksum with the checksum of the programDesc then add the vulkan key to it.
    desc.fChecksum = SkChecksum::Murmur3(desc.fStateKey.begin(), keyLength,
                                         desc.fProgramDesc.getChecksum());

    Entry* entry = nullptr;
    if (Entry** entryptr = fHashTable.find(desc)) {
        SkASSERT(*entryptr);
        entry = *entryptr;
    }
    if (!entry) {
#ifdef GR_PIPELINE_STATE_CACHE_STATS
        ++fCacheMisses;
#endif
        sk_sp<GrVkPipelineState> pipelineState(
            GrVkPipelineStateBuilder::CreatePipelineState(fGpu,
                                                          pipeline,
                                                          primProc,
                                                          primitiveType,
                                                          desc,
                                                          renderPass));
        if (nullptr == pipelineState) {
            return nullptr;
        }
        if (fCount < kMaxEntries) {
            entry = new Entry;
            fCount++;
        } else {
            SkASSERT(fCount == kMaxEntries);
            entry = fLRUList.head();
            fLRUList.remove(entry);
            entry->fPipelineState->freeGPUResources(fGpu);
            fHashTable.remove(entry->fPipelineState->getDesc());
        }
        entry->fPipelineState = std::move(pipelineState);
        fHashTable.set(entry);
        fLRUList.addToTail(entry);
        return entry->fPipelineState;
    } else {
        fLRUList.remove(entry);
        fLRUList.addToTail(entry);
    }
    return entry->fPipelineState;
}