Subversion Repositories filter_foundry

Rev

Rev 452 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 452 Rev 526
1
 
1
 
2
Building FilterFoundry with OpenWatcom
2
Building FilterFoundry with OpenWatcom
3
======================================
3
======================================
4
 
4
 
5
Tested with OpenWatcom 1.9 and OpenWatcom 2.0 together with Adobe Photoshop SDK 2021.
5
Tested with OpenWatcom 1.9 and OpenWatcom 2.0 together with Adobe Photoshop SDK 2021.
6
 
6
 
7
 
7
 
8
Prerequisites
8
Prerequisites
9
-------------
9
-------------
10
 
10
 
11
1) Flex and Bison
11
1) Flex and Bison
12
   Available here:
12
   Available here:
13
   https://sourceforge.net/projects/winflexbison/
13
   https://sourceforge.net/projects/winflexbison/
14
 
14
 
15
2) Adobe Photoshop SDK
15
2) Adobe Photoshop SDK
16
   Available on some Photoshop CDs, or can be downloaded at
16
   Available on some Photoshop CDs, or can be downloaded at
17
   https://www.adobe.com/devnet/photoshop/sdk.html
17
   https://developer.adobe.com/photoshop/
-
 
18
   (see more details at the ../photoshop_sdk/DOWNLOAD.txt)
18
 
19
 
19
3) Watcom 1.6beta RC1 or later
20
3) Watcom 1.6beta RC1 or later
20
   Available here:
21
   Available here:
21
   http://www.openwatcom.org/
22
   http://www.openwatcom.org/
22
   After installing, do a reboot, or set the environment manually.
23
   After installing, do a reboot, or set the environment manually.
23
 
24
 
24
 
25
 
25
Build setup
26
Build setup
26
-----------
27
-----------
27
 
28
 
28
There is no special build setup required.
29
There is no special build setup required.
29
Just open **wpj\filterfoundry.wpj** in Watcom's IDE and click "Make target".
30
Just open **wpj\filterfoundry.wpj** in Watcom's IDE and click "Make target".
30
 
31
 
31
Alternatively, run **wpj\make_watcom.bat** which should do the same.
32
Alternatively, run **wpj\make_watcom.bat** which should do the same.
32
 
33
 
33
IMPORTANT: Your path must not contain whitespaces!
34
IMPORTANT: Your path must not contain whitespaces!
34
For example, you must not use "C:\Users\John Doe\SVN\Filter Foundry\".
35
For example, you must not use "C:\Users\John Doe\SVN\Filter Foundry\".
35
 
36
 
36
 
37
 
37
Troubleshooting
38
Troubleshooting
38
---------------
39
---------------
39
 
40
 
40
- Please make sure that you must not have whitespaces in the pathname.
41
- Please make sure that you must not have whitespaces in the pathname.
41
 
42
 
42
- Missing **sdkddkver.h**:
43
- Missing **sdkddkver.h**:
43
  * In OpenWatcom 1.9:
44
  * In OpenWatcom 1.9:
44
    If you get the error message "Fatal Error! 62:  Unable to open 'sdkddkver.h'", please open 
45
    If you get the error message "Fatal Error! 62:  Unable to open 'sdkddkver.h'", please open 
45
    pluginsdk\photoshopapi\photoshop\PITypes.h in your Adobe Photoshop SDK and
46
    pluginsdk\photoshopapi\photoshop\PITypes.h in your Adobe Photoshop SDK and
46
    comment out the line "#include <sdkddkver.h> // for WINVER".
47
    comment out the line "#include <sdkddkver.h> // for WINVER".
47
    Alternatively, you can create an empty sdkddkver.h file in your wpj folder.
48
    Alternatively, you can create an empty sdkddkver.h file in your wpj folder.
48
  * Take care that the directory "." is added to the include path of the C-compiler
49
  * Take care that the directory "." is added to the include path of the C-compiler
49
    and the RC-compiler!
50
    and the RC-compiler!
50
 
51
 
51
- It is important that the correct calling convention is used.
52
- It is important that the correct calling convention is used.
52
  The calling convention needs to be set in
53
  The calling convention needs to be set in
53
  Options -> C Compiler Switches -> Memory Model and Processor Switches.
54
  Options -> C Compiler Switches -> Memory Model and Processor Switches.
