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