Skip to content

Commit dbc923b

Browse files
committed
Merge branch 'glsl' of github.com:projectM-visualizer/projectm into glsl
2 parents 5ea4dc4 + 5612dcb commit dbc923b

File tree

10 files changed

+128
-184
lines changed

10 files changed

+128
-184
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ script:
1313
- test -e src/projectM-sdl/projectMSDL
1414
- test -e src/libprojectM/libprojectM.la
1515
- test -e dist_install/share/projectM/fonts/Vera.ttf
16-
- test -e dist_install/share/projectM/shaders/blur.cg
1716
- test -d dist_install/share/projectM/presets
1817
- test -e dist_install/lib/libprojectM.la
1918
- test -e dist_install/include/libprojectM/projectM.hpp
@@ -34,9 +33,8 @@ matrix:
3433
- libsdl2-dev
3534
- libglew-dev
3635
- libftgl-dev
37-
- libsdl2-dev
38-
- libdevil-dev
3936
- libglm-dev
37+
- libc++-dev
4038
env:
4139
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
4240
# linux/gcc
@@ -50,9 +48,8 @@ matrix:
5048
- libsdl2-dev
5149
- libglew-dev
5250
- libftgl-dev
53-
- libsdl2-dev
54-
- libdevil-dev
5551
- libglm-dev
52+
- libc++-dev
5653
env:
5754
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
5855

configure.ac

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ AC_CONFIG_FILES([src/libprojectM/config.inp.in])
7575
AC_PREFIX_DEFAULT([/usr/local])
7676

7777
AC_PROG_MKDIR_P
78+
79+
AX_CHECK_COMPILE_FLAG([-stdlib=libc++], [
80+
CXXFLAGS="$CXXFLAGS -stdlib=libc++"])
7881

79-
AX_CHECK_COMPILE_FLAG([-std=c++14], [
80-
CXXFLAGS="$CXXFLAGS -std=c++14"])
82+
AX_CHECK_COMPILE_FLAG([-std=c++11], [
83+
CXXFLAGS="$CXXFLAGS -std=c++11"])
8184

