diff options
| author | Mai <mai.iam2048@gmail.com> | 2023-12-17 14:40:39 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-17 14:40:39 -0500 |
| commit | f589c04aa7684e72f9866d1d85e9cb32b3d281ca (patch) | |
| tree | d5cf7a22f818ad48ee5c6f4e333772058b9660ab /Source/Core/VideoBackends/Metal | |
| parent | e6c85bf8f09c54297bc71fd37432d7daa7f22bcc (diff) | |
| parent | 12dd15c8ddb587e2f76351b59e0097940061485b (diff) | |
Merge pull request #12372 from iwubcode/texture_usage_flag
VideoBackends / VideoCommon: add type enum to dictate how the texture is used; support texture 2d
Diffstat (limited to 'Source/Core/VideoBackends/Metal')
| -rw-r--r-- | Source/Core/VideoBackends/Metal/MTLGfx.mm | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Source/Core/VideoBackends/Metal/MTLGfx.mm b/Source/Core/VideoBackends/Metal/MTLGfx.mm index acc79683ef..d594117de5 100644 --- a/Source/Core/VideoBackends/Metal/MTLGfx.mm +++ b/Source/Core/VideoBackends/Metal/MTLGfx.mm @@ -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); |
