Skip to content

Commit

Permalink
Alternative OSD import of generated swift header.
Browse files Browse the repository at this point in the history
* The documentation is not quite clear how to import
  generated Swift headers with CXX interop from SwiftPM,
  attempting this alternative approach.
  • Loading branch information
furby-tm committed Nov 13, 2023
1 parent 4963948 commit 7ee2628
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,8 @@ let package = Package(
cxxSettings: [
.headerSearchPath("glLoader"),
/* autogenerated shader headers. */
.define("GPU_SHADERS_SWIFT_OSD_H", to: "../../../.build/\(Arch.hostTriplet)/debug/GPUShaders.build/GPUShaders-Swift.h", .when(configuration: .debug)),
.define("GPU_SHADERS_SWIFT_OSD_H", to: "../../../.build/\(Arch.hostTriplet)/release/GPUShaders.build/GPUShaders-Swift.h", .when(configuration: .release)),
.define("GPU_SHADERS_SWIFT_OSD_H", to: "../../.build/\(Arch.hostTriplet)/debug/GPUShaders.build/GPUShaders-Swift.h", .when(configuration: .debug)),
.define("GPU_SHADERS_SWIFT_OSD_H", to: "../../.build/\(Arch.hostTriplet)/release/GPUShaders.build/GPUShaders-Swift.h", .when(configuration: .release)),
],
swiftSettings: [
.interoperabilityMode(.Cxx),
Expand Down
35 changes: 0 additions & 35 deletions Sources/OpenSubdiv/include/OpenSubdiv/OSDSurfaceGpuShaders.h

This file was deleted.

1 change: 0 additions & 1 deletion Sources/OpenSubdiv/include/OpenSubdiv/OpenSubdiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
#include <OpenSubdiv/OSDSurfaceOpenCLGLVertexBuffer.h>
#include <OpenSubdiv/OSDSurfaceOpenCLPatchTable.h>
#include <OpenSubdiv/OSDSurfaceOpenCLVertexBuffer.h>
#include <OpenSubdiv/OSDSurfaceGpuShaders.h>
#ifdef __CUDA__
#include <OpenSubdiv/OSDSurfaceCudaGLVertexBuffer.h>
#include <OpenSubdiv/OSDSurfaceCudaPatchTable.h>
Expand Down
8 changes: 7 additions & 1 deletion Sources/OpenSubdiv/osd/GLComputeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@

#include "glLoader.h"

#if __has_include("GPUShaders/GPUShaders-Swift.h")
#include "GPUShaders/GPUShaders-Swift.h"
#else
#define GPU_SHADERS_INC <GPU_SHADERS_SWIFT_OSD_H>
#include GPU_SHADERS_INC
#endif

#include "OpenSubdiv/OSDSurfaceGLComputeEvaluator.h"
#include "OpenSubdiv/OSDSurfaceGLSLPatchShaderSource.h"
#include "OpenSubdiv/OSDSurfaceGpuShaders.h"

#include "OpenSubdiv/OSDAdaptiveError.h"
#include "OpenSubdiv/OSDAdaptiveStencilTable.h"
Expand Down
7 changes: 6 additions & 1 deletion Sources/OpenSubdiv/osd/GLSLPatchShaderSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@
// language governing permissions and limitations under the Apache License.
//

#if __has_include("GPUShaders/GPUShaders-Swift.h")
#include "GPUShaders/GPUShaders-Swift.h"
#else
#define GPU_SHADERS_INC <GPU_SHADERS_SWIFT_OSD_H>
#include GPU_SHADERS_INC
#endif

#include "OpenSubdiv/OSDSurfaceGLSLPatchShaderSource.h"
#include "OpenSubdiv/OSDSurfaceGpuShaders.h"
#include <sstream>
#include <string>

Expand Down
8 changes: 7 additions & 1 deletion Sources/OpenSubdiv/osd/GLXFBEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@

#include "glLoader.h"

#if __has_include("GPUShaders/GPUShaders-Swift.h")
#include "GPUShaders/GPUShaders-Swift.h"
#else
#define GPU_SHADERS_INC <GPU_SHADERS_SWIFT_OSD_H>
#include GPU_SHADERS_INC
#endif

#include "OpenSubdiv/OSDSurfaceGLXFBEvaluator.h"
#include "OpenSubdiv/OSDSurfaceGLSLPatchShaderSource.h"
#include "OpenSubdiv/OSDSurfaceGpuShaders.h"

#include <cstdio>
#include <sstream>
Expand Down
10 changes: 7 additions & 3 deletions Sources/OpenSubdiv/osd/MTLPatchShaderSource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@
// language governing permissions and limitations under the Apache License.
//

#if __has_include("GPUShaders/GPUShaders-Swift.h")
#import "GPUShaders/GPUShaders-Swift.h"
#else
#define GPU_SHADERS_INC <GPU_SHADERS_SWIFT_OSD_H>
#import GPU_SHADERS_INC
#endif

#include "OpenSubdiv/OSDAdaptiveError.h"
#include "OpenSubdiv/OSDSurfaceMTLPatchShaderSource.h"
#include "OpenSubdiv/OSDSurfaceGpuShaders.h"

#include <TargetConditionals.h>
#include <sstream>
#include <string>

#include GPU_SHADERS_INC

namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

Expand Down
10 changes: 7 additions & 3 deletions Sources/OpenSubdiv/osd/hlslPatchShaderSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
// language governing permissions and limitations under the Apache License.
//

#if __has_include("GPUShaders/GPUShaders-Swift.h")
#include "GPUShaders/GPUShaders-Swift.h"
#else
#define GPU_SHADERS_INC <GPU_SHADERS_SWIFT_OSD_H>
#include GPU_SHADERS_INC
#endif

#include "OpenSubdiv/OSDAdaptiveError.h"
#include "OpenSubdiv/OSDSurfaceHLSLPatchShaderSource.h"
#include "OpenSubdiv/OSDSurfaceGpuShaders.h"

#include <sstream>
#include <string>

#include GPU_SHADERS_INC

namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

Expand Down

0 comments on commit 7ee2628

Please sign in to comment.