Cycles: first batch of windows build fixes, not quite there yet.

This commit is contained in:
Brecht Van Lommel
2011-05-03 18:29:11 +00:00
parent 170f8c8c41
commit 2996f08f84
28 changed files with 112 additions and 57 deletions

View File

@@ -29,7 +29,8 @@ INCLUDE_DIRECTORIES(
../util
../subd
${BLENDER_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS})
${PYTHON_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH})
SET(LIBRARIES
cycles_render
@@ -41,7 +42,6 @@ SET(LIBRARIES
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
${OPENIMAGEIO_LIBRARY}
${PYTHON_LIBRARIES}
${GLUT_LIBRARIES}
${GLEW_LIBRARIES}
${BLENDER_LIBRARIES})
@@ -58,10 +58,21 @@ IF(WITH_CYCLES_OPENCL)
LIST(APPEND LIBRARIES ${OPENCL_LIBRARIES})
ENDIF()
LINK_DIRECTORIES(${PYTHON_LIBPATH})
SET(CMAKE_MODULE_LINKER_FLAGS ${PYTHON_MODULE_FLAGS})
ADD_LIBRARY(cycles_blender MODULE ${sources} ${headers})
ADD_DEPENDENCIES(cycles_blender bf_rna)
IF(WIN32)
TARGET_LINK_LIBRARIES(cycles_blender ${PYTHON_LINKFLAGS})
TARGET_LINK_LIBRARIES(cycles_blender debug ${PYTHON_LIBRARY}_d)
TARGET_LINK_LIBRARIES(cycles_blender optimized ${PYTHON_LIBRARY})
SET_TARGET_PROPERTIES(cycles_blender PROPERTIES PREFIX "lib")
SET_TARGET_PROPERTIES(cycles_blender PROPERTIES SUFFIX ".pyd")
ENDIF()
TARGET_LINK_LIBRARIES(cycles_blender ${LIBRARIES})
INSTALL(FILES ${addonfiles} DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
@@ -71,3 +82,13 @@ IF(UNIX AND NOT APPLE)
SET_TARGET_PROPERTIES(cycles_blender PROPERTIES INSTALL_RPATH $ORIGIN/lib)
ENDIF()
# Install DLL's
IF(WIN32)
FILE(GLOB OIIO_DLLS "${CYCLES_OIIO}/bin/*.dll")
FILE(GLOB BOOST_DLLS "${CYCLES_BOOST}/lib/*.dll")
INSTALL(FILES ${OIIO_DLLS} ${BOOST_DLLS}
DESTINATION ${CYCLES_INSTALL_PATH}/cycles)
ENDIF()

View File

@@ -218,7 +218,7 @@ void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int
blender_camera_from_object(&bcam, b_ob);
/* magic zoom formula */
bcam.zoom = b_rv3d.view_camera_zoom();
bcam.zoom = (float)b_rv3d.view_camera_zoom();
bcam.zoom = (1.41421f + bcam.zoom/50.0f);
bcam.zoom *= bcam.zoom;
bcam.zoom = 2.0f/bcam.zoom;

View File

@@ -77,7 +77,7 @@ static inline void object_free_duplilist(BL::Object self)
static inline bool object_is_modified(BL::Object self, BL::Scene scene, bool preview)
{
return rna_Object_is_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1));
return rna_Object_is_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false;
}
/* Utilities */
@@ -139,7 +139,7 @@ static inline uint get_layer(BL::Array<int, 20> array)
static inline bool get_boolean(PointerRNA& ptr, const char *name)
{
return RNA_boolean_get(&ptr, name);
return RNA_boolean_get(&ptr, name)? true: false;
}
static inline float get_float(PointerRNA& ptr, const char *name)

View File

@@ -467,7 +467,7 @@ void RegularBVH::refit_nodes()
assert(!params.top_level);
BoundBox bbox;
refit_node(0, pack.is_leaf[0], bbox);
refit_node(0, (pack.is_leaf[0])? true: false, bbox);
}
void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox)

View File

