Skip to content

Commit 1ec3c82

Browse files
committed
Fix Linux build
1 parent d767407 commit 1ec3c82

File tree

5 files changed

+83
-64
lines changed

5 files changed

+83
-64
lines changed

.gitignore

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,23 @@ Bin/Release/x64/App64.exe
1818
*.exe
1919
*.opendb
2020
*.db
21-
*.sln
21+
*.sln
22+
*.d
23+
24+
*.o
25+
26+
*.a
27+
28+
*.so
29+
30+
App/Makefile
31+
32+
Bin/Release/x64/
33+
34+
CLW/Makefile
35+
36+
Calc/Makefile
37+
38+
Gtest/Makefile
39+
40+
Makefile

App/CL/payload.cl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ typedef struct _Camera
3131
float3 right;
3232
float3 up;
3333
float3 p;
34-
34+
3535
// Image plane width & height in current units
3636
float2 dim;
37-
37+
3838
// Near and far Z
3939
float2 zcap;
4040
// Focal lenght
@@ -127,7 +127,7 @@ typedef struct _Material
127127
int type;
128128
int num_materials;
129129
};
130-
130+
131131
int twosided;
132132
} Material;
133133

@@ -162,8 +162,8 @@ typedef struct _Light
162162
int texdiffuse;
163163
float multiplier;
164164
};
165-
166-
165+
166+
167167
// Spot
168168
struct
169169
{
@@ -198,11 +198,11 @@ typedef struct _Volume
198198
{
199199
VolumeType type;
200200
PhaseFunction phase_func;
201-
201+
202202
// Id of volume data if present
203203
int data;
204204
int extra;
205-
205+
206206
// Absorbtion
207207
float3 sigma_a;
208208
// Scattering
@@ -245,7 +245,7 @@ typedef struct __matrix
245245
float4 m1;
246246
float4 m2;
247247
float4 m3;
248-
};
248+
} rows;
249249

250250
float m[16];
251251
};

