fix initialization
This commit is contained in:
parent
488c32e084
commit
32bc3fc4b4
1 changed files with 11 additions and 20 deletions
|
@ -10,6 +10,7 @@ import Control.Monad.Reader
|
||||||
import Control.Monad.Trans.Resource
|
import Control.Monad.Trans.Resource
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
|
import qualified Data.Vector.Storable as VS
|
||||||
import Foreign hiding (void)
|
import Foreign hiding (void)
|
||||||
import qualified Control.Concurrent.STM as STM
|
import qualified Control.Concurrent.STM as STM
|
||||||
import qualified Vulkan as Vk
|
import qualified Vulkan as Vk
|
||||||
|
@ -50,32 +51,22 @@ loadImageFromFile allocator uploadContext queue device file = do
|
||||||
|
|
||||||
let dataPtr = VMA.mappedData (bufferInfo stagingBuffer)
|
let dataPtr = VMA.mappedData (bufferInfo stagingBuffer)
|
||||||
|
|
||||||
liftIO $ V.mapM_
|
liftIO $ pokeArray (castPtr dataPtr) (VS.toList $ P.imageData pixels)
|
||||||
(\(idx, px) ->
|
|
||||||
poke
|
|
||||||
(castPtr dataPtr `plusPtr` (idx * sizeOf px))
|
|
||||||
px
|
|
||||||
)
|
|
||||||
(V.zip
|
|
||||||
(V.fromList [0..])
|
|
||||||
(V.convert $ P.imageData pixels)
|
|
||||||
)
|
|
||||||
|
|
||||||
let imageExtent = Vk.Extent3D
|
let imageExtent = Vk.Extent3D
|
||||||
{ width = fromIntegral $ texWidth
|
{ width = fromIntegral texWidth
|
||||||
, height = fromIntegral $ texHeight
|
, height = fromIntegral texHeight
|
||||||
, depth = 1
|
, depth = 1
|
||||||
}
|
}
|
||||||
dImgCreateInfo = Vk.zero
|
|
||||||
{ Vk.format = imageFormat
|
|
||||||
, Vk.usage = Vk.IMAGE_USAGE_SAMPLED_BIT .|. Vk.IMAGE_USAGE_TRANSFER_DST_BIT
|
|
||||||
, Vk.extent = imageExtent
|
|
||||||
}
|
|
||||||
dImgAllocCreateInfo = Vk.zero
|
dImgAllocCreateInfo = Vk.zero
|
||||||
{ VMA.usage = VMA.MEMORY_USAGE_GPU_ONLY
|
{ VMA.usage = VMA.MEMORY_USAGE_GPU_ONLY
|
||||||
} :: VMA.AllocationCreateInfo
|
} :: VMA.AllocationCreateInfo
|
||||||
|
dImgCreateInfo = imageCreate
|
||||||
|
imageFormat
|
||||||
|
imageExtent
|
||||||
|
(Vk.IMAGE_USAGE_SAMPLED_BIT .|. Vk.IMAGE_USAGE_TRANSFER_DST_BIT)
|
||||||
|
|
||||||
(newImage, allocation, _) <- snd <$>
|
(newImage, newAllocation, _) <- snd <$>
|
||||||
VMA.withImage allocator dImgCreateInfo dImgAllocCreateInfo allocate
|
VMA.withImage allocator dImgCreateInfo dImgAllocCreateInfo allocate
|
||||||
|
|
||||||
immediateSubmit
|
immediateSubmit
|
||||||
|
@ -95,7 +86,7 @@ loadImageFromFile allocator uploadContext queue device file = do
|
||||||
, Vk.newLayout = Vk.IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
|
, Vk.newLayout = Vk.IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
|
||||||
, Vk.image = newImage
|
, Vk.image = newImage
|
||||||
, Vk.subresourceRange = range
|
, Vk.subresourceRange = range
|
||||||
, Vk.srcAccessMask = bit 0
|
-- , Vk.srcAccessMask = bit 0
|
||||||
, Vk.dstAccessMask = Vk.ACCESS_TRANSFER_WRITE_BIT
|
, Vk.dstAccessMask = Vk.ACCESS_TRANSFER_WRITE_BIT
|
||||||
} :: Vk.ImageMemoryBarrier '[])
|
} :: Vk.ImageMemoryBarrier '[])
|
||||||
|
|
||||||
|
@ -149,7 +140,7 @@ loadImageFromFile allocator uploadContext queue device file = do
|
||||||
|
|
||||||
return $ AllocatedImage
|
return $ AllocatedImage
|
||||||
{ image = newImage
|
{ image = newImage
|
||||||
, allocation = allocation
|
, allocation = newAllocation
|
||||||
}
|
}
|
||||||
|
|
||||||
loadImages
|
loadImages
|
||||||
|
|
Loading…
Reference in a new issue