diff --git a/OpenEmuShaders.xcodeproj/project.pbxproj b/OpenEmuShaders.xcodeproj/project.pbxproj index 6e54bfc..8820b74 100644 --- a/OpenEmuShaders.xcodeproj/project.pbxproj +++ b/OpenEmuShaders.xcodeproj/project.pbxproj @@ -42,9 +42,7 @@ 05F5495C229BBA8800561C14 /* OEFilterChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 05F54954229BBA8800561C14 /* OEFilterChain.h */; settings = {ATTRIBUTES = (Public, ); }; }; 05F5495D229BBA8800561C14 /* OEFilterChain.m in Sources */ = {isa = PBXBuildFile; fileRef = 05F54955229BBA8800561C14 /* OEFilterChain.m */; }; A9020051FEB9717E8F2ABA14 /* ConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9020E619BC7ACEF5904D318 /* ConfigTests.swift */; }; - A902009F295CE6ED5C8FC8CA /* ShaderReflection.h in Headers */ = {isa = PBXBuildFile; fileRef = A9020B45B7562A79B4BCF645 /* ShaderReflection.h */; settings = {ATTRIBUTES = (Public, ); }; }; A90203772A0E044990C034EA /* NSScannerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A902023035423BDAFACA21E6 /* NSScannerTests.swift */; }; - A90205F1433179AFFF015F07 /* ShaderReflection.m in Sources */ = {isa = PBXBuildFile; fileRef = A9020642C9363659BECEAAFF /* ShaderReflection.m */; }; A90206302FA906B0B42F2CF2 /* ShaderPassSemantics.m in Sources */ = {isa = PBXBuildFile; fileRef = A90206493F90CBEED52108D7 /* ShaderPassSemantics.m */; }; A9020805BAF090A04D16722C /* ShaderPassSemantics.h in Headers */ = {isa = PBXBuildFile; fileRef = A9020BF6D6C3253BE8395A68 /* ShaderPassSemantics.h */; settings = {ATTRIBUTES = (Public, ); }; }; A9020AE1BBCE1F965F5F8436 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90203E4FFF77BAF2B3ECC24 /* Config.swift */; }; @@ -161,9 +159,7 @@ 05F5BB1022875C0B004D713C /* OpenEmuShadersTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenEmuShadersTests-Bridging-Header.h"; sourceTree = ""; }; A902023035423BDAFACA21E6 /* NSScannerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSScannerTests.swift; sourceTree = ""; }; A90203E4FFF77BAF2B3ECC24 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; - A9020642C9363659BECEAAFF /* ShaderReflection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShaderReflection.m; sourceTree = ""; }; A90206493F90CBEED52108D7 /* ShaderPassSemantics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShaderPassSemantics.m; sourceTree = ""; }; - A9020B45B7562A79B4BCF645 /* ShaderReflection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderReflection.h; sourceTree = ""; }; A9020BF6D6C3253BE8395A68 /* ShaderPassSemantics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShaderPassSemantics.h; sourceTree = ""; }; A9020E619BC7ACEF5904D318 /* ConfigTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigTests.swift; sourceTree = ""; }; A9020FD6E09797E3851BD2F2 /* MTLPixelConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MTLPixelConverter.swift; sourceTree = ""; }; @@ -222,8 +218,6 @@ 057848C125C2151900A842E7 /* OEShaderPassCompiler.swift */, 057847CD25C1250300A842E7 /* ShaderCompilerOptions.swift */, 05ABBEA22845FB1C006F1A8C /* ShaderReflection.swift */, - A9020B45B7562A79B4BCF645 /* ShaderReflection.h */, - A9020642C9363659BECEAAFF /* ShaderReflection.m */, A9020BF6D6C3253BE8395A68 /* ShaderPassSemantics.h */, A90206493F90CBEED52108D7 /* ShaderPassSemantics.m */, 05ABBE9B2842EA5A006F1A8C /* SlangCompiler.swift */, @@ -379,7 +373,6 @@ 056AC35B228BA11E005018DA /* OEEnums.h in Headers */, 052A2B8E22A475D300483370 /* OEPixelBuffer.h in Headers */, A9020805BAF090A04D16722C /* ShaderPassSemantics.h in Headers */, - A902009F295CE6ED5C8FC8CA /* ShaderReflection.h in Headers */, 05F5495B229BBA8800561C14 /* RendererCommon.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -588,7 +581,6 @@ 057847CE25C1250300A842E7 /* ShaderCompilerOptions.swift in Sources */, A90206302FA906B0B42F2CF2 /* ShaderPassSemantics.m in Sources */, 059258A022AD71500064273D /* OELogging.m in Sources */, - A90205F1433179AFFF015F07 /* ShaderReflection.m in Sources */, 05ABBEA32845FB1C006F1A8C /* ShaderReflection.swift in Sources */, A9020AE1BBCE1F965F5F8436 /* Config.swift in Sources */, 05ABBE9C2842EA5A006F1A8C /* SlangCompiler.swift in Sources */, diff --git a/OpenEmuShaders/OpenEmuShaders.h b/OpenEmuShaders/OpenEmuShaders.h index fa187d9..64e8a06 100644 --- a/OpenEmuShaders/OpenEmuShaders.h +++ b/OpenEmuShaders/OpenEmuShaders.h @@ -35,4 +35,3 @@ FOUNDATION_EXPORT const unsigned char OpenEmuShadersVersionString[]; #import #import #import -#import diff --git a/Source/ShaderReflection.h b/Source/ShaderReflection.h deleted file mode 100644 index 1ebefec..0000000 --- a/Source/ShaderReflection.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2019, OpenEmu Team -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the OpenEmu Team nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -@import Foundation; -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface ShaderTextureSemanticMeta : NSObject -@property (nonatomic) NSUInteger binding; -@property (nonatomic) NSUInteger uboOffset; -@property (nonatomic) NSUInteger pushOffset; -@property (nonatomic) OEStageUsage stageUsage; -@property (nonatomic) BOOL textureActive; -@property (nonatomic) BOOL uboActive; -@property (nonatomic) BOOL pushActive; -@end - -@interface ShaderSemanticMeta : NSObject -@property (nonatomic) NSUInteger uboOffset; -@property (nonatomic) NSUInteger pushOffset; -@property (nonatomic) NSUInteger numberOfComponents; -@property (nonatomic) BOOL uboActive; -@property (nonatomic) BOOL pushActive; -@end - -@interface ShaderTextureSemanticMap : NSObject -@property (nonatomic) OEShaderTextureSemantic semantic; -@property (nonatomic) NSUInteger index; -- (instancetype)initWithTextureSemantic:(OEShaderTextureSemantic)semantic index:(NSUInteger)index; -@end - -@interface ShaderSemanticMap : NSObject -@property (nonatomic) OEShaderBufferSemantic semantic; -@property (nonatomic) NSUInteger index; -- (instancetype)initWithSemantic:(OEShaderBufferSemantic)semantic index:(NSUInteger)index; -@end - -NS_ASSUME_NONNULL_END diff --git a/Source/ShaderReflection.m b/Source/ShaderReflection.m deleted file mode 100644 index cc7caa4..0000000 --- a/Source/ShaderReflection.m +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2019, OpenEmu Team -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the OpenEmu Team nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#import "ShaderReflection.h" -#import -#import "OELogging.h" - -@implementation ShaderTextureSemanticMeta -@end - -@implementation ShaderSemanticMeta -@end - -@implementation ShaderTextureSemanticMap - -- (instancetype)initWithTextureSemantic:(OEShaderTextureSemantic)semantic index:(NSUInteger)index -{ - if (self = [super init]) - { - self.semantic = semantic; - self.index = index; - } - return self; -} - -+ (instancetype)mapWithSemantic:(OEShaderTextureSemantic)semantic index:(NSUInteger)index -{ - return [[self alloc] initWithTextureSemantic:semantic index:index]; -} - -@end - -@implementation ShaderSemanticMap - -- (instancetype)initWithSemantic:(OEShaderBufferSemantic)semantic index:(NSUInteger)index -{ - if (self = [super init]) - { - self.semantic = semantic; - self.index = index; - } - return self; -} - -+ (instancetype)mapWithSemantic:(OEShaderBufferSemantic)semantic index:(NSUInteger)index -{ - return [[self alloc] initWithSemantic:semantic index:index]; -} - -@end diff --git a/Source/ShaderReflection.swift b/Source/ShaderReflection.swift index 6b66c89..741422d 100644 --- a/Source/ShaderReflection.swift +++ b/Source/ShaderReflection.swift @@ -25,6 +25,44 @@ import Foundation import os.log +@objc class ShaderTextureSemanticMeta: NSObject { + public var binding: UInt = 0 + public var uboOffset: UInt = 0 + public var pushOffset: UInt = 0 + public var stageUsage: OEStageUsage = [] + public var textureActive: Bool = false + public var uboActive: Bool = false + public var pushActive: Bool = false +} + +@objc class ShaderSemanticMeta: NSObject { + public var uboOffset: UInt = 0 + public var pushOffset: UInt = 0 + public var numberOfComponents: UInt = 0 + public var uboActive: Bool = false + public var pushActive: Bool = false +} + +@objc class ShaderTextureSemanticMap: NSObject { + public var semantic: OEShaderTextureSemantic + public var index: UInt + + public init(textureSemantic semantic: OEShaderTextureSemantic, index: UInt) { + self.semantic = semantic + self.index = index + } +} + +@objc class ShaderSemanticMap: NSObject { + public var semantic: OEShaderBufferSemantic + public var index: UInt + + public init(semantic: OEShaderBufferSemantic, index: UInt) { + self.semantic = semantic + self.index = index + } +} + @objc class ShaderReflection: NSObject { public var passNumber: UInt = 0 public var uboSize: Int = 0 @@ -245,6 +283,7 @@ import os.log return true } + @discardableResult public func setBinding(_ binding: UInt, forTextureSemantic semantic: OEShaderTextureSemantic, at index: UInt) -> Bool { guard var map = textures[semantic] else { return false } if reserve(&map, withCapacity: index, new: ShaderTextureSemanticMeta.init) { diff --git a/Source/SlangCompiler.swift b/Source/SlangCompiler.swift index f52986b..440a85c 100644 --- a/Source/SlangCompiler.swift +++ b/Source/SlangCompiler.swift @@ -46,8 +46,6 @@ class SlangCompiler { return try compileSPIRV(source, stage: .vertex) case .fragment: return try compileSPIRV(source, stage: .fragment) - @unknown default: - fatalError("Unexpected type") } }