Fix sdlviewer build on MSVC.

This commit is contained in:
Syoyo Fujita
2022-09-09 01:47:21 +09:00
parent 53b4133fd4
commit 5163ea591a
7 changed files with 46 additions and 22 deletions

View File

@@ -446,6 +446,11 @@ endif()
#
foreach(TINYUSDZ_LIB_TARGET ${TINYUSDZ_LIBS})
# /bigobj is required to avoid : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj
if(MSVC)
target_compile_options(${TINYUSDZ_LIB_TARGET} PRIVATE /bigobj)
endif()
if(TINYUSDZ_PRODUCTION_BUILD)
target_compile_definitions(${TINYUSDZ_LIB_TARGET}
PRIVATE "TINYUSDZ_PRODUCTION_BUILD")

View File

@@ -277,6 +277,7 @@ list(
../../src/tinyusdz.cc
../../src/io-util.cc
../../src/prim-types.cc
../../src/prim-reconstruct.cc
../../src/pprinter.cc
../../src/primvar.cc
../../src/crate-reader.cc
@@ -290,13 +291,13 @@ list(
../../src/image-loader.cc
../../src/value-types.cc
../../src/value-pprint.cc
../../src/tiny-format.cc
../../src/usdObj.cc
../../src/usdGeom.cc
../../src/usdLux.cc
../../src/usdShade.cc
../../src/xform.cc
../../src/tydra/render-data.cc
#../../src/integerCoding.cpp
#../../src/lz4-compression.cc
)
set(TINYUSDZ_DEP_SOURCES
@@ -310,8 +311,6 @@ set(TINYUSDZ_DEP_SOURCES
../../src/external/fpng.cpp
../../src/external/staticstruct.cc
../../src/external/tinyxml2/tinyxml2.cpp
#../../src/external/ryu/ryu/s2d.c
#../../src/external/ryu/ryu/s2f.c
)
set(GUI_SOURCES
@@ -370,6 +369,12 @@ if(USDVIEW_ENABLE_PHYSICS)
LinearMath)
endif()
if (MSVC)
# /bigobj is required to avoid : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj
target_compile_options(${BUILD_TARGET} PRIVATE /bigobj)
endif ()
if(WIN32)
# nothing.
elseif(APPLE)

View File

@@ -4,13 +4,13 @@
namespace example {
bool material_ui(tinyusdz::PreviewSurface &material)
bool material_ui(tinyusdz::UsdPreviewSurface &material)
{
bool changed = false;
if (!material.diffuseColor.HasTexture()) {
ImGui::InputFloat("diffuseColor", material.diffuseColor.color.data());
}
//if (!material.diffuseColor.HasTexture()) {
// ImGui::InputFloat("diffuseColor", material.diffuseColor.color.data());
//}
return changed;
}

View File

@@ -34,6 +34,6 @@ bool ImGuiComboUI(const std::string &caption, std::string &current_key,
}
bool material_ui(tinyusdz::PreviewSurface &material);
bool material_ui(tinyusdz::UsdPreviewSurface &material);
} // namesapce example

View File

@@ -82,6 +82,7 @@ bool LoadTextureImage(const tinyusdz::UVTexture &tex, Image *out_image) {
}
#endif
#if 0
bool ConvertToRenderMesh(const tinyusdz::GeomSphere& sphere,
DrawGeomMesh* dst) {
// TODO: Write our own sphere -> polygon converter
@@ -154,6 +155,7 @@ bool ConvertToRenderMesh(const tinyusdz::GeomSphere& sphere,
return true;
}
#endif
bool ConvertToRenderMesh(const tinyusdz::GeomMesh& mesh, DrawGeomMesh* dst) {
#if 0
@@ -164,7 +166,6 @@ bool ConvertToRenderMesh(const tinyusdz::GeomMesh& mesh, DrawGeomMesh* dst) {
<< " must be equal to mesh.GetNumPoints() * 3: " << mesh.GetNumPoints() * 3 << "\n";
return false;
}
#endif
dst->vertices.resize(mesh.points.size() * 3);
memcpy(dst->vertices.data(), mesh.points.data(),
dst->vertices.size() * sizeof(tinyusdz::value::point3f));
@@ -371,7 +372,8 @@ bool ConvertToRenderMesh(const tinyusdz::GeomMesh& mesh, DrawGeomMesh* dst) {
std::cout << "num triangulated faces = " << dst->facevertex_indices.size() / 3
<< "\n";
return true;
#endif
return false;
}
float3 Shade(const DrawGeomMesh& mesh, const DifferentialGeometry &dg, const PointLight &light) {

View File

@@ -78,7 +78,8 @@ struct DrawGeomMesh {
/// Required accessor API for NanoSG
///
const float *GetVertices() const {
return reinterpret_cast<const float *>(ref_mesh->points.data());
return nullptr; // TODO
//return reinterpret_cast<const float *>(ref_mesh->points.data());
}
size_t GetVertexStrideBytes() const { return sizeof(float) * 3; }

View File

@@ -182,21 +182,32 @@ struct Section {
// https://stackoverflow.com/questions/8513911/how-to-create-a-good-hash-combine-with-64-bit-output-inspired-by-boosthash-co
// From CityHash code.
template <class T>
inline void hash_combine(std::size_t &seed, const T &v) {
#if defined(__wasi__) || (sizeof(std::size_t) == 4) // 32bit platform
inline void hash_combine_impl32(std::size_t &seed, const T &v)
{
// Use boost version.
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
template <class T>
inline void hash_combine(std::size_t &seed, const T &v) {
#if defined(__wasi__) // 32bit platform
hash_compbine_impl32(seed, v);
#else
// Assume 64bit
std::hash<T> hasher;
const size_t kMul = 0x9ddfea08eb382d69ULL;
size_t a = (hasher(v) ^ seed) * kMul;
a ^= (a >> 47);
size_t b = (seed ^ a) * kMul;
b ^= (b >> 47);
seed = size_t(b * kMul);
if (sizeof(std::size_t) == 4) {
hash_combine_impl32(seed, v);
} else {
// Assume 64bit
std::hash<T> hasher;
const size_t kMul = 0x9ddfea08eb382d69ULL;
size_t a = (hasher(v) ^ seed) * kMul;
a ^= (a >> 47);
size_t b = (seed ^ a) * kMul;
b ^= (b >> 47);
seed = size_t(b * kMul);
}
#endif
}