donn
Joined: 05 Mar 2010
Posts: 321
|
Hey! So sorry about the massive delay here. I was meaning to respond so you would see the reply but also wanted to make the explanation adequate and do it justice.
It's going well! Currently on hold, I will come back to it to do FlipFluids, larger bodies of water, and improved visualization with Monte Carlo. Currently focusing on solid mechanics, soft bodies. Have everything set up, just testing, and the math is very hard.
The main organization:
1. VulkanTest:..........fasm
- ScreeningTest:..........main loop that presents images to the screen and sets them up initially.
- VulkanTest:..........the main loop that kicks off fluid shader dispatches
- BufferTest:..........a process that copies and maps memory from shader memory
- Fluid
- Each shader has an .inc to setup the shader pipeline, kick it off, synchronize, etc
include './Fluid/FluidAdvectionTest.inc'
include './Fluid/FluidJacobianTest.inc'
include './Fluid/FluidTorquesTest.inc'
include './Fluid/FluidDivergenceTest.inc'
include './Fluid/FluidProjectionTest.inc'
include './Fluid/FluidVisTest.inc'
- Each shader also has a resource file that defines what it requires in terms of buffers. These are parsed and built by a utility
2. Vulkan:..........fasm
- Wrappers around all the Vulkan library calls and some utilities to build more complicated buffers based on configs
- Image resources have a lot of specific settings, for exmaple
See Sample 4 below
See Sample 5 below
3. Fluid shaders:..........glsl (for now, which is MATLAB-like, building with SPIR-V in future)
- These do the fluid mechanics
VkFluidAdvection.comp etc
See Sample 6 below
See Sample 7 below
See Sample 8 below
Just a sampling! I'll provide more once the solid mechanics starts showing results or something new happens here. Or, of course if you have further questions. Also recommend reading the references at the end of the video. I think they're also in the description. The one by Harris is great to start with, along with Stam. I can explain how I approached their core principles, what I followed, what I strayed from, etc, and techniques.. for example Harris only works on 2D. Also can explain the general organization of things more if needed..!
Samples
Sample 1
testPrepareScreen:
namespace testPrepareScreen
push rbp
mov rbp, rsp
sub rsp, (8*6);+(8*6)
;mov rcx, [rbp+8]
;mov rdx, [rbp+12]
label imgIndex qword at rbp-8
label mappedMem qword at rbp-16
label bufferRef qword at rbp-24
label queueRef qword at rbp-32
label cmdBuffer qword at rbp-40
label vulkanRef qword at rbp-48
;virtual at rbp-64
; newList newList
;end virtual
;mov [flow], rcx
mov [vulkanRef], rcx
mov [cmdBuffer], rdx
mov [queueRef], r8
mov [imgIndex], r9
and rsp, -32
push rbx rbp rdi rsi rsp r12 r13 r14 r15
sub rsp, 8
mov rcx, [bufferStarted]
cmp rcx, 1
je skipBufferTest
sub rsp, 8*16
mov rdx, [imgIndex]
mov rcx, [vulkanRef]
call startBufferTest
add rsp, 8*16
skipBufferTest:
mov rcx, 1
mov [bufferStarted], rcx
sub rsp, 8*8
mov rdx, synchRefs.queueCompletionFence
mov rcx, [vulkanRef]
call resetFences
add rsp, 8*8
sub rsp, 8*16
mov r9, synchRefs.queueCompletionFence
mov r8, vkQueueRefs.queue1
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call submitQueue
add rsp, 8*16
waitLastPresentFenceCompletion:
sub rsp, 8*8
mov rdx, synchRefs.queueCompletionFence
mov rcx, [vulkanRef]
call getFenceStatus
add rsp, 8*8
cmp rax, 0
jne waitLastPresentFenceCompletion
sub rsp, 8*8
mov rdx, synchRefs.queueCompletionFence
mov rcx, [vulkanRef]
call resetFences
add rsp, 8*8
completed:
mov rax,0;[bufferRef]
add rsp, 8
pop r15 r14 r13 r12 rsp rsi rdi rbp rbx
mov rsp, rbp
pop rbp
retn 0
end namespace
Sample 2
jmp endScreenTest
presureJacobianPass:
mov rcx, [pressureLevel]
cmp rcx, 2
jne lowPress
mov rdx, 1200 ; high pressure iterations
jmp pressureDefined
lowPress:
cmp rcx, 0
jne medPress
mov rdx, 400 ; low pressure iterations
jmp pressureDefined
medPress:
mov rdx, 900 ; med pressure iterations
;mov rdx, 1200;400;;500; ; 500 is harris' max amt 100;55
pressureDefined:
mov [iterCount], rdx
; Pressure Jacobian
nextPressIter: ; next pressure jacobian iteration
mov rcx, [iterInd]
mov rdx, [iterCount]
cmp rcx, rdx
jnl endPressIter
;nextSlicePress:
;sub rsp, 8*8
;call getSliceIndex
;add rsp, 8*8
;mov rcx, rax
;cmp rcx, 1b ; final slice reached
;je doneSlicePress
sub rsp, 8*16
mov r12, vulkan.vkQueueRefs.queue1
mov qword [rsp+4*8], r12
mov r9, [currIndex]
mov r8, [vulkan.fluidJacPipelineInfoRef]
mov rdx, 0 ; set index
mov rcx, [vulkanRef]
call vulkan.testFluidJacobian
add rsp, 8*16
;jmp nextSlicePress
;doneSlicePress:
mov rcx, [iterInd]
add rcx, 1b
mov [iterInd], rcx
jmp nextPressIter
endPressIter:
Sample 3
namespace vulkan
prepareFluidJacobianTest:
namespace prepareFluidJacobianTest
push rbp
mov rbp, rsp
sub rsp, (8*6);+(8*6)
;mov rcx, [rbp+8]
;mov rdx, [rbp+12]
label heapAddress qword at rbp-8
label mappedMem qword at rbp-16
label bufferRef qword at rbp-24
label memoryRef qword at rbp-32
label prevItem qword at rbp-40
label vulkanRef qword at rbp-48
;virtual at rbp-64
; newList newList
;end virtual
;mov [flow], rcx
mov [vulkanRef], rcx
;mov [newList], rdx
and rsp, -32
push rbx rbp rdi rsi rsp r12 r13 r14 r15
sub rsp, 8
;mov rbx, vkImgResourceDefsRefLoc ; offsetBase used with resources
;mov rdx, [vkImgResDefsRef]
;mov [rbx], rdx ; Already cached by Advection
sub rsp, 8*8
mov r8, fluidJacResInfo
mov rdx, fluidJacPipelineInfo
mov rcx, [vulkanRef]
call newPipeline
add rsp, 8*8
mov [fluidJacPipelineInfoRef], rax
sub rsp, 8*16
mov r9, fluidJacResMemImgs
mov r8, fluidJacResDefs
mov rdx, [fluidJacPipelineInfoRef]
mov rcx, [vulkanRef]
call setupPipeline
add rsp, 8*16
mov rbx, [fluidJacPipelineInfoRef]
add rbx, pipelineInfo.resourceInfoRefLoc - pipelineInfo
mov rdx, [rbx]
mov [fluidJacResInfoRef], rdx
add rdx, resourceInfo.resourceDefsRefLoc - resourceInfo
mov r8, [rdx]
mov [fluidJacResDefsRef], r8
sub rsp, 8*8
mov rcx, fluidJacobianCompletedMsg
call debugMsg2
add rsp, 8*8
sub rsp, 8*16
mov r8, 0 ; [setIndex]
mov rdx, [fluidJacResInfoRef]
mov rcx, [vulkanRef]
call prepareRecordSetEntry
add rsp, 8*16
sub rsp, 8*16
mov r10, [fluidJacPipelineInfoRef]
mov qword [rsp+5*8], r10
mov rbx, [fluidJacResDefsRef]
add rbx, (fluidJacResDefs.set1.setRef - fluidJacResDefs)
mov r10, rbx ; descriptorSetsRef.ref1
mov qword [rsp+4*8], r10
mov r9, swapchainImagesRef.img1
mov r8, [bufferRef]
mov r12, [fluidJacPipelineInfoRef]
add r12, pipelineInfo.cmdBuffersRefLocs - pipelineInfo
mov r11, [r12]
add r11, 8*0 ; set1
mov rdx, r11
mov rcx, [vulkanRef]
call recordFluidJacDispatchCmd
add rsp, 8*16
completed:
sub rsp, 8*8
mov rcx, fluidJacobianCompletedMsg
call debugMsg2
add rsp, 8*8
mov rax,0;[bufferRef]
add rsp, 8
pop r15 r14 r13 r12 rsp rsi rdi rbp rbx
mov rsp, rbp
pop rbp
retn 0
end namespace
testFluidJacobian:
namespace testFluidJacobian
push rbp
mov rbp, rsp
mov r10, [rsp+8*6]
sub rsp, (8*9);+(8*6)
;mov rcx, [rbp+8]
;mov rdx, [rbp+12]
label imgIndex qword at rbp-8
label mappedMem qword at rbp-16
label bufferRef qword at rbp-24
label queueRef qword at rbp-32
label cmdBuffer qword at rbp-40
label vulkanRef qword at rbp-48
label pipelineInfoRef qword at rbp-56
label setIndex qword at rbp-64
label resDefsRef qword at rbp-72
;virtual at rbp-64
; newList newList
;end virtual
;mov [flow], rcx
mov [vulkanRef], rcx
mov [setIndex], rdx
mov [pipelineInfoRef], r8
mov [imgIndex], r9
mov [queueRef], r10
and rsp, -32
push rbx rbp rdi rsi rsp r12 r13 r14 r15
sub rsp, 8
sub rsp, 8*8
mov rcx, testFluidJacobianStartingMsg
;call debugMsg2
add rsp, 8*8
mov rbx, [pipelineInfoRef]
add rbx, pipelineInfo.resourceInfoRefLoc - pipelineInfo
mov rdx, [rbx]
add rdx, resourceInfo.resourceDefsRefLoc - resourceInfo
mov r8, [rdx]
mov [resDefsRef], r8
mov rbx, [pipelineInfoRef]
add rbx, pipelineInfo.cmdBuffersRefLocs - pipelineInfo
mov r8, [rbx]
mov rdx, 0
mov rcx, 8
mov rax, [setIndex]
imul rcx
add r8, rax
mov [cmdBuffer], r8
mov rcx, [bufferStarted]
cmp rcx, 1
je skipBufferTest
sub rsp, 8*16
mov rdx, [imgIndex]
mov rcx, [vulkanRef]
call startBufferTest
add rsp, 8*16
skipBufferTest:
mov rcx, 1
mov [bufferStarted], rcx
sub rsp, 8*8
mov rdx, synchRefs.queueCompletionFence
mov rcx, [vulkanRef]
call resetFences
add rsp, 8*8
sub rsp, 8*16
mov r9, synchRefs.queueCompletionFence
mov r8, [queueRef]
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call submitQueue2
add rsp, 8*16
waitLastPresentFenceCompletion:
sub rsp, 8*8
mov rdx, synchRefs.queueCompletionFence
mov rcx, [vulkanRef]
call getFenceStatus
add rsp, 8*8
cmp rax, 0
jne waitLastPresentFenceCompletion
; What should signal be?
sub rsp, 8*8
mov rdx, synchRefs.queueCompletionFence
mov rcx, [vulkanRef]
call resetFences
add rsp, 8*8
jmp skippedDebugBuff
sub rsp, 8*8
mov rcx, debugBreakMsg
call debugMsg2
add rsp, 8*8
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1]
;mov rdx, [r11]
add rdx, testBuffer1Ref.output1 - testBuffer1Ref
mov ecx, dword [rdx]
call debugNumMsg
add rsp, 8*8
;sub rsp, 8*8
;mov r11, [memRefs.ref1]
;mov rdx, [r11]
;add rdx, testBuffer1Ref.output2 - testBuffer1Ref
;mov ecx, dword [rdx]
;call debugNumMsg
;add rsp, 8*8
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1]
;mov rdx, [r11]
add rdx, testBuffer1Ref.output2 - testBuffer1Ref
mov ecx, dword [rdx]
call debugNumMsg
add rsp, 8*8
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1]
;mov rdx, [r11]
add rdx, testBuffer1Ref.output3 - testBuffer1Ref
mov ecx, dword [rdx]
call debugNumMsg
add rsp, 8*8
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1]
;mov rdx, [r11]
add rdx, testBuffer1Ref.output4 - testBuffer1Ref
mov ecx, dword [rdx]
call debugNumMsg
add rsp, 8*8
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1]
;mov rdx, [r11]
add rdx, testBuffer1Ref.output5 - testBuffer1Ref
mov ecx, dword [rdx]
call debugNumMsg
add rsp, 8*8
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1]
;mov rdx, [r11]
add rdx, testBuffer1Ref.output6 - testBuffer1Ref
mov ecx, dword [rdx]
call debugNumMsg
add rsp, 8*8
jmp skippedDebugBuff
skippedDebugBuff:
flushAgain:
;jmp skipFlushAgain
sub rsp, 8*8
mov r8, 100
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.mappedMem- resourceMemImg)
mov rdx, [r10] ;[memRefs.ref1] ; this needs new ref
mov rcx, testBuffer1Ref
call allocate.copy
add rsp, 8*8
sub rsp, 8*8
mov rcx, flushMappedMemMsg
;call debugMsg2
add rsp, 8*8
sub rsp, 8*16
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.memSize- resourceMemImg)
mov r9, [r10] ;[memRefs.ref1] ; this needs new ref
mov r8, 0
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.memRefLoc- resourceMemImg)
mov r11, [r10] ;rawMemRefs.ref1 ; this needs new ref
mov rdx, [r11] ; VkDeviceMemory*
mov rcx,[vulkanRef]
;call debugParams
add rsp, 8*16
sub rsp, 8*8
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.memSize- resourceMemImg)
mov r9, [r10] ;[memRefs.ref1] ; this needs new ref
mov r8, 0
mov rbx, [resDefsRef]
add rbx, (vkImgResDefs.set1.res1 - vkImgResDefs)+(resourceEntry.resourceMemImgRefLoc - resourceEntry)
mov r10, [rbx]
add r10, (resourceMemImg.memRefLoc- resourceMemImg)
mov r11, [r10] ;rawMemRefs.ref1 ; this needs new ref
mov rdx, [r11] ; VkDeviceMemory*
mov rcx,[vulkanRef]
call flushMappedMem
add rsp, 8*8
skipFlushAgain:
completed:
sub rsp, 8*8
mov rcx, testFluidJacobianCompletedMsg
;call debugMsg2
add rsp, 8*8
mov rax,0;[bufferRef]
add rsp, 8
pop r15 r14 r13 r12 rsp rsi rdi rbp rbx
mov rsp, rbp
pop rbp
retn 0
end namespace
; call
recordFluidJacDispatchCmd:
namespace recordFluidJacDispatchCmd
push rbp
mov rbp, rsp
mov r10, [rsp+8*6]
mov r11, [rsp+8*7]
sub rsp, (8*6);+(8*6)
;mov r11, [rsp+8*7]
;mov r12, [rsp+8*8]
;mov rcx, [rbp+8]
;mov rdx, [rbp+12]
label pipelineInfoRef qword at rbp-8
label imgRef qword at rbp-16
label bufferRef qword at rbp-24
label descriptorSetRef qword at rbp-32
label cmdBuffer qword at rbp-40
label vulkanRef qword at rbp-48
;virtual at rbp-64
; newList newList
;end virtual
mov [vulkanRef], rcx
mov [cmdBuffer], rdx
mov [bufferRef], r8
mov [imgRef], r9
mov [descriptorSetRef], r10
mov [pipelineInfoRef], r11
and rsp, -32
push rbx rbp rdi rsi rsp r12 r13 r14 r15
sub rsp, 8
sub rsp, 8*8
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call beginRecordCmd
add rsp, 8*8
sub rsp, 8*16
mov r9, [descriptorSetRef]
mov r8, [pipelineInfoRef]
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call bindDescriptorSets ; vkCmdBind
add rsp, 8*16
sub rsp, 8*8
mov r8, [pipelineInfoRef]
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call bindPipelines ; vkCmdBind
add rsp, 8*8
;sub rsp, 8*16
;mov r8, [imgRef]
;mov rdx, [cmdBuffer]
;mov rcx, [vulkanRef]
;call clearImgCmd
;add rsp, 8*16
mov rbx, [fluidAdvResDefsRef] ; MOVE TEMPPOINTS TO POINTS should only be done once
add rbx, (fluidAdvResDefs.set1.res9 - fluidAdvResDefs) + (resourceEntry.resRef - resourceEntry)
mov r8, [rbx] ; descriptorSetsRef.ref9
mov rdx, advecTempPointsToPointsbufferCopyInfoRef.srcBufferRef
mov [rdx], r8
mov rbx, [fluidAdvResDefsRef]
add rbx, (fluidAdvResDefs.set1.res2 - fluidAdvResDefs) + (resourceEntry.resRef - resourceEntry)
mov r8, [rbx] ; descriptorSetsRef.ref2
mov rdx, advecTempPointsToPointsbufferCopyInfoRef.dstBufferRef
mov [rdx], r8
mov rbx, [fluidAdvResDefsRef]
add rbx, (fluidAdvResDefs.set1.res9 - fluidAdvResDefs) + (resourceEntry.resSize - resourceEntry)
mov r8, [rbx] ; descriptorSetsRef.ref9
mov rdx, advecTempPointsToPointsbufferCopyInfoRef.vkSize
mov [rdx], r8
sub rsp, 8*16
mov r8, advecTempPointsToPointsbufferCopyInfoRef
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
;call copyBufferCmd
add rsp, 8*16
;cmp baseICount, 0 ; use dispatch or dispatchBase, get these baseCounts from pipelein or within pipelien
;boundHalfWidth*2.0 / sliceWidth
;baseIIndex
;baseJIndex
sub rsp, 8*8
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
;call dispatchCmdBuffer
add rsp, 8*8
sub rsp, 8*16
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call dispatchLinearCmdBuffers
add rsp, 8*16
sub rsp, 8*8
mov rdx, [cmdBuffer]
mov rcx, [vulkanRef]
call endRecordCmd
add rsp, 8*8
sub rsp, 8*8
mov rcx, rax
call debugNumMsg
add rsp, 8*8
completed:
mov rax, 0
add rsp, 8
pop r15 r14 r13 r12 rsp rsi rdi rbp rbx
mov rsp, rbp
pop rbp
retn 0
end namespace
end namespace
Sample 4
; setup pipeline once data specified
setupPipeline:
namespace setupPipeline
push rbp
mov rbp, rsp
sub rsp, (8*10);+(8*6)
;mov rcx, [rbp+8]
;mov rdx, [rbp+12]
label resourceEntriesRef qword at rbp-8
label resourceMemImgsRef qword at rbp-16
label pipelineCacheRef qword at rbp-24
label pipelineVals qword at rbp-32
label pipelineInfoRef qword at rbp-40
label vulkanRef qword at rbp-48
label resourceEntriesVals qword at rbp-56
label resourceInfoRef qword at rbp-64
label descriptorSetCount qword at rbp-72
label descriptorSetIndex qword at rbp-80
;virtual at rbp-64
; newList newList
;end virtual
;mov rdx, swapchainImagesRef.img1
;mov r8, imageViewRef.ref1
mov [vulkanRef], rcx
mov [pipelineInfoRef], rdx
mov [resourceEntriesRef], r8
mov [resourceMemImgsRef], r9
and rsp, -32
push rbx rbp rdi rsi rsp r12 r13 r14 r15
sub rsp, 8
sub rsp, 8*8
mov rcx, setupPipelineStartingMsg
call debugMsg2
add rsp, 8*8
sub rsp, 8*8
mov rcx, [pipelineInfoRef]
call loadSPIRV
add rsp, 8*8
sub rsp, 8*8
mov rdx, [pipelineInfoRef]
mov rcx, [vulkanRef]
call newShaderModule
add rsp, 8*8
sub rsp, 8*8
mov r8, [resourceEntriesRef]
mov rdx, [pipelineInfoRef]
mov rcx, [vulkanRef]
call newDescriptorSetLayout
add rsp, 8*8
sub rsp, 8*8
mov rdx, [pipelineInfoRef]
mov rcx, [vulkanRef]
call newPipelineLayout
add rsp, 8*8
sub rsp, 8*8
mov r8, [pipelineInfoRef]
mov rdx, 0 ; cache
mov rcx, [vulkanRef]
call newComputePipeline ; requires pipelineLayout, shaderModule
add rsp, 8*8
sub rsp, 8*16
mov r9, [resourceMemImgsRef]
mov r8, [resourceEntriesRef]
mov rdx, [pipelineInfoRef]
mov rcx, [vulkanRef]
call buildResources
add rsp, 8*16
mov rcx, 0
mov [descriptorSetIndex], rcx
mov rbx, [pipelineInfoRef]
add rbx, pipelineInfo.resourceInfoRefLoc - pipelineInfo
mov r10, [rbx]
mov [resourceInfoRef], r10
add r10, resourceInfo.resourceDefsRefLoc - resourceInfo
mov rdx, [r10]
mov [resourceEntriesVals], rdx
mov r10, [resourceInfoRef]
add r10, resourceInfo.descriptorSetCount - resourceInfo
mov rcx, [r10]
mov [descriptorSetCount], rcx
nextSet:
mov rdx, [descriptorSetCount]
mov rcx, [descriptorSetIndex]
cmp rcx, rdx
jnl completed
sub rsp, 8*8
mov rcx, nextSetMsg
call debugMsg2
add rsp, 8*8
mov r12, [pipelineInfoRef]
add r12, pipelineInfo.cmdBuffersRefLocs - pipelineInfo
mov r11, [r12]
mov rcx, [descriptorSetIndex]
mov rax, 8
mov rdx, 0
imul rcx
add r11, rax
sub rsp, 8*8
mov r8, r11
mov rdx, 0 ; cmd Pool index
mov rcx, [vulkanRef]
call allocCmdBuffer
add rsp, 8*8
mov rbx, [resourceEntriesVals]
mov r10, [resourceInfoRef]
add r10, resourceInfo.setEntrySize - resourceInfo
mov rcx, [r10]
add rbx, rcx
mov [resourceEntriesVals], rbx ; go past setEntry
sub rsp, 8*16
mov rbx, [resourceInfoRef]
add rbx, resourceInfo.resourceDefsRefLoc - resourceInfo
mov r9, [rbx] ; base resourceentriesref so copying of resources from it can occur
mov r10, [resourceInfoRef]
add r10, resourceInfo.bindingsCount - resourceInfo
mov r8, [r10] ; resCount
mov rdx, [resourceEntriesVals] ; resourceEntriesRef
mov rcx, [vulkanRef]
call buildBuffers
add rsp, 8*16
mov rbx, [resourceEntriesVals]
mov r10, [resourceInfoRef]
add r10, resourceInfo.entriesSize - resourceInfo
mov rcx, [r10]
add rbx, rcx
mov [resourceEntriesVals], rbx ; go past setEntry
mov rcx, [descriptorSetIndex]
add rcx, 1b
mov [descriptorSetIndex], rcx
jmp nextSet
completed:
mov rax, [pipelineInfoRef]
add rsp, 8
pop r15 r14 r13 r12 rsp rsi rdi rbp rbx
mov rsp, rbp
pop rbp
retn 0
end namespace
Sample 5
; call vkEnumeratePhysicalDevices
enumPhysDevs:
namespace enumPhysDevs
push rbp
mov rbp, rsp
sub rsp, (8*6);+(8*6)
;mov rcx, [rbp+8]
;mov rdx, [rbp+12]
label heapAddress qword at rbp-8
label handleAllocatedMemory qword at rbp-16
label newList qword at rbp-24
label flow qword at rbp-32
label prevItem qword at rbp-40
label vulkanRef qword at rbp-48
;virtual at rbp-64
; newList newList
;end virtual
mov [vulkanRef], rcx
;mov [newList], rdx
and rsp, -32
push rbx rbp rdi rsi rsp r12 r13 r14 r15
sub rsp, 8
; vkInstanceRef
; 0
; vkInstanceCreateInfoRef
sub rsp, 8*8
mov rbx, [vulkanRef]
add rbx, Vulkan.devicesAddr
mov r8, rbx;[rbx]
mov rbx, [vulkanRef]
add rbx, Vulkan.deviceCount
mov rdx, rbx;[rbx]
mov rbx, [vulkanRef]
add rbx, Vulkan.vkInstanceRef
mov rcx, [rbx]
mov rbx, vkEnumeratePhysicalDevicesProc
mov r10, [rbx]
call r10
add rsp, 8*8
;mov [vkCreateInstanceProc], rax
;sub rsp, 8*8
;mov rcx, rax
;call debugNumMsg
;add rsp, 8*8
completed:
mov rax, 0
add rsp, 8
pop r15 r14 r13 r12 rsp rsi rdi rbp rbx
mov rsp, rbp
pop rbp
retn 0
end namespace
Sample 6
void main() {
ivec2 pathPos = ivec2(0,0);
pathPos.x = int(gl_LocalInvocationID.x);
pathPos.y = int(gl_LocalInvocationID.y);
int baseI = int(gl_WorkGroupID.x);
int baseJ = int(gl_WorkGroupID.y);
int baseK = int(gl_WorkGroupID.z);
ivec2 slicePathPos = pathPos;
int sliceHeight = b1.b1s[0].sliceHeight; //32;
int sliceWidth = b1.b1s[0].sliceWidth; //32; // should not specify these manually!
float atmosphericPressure = 0.0;//0.001;//0.0;//0.001;
float boundsPressure = 0.0;//100.0;//0.001;
vec3 bounds1[8];
vec3 bounds2[8];
Bearing bearing;
bearing = updateBearingSlices(bearing, baseI, baseJ, baseK);
Fluid fluid = b1.b1s[0].fluid;
fluid.boundHalfWidth = b1.b1s[0].fluid.boundHalfWidth; //112.0f;//85;//60;180;//85;//60.0;//64.0;//128.0;//256;
fluid.boundHalfLength = b1.b1s[0].fluid.boundHalfLength; //45.0f;//42;72;//42;//28.0;//32.0;// 64.0;//128;
fluid.boundHalfHeight = b1.b1s[0].fluid.boundHalfHeight; //64.0f;//42;72;//42;//28.0;//32.0;//64.0;//128;
Sample 7
// 1 if diffusion, 0 if pressure calc.
vec3 jacobian(Fluid fluid, PSample pSample, PSample velSample, float divergenceAmt, int jacobianDiffusion){
vec3 jacobianAmt;
float betaVal;
float timeStep = fluid.timeStep;
if (jacobianDiffusion == 1 ){
vec3 fieldL = velSample.velocities[0];
vec3 fieldR = velSample.velocities[1];
vec3 fieldD = velSample.velocities[2];
vec3 fieldT = velSample.velocities[3];
vec3 fieldF = velSample.velocities[4];
vec3 fieldB = velSample.velocities[5];
float alphVal = 0.0;
//alphVal = 1.0/((0.000001)*timeStep); // water 0.0001 gas 0.000001?
alphVal = 1.0/((0.0001)*timeStep); // water 0.0001 gas 0.000001?
//alphVal = 1.0/((0.1)*timeStep); // water 0.0001 gas 0.000001? // new way
jacobianAmt = (fieldL + fieldR + fieldD + fieldT + fieldF + fieldB + (alphVal*velSample.cellVelocity)) / (6.0+alphVal);
}else{
betaVal = 6.0;
float fieldL = pSample.pressures[0];
float fieldR = pSample.pressures[1];
float fieldD = pSample.pressures[2];
float fieldT = pSample.pressures[3];
float fieldF = pSample.pressures[4];
float fieldB = pSample.pressures[5];
jacobianAmt.x = (fieldL + fieldR + fieldD + fieldT + fieldF + fieldB - divergenceAmt) / betaVal;
}
return jacobianAmt;
}
Sample 8
float divergence(Fluid fluid, PSample pSample){
float divergenceAmt;
vec3 fieldL = pSample.velocities[0]; //.lVelocity;
vec3 fieldR = pSample.velocities[1]; //.rVelocity;
vec3 fieldD = pSample.velocities[2]; //.dVelocity;
vec3 fieldT = pSample.velocities[3]; //.tVelocity;
vec3 fieldF = pSample.velocities[4]; //.fVelocity;
vec3 fieldB = pSample.velocities[5]; //.bVelocity;
divergenceAmt = 0.5f * ((fieldR.x - fieldL.x) +
(fieldT.y - fieldD.y) +
(fieldF.z - fieldB.z));
return divergenceAmt;
}
|