Skip to content

Commit

Permalink
Temporarily disable OSD shader gen.
Browse files Browse the repository at this point in the history
* Need to think of a nice way to automatically
  import the generated Swift header that is portable
  for consumers of SwiftUSD.
  • Loading branch information
furby-tm committed Nov 13, 2023
1 parent f8c82f6 commit 427e398
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 22 deletions.
16 changes: 11 additions & 5 deletions Sources/OpenSubdiv/osd/GLComputeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

#include "glLoader.h"

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

#include "OpenSubdiv/OSDSurfaceGLComputeEvaluator.h"
#include "OpenSubdiv/OSDSurfaceGLSLPatchShaderSource.h"
Expand All @@ -42,13 +44,12 @@
#include <sstream>
#include <vector>

#include GPU_SHADERS_INC

namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

namespace Osd {

#if 0
/* and here, we use our Swift implementation right out of the box, in cxx. magic. */
static GPUShaders::GPUShaders glCompShaders = GPUShaders::GPUShaders::init();
static swift::String glCompCode = glCompShaders.setupMetal();
Expand All @@ -61,6 +62,11 @@ static const char *getShaderCode() {
ss.str().copy(source, bufSize);
return &source[bufSize];
}
#else // 0
static const char *getShaderCode() {
return "";
}
#endif

static const char *shaderSource = getShaderCode();

Expand Down
16 changes: 11 additions & 5 deletions Sources/OpenSubdiv/osd/GLSLPatchShaderSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,25 @@
// language governing permissions and limitations under the Apache License.
//

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

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

#include GPU_SHADERS_INC

namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {

namespace Osd {

#if 0
/* and here, we use our Swift implementation right out of the box, in cxx. magic. */
static GPUShaders::GPUShaders glslShaders = GPUShaders::GPUShaders::init();
static swift::String glslCode = glslShaders.setupMetal();
Expand All @@ -52,6 +53,11 @@ static const char *getShaderCode() {
ss.str().copy(source, bufSize);
return &source[bufSize];
}
#else // 0
static const char *getShaderCode() {
return "";
}
#endif

static const char *commonShaderSource = getShaderCode();
static const char *commonTessShaderSource = getShaderCode();
Expand Down
16 changes: 11 additions & 5 deletions Sources/OpenSubdiv/osd/GLXFBEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

#include "glLoader.h"

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

#include "OpenSubdiv/OSDSurfaceGLXFBEvaluator.h"
#include "OpenSubdiv/OSDSurfaceGLSLPatchShaderSource.h"
Expand All @@ -42,8 +44,6 @@
#include "OpenSubdiv/OSDAdaptiveError.h"
#include "OpenSubdiv/OSDAdaptiveStencilTable.h"

#include GPU_SHADERS_INC

#if _MSC_VER
#define snprintf _snprintf
#endif
Expand All @@ -53,6 +53,7 @@ namespace OPENSUBDIV_VERSION {

namespace Osd {

#if 0
/* and here, we use our Swift implementation right out of the box, in cxx. magic. */
static GPUShaders::GPUShaders glXShaders = GPUShaders::GPUShaders::init();
static swift::String glXCode = glXShaders.setupMetal();
Expand All @@ -65,6 +66,11 @@ static const char *getShaderCode() {
ss.str().copy(source, bufSize);
return &source[bufSize];
}
#else // 0
static const char *getShaderCode() {
return "";
}
#endif

static const char *shaderSource = getShaderCode();

Expand Down
21 changes: 18 additions & 3 deletions Sources/OpenSubdiv/osd/MTLPatchShaderSource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
// language governing permissions and limitations under the Apache License.
//

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

#include "OpenSubdiv/OSDAdaptiveError.h"
#include "OpenSubdiv/OSDSurfaceMTLPatchShaderSource.h"
Expand All @@ -41,6 +43,7 @@

namespace Osd {

#if 0
/* and here, we use our Swift implementation right out of the box, in cxx. magic. */
static GPUShaders::GPUShaders mtlShaders = GPUShaders::GPUShaders::init();
static swift::String shaderCode = mtlShaders.setupMetal();
Expand All @@ -55,6 +58,18 @@
static std::string gregoryShaderSource([shaderCode UTF8String]);
static std::string gregoryBasisShaderSource([shaderCode UTF8String]);
static std::string gregoryTriangleShaderSource([shaderCode UTF8String]);
#else // 0
static std::string commonShaderSource("");
static std::string commonTessShaderSource("");
static std::string patchLegacyShaderSource("");
static std::string patchBasisTypesShaderSource("");
static std::string patchBasisShaderSource("");
static std::string bsplineShaderSource("");
static std::string boxSplineTriangleShaderSource("");
static std::string gregoryShaderSource("");
static std::string gregoryBasisShaderSource("");
static std::string gregoryTriangleShaderSource("");
#endif

static std::string GetPatchTypeDefine(
Far::PatchDescriptor::Type type,
Expand Down
22 changes: 18 additions & 4 deletions Sources/OpenSubdiv/osd/hlslPatchShaderSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
// language governing permissions and limitations under the Apache License.
//

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

#include "OpenSubdiv/OSDAdaptiveError.h"
#include "OpenSubdiv/OSDSurfaceHLSLPatchShaderSource.h"
Expand All @@ -40,6 +42,7 @@ namespace OPENSUBDIV_VERSION {

namespace Osd {

#if 0
/* and here, we use our Swift implementation right out of the box, in cxx. magic. */
static GPUShaders::GPUShaders hlslShaders = GPUShaders::GPUShaders::init();
static swift::String hlslCode = hlslShaders.setupMetal();
Expand All @@ -52,7 +55,6 @@ static const char *getShaderCode() {
ss.str().copy(source, bufSize);
return &source[bufSize];
}

static const char *commonShaderSource = getShaderCode();
static const char *commonTessShaderSource = getShaderCode();
static const char *patchLegacyShaderSource = getShaderCode();
Expand All @@ -63,6 +65,18 @@ static const char *bsplineShaderSource = getShaderCode();
static const char *gregoryShaderSource = getShaderCode();
static const char *gregoryBasisShaderSource = getShaderCode();
static const char *gregoryTriangleShaderSource = getShaderCode();
#else // 0
static const char *commonShaderSource = "";
static const char *commonTessShaderSource = "";
static const char *patchLegacyShaderSource = "";
static const char *patchBasisTypesShaderSource = "";
static const char *patchBasisShaderSource = "";
static const char *boxSplineTriangleShaderSource = "";
static const char *bsplineShaderSource = "";
static const char *gregoryShaderSource = "";
static const char *gregoryBasisShaderSource = "";
static const char *gregoryTriangleShaderSource = "";
#endif // 0

/*static*/
std::string HLSLPatchShaderSource::GetPatchDrawingShaderSource() {
Expand Down

0 comments on commit 427e398

Please sign in to comment.