mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
VideoBackends / VideoCommon: add type enum to dictate whether a texture is a 2D texture, a texture array, or a cube map; support 2D texture type across backends
Co-authored-by: TellowKrinkle <tellowkrinkle@gmail.com>
This commit is contained in:
@ -36,14 +36,29 @@ bool Metal::Gfx::IsHeadless() const
|
||||
|
||||
// MARK: Texture Creation
|
||||
|
||||
static MTLTextureType FromAbstract(AbstractTextureType type, bool multisample)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AbstractTextureType::Texture_2D:
|
||||
return multisample ? MTLTextureType2DMultisample : MTLTextureType2D;
|
||||
case AbstractTextureType::Texture_2DArray:
|
||||
return multisample ? MTLTextureType2DMultisampleArray : MTLTextureType2DArray;
|
||||
case AbstractTextureType::Texture_CubeMap:
|
||||
return MTLTextureTypeCube;
|
||||
}
|
||||
|
||||
ASSERT(false);
|
||||
return MTLTextureType2DArray;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractTexture> Metal::Gfx::CreateTexture(const TextureConfig& config,
|
||||
std::string_view name)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
MRCOwned<MTLTextureDescriptor*> desc = MRCTransfer([MTLTextureDescriptor new]);
|
||||
[desc setTextureType:config.samples > 1 ? MTLTextureType2DMultisampleArray :
|
||||
MTLTextureType2DArray];
|
||||
[desc setTextureType:FromAbstract(config.type, config.samples > 1)];
|
||||
[desc setPixelFormat:Util::FromAbstract(config.format)];
|
||||
[desc setWidth:config.width];
|
||||
[desc setHeight:config.height];
|
||||
@ -490,8 +505,8 @@ void Metal::Gfx::SetupSurface()
|
||||
|
||||
[m_layer setDrawableSize:{static_cast<double>(info.width), static_cast<double>(info.height)}];
|
||||
|
||||
TextureConfig cfg(info.width, info.height, 1, 1, 1, info.format,
|
||||
AbstractTextureFlag_RenderTarget);
|
||||
TextureConfig cfg(info.width, info.height, 1, 1, 1, info.format, AbstractTextureFlag_RenderTarget,
|
||||
AbstractTextureType::Texture_2DArray);
|
||||
m_bb_texture = std::make_unique<Texture>(nullptr, cfg);
|
||||
m_backbuffer = std::make_unique<Framebuffer>(
|
||||
m_bb_texture.get(), nullptr, std::vector<AbstractTexture*>{}, info.width, info.height, 1, 1);
|
||||
|
Reference in New Issue
Block a user