54
  There, select "Pentium Pro stack-based calling" (default is "Pentium Pro register based calling").
55
  There, select "Pentium Pro stack-based calling" (default is "Pentium Pro register based calling").
55
  The wpj project should already have this setting applied.
56
  The wpj project should already have this setting applied.
56
 
57
 
57
- If you receive the error message "lex.yy.c(580): Error! E1009: Expecting ';' but found '1'",
58
- If you receive the error message "lex.yy.c(580): Error! E1009: Expecting ';' but found '1'",
58
  check if the compiler directive "YY_SKIP_YYWRAP" is set.
59
  check if the compiler directive "YY_SKIP_YYWRAP" is set.
59
  Go to Options -> C Compiler Switches -> Source switches, and add YY_SKIP_YYWRAP=1 .
60
  Go to Options -> C Compiler Switches -> Source switches, and add YY_SKIP_YYWRAP=1 .
60
  The wpj project should already have this setting applied.
61
  The wpj project should already have this setting applied.
61
 
62
 
62
- The path to the Photoshop SDK and to Win Flex/Bison (PreBuild event)
63
- The path to the Photoshop SDK and to Win Flex/Bison (PreBuild event)
63
  is already set in the project file. Please note that changing these
64
  is already set in the project file. Please note that changing these
64
  paths is a bit complicated. There are several bugs in older versions of OpenWatcom
65
  paths is a bit complicated. There are several bugs in older versions of OpenWatcom
65
  where you can only make the pre-build-events shorter, but not longer).
66
  where you can only make the pre-build-events shorter, but not longer).
66
  You have to edit the WPJ file with a text editor.
67
  You have to edit the WPJ file with a text editor.
67
  Remember how many characters you have added or deleted,
68
  Remember how many characters you have added or deleted,
68
  and subtract or add them to the number written above the before-instructions.
69
  and subtract or add them to the number written above the before-instructions.
69
  This is the number of bytes of the commands.
70
  This is the number of bytes of the commands.
70
 
71
 
71
- In the code, it is important that all variables are declared at the
72
- In the code, it is important that all variables are declared at the
72
  top of the scope (curly brackets) and that there is no executable code or
73
  top of the scope (curly brackets) and that there is no executable code or
73
  assignments in between.
74
  assignments in between.
74
 
75
 
75
Wrong:
76
Wrong:
76
 
77
 
77
    int a;
78
    int a;
78
    int b = GetXYZ();
79
    int b = GetXYZ();
79
    int c;
80
    int c;
80
 
81
 
81
Correct:
82
Correct:
82
 
83
 
83
    int a;
84
    int a;
84
    int b;
85
    int b;
85
    int c;
86
    int c;
86
    b = GetXYZ();
87
    b = GetXYZ();
87
 
88
 
88
 
89
 
89
Performance
90
Performance
90
-----------
91
-----------
91
 
92
 
92
### In Comparison to Filter Factory, the WPJ build without "-s" (Disable stack depth checking) is super slow!
93
### In Comparison to Filter Factory, the WPJ build without "-s" (Disable stack depth checking) is super slow!
93
 
94
 
94
Example:
95
Example:
95
 
96
 
96
Picture 5412x3962 pixels RGBA without transparency
97
Picture 5412x3962 pixels RGBA without transparency
97
 
98
 
98
    R: put(rnd(i,255),0),get(0)>255-i+val(0,-128,128)?255:0
99
    R: put(rnd(i,255),0),get(0)>255-i+val(0,-128,128)?255:0
99
    G: get(0)>255-i+val(0,-128,128)?255:0
100
    G: get(0)>255-i+val(0,-128,128)?255:0
100
    B: get(0)>255-i+val(0,-128,128)?255:0
101
    B: get(0)>255-i+val(0,-128,128)?255:0
101
    A: a
102
    A: a
102
 
103
 
103
Approximate measurements:
104
Approximate measurements:
104
 
105
 
105
    Filter Factory:          1,8 seconds
106
    Filter Factory:          1,8 seconds
106
    Foundry VC++ Debug:      20 seconds
107
    Foundry VC++ Debug:      20 seconds
107
    Foundry WPJ Optimized:   18 seconds
108
    Foundry WPJ Optimized:   18 seconds
108
    Foundry WPJ "-s" opt.:   3,2 seconds
