-
Forum: Multimedia
Delphi
by Kas Ob.,
8. Nov 2023
Data comes from my earlier test
const
Count = 1000000;
DATA_LEN = 1024;
var
Data: array of Integer;
CData: array of Byte;
....
begin
-
Forum: Multimedia
Delphi
by Kas Ob.,
8. Nov 2023
And of course i forgot about pop and push :oops:
-
Forum: Multimedia
Delphi
by Kas Ob.,
8. Nov 2023
@Stevie, nice !
I was going to more generic reusable one like this:
{$ALIGN 16}
procedure TestCMovShort;
const
LOWER_LIMIT = 0;
HIGHER_LIMIT = 255;
asm
mov esi, HIGHER_LIMIT // High Limit
-
Forum: Multimedia
Delphi
by Kas Ob.,
7. Nov 2023
Thank you very much, i have no idea what i was thinking missing all that.
here revised version of that benchmark with some semi-real data simulation over 1kb repeated million time.
uses
System.SysUtils,
Windows;
const
Count = 1000000;
DATA_LEN = 1024;
-
Forum: Multimedia
Delphi
by Kas Ob.,
7. Nov 2023
Does it matter what value in the fourth byte !?, no it doesn't, you can load four bytes and perform the same operation on them the cycles are the same and just drop the last value, if there is a fear of overflowing a buffer, perform the loop on all unless there except the last byte of them all.
Anyway i might find the mood and time to do it in MMX and SSE, why not !
Let do clamping...
-
Forum: Multimedia
Delphi
by Kas Ob.,
7. Nov 2023
You are really hardworking on this !
Are you familiar with CMOV instruction ?!!
Read about it from here https://www.felixcloutier.com/x86/cmovcc
Also search and research example for it and its usage, and trust me you will feel real good after that and your above code will go brrrrrrr faster.
eg. That part of clamping the slow one replacing values with
if v < 0 then
Blue :=...
-
Forum: Multimedia
Delphi
by Kas Ob.,
20. Okt 2023
Thank you, and i was wrong, it is a mistake, as i was after the speed not the functionality per se, and that is wrong, i was aware of of negative values, but was after proving a different thing.
So here fixed a function that will generate the right image, (well i hope so this time :oops: )
procedure SetPixel(XOffset, YOffset: NativeInt; Factor: NativeUInt);
var
AP: TPBGR;
v:...
-
Forum: Multimedia
Delphi
by Kas Ob.,
20. Okt 2023
Yes, and thank you, i see my mistake, though the difference should not negate the gain in performance from using removing EnsureRange and replacing shr 4 with div on x64.
The code can be rearranged little more.
-
Forum: Multimedia
Delphi
by Kas Ob.,
20. Okt 2023
Forgot to attach a screenshot of my result
May be not in everyone interest to notice that, but do you see the consistency in the result, or the closeness of the result, this show the relax and the ability of the cache on CPU level, just by removing the EnsureRange branching for each pixel 3 times.
-
Forum: Multimedia
Delphi
by Kas Ob.,
20. Okt 2023
Hi for all,
Please bare a little with me, i mean really don't take my calling the Delphi Compiler as an offense toward anyone, it is just i know it, i used to be and still earning my bread from optimizing old and new code, i know the compiler very intimately to call it a fucking centuries old brick.
I will explain just this piece of code, and if you want to expand on it, but first and...
-
Forum: Multimedia
Delphi
by Kas Ob.,
19. Okt 2023
:shock: :?
-
Forum: Multimedia
Delphi
by Kas Ob.,
19. Okt 2023
I am more angry than you about the loss of readability and the risk with it :wall:, BUT the CPU is more retarded than a 15th century brick, and without pushing its face into the point with "with" it will not generate a decent code (in many cases anyway).
So yes, i am more angry about the compiler than the "with" or who use it.
-
Forum: Multimedia
Delphi
by Kas Ob.,
19. Okt 2023
Excellent work.
I have few suggestion:
1) Switch from using Integer to NativeUInt or NativeInt, this will pay in x64, as the compiler will not have to insert resizing instructions like movzx and will have the ability to use full register operation.
2) Replace that EnsureRange with simple old fashion if-statement, saving a needless branch.
3) I wouldn't trust the compiler to generate fast...