packages feed

wgpu-hs 0.2.0.0 → 0.2.0.1

raw patch · 5 files changed

+46/−12 lines, 5 filesdep ~wgpu-raw-hsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: wgpu-raw-hs

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for wgpu-hs +## 0.2.0.1 -- 2021-08-24++- Added Linux support for surfaces and DLL loading.+- Updated `triangle` example to reallocate SwapChain correctly on resize.+ ## 0.2.0.0 -- 2021-08-22  - Added MS Windows support for surfaces and DLL loading.
examples/triangle/Main.hs view
@@ -5,11 +5,12 @@ -- | Let's draw a triangle! module Main (main) where -import Control.Monad (unless)+import Control.Monad (unless, when) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Except (runExceptT) import Control.Monad.Trans.Maybe (MaybeT (MaybeT), maybeToExceptT) import Data.Default (def)+import Data.IORef (IORef, newIORef, readIORef, writeIORef) import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as TextIO@@ -28,12 +29,10 @@     exitFailure    -- create the GLFW window without a "client API"-  let initWidth, initHeight :: Int-      initWidth = 640-      initHeight = 480+  windowSzRef <- newIORef (640, 480)   GLFW.windowHint (GLFW.WindowHint'ClientAPI GLFW.ClientAPI'NoAPI)   window <- do-    mWin <- GLFW.createWindow initWidth initHeight "Triangle" Nothing Nothing+    mWin <- GLFW.createWindow 640 480 "Triangle" Nothing Nothing     case mWin of       Just w -> pure w       Nothing -> do@@ -61,10 +60,11 @@           { swapChainLabel = "SwapChain",             usage = WGPU.TextureUsageRenderAttachment,             swapChainFormat = swapChainFormat,-            width = fromIntegral initWidth,-            height = fromIntegral initHeight,+            width = 640,+            height = 480,             presentMode = WGPU.PresentModeFifo           }+    swapChainRef <- newIORef swapChain     pipelineLayout <-       WGPU.createPipelineLayout         device@@ -92,6 +92,8 @@           }      let loop = do+          -- update swapchain if the window size is different+          updateSwapChain device surface window swapChainFormat windowSzRef swapChainRef           -- render           nextTexture <- WGPU.getSwapChainCurrentTextureView swapChain           encoder <- WGPU.createCommandEncoder device "Command Encoder"@@ -170,6 +172,33 @@   queue <- lift $ WGPU.getQueue device    pure Resources {..}++updateSwapChain ::+  WGPU.Device ->+  WGPU.Surface ->+  GLFW.Window ->+  WGPU.TextureFormat ->+  IORef (Int, Int) ->+  IORef WGPU.SwapChain ->+  IO ()+updateSwapChain device surface window textureFormat szRef swapChainRef = do+  oldSz <- readIORef szRef+  curSz <- GLFW.getWindowSize window+  when (curSz /= oldSz) $ do+    writeIORef szRef curSz+    swapChain <-+      WGPU.createSwapChain+        device+        surface+        WGPU.SwapChainDescriptor+          { swapChainLabel = "SwapChain",+            usage = WGPU.TextureUsageRenderAttachment,+            swapChainFormat = textureFormat,+            width = fromIntegral . fst $ curSz,+            height = fromIntegral . snd $ curSz,+            presentMode = WGPU.PresentModeFifo+          }+    writeIORef swapChainRef swapChain  shaderSrc :: WGPU.WGSL shaderSrc =
src-internal/WGPU/Internal/Instance.hs view
@@ -142,7 +142,7 @@   case System.Info.os of     "darwin" -> "libwgpu_native.dylib"     "mingw32" -> "wgpu_native.dll"-    "linux" -> "libwgpu_native.dylib"+    "linux" -> "libwgpu_native.so"     other ->       error $ "platformDylibName: unknown / unhandled platform: " <> other 
src/WGPU.hs view
@@ -5,7 +5,7 @@ -- Copyright   : Copyright (C) Jonathan Merritt 2021 -- Maintainer  : Jonathan Merritt <j.s.merritt@gmail.com> -- Stability   : experimental--- Portability : macOS+-- Portability : macOS, Linux, Windows -- -- Layout of this module should be guided by the evolving -- <https://www.w3.org/TR/webgpu/ WebGPU Specification>.@@ -212,7 +212,7 @@ -- -- === Platform Support ----- Currently, macOS (Metal) and Windows are supported. Linux support is planned.+-- Currently, macOS (Metal), Windows and Linux are supported. -- -- === Dependence on GLFW-b --
wgpu-hs.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               wgpu-hs-version:            0.2.0.0+version:            0.2.0.1 synopsis:           WGPU description:        A high-level binding to WGPU. bug-reports:        https://github.com/lancelet/wgpu-hs/issues@@ -70,7 +70,7 @@     , transformers      ^>=0.5.6     , vector            ^>=0.12.3     , wgpu-hs-internal-    , wgpu-raw-hs       ==0.2.0.0+    , wgpu-raw-hs       ==0.2.0.1    exposed-modules: WGPU