u32 VulkanContext::GetReadbackMemoryType(u32 bits, bool* is_coherent, bool* is_cached) { // Try for cached and coherent memory first. VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; u32 type_index; if (!GetMemoryType(bits, flags, &type_index)) { // For readbacks, caching is more important than coherency. flags &= ~VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; if (!GetMemoryType(bits, flags, &type_index)) { WARN_LOG(VIDEO, "Vulkan: Failed to find a cached memory type for readbacks, this will affect " "performance."); // Remove the cached bit as well. flags &= ~VK_MEMORY_PROPERTY_HOST_CACHED_BIT; if (!GetMemoryType(bits, flags, &type_index)) { // We shouldn't have any memory types that aren't host-visible. PanicAlert("Unable to get memory type for upload."); type_index = 0; } } } if (is_coherent) *is_coherent = ((flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0); if (is_cached) *is_cached = ((flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) != 0); return type_index; }
u32 VulkanContext::GetUploadMemoryType(u32 bits, bool* is_coherent) { // Try for coherent memory first. VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; u32 type_index; if (!GetMemoryType(bits, flags, &type_index)) { WARN_LOG( VIDEO, "Vulkan: Failed to find a coherent memory type for uploads, this will affect performance."); // Try non-coherent memory. flags &= ~VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; if (!GetMemoryType(bits, flags, &type_index)) { // We shouldn't have any memory types that aren't host-visible. PanicAlert("Unable to get memory type for upload."); type_index = 0; } } if (is_coherent) *is_coherent = ((flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0); return type_index; }
bool CItemStone::CheckValidMember( CStoneMember * pMember ) { ADDTOCALLSTACK("CItemStone::CheckValidMember"); ASSERT(pMember); ASSERT( pMember->GetParent() == this ); if ( GetAmount()==0 || g_Serv.m_iExitFlag ) // no reason to elect new if the stone is dead. return( true ); // we are deleting anyhow. switch ( pMember->GetPriv()) { case STONEPRIV_MASTER: case STONEPRIV_MEMBER: case STONEPRIV_CANDIDATE: case STONEPRIV_ACCEPTED: if ( GetMemoryType()) { // Make sure the member has a memory that links them back here. CChar * pChar = pMember->GetLinkUID().CharFind(); if ( pChar == NULL ) break; if ( pChar->Guild_Find( GetMemoryType()) != this ) break; } return( true ); case STONEPRIV_ENEMY: { CItemStone * pEnemyStone = dynamic_cast <CItemStone *>( pMember->GetLinkUID().ItemFind()); if ( pEnemyStone == NULL ) break; CStoneMember * pEnemyMember = pEnemyStone->GetMember(this); if ( pEnemyMember == NULL ) break; if ( pMember->GetWeDeclared() && ! pEnemyMember->GetTheyDeclared()) break; if ( pMember->GetTheyDeclared() && ! pEnemyMember->GetWeDeclared()) break; } return( true ); default: break; } // just delete this member. (it is mislinked) DEBUG_ERR(( "Stone UID=0%lx has mislinked member uid=0%lx\n", (DWORD) GetUID(), (DWORD) pMember->GetLinkUID())); return( false ); }
u32 VulkanContext::GetMemoryType(u32 bits, VkMemoryPropertyFlags properties) { u32 type_index = VK_MAX_MEMORY_TYPES; if (!GetMemoryType(bits, properties, &type_index)) PanicAlert("Unable to find memory type for %x:%x", bits, properties); return type_index; }
CStoneMember * CItemStone::AddRecruit(const CChar * pChar, STONEPRIV_TYPE iPriv, bool bFull) { ADDTOCALLSTACK("CItemStone::AddRecruit"); // CLIMODE_TARG_STONE_RECRUIT // Set as member or candidate. if ( !pChar || !pChar->m_pPlayer ) { Speak( "Only players can be members!"); return NULL; } TCHAR * z = Str_GetTemp(); const CItemStone * pStone = pChar->Guild_Find( GetMemoryType()); if ( pStone && pStone != this ) { sprintf(z, "%s appears to belong to %s. Must resign previous %s", static_cast<LPCTSTR>(pChar->GetName()), static_cast<LPCTSTR>(pStone->GetName()), static_cast<LPCTSTR>(GetTypeName())); Speak(z); return NULL; } if ( IsType(IT_STONE_TOWN) && IsAttr(ATTR_OWNED) && iPriv == STONEPRIV_CANDIDATE ) { // instant member. iPriv = STONEPRIV_MEMBER; } CStoneMember * pMember = GetMember(pChar); if ( pMember ) { // I'm already a member of some sort. if ( pMember->GetPriv() == iPriv || iPriv == STONEPRIV_CANDIDATE ) { sprintf(z, "%s is already %s %s.", static_cast<LPCTSTR>(pChar->GetName()), static_cast<LPCTSTR>(pMember->GetPrivName()), static_cast<LPCTSTR>(GetName())); Speak(z); return NULL; } pMember->SetPriv( iPriv ); } else { pMember = new CStoneMember(this, pChar->GetUID(), iPriv); if ( bFull ) // full join means becoming a full member already { pMember->SetPriv(STONEPRIV_MEMBER); pMember->SetAbbrev(true); } } if ( pMember->IsPrivMember()) { pMember->SetLoyalTo(pChar); ElectMaster(); // just in case this is the first. } sprintf(z, "%s is now %s %s", static_cast<LPCTSTR>(pChar->GetName()), static_cast<LPCTSTR>(pMember->GetPrivName()), static_cast<LPCTSTR>(GetName())); Speak(z); return pMember; }