@@ -26,7 +26,7 @@
CCL_NAMESPACE_BEGIN
class BVHNode;
class BVHStackEntry;
struct BVHStackEntry;
class BVHParams;
class BoundBox;
class CacheData;

View File

@@ -359,8 +359,8 @@ BVHBuild::SpatialSplit BVHBuild::find_spatial_split(const NodeSpec& spec, float
const Reference& ref = references[refIdx];
float3 firstBinf = (ref.bounds.min - origin) * invBinSize;
float3 lastBinf = (ref.bounds.max - origin) * invBinSize;
int3 firstBin = make_int3(firstBinf.x, firstBinf.y, firstBinf.z);
int3 lastBin = make_int3(lastBinf.x, lastBinf.y, lastBinf.z);
int3 firstBin = make_int3((int)firstBinf.x, (int)firstBinf.y, (int)firstBinf.z);
int3 lastBin = make_int3((int)lastBinf.x, (int)lastBinf.y, (int)lastBinf.z);
firstBin = clamp(firstBin, 0, BVHParams::NUM_SPATIAL_BINS - 1);
lastBin = clamp(lastBin, firstBin, BVHParams::NUM_SPATIAL_BINS - 1);

View File

@@ -8,9 +8,6 @@ SET(Boost_ADDITIONAL_VERSIONS "1.45" "1.44"
"1.41" "1.41.0" "1.40" "1.40.0"
"1.39" "1.39.0" "1.38" "1.38.0"
"1.37" "1.37.0" "1.34.1" "1_34_1")
IF(LINKSTATIC)
SET(Boost_USE_STATIC_LIBS ON)
ENDIF()
SET(Boost_USE_MULTITHREADED ON)
@@ -25,6 +22,8 @@ MESSAGE(STATUS "Boost libraries ${Boost_LIBRARIES}")
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")
LINK_DIRECTORIES("${Boost_LIBRARY_DIRS}")
ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB)
IF(WITH_CYCLES_NETWORK)
ADD_DEFINITIONS(-DWITH_NETWORK)
ENDIF()
@@ -126,8 +125,10 @@ IF(WITH_CYCLES_BLENDER)
${CMAKE_SOURCE_DIR}/source/blender/blenloader
${CMAKE_BINARY_DIR}/source/blender/makesrna/intern)
IF(WIN32)
SET(BLENDER_LIBRARIES ${CMAKE_BINARY_DIR}/bin/Release/blender.lib)
SET(BLENDER_LIBRARIES ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/blender.lib)
ENDIF()
ADD_DEFINITIONS(-DBLENDER_PLUGIN)
ENDIF()
###########################################################################

View File

