@@ -242,7 +242,7 @@ index 64e4dc9..1d14600 100644
242242 }
243243 }
244244diff --git a/plume_metal.cpp b/plume_metal.cpp
245- index ebbbaa3..c72adf6 100644
245+ index ebbbaa3..6c91662 100644
246246--- a/plume_metal.cpp
247247+++ b/plume_metal.cpp
248248@@ -14,8 +14,12 @@
@@ -258,7 +258,7 @@ index ebbbaa3..c72adf6 100644
258258
259259 #include "plume_metal.h"
260260
261- @@ -38,6 +42,304 @@ namespace plume {
261+ @@ -38,6 +42,307 @@ namespace plume {
262262 return (n + alignment - 1) & ~(alignment - 1);
263263 }
264264
@@ -496,6 +496,9 @@ index ebbbaa3..c72adf6 100644
496496+ options.platform = spirv_cross::CompilerMSL::Options::iOS;
497497+ options.ios_support_base_vertex_instance = true;
498498+ options.emulate_cube_array = true;
499+ + spirv_cross::CompilerGLSL::Options commonOptions = compiler.get_common_options();
500+ + commonOptions.vertex.flip_vert_y = true;
501+ + compiler.set_common_options(commonOptions);
499502+ #else
500503+ options.platform = spirv_cross::CompilerMSL::Options::macOS;
501504+ #endif
@@ -563,7 +566,7 @@ index ebbbaa3..c72adf6 100644
563566 uint64_t createClearPipelineKey(MTL::RenderPipelineDescriptor *pipelineDesc, bool depthWriteEnabled, bool stencilWriteEnabled) {
564567 auto colorFormat = [&](uint32_t index) {
565568 if (auto colorAttachment = pipelineDesc->colorAttachments()->object(index)) {
566- @@ -1133,7 +1435 ,7 @@ namespace plume {
569+ @@ -1133,7 +1438 ,7 @@ namespace plume {
567570 }
568571
569572 uint64_t MetalBuffer::getDeviceAddress() const {
@@ -572,7 +575,7 @@ index ebbbaa3..c72adf6 100644
572575 return mtl->gpuAddress();
573576 }
574577
575- @@ -1278,24 +1580 ,46 @@ namespace plume {
578+ @@ -1278,24 +1583 ,46 @@ namespace plume {
576579 assert(device != nullptr);
577580 assert(data != nullptr);
578581 assert(size > 0);
@@ -625,7 +628,7 @@ index ebbbaa3..c72adf6 100644
625628 if (debugName) {
626629 debugName->release();
627630 }
628- @@ -1306,10 +1630 ,16 @@ namespace plume {
631+ @@ -1306,10 +1633 ,16 @@ namespace plume {
629632 debugName->release();
630633 }
631634 debugName = NS::String::string(name.c_str(), NS::UTF8StringEncoding);
@@ -643,7 +646,7 @@ index ebbbaa3..c72adf6 100644
643646 MTL::FunctionConstantValues *values = MTL::FunctionConstantValues::alloc()->init();
644647 if (specConstants != nullptr) {
645648 for (uint32_t i = 0; i < specConstantsCount; i++) {
646- @@ -1325,6 +1655 ,10 @@ namespace plume {
649+ @@ -1325,6 +1658 ,10 @@ namespace plume {
647650 fprintf(stderr, "MTLLibrary newFunction: failed with error: %s.\n", error->localizedDescription()->utf8String());
648651 return nullptr;
649652 }
@@ -654,7 +657,7 @@ index ebbbaa3..c72adf6 100644
654657
655658 if (debugName) {
656659 function->setLabel(debugName);
657- @@ -1384,6 +1718 ,11 @@ namespace plume {
660+ @@ -1384,6 +1721 ,11 @@ namespace plume {
658661
659662 MTL::ComputePipelineDescriptor *descriptor = MTL::ComputePipelineDescriptor::alloc()->init();
660663 MTL::Function *function = computeShader->createFunction(desc.specConstants, desc.specConstantsCount);
@@ -666,7 +669,7 @@ index ebbbaa3..c72adf6 100644
666669 descriptor->setComputeFunction(function);
667670 descriptor->setLabel(computeShader->functionName);
668671
669- @@ -1437,6 +1776 ,13 @@ namespace plume {
672+ @@ -1437,6 +1779 ,13 @@ namespace plume {
670673 const MetalShader *metalShader = static_cast<const MetalShader *>(desc.vertexShader);
671674
672675 MTL::Function *vertexFunction = metalShader->createFunction(desc.specConstants, desc.specConstantsCount);
@@ -680,7 +683,7 @@ index ebbbaa3..c72adf6 100644
680683 descriptor->setVertexFunction(vertexFunction);
681684
682685 MTL::VertexDescriptor *vertexDescriptor = MTL::VertexDescriptor::alloc()->init();
683- @@ -1479,6 +1825 ,15 @@ namespace plume {
686+ @@ -1479,6 +1828 ,15 @@ namespace plume {
684687 if (desc.pixelShader != nullptr) {
685688 const MetalShader *pixelShader = static_cast<const MetalShader *>(desc.pixelShader);
686689 MTL::Function *fragmentFunction = pixelShader->createFunction(desc.specConstants, desc.specConstantsCount);
@@ -696,7 +699,7 @@ index ebbbaa3..c72adf6 100644
696699 descriptor->setFragmentFunction(fragmentFunction);
697700 fragmentFunction->release();
698701 }
699- @@ -1547,8 +1902 ,24 @@ namespace plume {
702+ @@ -1547,8 +1905 ,24 @@ namespace plume {
700703 state.depthBiasSlopeFactor = desc.slopeScaledDepthBias;
701704 }
702705
@@ -723,7 +726,7 @@ index ebbbaa3..c72adf6 100644
723726 return;
724727 }
725728
726- @@ -1793,6 +2164 ,11 @@ namespace plume {
729+ @@ -1793,6 +2167 ,11 @@ namespace plume {
727730
728731 MetalSwapChain::MetalSwapChain(MetalCommandQueue *commandQueue, const RenderWindow renderWindow, uint32_t textureCount, const RenderFormat format) {
729732 this->layer = static_cast<CA::MetalLayer*>(renderWindow.view);
@@ -735,7 +738,7 @@ index ebbbaa3..c72adf6 100644
735738 layer->setDevice(commandQueue->device->mtl);
736739 layer->setPixelFormat(mapPixelFormat(format));
737740
738- @@ -1819,7 +2195 ,10 @@ namespace plume {
741+ @@ -1819,7 +2198 ,10 @@ namespace plume {
739742 }
740743
741744 bool MetalSwapChain::present(const uint32_t textureIndex, RenderCommandSemaphore **waitSemaphores, const uint32_t waitSemaphoreCount) {
@@ -747,7 +750,7 @@ index ebbbaa3..c72adf6 100644
747750 NS::AutoreleasePool *releasePool = NS::AutoreleasePool::alloc()->init();
748751
749752 const MetalDrawable &drawable = drawables[textureIndex];
750- @@ -1861,7 +2240 ,7 @@ namespace plume {
753+ @@ -1861,7 +2243 ,7 @@ namespace plume {
751754 bool MetalSwapChain::resize() {
752755 getWindowSize(width, height);
753756
@@ -756,7 +759,7 @@ index ebbbaa3..c72adf6 100644
756759 return false;
757760 }
758761
759- @@ -1886,11 +2265 ,29 @@ namespace plume {
762+ @@ -1886,11 +2268 ,29 @@ namespace plume {
760763 }
761764
762765 void MetalSwapChain::setVsyncEnabled(const bool vsyncEnabled) {
@@ -786,7 +789,7 @@ index ebbbaa3..c72adf6 100644
786789 }
787790
788791 uint32_t MetalSwapChain::getWidth() const {
789- @@ -1910,6 +2307 ,10 @@ namespace plume {
792+ @@ -1910,6 +2310 ,10 @@ namespace plume {
790793 assert(textureIndex != nullptr);
791794 assert(*textureIndex < MAX_DRAWABLES);
792795
@@ -797,15 +800,15 @@ index ebbbaa3..c72adf6 100644
797800 NS::AutoreleasePool *releasePool = NS::AutoreleasePool::alloc()->init();
798801
799802 // Create a command buffer just to encode the signal
800- @@ -1923,6 +2324 ,7 @@ namespace plume {
803+ @@ -1923,6 +2327 ,7 @@ namespace plume {
801804 CA::MetalDrawable *nextDrawable = layer->nextDrawable();
802805 if (nextDrawable == nullptr) {
803806 fprintf(stderr, "No more drawables available for rendering.\n");
804807+ releasePool->release();
805808 return false;
806809 }
807810
808- @@ -1954,10 +2356 ,20 @@ namespace plume {
811+ @@ -1954,10 +2359 ,20 @@ namespace plume {
809812 }
810813
811814 uint32_t MetalSwapChain::getRefreshRate() const {
@@ -826,7 +829,7 @@ index ebbbaa3..c72adf6 100644
826829 CocoaWindowAttributes attributes;
827830 windowWrapper->getWindowAttributes(&attributes);
828831 dstWidth = attributes.width;
829- @@ -3308,6 +3720 ,9 @@ namespace plume {
832+ @@ -3308,6 +3723 ,9 @@ namespace plume {
830833 this->renderInterface = renderInterface;
831834
832835 // Device Selection
@@ -836,7 +839,7 @@ index ebbbaa3..c72adf6 100644
836839 const NS::Array* devices = MTL::CopyAllDevices();
837840 MTL::Device *preferredDevice = nullptr;
838841 for (NS::UInteger i = 0; i < devices->count(); i++) {
839- @@ -3320,12 +3735 ,31 @@ namespace plume {
842+ @@ -3320,12 +3738 ,31 @@ namespace plume {
840843 }
841844
842845 mtl = preferredDevice ? preferredDevice : MTL::CreateSystemDefaultDevice();;
@@ -869,7 +872,7 @@ index ebbbaa3..c72adf6 100644
869872
870873 // Setup blit, clear and resolve shaders / pipelines
871874 createClearShaderLibrary();
872- @@ -3337,7 +3771 ,7 @@ namespace plume {
875+ @@ -3337,7 +3774 ,7 @@ namespace plume {
873876 // TODO: Support Raytracing.
874877 // capabilities.raytracing = mtl->supportsRaytracing();
875878 capabilities.maxTextureSize = mtl->supportsFamily(MTL::GPUFamilyApple3) ? 16384 : 8192;
@@ -878,7 +881,7 @@ index ebbbaa3..c72adf6 100644
878881 capabilities.resolveModes = false;
879882 #if PLUME_IOS
880883 capabilities.descriptorIndexing = mtl->supportsFamily(MTL::GPUFamilyApple3);
881- @@ -3345,11 +3779 ,11 @@ namespace plume {
884+ @@ -3345,11 +3782 ,11 @@ namespace plume {
882885 capabilities.descriptorIndexing = true;
883886 #endif
884887 capabilities.scalarBlockLayout = true;
@@ -893,7 +896,7 @@ index ebbbaa3..c72adf6 100644
893896 capabilities.gpuUploadHeap = capabilities.uma;
894897 capabilities.queryPools = false;
895898
896- @@ -3357,17 +3791 ,19 @@ namespace plume {
899+ @@ -3357,17 +3794 ,19 @@ namespace plume {
897900 }
898901
899902 MetalDevice::~MetalDevice() {
@@ -919,7 +922,7 @@ index ebbbaa3..c72adf6 100644
919922 }
920923
921924 std::unique_ptr<RenderDescriptorSet> MetalDevice::createDescriptorSet(const RenderDescriptorSetDesc &desc) {
922- @@ -3635,16 +4071 ,24 @@ namespace plume {
925+ @@ -3635,16 +4074 ,24 @@ namespace plume {
923926
924927 MetalInterface::MetalInterface() {
925928 NS::AutoreleasePool *releasePool = NS::AutoreleasePool::alloc()->init();
0 commit comments