当前位置: 首页>>代码示例>>C++>>正文


C++ TCacheEntryBase::LoadFromTmem方法代码示例

本文整理汇总了C++中TCacheEntryBase::LoadFromTmem方法的典型用法代码示例。如果您正苦于以下问题:C++ TCacheEntryBase::LoadFromTmem方法的具体用法?C++ TCacheEntryBase::LoadFromTmem怎么用?C++ TCacheEntryBase::LoadFromTmem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TCacheEntryBase的用法示例。


在下文中一共展示了TCacheEntryBase::LoadFromTmem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Load


//.........这里部分代码省略.........
	const bool use_scaling = (g_ActiveConfig.iTexScalingType > 0) && !hires_tex && (width < 384) && (height < 384);
	if (use_scaling)
	{
		config.width *= g_ActiveConfig.iTexScalingFactor;
		config.height *= g_ActiveConfig.iTexScalingFactor;
		config.pcformat = PC_TEX_FMT_RGBA32;
	}
	TCacheEntryBase* entry = AllocateTexture(config);
	GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);

	iter = textures_by_address.emplace((u64)address, entry);
	if (g_ActiveConfig.iSafeTextureCache_ColorSamples == 0 ||
		std::max(texture_size, palette_size) <= (u32)g_ActiveConfig.iSafeTextureCache_ColorSamples * 8)
	{
		entry->textures_by_hash_iter = textures_by_hash.emplace(full_hash, entry);
	}

	entry->SetGeneralParameters(address, texture_size, full_format);
	entry->SetDimensions(nativeW, nativeH, tex_levels);
	entry->SetHiresParams(!!hires_tex, basename, use_scaling);
	entry->SetHashes(full_hash, tex_hash);
	entry->is_efb_copy = false;

	// load texture
	if (hires_tex)
	{
		entry->Load(TextureCacheBase::temp, width, height, expandedWidth, 0);
		u8 *Bufferptr = TextureCacheBase::temp;
		Bufferptr += TextureUtil::GetTextureSizeInBytes(width, height, pcfmt);
		for (u32 level = 1; level != texLevels; ++level)
		{
			u32 mip_width = TextureUtil::CalculateLevelSize(width, level);
			u32 mip_height = TextureUtil::CalculateLevelSize(height, level);
			entry->Load(Bufferptr, mip_width, mip_height, mip_width, level);
			Bufferptr += TextureUtil::GetTextureSizeInBytes(mip_width, mip_height, pcfmt);
		}
		if (config.materialmap)
		{
			entry->LoadMaterialMap(Bufferptr, width, height, 0);
			Bufferptr += TextureUtil::GetTextureSizeInBytes(width, height, pcfmt);
			for (u32 level = 1; level != texLevels; ++level)
			{
				u32 mip_width = TextureUtil::CalculateLevelSize(width, level);
				u32 mip_height = TextureUtil::CalculateLevelSize(height, level);
				entry->LoadMaterialMap(Bufferptr, mip_width, mip_height, level);
				Bufferptr += TextureUtil::GetTextureSizeInBytes(mip_width, mip_height, pcfmt);
			}
		}
	}
	else
	{
		if (!(texformat == GX_TF_RGBA8 && from_tmem))
		{
			entry->Load(src_data, width, height, expandedWidth,
				expandedHeight, texformat, tlutaddr, (TlutFormat)tlutfmt, 0);
		}
		else
		{
			u8* src_data_gb = &texMem[bpmem.tex[stage / 4].texImage2[stage % 4].tmem_odd * TMEM_LINE_SIZE];
			entry->LoadFromTmem(src_data, src_data_gb, width, height, expandedWidth,
				expandedHeight, 0);
		}
		if (g_ActiveConfig.bDumpTextures)
		{
			DumpTexture(entry, basename, 0);
		}
		src_data += texture_size;

		const u8* ptr_even = NULL;
		const u8* ptr_odd = NULL;
		if (from_tmem)
		{
			ptr_even = &texMem[bpmem.tex[stage / 4].texImage1[stage % 4].tmem_even * TMEM_LINE_SIZE + texture_size];
			ptr_odd = &texMem[bpmem.tex[stage / 4].texImage2[stage % 4].tmem_odd * TMEM_LINE_SIZE];
		}

		for (u32 level = 1; level != texLevels; ++level)
		{
			const u32 mip_width = TextureUtil::CalculateLevelSize(width, level);
			const u32 mip_height = TextureUtil::CalculateLevelSize(height, level);
			const u32 expanded_mip_width = ROUND_UP(mip_width, bsw);
			const u32 expanded_mip_height = ROUND_UP(mip_height, bsh);

			const u8*& mip_src_data = from_tmem
				? ((level % 2) ? ptr_odd : ptr_even)
				: src_data;
			entry->Load(mip_src_data, mip_width, mip_height, expanded_mip_width,
				expanded_mip_height, texformat, tlutaddr, (TlutFormat)tlutfmt, level);
			mip_src_data += TexDecoder_GetTextureSizeInBytes(expanded_mip_width, expanded_mip_height, texformat);

			if (g_ActiveConfig.bDumpTextures)
				DumpTexture(entry, basename, level);
		}
	}

	INCSTAT(stats.numTexturesCreated);
	SETSTAT(stats.numTexturesAlive, textures_by_address.size());
	entry = DoPartialTextureUpdates(iter);
	return ReturnEntry(stage, entry);
}
开发者ID:gamax92,项目名称:Ishiiruka,代码行数:101,代码来源:TextureCacheBase.cpp


注:本文中的TCacheEntryBase::LoadFromTmem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。