@@ -11,7 +11,7 @@ IF(APPLE)
ENDIF(APPLE)
IF(WIN32)
SET(CMAKE_CXX_FLAGS "-D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast")
SET(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
SET(PYTHON_MODULE_FLAGS "-DLL")
ENDIF(WIN32)

View File

@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES(
../util
../render
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR})
${GLEW_INCLUDE_PATH})
SET(sources
device.cpp

View File

@@ -356,7 +356,8 @@ public:
cuda_assert(cuParamSetv(cuPathTrace, offset, &d_rng_state, sizeof(d_rng_state)))
offset += sizeof(d_rng_state);
offset = cuda_align_up(offset, __alignof(task.pass));
int pass = task.pass;
offset = cuda_align_up(offset, __alignof(pass));
cuda_assert(cuParamSeti(cuPathTrace, offset, task.pass))
offset += sizeof(task.pass);
@@ -413,7 +414,8 @@ public:
cuda_assert(cuParamSetv(cuFilmConvert, offset, &d_buffer, sizeof(d_buffer)))
offset += sizeof(d_buffer);
offset = cuda_align_up(offset, __alignof(task.pass));
int pass = task.pass;
offset = cuda_align_up(offset, __alignof(pass));
cuda_assert(cuParamSeti(cuFilmConvert, offset, task.pass))
offset += sizeof(task.pass);
@@ -475,7 +477,8 @@ public:
cuda_assert(cuParamSetv(cuDisplace, offset, &d_offset, sizeof(d_offset)))
offset += sizeof(d_offset);
offset = cuda_align_up(offset, __alignof(task.displace_x));
int displace_x = task.displace_x;
offset = cuda_align_up(offset, __alignof(displace_x));
cuda_assert(cuParamSeti(cuDisplace, offset, task.displace_x))
offset += sizeof(task.displace_x);
@@ -621,18 +624,18 @@ public:
glColor3f(1.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(0, y, 0.0f);
glTranslatef(0.0f, (float)y, 0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f((float)w/(float)width, 0);
glVertex2f(width, 0);
glVertex2f((float)width, 0.0f);
glTexCoord2f((float)w/(float)width, (float)h/(float)height);
glVertex2f(width, height);
glTexCoord2f(0, (float)h/(float)height);
glVertex2f(0, height);
glVertex2f((float)width, (float)height);
glTexCoord2f(0.0f, (float)h/(float)height);
glVertex2f(0.0f, (float)height);
glEnd();

View File

@@ -44,9 +44,9 @@ __device uchar4 film_float_to_byte(float4 color)
uchar4 result;
/* simple float to byte conversion */
result.x = clamp(color.x*255.0f, 0.0f, 255.0f);
result.y = clamp(color.y*255.0f, 0.0f, 255.0f);
result.z = clamp(color.z*255.0f, 0.0f, 255.0f);
result.x = (uchar)clamp(color.x*255.0f, 0.0f, 255.0f);
result.y = (uchar)clamp(color.y*255.0f, 0.0f, 255.0f);
result.z = (uchar)clamp(color.z*255.0f, 0.0f, 255.0f);
result.w = 255;
return result;

View File

@@ -143,9 +143,9 @@ __device float perlin_periodic(float x, float y, float z, float3 pperiod)
int3 p;
p.x = fmaxf(quick_floor(pperiod.x), 1);
p.y = fmaxf(quick_floor(pperiod.y), 1);
p.z = fmaxf(quick_floor(pperiod.z), 1);
p.x = max(quick_floor(pperiod.x), 1);
p.y = max(quick_floor(pperiod.y), 1);
p.z = max(quick_floor(pperiod.z), 1);
float u = fade(fx);
float v = fade(fy);

View File

@@ -64,12 +64,12 @@ __device void voronoi(float3 p, NodeDistanceMetric distance_metric, float e, flo
for(xx = xi-1; xx <= xi+1; xx++) {
for(yy = yi-1; yy <= yi+1; yy++) {
for(zz = zi-1; zz <= zi+1; zz++) {
float3 ip = make_float3(xx, yy, zz);
float3 ip = make_float3((float)xx, (float)yy, (float)zz);
float3 vp = cellnoise_color(ip);
float3 pd = p - (vp + ip);
float d = voronoi_distance(distance_metric, pd, e);
vp += make_float3(xx, yy, zz);
vp += make_float3((float)xx, (float)yy, (float)zz);
if(d < da[0]) {
da[3] = da[2];

View File

@@ -1,5 +1,13 @@
INCLUDE_DIRECTORIES(. ../device ../kernel ../kernel/svm ../kernel/osl ../bvh ../util)
INCLUDE_DIRECTORIES(
.
../device
../kernel
../kernel/svm
../kernel/osl
../bvh
../util
${GLEW_INCLUDE_PATH})
SET(sources
attribute.cpp

View File

@@ -28,7 +28,7 @@
CCL_NAMESPACE_BEGIN
class Device;
class float4;
struct float4;
/* Render Buffers */

View File

@@ -990,8 +990,8 @@ void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *
compiler.add_node(NODE_CLOSURE_BSDF,
closure,
(param1)? __float_as_int(param1->value.x): 0.0f,
(param2)? __float_as_int(param2->value.x): 0.0f);
__float_as_int((param1)? param1->value.x: 0.0f),
__float_as_int((param2)? param2->value.x: 0.0f));
}
void BsdfNode::compile(SVMCompiler& compiler)

View File

@@ -31,7 +31,7 @@ class DeviceScene;
class Mesh;
class Progress;
class Scene;
class Transform;
struct Transform;
/* Object */

View File

@@ -35,7 +35,7 @@ class Mesh;
class Progress;
class Scene;
class ShaderGraph;
class float3;
struct float3;
/* Shader describing the appearance of a Mesh, Light or Background.
*

View File

@@ -30,7 +30,7 @@ CCL_NAMESPACE_BEGIN
class Device;
class DeviceScene;
class ImageManager;
class KernelSunSky;
struct KernelSunSky;
class Scene;
class ShaderGraph;
class ShaderInput;

View File

@@ -228,7 +228,7 @@ void SubdAccBuilder::computeEdgeStencil(SubdFaceRing *ring, GregoryAccStencil *s
computeBoundaryTangentStencils(ring, vert, r0, r1);
int k = valence - 1;
float omega = M_PI / k;
float omega = M_PI_F / k;
int eid1 = edge1Indices[primitiveOffset + v];
int eid2 = edge2Indices[primitiveOffset + v];
@@ -298,7 +298,7 @@ void SubdAccBuilder::computeEdgeStencil(SubdFaceRing *ring, GregoryAccStencil *s
}
}
else {
float costerm = cosf(M_PI / valence);
float costerm = cosf(M_PI_F / valence);
float sqrtterm = sqrtf(4.0f + costerm*costerm);
/* float tangentScale = 1.0f; */
@@ -319,11 +319,11 @@ void SubdAccBuilder::computeEdgeStencil(SubdFaceRing *ring, GregoryAccStencil *s
SubdEdge *edge = eit.current();
assert(vert->co == edge->from()->co);
float costerm1_a = cosf(M_PI * 2 * (j-i1) / valence);
float costerm1_b = cosf(M_PI * (2 * (j-i1)-1) / valence); /* -1 instead of +1 b/c of edge->next->to() */
float costerm1_a = cosf(M_PI_F * 2 * (j-i1) / valence);
float costerm1_b = cosf(M_PI_F * (2 * (j-i1)-1) / valence); /* -1 instead of +1 b/c of edge->next->to() */
float costerm2_a = cosf(M_PI * 2 * (j-i2) / valence);
float costerm2_b = cosf(M_PI * (2 * (j-i2)-1) / valence); /* -1 instead of +1 b/c of edge->next->to() */
float costerm2_a = cosf(M_PI_F * 2 * (j-i2) / valence);
float costerm2_b = cosf(M_PI_F * (2 * (j-i2)-1) / valence); /* -1 instead of +1 b/c of edge->next->to() */
stencil->get(eid1, edge->to()) += alpha * costerm1_a;
@@ -413,10 +413,10 @@ void SubdAccBuilder::computeInteriorStencil(SubdFaceRing *ring, GregoryAccStenci
}
else {
SubdVert *e0 = edge->from();
float costerm0 = cosf(2.0f * M_PI / pseudoValence(e0));
float costerm0 = cosf(2.0f * M_PI_F / pseudoValence(e0));
SubdVert *f0 = edge->to();
float costerm1 = cosf(2.0f * M_PI / pseudoValence(f0));
float costerm1 = cosf(2.0f * M_PI_F / pseudoValence(f0));
/* p0 +------+ q0
* | |
@@ -566,7 +566,7 @@ void SubdAccBuilder::computeBoundaryTangentStencils(SubdFaceRing *ring, SubdVert
int valence = vert->valence();
int k = valence - 1;
float omega = M_PI / k;
float omega = M_PI_F / k;
float s = sinf(omega);
float c = cosf(omega);

View File

@@ -82,8 +82,8 @@ int DiagSplit::T(Patch *patch, float2 Pstart, float2 Pend)
Plast = P;
}
int tmin = ceil(Lsum/dicing_rate);
int tmax = ceil((test_steps-1)*Lmax/dicing_rate); // XXX paper says N instead of N-1, seems wrong?
int tmin = (int)ceil(Lsum/dicing_rate);
int tmax = (int)ceil((test_steps-1)*Lmax/dicing_rate); // XXX paper says N instead of N-1, seems wrong?
if(tmax - tmin > split_threshold)
return DSPLIT_NON_UNIFORM;

View File

@@ -20,7 +20,7 @@
#define __UTIL_MAP_H__
#include <map>
#include <tr1/unordered_map>
#include <boost/tr1/unordered_map.hpp>
CCL_NAMESPACE_BEGIN

View File

@@ -48,7 +48,8 @@ CCL_NAMESPACE_BEGIN
#ifdef _WIN32
#define copysignf _copysign
#define copysignf(x, y) ((float)_copysign(x, y))
#define hypotf(x, y) _hypotf(x, y)
__device_inline float fmaxf(float a, float b)
{

View File

@@ -20,7 +20,7 @@
#define __UTIL_SET_H__
#include <set>
#include <tr1/unordered_set>
#include <boost/tr1/unordered_set.hpp>
CCL_NAMESPACE_BEGIN

View File

@@ -34,7 +34,12 @@
#define __local
#define __shared
#define __constant
#ifdef __GNUC__
#define __device_inline static inline __attribute__((always_inline))
#else
#define __device_inline static __forceinline
#endif
#endif

View File

@@ -63,7 +63,11 @@
#ifndef LIBEXPORT
#ifdef _WIN32
#ifdef BLENDER_PLUGIN
#define LIBEXPORT __declspec(dllimport)
#else
#define LIBEXPORT __declspec(dllexport)
#endif
#else
#define LIBEXPORT
#endif

View File

@@ -36,11 +36,17 @@
extern "C" {
#endif
#ifndef LIBEXPORT
#ifdef _WIN32
#ifdef BLENDER_PLUGIN
#define LIBEXPORT __declspec(dllimport)
#else
#define LIBEXPORT __declspec(dllexport)
#endif
#else
#define LIBEXPORT
#endif
#endif
struct ParameterList;
struct FunctionRNA;

View File

@@ -2450,11 +2450,17 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
" Do not edit manually, changes will be overwritten. */\n\n"
"#define RNA_RUNTIME\n\n");
fprintf(f, "#ifndef LIBEXPORT\n");
fprintf(f, "#ifdef _WIN32\n");
fprintf(f, "#ifdef BLENDER_PLUGIN\n");
fprintf(f, "#define LIBEXPORT __declspec(dllimport)\n");
fprintf(f, "#else\n");
fprintf(f, "#define LIBEXPORT __declspec(dllexport)\n");
fprintf(f, "#endif\n");
fprintf(f, "#else\n");
fprintf(f, "#define LIBEXPORT\n");
fprintf(f, "#endif\n\n");
fprintf(f, "#endif\n");
fprintf(f, "#endif\n");
fprintf(f, "#include <float.h>\n");
fprintf(f, "#include <stdio.h>\n");
@@ -2580,7 +2586,7 @@ static const char *cpp_classes = ""
"namespace BL {\n"
"\n"
"#define BOOLEAN_PROPERTY(sname, identifier) \\\n"
" inline bool sname::identifier(void) { return (bool)sname##_##identifier##_get(&ptr); }\n"
" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; }\n"
"\n"
"#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n"
" inline Array<int,size> sname::identifier(void) \\\n"
@@ -2622,7 +2628,7 @@ static const char *cpp_classes = ""
"public:\n"
" Pointer(const PointerRNA& p) : ptr(p) { }\n"
" operator const PointerRNA&() { return ptr; }\n"
" bool is_a(StructRNA *type) { return RNA_struct_is_a(ptr.type, type); }\n"
" bool is_a(StructRNA *type) { return RNA_struct_is_a(ptr.type, type)? true: false; }\n"
" operator void*() { return ptr.data; }\n"
" operator bool() { return ptr.data != NULL; }\n"
"\n"