Forum > Russian
Баги CYBERGRAPHICS AmigaOS 4.1
TRon:
@Smalovsky:
I was able to confirm this issue for fpc 3.2.2. I have not checked if it is already fixed in fpc trunk (the default os alignment for records should usually take care of this)
It is indeed an alignment issue for the record structure TCyberModeNode in unit cybergraphics (OS4units).
In order to fix it you have to change that structure to a packed record.
Currently you can use two options to workaround the issue:
1: declare the fixed correct structure inside your program
2: copy the cybergraphics.pas header-file next to your project and in that copied file, fix the record structure. During compilation the compiler will then automatically pick up on the (modified/fixed) cybergraphics unit in your project directory first.
So for example, for using the workaround inside a project you could use:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program ListCGFXModes; uses exec, agraphics, cybergraphics; type PCyberModeNode = ^TCyberModeNode; TCyberModeNode = packed record // <--- make it a packed record Node: TNode; ModeText: array[0..DISPLAYNAMELEN - 1] of Char; // name for this mode DisplayID: ULONG; // display id associated with the node Width: UWORD; // visible width Height: UWORD; // visible height Depth: UWORD; // display depth DisplayTagList: PTagItem; // taglist with extended ModeID information end; procedure ListModes;var nodeList: PList; node: PNode; cgxNode: PCyberModeNode absolute node;begin nodeList := AllocCModeListTagList(nil); if assigned(nodeList) then begin node := nodelist^.lh_head; while assigned(node^.ln_succ) do begin write('Mode = ' , cgxNode^.ModeText); write(' Width = ', cgxNode^.Width); write(' Height = ', cgxNode^.Height); write(' Depth = ', cgxNode^.Depth); writeln; node := node^.ln_succ; end; FreeCModeList(nodeList); end else writeln('Unable to obtain CGFX Mode list');end; begin ListModes;end.
Also note the use of a more correct way to travers the nodelist (for more information about exec lists and how to use them see here and in particular this) as well as freeing the allocated list.
As written by alextp, bugs can be reported at gitlab: https://gitlab.com/freepascal.org/fpc/source/-/issues
Sorry for me to keep corresponding in English, I meant no disrespect by doing so (I just can't read/write Russian and I do not like butchering my response by using a online translator). Thank you for reporting !
Smalovsky:
Из-за того что я использую эмулятор, мне трудно оценить скорость библиотеки.
Я написал два теста для оценки скорости библиотеки.
Первый тест статический, в котором оценивается скорость вывода пиксельного массива в окно размером 640 на 480 пикселей. Пиксельный массив 500 раз выводится на экран, и затем оценивается показатель fps.
Второй тест динамический, который длится около 50 секунд. Пиксельный массив формируется каждый кадр по определённым правилам. Этот тест показывает общую производительность системы с помощью показателя fps.
Пожалуйста, помогите мне определить степень замедления эмулятора по сравнению с реальными компьютерами. Проведите тесты и напишите - какую машину использовали и результаты тестов(fps).
У меня вышло: первый тест 9.4 fps , второй 2.2 fps.
Google translation:
Because I use an emulator, it is difficult for me to estimate the speed of the library.
I wrote two tests to estimate the speed of the library.
The first test is static, which estimates the speed of outputting a pixel array to a window of 640 by 480 pixels. The pixel array is output to the screen 500 times, and then the fps indicator is estimated.
The second test is dynamic, which lasts about 50 seconds. The pixel array is formed every frame according to certain rules. This test shows the overall performance of the system using the fps indicator.
Please help me determine the degree of slowdown of the emulator compared to real computers. Run the tests and write - which machine was used and the test results (fps).
I got: the first test 9.4 fps, the second 2.2 fps.
1. Static test
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Program Cyber_fps;uses exec, sysutils, utility, intuition,agraphics,cybergraphics,timer,math; var win:PWindow; done:Boolean=False; Msg:PMessage; pix_array:ARRAY[0..307199] of ULONG; x,y:Integer; color_part1,color_part2,color_part3:ULONG; tr:PTimerequest; tp:PMsgPort; start_sec,end_sec:ULONG; start_micro,end_micro:ULONG; ptm:PTimeval; test_time:float; n,i:Integer; fps:float; err:longint; begin tp:=createport(nil,0); if tp=nil then halt() else begin tr:=PTimerequest(CreateExtIO(tp,Sizeof(TTimerequest))); if tr=nil then begin deleteport(tp); halt(); end else begin err:=OpenDevice(TIMERNAME,UNIT_MICROHZ,PIORequest(tr),0); if err<>0 then begin DeleteExtIO(PIORequest(tr)); DeletePort(tp); halt(); end; end; end; tr^.tr_Node.io_Command:=TR_GETSYSTIME; win:=OpenWindowTags(nil, [WA_InnerWidth,AsTag(640), WA_InnerHeight,AsTag(480), WA_MinWidth,AsTag(100), WA_MinHeight,AsTag(100), WA_Left,AsTag(300), WA_Top,AsTag(50), WA_Title,AsTag('My Window'), WA_DepthGadget,AsTag(True), WA_SizeGadget,AsTag(True), WA_DragBar,AsTag(True), WA_Flags,WFLG_Closegadget or WFLG_GIMMEZEROZERO, WA_IDCMP,IDCMP_CLOSEWINDOW or IDCMP_REFRESHWINDOW, TAG_END]); for y:=0 to 479 do begin for x:=0 to 639 do begin color_part1:=x; color_part2:=$F00; color_part3:=(x+y); pix_array[y*640+x]:=(color_part1 xor color_part2 or color_part3) and $00FFFFFF; end; end; n:=500; DoIO(PIORequest(tr)); ptm:=@tr^.tr_time; start_sec:=ptm^.tv_secs; start_micro:=ptm^.tv_micro; for i:=0 to n do WritePixelArray(@pix_array,0,0,640*SizeOf(ULONG),win^.RPort,0,0,640,480,RECTFMT_ARGB); DoIO(PIORequest(tr)); ptm:=@tr^.tr_time; end_sec:=ptm^.tv_secs; end_micro:=ptm^.tv_micro; test_time:=end_sec-start_sec+(end_micro-start_micro)/1000000; fps:=n/test_time; writeln('start sec= ',start_sec,' start micro= ',start_micro); writeln('end sec= ',end_sec,' end micro= ',end_micro); writeln('test time= ',test_time:10:5); writeln('fps= ',fps:10:5); repeat WaitPort(Win^.UserPort); Msg:=GetMsg(Win^.UserPort); case PIntuiMessage(Msg)^.IClass of IDCMP_CloseWindow: done:=True; end; ReplyMsg(Msg); Until done; CloseDevice(PIORequest(tr)); DeleteExtIO(PIORequest(tr)); DeletePort(tp); CloseWindow(Win);end.
2. Dynamic test
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Program Cyber_fps2;uses exec, sysutils, utility, intuition,agraphics,cybergraphics,timer,math; var win:PWindow; done:Boolean=False; Msg:PMessage; pix_array:ARRAY[0..307199] of ULONG; x,y:Integer; color_part1,color_part2,color_part3:ULONG; tr:PTimerequest; tp:PMsgPort; start_sec,end_sec:ULONG; start_micro,end_micro:ULONG; ptm:PTimeval; test_time:float; n:LongInt; fps:float; err:LongInt; r,dir:UBYTE;begin tp:=createport(nil,0); if tp=nil then halt() else begin tr:=PTimerequest(CreateExtIO(tp,Sizeof(TTimerequest))); if tr=nil then begin deleteport(tp); halt(); end else begin err:=OpenDevice(TIMERNAME,UNIT_MICROHZ,PIORequest(tr),0); if err<>0 then begin DeleteExtIO(PIORequest(tr)); DeletePort(tp); halt(); end; end; end; tr^.tr_Node.io_Command:=TR_GETSYSTIME; win:=OpenWindowTags(nil, [WA_InnerWidth,AsTag(640), WA_InnerHeight,AsTag(480), WA_MinWidth,AsTag(100), WA_MinHeight,AsTag(100), WA_Left,AsTag(300), WA_Top,AsTag(50), WA_Title,AsTag('My Window'), WA_DepthGadget,AsTag(True), WA_SizeGadget,AsTag(True), WA_DragBar,AsTag(True), WA_Flags,WFLG_Closegadget or WFLG_GIMMEZEROZERO, WA_IDCMP,IDCMP_CLOSEWINDOW or IDCMP_REFRESHWINDOW, TAG_END]); randomize; n:=0; test_time:=0; r:=0; dir:=1; DoIO(PIORequest(tr)); ptm:=@tr^.tr_time; start_sec:=ptm^.tv_secs; start_micro:=ptm^.tv_micro; repeat for y:=0 to 479 do begin for x:=0 to 639 do begin color_part1:=x+system.random(r); color_part2:=y+system.random(r); color_part3:=(x+y)+system.random(r); pix_array[y*640+x]:=(color_part1 or color_part2 or color_part3) and $00FFFFFF; end; end; if dir=1 then begin r:=r+1; if r=50 then dir:=2; end else begin r:=r-1; if r=0 then dir:=1; end; WritePixelArray(@pix_array,0,0,640*SizeOf(ULONG),win^.RPort,0,0,640,480,RECTFMT_ARGB); DoIO(PIORequest(tr)); ptm:=@tr^.tr_time; end_sec:=ptm^.tv_secs; end_micro:=ptm^.tv_micro; test_time:=end_sec-start_sec+(end_micro-start_micro)/1000000; n:=n+1; until test_time>50; fps:=n/test_time; writeln('start sec= ',start_sec,' start micro= ',start_micro); writeln('end sec= ',end_sec,' end micro= ',end_micro); writeln('test time= ',test_time:10:5); writeln('fps= ',fps:10:5); repeat WaitPort(Win^.UserPort); Msg:=GetMsg(Win^.UserPort); case PIntuiMessage(Msg)^.IClass of IDCMP_CloseWindow: done:=True; end; ReplyMsg(Msg); Until done; CloseDevice(PIORequest(tr)); DeleteExtIO(PIORequest(tr)); DeletePort(tp); CloseWindow(Win);end.
Navigation
[0] Message Index
[*] Previous page