flat assembler
Message board for the users of flat assembler.

Index > Windows > Direct3D 12 Example

Author
Thread Post new topic Reply to topic
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 28 Aug 2015, 21:36
I have implemented basic Direct3D 12 application. This is just an example that displays single triangle. Application code, trivial shaders and D3D12 header (not complete) are all in my github repo. Windows 10 is ofcourse required to run this program.

https://github.com/michal-z/asmart/tree/master/d3d12tri
Post 28 Aug 2015, 21:36
View user's profile Send private message Visit poster's website Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable 28 Aug 2015, 23:42
Thanks for this
Post 28 Aug 2015, 23:42
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1769
Roman 29 Aug 2015, 14:10
Its cool ! Dude Smile
I recommend using more macros. For Directx 12 functions.
Easier and quicker to write code.
I do this for Directx 11 Smile
Post 29 Aug 2015, 14:10
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1769
Roman 29 Aug 2015, 14:13
randall
Why many asm commands begin symbol $ ?
Post 29 Aug 2015, 14:13
View user's profile Send private message Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable 29 Aug 2015, 14:37
Macros don't make it quicker to write code, it's an illusion.
Post 29 Aug 2015, 14:37
View user's profile Send private message Reply with quote
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 29 Aug 2015, 14:38
Roman wrote:
randall
Why many asm commands begin symbol $ ?


I prefix asm instructions with $ to force FASMW to highlight them.
Post 29 Aug 2015, 14:38
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1769
Roman 29 Aug 2015, 15:59
PeExecutable
I write 3d level editor for Directx 11.
I use a lot macros. Like macro savefile name,buffer or macro loadfile name,buffer
Or macro PrintMatrix text, address matrix
Or macro render_GUI Menu.
Or macro DX11LoadTexture name,Mesh
Or macro CopyMatrix FromMatrix,ToMatrix
Or macro PrintInt text,value
When you write a great and serious program, without macros to hard.
And macros easy to read and understand Smile
I understood this from my experience.
Post 29 Aug 2015, 15:59
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1769
Roman 29 Aug 2015, 16:12
Thanks to macros FASM become the great asm editor Smile
Post 29 Aug 2015, 16:12
View user's profile Send private message Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable 29 Aug 2015, 16:43
You have to understand me better than that. The reason I say that the benefits of macros is an illusion is because of the overloaded impression you create if you forget to talk bad about them. Smile (And I do mean that seriously, I've seen people spend 11 years doing macros without producing any program worth the word 'seriousness')

People overdo them, balance out the impression.

I don't like to be pessimistic, but when it comes to your macros, they're fine, but when you need to perform an action repeatedly, like setting a texture for example, you don't want to put that in a macro and repeat the code in your render loop. You want to create tiny very compact c-call functions so it gets a nice small place in the cache. The benefits of omitting one call up against the waste of cache use is absolutely not worth it when it comes to actions that needs to be done repeatedly in critical code.

Macros are excellent in non-critical code, because you can waste as much memory you want with non critical code, because it will eventually flush out of the cache anyway.

The design principles are:

1. Initialization code goes here
2. Cleanup code goes here
3. Non critical library function include file here
4. Main window procedure included here
5. Critical library functions goes here
6. Main game/program code here
7. Render and Message Loop here

Point 1-3 (Use heavy macros, waste as much memory as you want)
Point 4-7 (Specialize everything, be careful with expensive macros)

You want to flush out 1-3 from cache by placing it away from 4-7. That means if you have a library, you should split that library up into two include files. One include file with non-critical functions and the other with critical functions. Include the critical include file right above the main loop.

Normally the critical functions will get cached properly anyway, but by ordering it like this you reduce the chance of an address collision and cache pollution.

There is nothing wrong with macros, but one shouldn't forget its use, primarily macro's are made to simplify and reduce the work that the coder needs to do, but when it comes to special places in your code, you need to bring out some manual labour to get the basics perfect.

Personally, I use macros but not very extensively because they make the code very specific to fasm and can't easily be ported to other assemblers or other languages.

One useful thing to do with macros is to implement Text to speech with macros when debugging a direct3d app, to have windows "say" the error message loud, so you can hear it in a full screen program. Simple but useful. Use match with DEBUG equ TRUE/FALSE, if TRUE it will say the error loud, if FALSE it will print the error. Very Happy
Post 29 Aug 2015, 16:43
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1769
Roman 30 Aug 2015, 05:21
randall
How many do you have FPS, on your computer ?
I talk about Directx 12 example.
And please , tell about your model CPU and Video Card.
Post 30 Aug 2015, 05:21
View user's profile Send private message Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable 30 Aug 2015, 09:08
I have a VERY powerful one.


Last edited by PeExecutable on 30 Aug 2015, 09:37; edited 1 time in total
Post 30 Aug 2015, 09:08
View user's profile Send private message Reply with quote
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 30 Aug 2015, 09:21
Roman wrote:
randall
How many do you have FPS, on your computer ?
I talk about Directx 12 example.
And please , tell about your model CPU and Video Card.


Almost 7000 fps (147-150 micro seconds per frame). Haswell i7, AMD Radeon 260X.
Post 30 Aug 2015, 09:21
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1769
Roman 30 Aug 2015, 10:40
randall
Thanks !
Post 30 Aug 2015, 10:40
View user's profile Send private message Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable 30 Aug 2015, 10:49
Tiny ! ( Not Randall's Very Happy )

Based on the card it's a very clever card, I've seen cards that are incredibly stupid choices, but that one is a good one, and I have a tremendeously good one myself. Then there are the mid range clever cards.
Post 30 Aug 2015, 10:49
View user's profile Send private message Reply with quote
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 30 Aug 2015, 10:56
I have updated my program to use macros for function calls. Code is shorter and easier to read now.
Post 30 Aug 2015, 10:56
View user's profile Send private message Visit poster's website Reply with quote
PeExecutable



Joined: 26 Jun 2015
Posts: 181
PeExecutable 30 Aug 2015, 10:59
Are you absolutely sure that is what you want?

10-18 (50)

Macros ftw. Very Happy
Post 30 Aug 2015, 10:59
View user's profile Send private message Reply with quote
randall



Joined: 03 Dec 2011
Posts: 155
Location: Poland
randall 30 Aug 2015, 20:01
PeExecutable wrote:
Are you absolutely sure that is what you want?

10-18 (50)

Macros ftw. Very Happy


Well, I am absolutely sure that I shouldn't listen to you.
Post 30 Aug 2015, 20:01
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.