From faebec1f054fc63a0179b130ce52b0a10f1b2a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 9 Oct 2015 22:13:32 -0700 Subject: [PATCH] Metal: Fixed MRT. --- .../shaders/metal/fs_deferred_geom.bin | Bin 1533 -> 1605 bytes src/bgfx.cpp | 2 +- src/renderer_mtl.mm | 19 ++++++++---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/examples/runtime/shaders/metal/fs_deferred_geom.bin b/examples/runtime/shaders/metal/fs_deferred_geom.bin index 84b3857a43dca2b6fa68ae6fa6b31a08c09d157f..8a18929a80c0d0933415ef6150b2e1f0914838c3 100644 GIT binary patch delta 96 zcmey%eUyjCE!cy_^2EGH3=C#$6M0s+D=1_n=A@Y@r02xD6(y#-B$gz`8z@9aC+Fwn Z7ik!1#>QH6VN+uWS7QiLvvIQ*D**MJAAJA- delta 24 gcmX@g^Ou{)E!cy_^2EGH3=HpBC-SV=_{WnK0CI{6e*gdg diff --git a/src/bgfx.cpp b/src/bgfx.cpp index da1ee525..85678f51 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1621,7 +1621,7 @@ again: } else { -#if 0 +#if 1 if (s_rendererCreator[RendererType::Metal].supported) { _type = RendererType::Metal; diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index ae7e592c..007c2bcb 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -412,10 +412,7 @@ namespace bgfx { namespace mtl ); g_caps.maxTextureSize = 2048; //ASK: real caps width/height: 4096, but max depth(3D) size is only: 2048 - //TODO: OSX -#if BX_PLATFORM_IOS - g_caps.maxFBAttachments = uint8_t(bx::uint32_min(m_device.supportsFeatureSet(MTLFeatureSet_iOS_GPUFamily2_v1) ? 8 :4, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS)); -#endif // BX_PLATFORM_* + g_caps.maxFBAttachments = 4; // uint8_t(bx::uint32_min(m_device.supportsFeatureSet(MTLFeatureSet_iOS_GPUFamily2_v1) ? 8 : 4, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS)); //todo: vendor id, device id, gpu enum //todo: texture format caps @@ -1819,7 +1816,7 @@ namespace bgfx { namespace mtl ); -// const bool bufferOnly = 0 != (_flags&BGFX_TEXTURE_RT_BUFFER_ONLY); + const bool bufferOnly = 0 != (_flags&BGFX_TEXTURE_RT_BUFFER_ONLY); const bool computeWrite = 0 != (_flags&BGFX_TEXTURE_COMPUTE_WRITE); // const bool renderTarget = 0 != (_flags&BGFX_TEXTURE_RT_MASK); const bool srgb = 0 != (_flags&BGFX_TEXTURE_SRGB) || imageContainer.m_srgb; @@ -1840,14 +1837,14 @@ namespace bgfx { namespace mtl } desc.pixelFormat = format; - desc.width = textureWidth; + desc.width = textureWidth; desc.height = textureHeight; - desc.depth = bx::uint32_max(1,imageContainer.m_depth); + desc.depth = bx::uint32_max(1,imageContainer.m_depth); desc.mipmapLevelCount = imageContainer.m_numMips; - desc.sampleCount = 1; //TODO: set samplecount - If textureType is not MTLTextureType2DMultisample, the value must be 1. - desc.resourceOptions = MTLResourceStorageModePrivate; - desc.cpuCacheMode = MTLCPUCacheModeDefaultCache; - desc.storageMode = 1 /*MTLStorageModeManaged*/; + desc.sampleCount = 1; //TODO: set samplecount - If textureType is not MTLTextureType2DMultisample, the value must be 1. + desc.resourceOptions = MTLResourceStorageModePrivate; + desc.cpuCacheMode = MTLCPUCacheModeDefaultCache; + desc.storageMode = bufferOnly ? 1 /*MTLStorageModeManaged*/ : 2 /*MTLStorageModePrivate*/; desc.usage = MTLTextureUsageShaderRead; //TODO: set resource flags depending on usage(renderTarget/computeWrite/etc) on iOS9/OSX