Skip to content

Commit

Permalink
macOS 12 specific fixes (I think)
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Jun 25, 2021
1 parent 111901a commit 6ba33e6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 53 deletions.
16 changes: 10 additions & 6 deletions ShaderMania.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ShaderMania.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = G6R6L3VH62;
ENABLE_PREVIEWS = YES;
Expand All @@ -508,9 +509,10 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.5;
MARKETING_VERSION = 1.51;
PRODUCT_BUNDLE_IDENTIFIER = com.moenig.shadermania;
PRODUCT_NAME = ShaderMania;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_OBJC_BRIDGING_HEADER = Shared/Metal.h;
SWIFT_VERSION = 5.0;
Expand All @@ -524,6 +526,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ShaderMania.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = G6R6L3VH62;
ENABLE_PREVIEWS = YES;
Expand All @@ -533,9 +536,10 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.5;
MARKETING_VERSION = 1.51;
PRODUCT_BUNDLE_IDENTIFIER = com.moenig.shadermania;
PRODUCT_NAME = ShaderMania;
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = iphoneos;
SWIFT_OBJC_BRIDGING_HEADER = Shared/Metal.h;
SWIFT_VERSION = 5.0;
Expand All @@ -553,7 +557,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = G6R6L3VH62;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
Expand All @@ -563,7 +567,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.5;
MARKETING_VERSION = 1.51;
PRODUCT_BUNDLE_IDENTIFIER = com.moenig.shadermania;
PRODUCT_NAME = ShaderMania;
SDKROOT = macosx;
Expand All @@ -581,7 +585,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = G6R6L3VH62;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
Expand All @@ -591,7 +595,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.5;
MARKETING_VERSION = 1.51;
PRODUCT_BUNDLE_IDENTIFIER = com.moenig.shadermania;
PRODUCT_NAME = ShaderMania;
SDKROOT = macosx;
Expand Down
13 changes: 6 additions & 7 deletions Shared/MetalDrawables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ class MetalDrawables
viewSize = float2(Float(metalView.bounds.width), Float(metalView.bounds.height))

commandBuffer = commandQueue.makeCommandBuffer()!
let renderPassDescriptor = metalView.currentRenderPassDescriptor

renderPassDescriptor!.colorAttachments[0].loadAction = .clear
renderPassDescriptor!.colorAttachments[0].clearColor = MTLClearColor( red: Double(clearColor.x), green: Double(clearColor.y), blue: Double(clearColor.z), alpha: Double(clearColor.w))

if renderPassDescriptor != nil {
renderEncoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor! )
if let renderPassDescriptor = metalView.currentRenderPassDescriptor {

renderPassDescriptor.colorAttachments[0].loadAction = .clear
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor( red: Double(clearColor.x), green: Double(clearColor.y), blue: Double(clearColor.z), alpha: Double(clearColor.w))

renderEncoder = commandBuffer.makeRenderCommandEncoder(descriptor: renderPassDescriptor )
return renderEncoder
}

Expand Down
71 changes: 36 additions & 35 deletions Shared/NodesWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,50 +105,51 @@ public class NodesWidget : ObservableObject
firstDraw = false
}

drawables.encodeStart()

drawables.drawBoxPattern(position: float2(0,0), size: drawables.viewSize, fillColor: float4(0.12, 0.12, 0.12, 1), borderColor: float4(0.14, 0.14, 0.14, 1))
if let _ = drawables.encodeStart() {
drawables.drawBoxPattern(position: float2(0,0), size: drawables.viewSize, fillColor: float4(0.12, 0.12, 0.12, 1), borderColor: float4(0.14, 0.14, 0.14, 1))

let skin = NodeSkin(drawables.font, fontScale: 0.4, graphZoom: graphZoom)
//drawables.drawDisk(position: float2(0,0), radius: 50)
//drawables.drawBox(position: float2(100,100), size: float2(100, 50))

if let assets = core.assetFolder?.assets {
for asset in assets {

//print(asset.type, asset.name)
drawNode(asset, asset === currentNode, skin)
let skin = NodeSkin(drawables.font, fontScale: 0.4, graphZoom: graphZoom)
//drawables.drawDisk(position: float2(0,0), radius: 50)
//drawables.drawBox(position: float2(100,100), size: float2(100, 50))

if let assets = core.assetFolder?.assets {
for asset in assets {

//print(asset.type, asset.name)
drawNode(asset, asset === currentNode, skin)
}
}
}

if action == .Connecting {
if let id = currentTerminalId {
let rect = getTerminal(currentNode!, id: id)

if let mousePos = mouseMovedPos {
drawables.drawLine(startPos: rect.middle(), endPos: mousePos, radius: 0.6, fillColor: skin.selectedTerminalColor)
if action == .Connecting {
if let id = currentTerminalId {
let rect = getTerminal(currentNode!, id: id)
if let mousePos = mouseMovedPos {
drawables.drawLine(startPos: rect.middle(), endPos: mousePos, radius: 0.6, fillColor: skin.selectedTerminalColor)
}
}
}
}

// Draw Connections
if let assets = core.assetFolder?.assets {
for asset in assets {

for (index, nodeUUID) in asset.slots {
if let connTo = core.assetFolder!.getAssetById(nodeUUID) {
let dRect = getTerminal(connTo, id: -1)
let sRect = getTerminal(asset, id: index)

if sRect.x != 0.0 && sRect.y != 0.0 {
drawables.drawLine(startPos: sRect.middle(), endPos: dRect.middle(), radius: 0.6, fillColor: skin.selectedTerminalColor)
// Draw Connections
if let assets = core.assetFolder?.assets {
for asset in assets {
for (index, nodeUUID) in asset.slots {
if let connTo = core.assetFolder!.getAssetById(nodeUUID) {
let dRect = getTerminal(connTo, id: -1)
let sRect = getTerminal(asset, id: index)
if sRect.x != 0.0 && sRect.y != 0.0 {
drawables.drawLine(startPos: sRect.middle(), endPos: dRect.middle(), radius: 0.6, fillColor: skin.selectedTerminalColor)
}
}
}
}
}

drawables.encodeEnd()
}

drawables.encodeEnd()
}

func drawNode(_ node: Asset,_ selected: Bool,_ skin: NodeSkin)
Expand Down
10 changes: 5 additions & 5 deletions Shared/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ class Project

/// Update the parameter data for the shader
if let shader = asset.shader {
if shader.paramDataBuffer != nil {
shader.paramDataBuffer!.setPurgeableState(.empty)
shader.paramDataBuffer = nil
}

shader.paramDataBuffer = device.makeBuffer(bytes: asset.shaderData, length: asset.shaderData.count * MemoryLayout<SIMD4<Float>>.stride, options: [])!
if shader.paramDataBuffer == nil {
shader.paramDataBuffer = device.makeBuffer(bytes: asset.shaderData, length: asset.shaderData.count * MemoryLayout<SIMD4<Float>>.stride, options: [])!
} else {
shader.paramDataBuffer!.contents().copyMemory(from: asset.shaderData, byteCount: asset.shaderData.count * MemoryLayout<SIMD4<Float>>.stride)
}

renderEncoder.setFragmentBuffer(shader.paramDataBuffer, offset: 0, index: 5)
}
Expand Down

0 comments on commit 6ba33e6

Please sign in to comment.