8285
dnl Qt
8386
AC_ARG_ENABLE([qt],

src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void PresetInputs::update(const BeatDetect & music, const PipelineContext & cont
3535
float **alloc_mesh(size_t gx, size_t gy)
3636
{
3737
// round gy up to multiple 4 (for possible SSE optimization)
38-
// gy = (gy+3) & ~(size_t)3;
38+
gy = (gy+3) & ~(size_t)3;
3939

4040
float **mesh = (float **)wipe_aligned_alloc(gx * sizeof(float *));
4141
float *m = (float *)wipe_aligned_alloc(gx * gy * sizeof(float));
@@ -236,7 +236,7 @@ inline __m128 _mm_pow(__m128 x, __m128 y)
236236
float X[4];
237237
float Y[4];
238238
_mm_store_ps(X,x);
239-
_mm_store_ps(Y,x);
239+
_mm_store_ps(Y,y);
240240
X[0] = __builtin_powf(X[0],Y[0]);
241241
X[1] = __builtin_powf(X[1],Y[1]);
242242
X[2] = __builtin_powf(X[2],Y[2]);
@@ -441,11 +441,11 @@ void PresetOutputs::PerPixelMath_sse(const PipelineContext &context)
441441

442442
void PresetOutputs::PerPixelMath(const PipelineContext &context)
443443
{
444-
//#ifdef __SSE2__
445-
// PerPixelMath_sse(context);
446-
//#else
444+
#ifdef __SSE2__
445+
PerPixelMath_sse(context);
446+
#else
447447
PerPixelMath_c(context);
448-
//#endif
448+
#endif
449449
}
450450

451451

src/libprojectM/Renderer/HLSLTranslator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using namespace M4;
1111

1212

13-
std::unique_ptr<std::string> HLSLTranslator::parse(const std::string & shaderType, const char *fileName, const std::string &fullSource) {
13+
std::string HLSLTranslator::parse(const std::string & shaderType, const char *fileName, const std::string &fullSource) {
1414
// alloc
1515
GLSLGenerator generator;
1616
Allocator allocator;
@@ -37,7 +37,7 @@ std::unique_ptr<std::string> HLSLTranslator::parse(const std::string & shaderTyp
3737
out2 << sourcePreprocessed;
3838
out2.close();
3939
#endif
40-
return nullptr;
40+
return std::string();
4141
}
4242

4343
// generate GLSL
@@ -50,10 +50,10 @@ std::unique_ptr<std::string> HLSLTranslator::parse(const std::string & shaderTyp
5050
out2 << sourcePreprocessed;
5151
out2.close();
5252
#endif
53-
return nullptr;
53+
return std::string();
5454
}
5555

56-
return std::make_unique<std::string>(generator.GetResult());
56+
return std::string(generator.GetResult());
5757
}
5858

5959

src/libprojectM/Renderer/HLSLTranslator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class HLSLTranslator {
2929
public:
30-
std::unique_ptr<std::string> parse(const std::string & shaderType, const char *fileName, const std::string &fullSource);
30+
std::string parse(const std::string & shaderType, const char *fileName, const std::string &fullSource);
3131
};
3232

3333
#endif

src/libprojectM/Renderer/PerlinNoise.cpp

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,57 @@
1111

1212
PerlinNoise::PerlinNoise()
1313
{
14-
for (int x = 0; x < 256;x++)
15-
for (int y = 0; y < 256;y++)
16-
noise_lq[x][y] = noise(x , y);
14+
for (int x = 0; x < 256;x++) {
15+
for (int y = 0; y < 256;y++) {
16+
noise_lq[x][y][0] = noise(x , y);
17+
noise_lq[x][y][1] = noise_lq[x][y][0];
18+
noise_lq[x][y][2] = noise_lq[x][y][0];
19+
}
20+
}
1721

18-
for (int x = 0; x < 32;x++)
19-
for (int y = 0; y < 32;y++)
20-
noise_lq_lite[x][y] = noise(4*x,16*y);
22+
for (int x = 0; x < 32;x++) {
23+
for (int y = 0; y < 32;y++) {
24+
noise_lq_lite[x][y][0] = noise(4*x,16*y);
25+
noise_lq_lite[x][y][1] = noise_lq_lite[x][y][0];
26+
noise_lq_lite[x][y][2] = noise_lq_lite[x][y][0];
27+
}
28+
}
2129

22-
for (int x = 0; x < 256;x++)
23-
for (int y = 0; y < 256;y++)
24-
noise_mq[x][y] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
30+
for (int x = 0; x < 256;x++) {
31+
for (int y = 0; y < 256;y++) {
32+
noise_mq[x][y][0] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
33+
noise_mq[x][y][1] = noise_mq[x][y][0];
34+
noise_mq[x][y][2] = noise_mq[x][y][0];
35+
}
36+
}
2537

26-
for (int x = 0; x < 256;x++)
27-
for (int y = 0; y < 256;y++)
28-
noise_hq[x][y] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
38+
for (int x = 0; x < 256;x++) {
39+
for (int y = 0; y < 256;y++) {
40+
noise_hq[x][y][0] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
41+
noise_hq[x][y][1] = noise_hq[x][y][0];
42+
noise_hq[x][y][2] = noise_hq[x][y][0];
43+
}
44+
}
2945

30-
for (int x = 0; x < 32;x++)
31-
for (int y = 0; y < 32;y++)
32-
for (int z = 0; z < 32;z++)
33-
noise_lq_vol[x][y][z] = noise(x,y,z);
46+
for (int x = 0; x < 32;x++) {
47+
for (int y = 0; y < 32;y++) {
48+
for (int z = 0; z < 32;z++) {
49+
noise_lq_vol[x][y][z][0] = noise(x,y,z);
50+
noise_lq_vol[x][y][z][1] = noise_lq_vol[x][y][z][0];
51+
noise_lq_vol[x][y][z][2] = noise_lq_vol[x][y][z][0];
52+
}
53+
}
54+
}
3455

35-
for (int x = 0; x < 32;x++)
36-
for (int y = 0; y < 32;y++)
37-
for (int z = 0; z < 32;z++)
38-
noise_hq_vol[x][y][z] = noise(x,y,z);//perlin_noise_3d(x,y,z,6121,7,seed3,0.5,64);
39-
40-
int seed = rand()%1000;
41-
42-
int size = 512;
43-
int octaves = sqrt((double)size);
44-
45-
for (int x = 0; x < size;x++)
46-
for (int y = 0; y < size;y++)
47-
noise_perlin[x][y] = perlin_noise_2d(x,y,6321,octaves,seed,0.5,size/4);
56+
for (int x = 0; x < 32;x++) {
57+
for (int y = 0; y < 32;y++) {
58+
for (int z = 0; z < 32;z++) {
59+
noise_hq_vol[x][y][z][0] = noise(x,y,z);
60+
noise_hq_vol[x][y][z][1] = noise_hq_vol[x][y][z][0];
61+
noise_hq_vol[x][y][z][2] = noise_hq_vol[x][y][z][0];
62+
}
63+
}
64+
}
4865
}
4966

5067
PerlinNoise::~PerlinNoise()

src/libprojectM/Renderer/PerlinNoise.hpp

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ class PerlinNoise
1414
{
1515
public:
1616

17-
float noise_lq[256][256];
18-
float noise_lq_lite[32][32];
19-
float noise_mq[256][256];
20-
float noise_hq[256][256];
21-
float noise_perlin[512][512];
22-
float noise_lq_vol[32][32][32];
23-
float noise_hq_vol[32][32][32];
17+
float noise_lq[256][256][3];
18+
float noise_lq_lite[32][32][3];
19+
float noise_mq[256][256][3];
20+
float noise_hq[256][256][3];
21+
float noise_lq_vol[32][32][32][3];
22+
float noise_hq_vol[32][32][32][3];
2423

2524

2625
PerlinNoise();
@@ -46,14 +45,6 @@ class PerlinNoise
4645
return noise(n);
4746
}
4847

49-
static inline float cos_interp(float a, float b, float x)
50-
{
51-
float ft = x * 3.1415927;
52-
float f = (1 - cos(ft)) * .5;
53-
54-
return a*(1-f) + b*f;
55-
}
56-
5748
static inline float cubic_interp(float v0, float v1, float v2, float v3, float x)
5849
{
5950
float P = (v3 - v2) - (v0 - v1);
@@ -100,53 +91,6 @@ class PerlinNoise
10091

10192
}
10293

103-
static inline float perlin_octave_2d(float x,float y, int width, int seed, float period)
104-
{
105-
106-
float freq=1/(float)(period);
107-
108-
int num=(int)(width*freq);
109-
int step_x=(int)(x*freq);
110-
int step_y=(int)(y*freq);
111-
float zone_x=x*freq-step_x;
112-
float zone_y=y*freq-step_y;
113-
int box=step_x+step_y*num;
114-
int noisedata=(box+seed);
115-
116-
float u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x);
117-
float a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x);
118-
float b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x);
119-
float v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x);
120-
121-
float value=cubic_interp(u,a,b,v,zone_y);
122-
123-
return value;
124-
}
125-
126-
127-
static inline float perlin_octave_2d_cos(float x,float y, int width, int seed, float period)
128-
{
129-
130-
float freq=1/(float)(period);
131-
132-
int num=(int)(width*freq);
133-
int step_x=(int)(x*freq);
134-
int step_y=(int)(y*freq);
135-
float zone_x=x*freq-step_x;
136-
float zone_y=y*freq-step_y;
137-
int box=step_x+step_y*num;
138-
int noisedata=(box+seed);
139-
140-
float a=cos_interp(noise(noisedata),noise(noisedata+1),zone_x);
141-
float b=cos_interp(noise(noisedata+num),noise(noisedata+1+num),zone_x);
142-
143-
float value=cos_interp(a,b,zone_y);
144-
145-
return value;
146-
}
147-
148-
149-
15094
static inline float perlin_octave_3d(float x,float y, float z,int width, int seed, float period)
15195
{
15296
float freq=1/(float)(period);
@@ -204,21 +148,6 @@ class PerlinNoise
204148
}
205149

206150

207-
static inline float perlin_noise_2d(int x, int y, int width, int octaves, int seed, float persistance, float basePeriod)
208-
{
209-
float p = persistance;
210-
float val = 0.0;
211-
212-
for (int i = 0; i<octaves;i++)
213-
{
214-
val += perlin_octave_2d_cos(x,y,width,seed,basePeriod) * p;
215-
216-
basePeriod *= 0.5;
217-
p *= persistance;
218-
}
219-
return val;
220-
}
221-
222151
static inline float perlin_noise_3d(int x, int y, int z, int width, int octaves, int seed, float persistance, float basePeriod)
223152
{
224153
float p = persistance;

0 commit comments

Comments
 (0)