109
    Foundry WPJ "-s" opt.:   3,2 seconds
109
    Foundry Vc++ Release:    2,8 seconds
110
    Foundry Vc++ Release:    2,8 seconds
110
    Foundry WingW Release:   2,8 seconds
111
    Foundry WingW Release:   2,8 seconds
111
 
112
 
112
### What does "Fastest possible code (-otexan)" mean?
113
### What does "Fastest possible code (-otexan)" mean?
113
 
114
 
114
"otexan" contains "s" (because "ox" is equal to "obmiler" and "s").
115
"otexan" contains "s" (because "ox" is equal to "obmiler" and "s").
115
 
116
 
116
So, "-otexan" means:
117
So, "-otexan" means:
117
 
118
 
118
- Branch prediction (-ob)
119
- Branch prediction (-ob)
119
- Loop optimizations (-ol)
120
- Loop optimizations (-ol)
120
- In-line intrinsic functions (-oi)
121
- In-line intrinsic functions (-oi)
121
- Instruction scheduling (-or)
122
- Instruction scheduling (-or)
122
- Math optimizations (-om)
123
- Math optimizations (-om)
123
- Expand function in-line (-oe)
124
- Expand function in-line (-oe)
124
- Disable stack depth checking (-s)
125
- Disable stack depth checking (-s)
125
 
126
 
126
### Attention! Some optimizations break the code:
127
### Attention! Some optimizations break the code:
127
 
128
 
128
As soon as "Disable stack depth checking" is enabled, the code crashes
129
As soon as "Disable stack depth checking" is enabled, the code crashes
129
on some combinations of machines and Photoshop versions.
130
on some combinations of machines and Photoshop versions.
130
 
131
 
131
Win98 VM + Photoshop 3.0.x: Clicking any button (Make, Load, Cancel) will cause SegFault.
132
Win98 VM + Photoshop 3.0.x: Clicking any button (Make, Load, Cancel) will cause SegFault.
132
Win98 VM + Photoshop 7.0 : No problem
133
Win98 VM + Photoshop 7.0 : No problem
133
Win10 PC + Photoshop 3.0.x: No problem.
134
Win10 PC + Photoshop 3.0.x: No problem.
134
 
135
 
135
I haven't been able to detect why/where the stack is overloaded.
136
I haven't been able to detect why/where the stack is overloaded.
136
If anyone has an idea, please contact me.
137
If anyone has an idea, please contact me.
137
Maybe the initial stack size is just too small?
138
Maybe the initial stack size is just too small?
138
Because the code should be OK - Application Verifier has not detected anything wrong.
139
Because the code should be OK - Application Verifier has not detected anything wrong.
139
 
140
 
140
https://open-watcom.github.io/open-watcom-v2-wikidocs/c_readme.html
141
https://open-watcom.github.io/open-watcom-v2-wikidocs/c_readme.html
141
http://www.azillionmonkeys.com/qed/watfaq.shtml (Q19)
142
http://www.azillionmonkeys.com/qed/watfaq.shtml (Q19)
142
 
143
 
143
However, if we add `-sg` (generate calls to grow the stack), it seems to work.
144
However, if we add `-sg` (generate calls to grow the stack), it seems to work.
144
 
145
 
145
 
146
 
146
Remarks
147
Remarks
147
-------
148
-------
148
 
149
 
149
flex and bison are currently invoked as a batch process.
150
flex and bison are currently invoked as a batch process.
150
This is defined in the menu File->Before.
151
This is defined in the menu File->Before.
151
The IDE fails to build the project when filenames contain more than one dot.
152
The IDE fails to build the project when filenames contain more than one dot.
152
Therefore the output files of bison and lex are renamed.
153
Therefore the output files of bison and lex are renamed.
153
There is no error checking done.
154
There is no error checking done.
154
Probably it would be better to write a small wmake file for this purpose.
155
Probably it would be better to write a small wmake file for this purpose.
155
 
156
 
156
C-switches which are not recognized by the OpenWatcom IDE:
157
C-switches which are not recognized by the OpenWatcom IDE:
157
 
158
 
158
    -aq  turn off qualifier mismatch warning for const/volatile
159
    -aq  turn off qualifier mismatch warning for const/volatile
159
    -sg  generate calls to grow the stack
160
    -sg  generate calls to grow the stack