Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v5
with:
repository: treeform/shady
ref: shady-backends
path: shady
- uses: treeform/setup-nim-action@v6
- run: nimby install shady/shady.nimble
- run: nimby install gltf/gltf.nimble
working-directory: ${{ github.workspace }}/..
- name: Install OpenGL test dependencies (Linux)
Expand Down Expand Up @@ -57,12 +63,57 @@ jobs:
with:
path: ${{ github.workspace }}
- run: nim check src/gltf.nim
- run: nim r -d:release tests/backend_shaders.nim
- name: Run tests (Linux)
if: runner.os == 'Linux'
run: xvfb-run -s "-screen 0 1024x768x24" env LIBGL_ALWAYS_SOFTWARE=1 nim r tests/tests.nim
run: xvfb-run -s "-screen 0 1024x768x24" env LIBGL_ALWAYS_SOFTWARE=1 nim r -d:release tests/tests.nim
- name: Run tests (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
nim c -o:tests.exe tests/tests.nim
nim c -d:release -o:tests.exe tests/tests.nim
.\tests.exe

backend-compile:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
backend: opengl
flags: -d:useOpenGL
- os: windows-latest
backend: opengl
flags: -d:useOpenGL
- os: windows-latest
backend: directx
flags: -d:useDirectX
- os: windows-latest
backend: vulkan
flags: -d:useVulkan
- os: macos-latest
backend: opengl
flags: -d:useOpenGL
- os: macos-latest
backend: metal
flags: -d:useMetal4
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v5
with:
repository: treeform/shady
ref: shady-backends
path: shady
- uses: treeform/setup-nim-action@v6
- run: nimby install shady/shady.nimble
- run: nimby install gltf/gltf.nimble
working-directory: ${{ github.workspace }}/..
- name: Generate viewer atlas
run: nim r tools/gen_atlas.nim
- name: Validate backend shaders (${{ matrix.backend }})
run: nim r -d:release ${{ matrix.flags }} tests/backend_shaders.nim
- name: Compile sample assets (${{ matrix.backend }})
run: nim c --compileOnly -d:release -d:shadyBinaryShaders ${{ matrix.flags }} tests/sample_assets.nim
- name: Compile viewer (${{ matrix.backend }})
run: nim c --compileOnly -d:release -d:shadyBinaryShaders ${{ matrix.flags }} tools/gltf_viewer.nim
6 changes: 6 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v5
with:
repository: treeform/shady
ref: shady-backends
path: shady
- uses: treeform/setup-nim-action@v6
- run: nimby install shady/shady.nimble
- run: nimby install gltf/gltf.nimble
working-directory: ${{ github.workspace }}/..
- run: nim doc --index:on --project --git.url:https://github.com/${{ github.repository }} --git.commit:master --out:${{ env.deploy-dir }} ${{ env.nim-src }}
Expand Down
2 changes: 2 additions & 0 deletions gltf.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ requires "opengl >= 1.2.3"
requires "webby >= 0.2.1"
requires "windy >= 0.4.4"
requires "silky >= 0.0.2"
requires "shady >= 0.0.2"
requires "metal4 >= 0.1.0"
5 changes: 3 additions & 2 deletions src/gltf/animations.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import
std/math,
vmath,
common, models
common,
models

proc resetToBase*(node: Node) =
## Reset the node and its children to the original transform.
Expand Down Expand Up @@ -258,6 +259,7 @@ proc applyMorphs(node: Node) =
tangent.x = dir.x
tangent.y = dir.y
tangent.z = dir.z
primitive.markGeometryDirty()
for child in node.nodes:
child.applyMorphs()

Expand Down Expand Up @@ -341,4 +343,3 @@ proc updateAnimation*(node: Node, dt: float32) =
if clipIdx >= 0 and clipIdx < node.animations.len:
applyClipAt(node.animations[clipIdx], node.animTime)
node.applyMorphs()
node.updateOnGpu()
46 changes: 46 additions & 0 deletions src/gltf/backends/directx/common.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
when not defined(windows):
{.error: "The glTF DirectX backend requires Windows.".}

import
pkg/dx12

type
DxTopology* = enum
dtPoint, dtLine, dtTriangle

PipelineKey* = object
topology*: DxTopology
doubleSided*: bool
blended*: bool

DxTexture* = ref object
resource*: ID3D12Resource
format*: uint32
isCube*: bool
mipLevels*: int

PrimitiveData* = ref object
geometryVersion*: uint64
vertexBuffer*: ID3D12Resource
vertexBufferPtr*: pointer
vertexBufferView*: D3D12_VERTEX_BUFFER_VIEW
vertexCapacity*: int
indexBuffer*: ID3D12Resource
indexBufferPtr*: pointer
indexBufferView*: D3D12_INDEX_BUFFER_VIEW
indexCapacity*: int
indexCount*: int
topology*: uint32
topologyKind*: DxTopology

MaterialData* = ref object
materialVersion*: uint64
heap*: ID3D12DescriptorHeap
handleGpu*: D3D12_GPU_DESCRIPTOR_HANDLE
textures*: seq[DxTexture]

GltfFileData* = ref object
sceneVersion*: uint64

DxPrimitive* = PrimitiveData
DxMaterial* = MaterialData
Loading
Loading