News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

The Ascended ASM game creation thread

Started by Lonewolff, April 09, 2018, 02:21:23 PM

Previous topic - Next topic

Lonewolff

So the benchmarks are in

Presently get an erratic frame rate in C++ of 6000 to 7500 FPS.

Frame rate is currently slower in ASM but is a very solid ~6000 FPS.

Lonewolff

Probably premature. But would be interesting to see how (and if) this runs for other people.

The DX initialisation still needs a little more work to make it robust, but should do the job.

I have attached the current build below.  :t

(Bear in mind it will only work on Windows 7 and above, as this is the minimum platform required for DirectX 11  :idea:)

Siekmanski

 8) 5500 FPS ( NVIDIA GeForce GTX 770 )
Creative coders use backward thinking techniques as a strategy.

jj2007

Quote from: Lonewolff on April 13, 2018, 09:30:36 AM
Probably premature. But would be interesting to see how (and if) this runs for other people.

On Win7-64, I see just a white rectangle. One core is at 50%.

Lonewolff

Nice!  :t

Thanks guys. Hopefully something nicer and more interactive on the next test  :biggrin:

Lonewolff

Going great with this project. Everything is getting laid out nicely.  8)

Spent time refactoring the code in to nice re-usable proto's.

Now on to the nasty 3D mathematics - Ugghh! Not my strong point. Gotta be done though, as a personal rite of passage. On to that right now.  :t

LordAdef

I'm curious to see your original c++ project in action. The avatar picture from the game is great.

By the way, once in a while, put some code here for us to check out

Lonewolff

At this stage this is what the main application and loop looks like


.code
WinMain proc
local windowWidth:dword
local windowHeight:dword
mov windowWidth, 1280
mov windowHeight, 720

; Create window
invoke SystemWindowCreate, windowWidth, windowHeight
mov hWnd, eax

; Create device and swap chain
invoke SystemDeviceCreate, windowWidth, windowHeight, hWnd

; Create vertex shader
mov ecx, SIZEOFvertexShaderData
invoke ShaderVertexCreate, addr d3dVertexShader, addr vertexShaderData, ecx

; Create pixel shader
mov ecx, SIZEOFpixelShaderData
invoke ShaderPixelCreate, addr d3dPixelShader, addr pixelShaderData, ecx


; Create input layout XY
mov ecx, SIZEOFvertexShaderData
coinvoke d3dDevice, ID3D11Device, CreateInputLayout, addr inputDescP, 1, addr vertexShaderData, ecx, addr d3dInputLayout
invoke SystemError, TEXT_("Failed to create input layout.")

; Create vetex buffer
coinvoke d3dDevice, ID3D11Device, CreateBuffer, addr vertexDesc, addr resourceData, addr d3dVertexBuffer
invoke SystemError, TEXT_("Failed to create vertex buffer.")

; Reset performance counters
invoke QueryPerformanceFrequency, addr TimeFrequency
invoke QueryPerformanceCounter, addr TimeStart

; Constant buffer creation (for the WVP matrices)
mov ebx, offset constDesc
cd equ [ebx.D3D11_BUFFER_DESC]
mov cd.BindFlags, D3D11_BIND_CONSTANT_BUFFER
mov cd.ByteWidth, 192
mov cd.Usage, D3D11_USAGE_DEFAULT
coinvoke d3dDevice, ID3D11Device, CreateBuffer, addr cd, 0, addr d3dWvpCB
invoke SystemError, TEXT_("Failed to create constant buffer.")

; Show window once initialisation has succeeded
invoke ShowWindow, hWnd, 1

; Main loop
.while 1
; Windows message pump
invoke PeekMessage, ADDR msg, NULL, 0, 0, PM_REMOVE
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.if msg.message == WM_QUIT
.break
.endif

; Update the frame rate counter
invoke TimerFPS

; Set render target as active
coinvoke d3dContext, ID3D11DeviceContext, OMSetRenderTargets, 1, addr d3dBackBufferRTV, 0

; Clear back buffer
coinvoke d3dContext, ID3D11DeviceContext, ClearRenderTargetView, d3dBackBufferRTV,addr BackgroundColor

; Set shaders
coinvoke d3dContext, ID3D11DeviceContext, VSSetShader, d3dVertexShader, 0, 0
coinvoke d3dContext, ID3D11DeviceContext, PSSetShader, d3dPixelShader, 0, 0

; Draw the quad
coinvoke d3dContext, ID3D11DeviceContext, IASetInputLayout, d3dInputLayout
coinvoke d3dContext, ID3D11DeviceContext, IASetVertexBuffers, 0, 1, addr d3dVertexBuffer, addr dataStride, addr dataOffset
coinvoke d3dContext, ID3D11DeviceContext, IASetPrimitiveTopology, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
coinvoke d3dContext, ID3D11DeviceContext, Draw, 6, 0

; Present
coinvoke d3dSwapchain, IDXGISwapChain, Present, 0, 0
.endw

call SystemExitApplication

WinMain endp
end WinMain


Lot's of error handling. So if something breaks, I should know where to look for the cause (generally a result of the end system not being compatible with some call I have made). In an ideal world, the end user won't have any problems.

I'd spoil it and send more screenshot of what my game looked like in C++ back when I was working on it, but it would be cooler knowing the screenshots are coming from my ASM version. So I'll have to hold out on you for the moment on that front.  :biggrin:

Lonewolff

It's weird...

I am fleshing out my matrix calculations in C++ and comparing against DirectXMath to make sure my results are correct and my un-optimised code is running rings around Microsoft's implementation  :icon_eek:

I'm up to 436% faster already.  :dazzled:


Siekmanski

Quote from: Lonewolff on April 15, 2018, 07:34:19 PM
It's weird...

I am fleshing out my matrix calculations in C++ and comparing against DirectXMath to make sure my results are correct and my un-optimised code is running rings around Microsoft's implementation  :icon_eek:

I'm up to 436% faster already.  :dazzled:

Have you fasten your seat belts?  :bgrin:

"mov ebx, offset constDesc"
About EBX you need to preserve that one, also counts for ESI and EDI.
Creative coders use backward thinking techniques as a strategy.

Lonewolff

Thanks man!

How do you preserve it? Noob here.  :bgrin:

jj2007

push ebx  ; preserved
mov ebx, 123
pop ebx   ; restored

Lonewolff


Lonewolff

#28
Almost have enough of my matrix library made to make something usable.

Fleshed it out in C++. And I'm already beating Microsoft's implementation by a mile.



The top results are MS's and the bottom are my own implementation.

Will translate this over to ASM shortly and see if I can then set up a 3D camera for this project.  8)

Lonewolff

Almost finished writing part one of my matrix library (yet another thing I had to learn from scratch - LOL  :bgrin:)

The results are pretty good.



Beating Microsoft's matrix library by a huge amount and am just behind my own C++ implementation.

This is a great result as I can see plenty of places I can improve my ASM code. At this point I am just making the calculations work out correctly - which they are.  :t

MatrixTranspose and MatrixMultiply to finish off next and then I should be good to set up a 3D camera.