first little steps
This commit is contained in:
parent
b5ea2b1359
commit
a655a8be06
4 changed files with 53 additions and 28 deletions
30
flake.lock
30
flake.lock
|
@ -1,12 +1,15 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1680776469,
|
"lastModified": 1681202837,
|
||||||
"narHash": "sha256-3CXUDK/3q/kieWtdsYpDOBJw3Gw4Af6x+2EiSnIkNQw=",
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "411e8764155aa9354dbcd6d5faaeb97e9e3dce24",
|
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -17,11 +20,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1680910595,
|
"lastModified": 1681647474,
|
||||||
"narHash": "sha256-LA6EEVZrHO2qdgvwFBbXc0N7IVI2VziXgzejGrtQrjg=",
|
"narHash": "sha256-9CLzptrmk9TjN9gpiINUwuVoFEyN0BuPM6Cy/FbP38k=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d682cbf1548727b57ed1071e02399a4109384bb1",
|
"rev": "d68fa3ed1e489582e7a3063831c8fd1f3d1a8a38",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -35,6 +38,21 @@
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
@ -16,5 +16,6 @@ layout(set = 0, binding = 1) uniform SceneData{
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
//outColor = vec4(fragColor.xyz + sceneData.ambientColor.xyz, 1.0f);
|
//outColor = vec4(fragColor.xyz + sceneData.ambientColor.xyz, 1.0f);
|
||||||
|
//outColor = fragColor;
|
||||||
outColor = sceneData.ambientColor;
|
outColor = sceneData.ambientColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import Devices
|
||||||
import Types
|
import Types
|
||||||
import Memory
|
import Memory
|
||||||
import Util
|
import Util
|
||||||
|
import Control.Exception (bracket, bracket_)
|
||||||
|
|
||||||
frameOverlap :: Int
|
frameOverlap :: Int
|
||||||
frameOverlap = 2
|
frameOverlap = 2
|
||||||
|
@ -275,30 +276,31 @@ recordCommandBuffer
|
||||||
deviceProps
|
deviceProps
|
||||||
|
|
||||||
|
|
||||||
scenePointer <- VMA.mapMemory allocator (bufferAllocation sceneParameterBuffer)
|
liftIO $ VMA.withMappedMemory allocator (bufferAllocation sceneParameterBuffer) bracket $
|
||||||
|
\scenePointer ->
|
||||||
|
|
||||||
-- dataPointer <- liftIO $ new scenePointer
|
-- dataPointer <- liftIO $ new scenePointer
|
||||||
|
|
||||||
-- paramsPtr <- liftIO (new ambientParams)
|
-- paramsPtr <- liftIO (new ambientParams)
|
||||||
|
|
||||||
-- liftIO $ copyBytes
|
-- liftIO $ copyBytes
|
||||||
-- (scenePointer `plusPtr` (fromIntegral sceneDataOffset * fromIntegral frameIndex))
|
-- (scenePointer `plusPtr` (fromIntegral sceneDataOffset * fromIntegral frameIndex))
|
||||||
-- paramsPtr
|
-- paramsPtr
|
||||||
-- (sizeOf undefinedGPUSceneData)
|
-- (sizeOf undefinedGPUSceneData)
|
||||||
|
|
||||||
liftIO $ poke
|
liftIO $ poke
|
||||||
(castPtr scenePointer `plusPtr` (fromIntegral sceneDataOffset * frameIndex))
|
(castPtr scenePointer `plusPtr` (fromIntegral sceneDataOffset * frameIndex))
|
||||||
-- (castPtr scenePointer `plusPtr`
|
-- (castPtr scenePointer `plusPtr`
|
||||||
-- (fromIntegral $
|
-- (fromIntegral $
|
||||||
-- padUniformBufferSize (fromIntegral $ sizeOf (undefinedGPUSceneData)) deviceProps))-- *
|
-- padUniformBufferSize (fromIntegral $ sizeOf (undefinedGPUSceneData)) deviceProps))-- *
|
||||||
-- -- fromIntegral frameIndex))
|
-- -- fromIntegral frameIndex))
|
||||||
ambientParams
|
ambientParams
|
||||||
|
|
||||||
-- liftIO $ do
|
-- liftIO $ do
|
||||||
-- test <- peek (castPtr scenePointer :: Ptr GPUSceneData)
|
-- test <- peek (castPtr scenePointer :: Ptr GPUSceneData)
|
||||||
-- print test
|
-- print test
|
||||||
|
|
||||||
VMA.unmapMemory allocator (bufferAllocation sceneParameterBuffer)
|
-- VMA.unmapMemory allocator (bufferAllocation sceneParameterBuffer)
|
||||||
|
|
||||||
renderObjects <- (liftIO . STM.atomically . STM.readTMVar) =<< asks renderables
|
renderObjects <- (liftIO . STM.atomically . STM.readTMVar) =<< asks renderables
|
||||||
meshMap <- (liftIO . STM.atomically . STM.readTMVar) =<< asks meshLibrary
|
meshMap <- (liftIO . STM.atomically . STM.readTMVar) =<< asks meshLibrary
|
||||||
|
@ -330,11 +332,15 @@ recordCommandBuffer
|
||||||
mesh = meshMap M.! meshID
|
mesh = meshMap M.! meshID
|
||||||
material = materialMap M.! materialID
|
material = materialMap M.! materialID
|
||||||
|
|
||||||
memoryPointer <- VMA.mapMemory allocator (bufferAllocation $ frameCameraBuffer frame)
|
liftIO $ VMA.withMappedMemory
|
||||||
|
allocator
|
||||||
|
(bufferAllocation $ frameCameraBuffer frame)
|
||||||
|
bracket
|
||||||
|
$ \memoryPointer ->
|
||||||
|
|
||||||
liftIO $ poke (castPtr memoryPointer) cameraData
|
liftIO $ poke (castPtr memoryPointer) cameraData
|
||||||
|
|
||||||
VMA.unmapMemory allocator (bufferAllocation $ frameCameraBuffer frame)
|
-- VMA.unmapMemory allocator (bufferAllocation $ frameCameraBuffer frame)
|
||||||
|
|
||||||
Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS (materialPipeline material)
|
Vk.cmdBindPipeline commandBuffer Vk.PIPELINE_BIND_POINT_GRAPHICS (materialPipeline material)
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ initDescriptors device = do
|
||||||
0
|
0
|
||||||
sceneBind = descriptorsetLayoutBinding
|
sceneBind = descriptorsetLayoutBinding
|
||||||
Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
|
Vk.DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
|
||||||
(Vk.SHADER_STAGE_VERTEX_BIT .|. Vk.SHADER_STAGE_FRAGMENT_BIT)
|
Vk.SHADER_STAGE_FRAGMENT_BIT
|
||||||
1
|
1
|
||||||
objectBind = descriptorsetLayoutBinding
|
objectBind = descriptorsetLayoutBinding
|
||||||
Vk.DESCRIPTOR_TYPE_STORAGE_BUFFER
|
Vk.DESCRIPTOR_TYPE_STORAGE_BUFFER
|
||||||
|
|
Loading…
Reference in a new issue