App/CL/scene.cl

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,35 @@ void DifferentialGeometry_Fill(// Scene
6363
// Determine shape and polygon
6464
int shapeid = isect->shapeid - 1;
6565
int primid = isect->primid;
66-
66+
6767
// Get barycentrics
6868
float2 uv = isect->uvwt.xy;
69-
69+
7070
// Extract shape data
7171
Shape shape = scene->shapes[shapeid];
7272
//float3 linearvelocity = shape.linearvelocity;
7373
//float4 angularvelocity = shape.angularvelocity;
74-
74+
7575
// Fetch indices starting from startidx and offset by primid
7676
int i0 = scene->indices[shape.startidx + 3 * primid];
7777
int i1 = scene->indices[shape.startidx + 3 * primid + 1];
7878
int i2 = scene->indices[shape.startidx + 3 * primid + 2];
79-
79+
8080
// Fetch normals
8181
float3 n0 = scene->normals[shape.startvtx + i0];
8282
float3 n1 = scene->normals[shape.startvtx + i1];
8383
float3 n2 = scene->normals[shape.startvtx + i2];
84-
84+
8585
// Fetch positions
8686
float3 v0 = scene->vertices[shape.startvtx + i0];
8787
float3 v1 = scene->vertices[shape.startvtx + i1];
8888
float3 v2 = scene->vertices[shape.startvtx + i2];
89-
89+
9090
// Fetch UVs
9191
float2 uv0 = scene->uvs[shape.startvtx + i0];
9292
float2 uv1 = scene->uvs[shape.startvtx + i1];
9393
float2 uv2 = scene->uvs[shape.startvtx + i2];
94-
94+
9595
// Calculate barycentric position and normal
9696
diffgeo->n = normalize(transform_vector((1.f - uv.x - uv.y) * n0 + uv.x * n1 + uv.y * n2, shape.m0, shape.m1, shape.m2, shape.m3));
9797
diffgeo->p = transform_point((1.f - uv.x - uv.y) * v0 + uv.x * v1 + uv.y * v2, shape.m0, shape.m1, shape.m2, shape.m3);
@@ -101,7 +101,7 @@ void DifferentialGeometry_Fill(// Scene
101101

102102
if (dot(diffgeo->ng, diffgeo->n) < 0.f)
103103
diffgeo->ng = -diffgeo->ng;
104-
104+
105105
// Get material at shading point
106106
int matidx = scene->materialids[shape.startidx / 3 + primid];
107107
diffgeo->mat = scene->materials[matidx];
@@ -111,12 +111,12 @@ void DifferentialGeometry_Fill(// Scene
111111
float du2 = uv1.x - uv2.x;
112112
float dv1 = uv0.y - uv2.y;
113113
float dv2 = uv1.y - uv2.y;
114-
114+
115115
float3 dp1 = v0 - v2;
116116
float3 dp2 = v1 - v2;
117-
117+
118118
float det = du1 * dv2 - dv1 * du2;
119-
119+
120120
if (0 && det != 0.f)
121121
{
122122
float invdet = 1.f / det;
@@ -128,7 +128,7 @@ void DifferentialGeometry_Fill(// Scene
128128
diffgeo->dpdu = normalize(GetOrthoVector(diffgeo->n));
129129
diffgeo->dpdv = normalize(cross(diffgeo->n, diffgeo->dpdu));
130130
}
131-
131+
132132

133133

134134
// Fix all to be orthogonal
@@ -149,18 +149,18 @@ void DifferentialGeometry_CalculateTangentTransforms(DifferentialGeometry* diffg
149149
diffgeo->n,
150150
diffgeo->dpdv);
151151

152-
diffgeo->world_to_tangent.m0.w = -dot(diffgeo->dpdu, diffgeo->p);
153-
diffgeo->world_to_tangent.m1.w = -dot(diffgeo->n, diffgeo->p);
154-
diffgeo->world_to_tangent.m2.w = -dot(diffgeo->dpdv, diffgeo->p);
152+
diffgeo->world_to_tangent.rows.m0.w = -dot(diffgeo->dpdu, diffgeo->p);
153+
diffgeo->world_to_tangent.rows.m1.w = -dot(diffgeo->n, diffgeo->p);
154+
diffgeo->world_to_tangent.rows.m2.w = -dot(diffgeo->dpdv, diffgeo->p);
155155

156156
diffgeo->tangent_to_world = matrix_from_cols3(
157-
diffgeo->world_to_tangent.m0.xyz,
158-
diffgeo->world_to_tangent.m1.xyz,
159-
diffgeo->world_to_tangent.m2.xyz);
157+
diffgeo->world_to_tangent.rows.m0.xyz,
158+
diffgeo->world_to_tangent.rows.m1.xyz,
159+
diffgeo->world_to_tangent.rows.m2.xyz);
160160

161-
diffgeo->tangent_to_world.m0.w = diffgeo->p.x;
162-
diffgeo->tangent_to_world.m1.w = diffgeo->p.y;
163-
diffgeo->tangent_to_world.m2.w = diffgeo->p.z;
161+
diffgeo->tangent_to_world.rows.m0.w = diffgeo->p.x;
162+
diffgeo->tangent_to_world.rows.m1.w = diffgeo->p.y;
163+
diffgeo->tangent_to_world.rows.m2.w = diffgeo->p.z;
164164
}
165165

166166
int Scene_SampleLight(Scene const* scene, float sample, float* pdf)

App/CL/utils.cl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,73 +72,73 @@ float matrix_get(matrix m, int i, int j)
7272
matrix matrix_from_cols(float4 c0, float4 c1, float4 c2, float4 c3)
7373
{
7474
matrix m;
75-
m.m0 = make_float4(c0.x, c1.x, c2.x, c3.x);
76-
m.m1 = make_float4(c0.y, c1.y, c2.y, c3.y);
77-
m.m2 = make_float4(c0.z, c1.z, c2.z, c3.z);
78-
m.m3 = make_float4(c0.w, c1.w, c2.w, c3.w);
75+
m.rows.m0 = make_float4(c0.x, c1.x, c2.x, c3.x);
76+
m.rows.m1 = make_float4(c0.y, c1.y, c2.y, c3.y);
77+
m.rows.m2 = make_float4(c0.z, c1.z, c2.z, c3.z);
78+
m.rows.m3 = make_float4(c0.w, c1.w, c2.w, c3.w);
7979
return m;
8080
}
8181

8282
matrix matrix_from_rows(float4 c0, float4 c1, float4 c2, float4 c3)
8383
{
8484
matrix m;
85-
m.m0 = c0;
86-
m.m1 = c1;
87-
m.m2 = c2;
88-
m.m3 = c3;
85+
m.rows.m0 = c0;
86+
m.rows.m1 = c1;
87+
m.rows.m2 = c2;
88+
m.rows.m3 = c3;
8989
return m;
9090
}
9191

9292
matrix matrix_from_rows3(float3 c0, float3 c1, float3 c2)
9393
{
9494
matrix m;
95-
m.m0.xyz = c0; m.m0.w = 0;
96-
m.m1.xyz = c1; m.m1.w = 0;
97-
m.m2.xyz = c2; m.m2.w = 0;
98-
m.m3 = make_float4(0.f, 0.f, 0.f, 1.f);
95+
m.rows.m0.xyz = c0; m.rows.m0.w = 0;
96+
m.rows.m1.xyz = c1; m.rows.m1.w = 0;
97+
m.rows.m2.xyz = c2; m.rows.m2.w = 0;
98+
m.rows.m3 = make_float4(0.f, 0.f, 0.f, 1.f);
9999
return m;
100100
}
101101

102102
matrix matrix_from_cols3(float3 c0, float3 c1, float3 c2)
103103
{
104104
matrix m;
105-
m.m0 = make_float4(c0.x, c1.x, c2.x, 0.f);
106-
m.m1 = make_float4(c0.y, c1.y, c2.y, 0.f);
107-
m.m2 = make_float4(c0.z, c1.z, c2.z, 0.f);
108-
m.m3 = make_float4(0.f, 0.f, 0.f, 1.f);
105+
m.rows.m0 = make_float4(c0.x, c1.x, c2.x, 0.f);
106+
m.rows.m1 = make_float4(c0.y, c1.y, c2.y, 0.f);
107+
m.rows.m2 = make_float4(c0.z, c1.z, c2.z, 0.f);
108+
m.rows.m3 = make_float4(0.f, 0.f, 0.f, 1.f);
109109
return m;
110110
}
111111

112112
matrix matrix_transpose(matrix m)
113113
{
114-
return matrix_from_cols(m.m0, m.m1, m.m2, m.m3);
114+
return matrix_from_cols(m.rows.m0, m.rows.m1, m.rows.m2, m.rows.m3);
115115
}
116116

117117
float4 matrix_mul_vector4(matrix m, float4 v)
118118
{
119119
float4 res;
120-
res.x = dot(m.m0, v);
121-
res.y = dot(m.m1, v);
122-
res.z = dot(m.m2, v);
123-
res.w = dot(m.m3, v);
120+
res.x = dot(m.rows.m0, v);
121+
res.y = dot(m.rows.m1, v);
122+
res.z = dot(m.rows.m2, v);
123+
res.w = dot(m.rows.m3, v);
124124
return res;
125125
}
126126

127127
float3 matrix_mul_vector3(matrix m, float3 v)
128128
{
129129
float3 res;
130-
res.x = dot(m.m0.xyz, v);
131-
res.y = dot(m.m1.xyz, v);
132-
res.z = dot(m.m2.xyz, v);
130+
res.x = dot(m.rows.m0.xyz, v);
131+
res.y = dot(m.rows.m1.xyz, v);
132+
res.z = dot(m.rows.m2.xyz, v);
133133
return res;
134134
}
135135

136136
float3 matrix_mul_point3(matrix m, float3 v)
137137
{
138138
float3 res;
139-
res.x = dot(m.m0.xyz, v) + m.m0.w;
140-
res.y = dot(m.m1.xyz, v) + m.m1.w;
141-
res.z = dot(m.m2.xyz, v) + m.m2.w;
139+
res.x = dot(m.rows.m0.xyz, v) + m.rows.m0.w;
140+
res.y = dot(m.rows.m1.xyz, v) + m.rows.m1.w;
141+
res.z = dot(m.rows.m2.xyz, v) + m.rows.m2.w;
142142
return res;
143143
}
144144

App/Scene/IO/material_io.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "Scene/material.h"
77

88
#include "Scene/IO/image_io.h"
9-
#include "Scene/Collector/Collector.h"
9+
#include "Scene/Collector/collector.h"
1010

1111

1212
#include "XML/tinyxml2.h"
@@ -18,7 +18,7 @@
1818
namespace Baikal
1919
{
2020
using namespace tinyxml2;
21-
21+
2222
// XML based material IO implememtation
2323
class MaterialIoXML : public MaterialIo
2424
{
@@ -60,7 +60,7 @@ namespace Baikal
6060
std::set<ResolveRequest> m_resolve_requests;
6161
std::string m_base_path;
6262
};
63-
63+
6464
MaterialIo* MaterialIo::CreateMaterialIoXML()
6565
{
6666
return new MaterialIoXML();
@@ -106,7 +106,7 @@ namespace Baikal
106106

107107
static SingleBxdf::BxdfType StringToBxdf(std::string const& bxdf)
108108
{
109-
static std::map<std::string, SingleBxdf::BxdfType> bxdf_map =
109+
static std::map<std::string, SingleBxdf::BxdfType> bxdf_map =
110110
{
111111
{ "zero" , Baikal::SingleBxdf::BxdfType::kZero },
112112
{ "lambert" , Baikal::SingleBxdf::BxdfType::kLambert },
@@ -167,7 +167,7 @@ namespace Baikal
167167
else
168168
{
169169
printer.PushAttribute("type", "material");
170-
170+
171171
printer.PushAttribute("value", (int)(reinterpret_cast<std::uint64_t>(value.mat_value)));
172172
}
173173

@@ -243,13 +243,13 @@ namespace Baikal
243243
if (type == MultiBxdf::Type::kFresnelBlend)
244244
{
245245
Material::InputValue ior = material->GetInputValue("ior");
246-
246+
247247
WriteInput(io, printer, "ior", ior);
248248
}
249249
else
250250
{
251251
Material::InputValue weight = material->GetInputValue("weight");
252-
252+
253253
WriteInput(io, printer, "weight", weight);
254254
}
255255
}

0 commit comments

Comments
 (0)