Trying to fix no available video device :(

This commit is contained in:
Warwick New 2025-04-22 00:10:36 +01:00
parent cbd4b0f0e9
commit 5a1a85885a
4 changed files with 78 additions and 4 deletions

View file

@ -1,6 +1,55 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixgl": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1713543440,
"narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=",
"owner": "nix-community",
"repo": "nixGL",
"rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixGL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1660551188,
"narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1744463964,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
@ -18,7 +67,8 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
"nixgl": "nixgl",
"nixpkgs": "nixpkgs_2"
}
}
},

View file

@ -2,13 +2,16 @@
description = "Development Environment";
inputs = {
nixgl.url = "github:nix-community/nixGL";
nixpkgs.url= "github:nixos/nixpkgs/nixos-unstable";
};
outputs = {self, nixpkgs, ...}:
outputs = {self, nixpkgs, nixgl,...}:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ nixgl.overlay ];
};
in {
devShells.x86_64-linux.default = (import ./shell.nix { inherit pkgs; });
};

View file

@ -8,6 +8,8 @@ pkgs.mkShell
cglm
sdl3
sdl3-image
nixgl.nixVulkanIntel
vulkan-headers
];
shellHook = ''
export PS1="(webgpu) $PS1"

View file

@ -1,6 +1,11 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_vulkan.h>
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>
#include <webgpu/webgpu.h>
static void OnRequestAdapter(WGPURequestAdapterStatus status,
@ -35,6 +40,20 @@ void requestAdapterSync(WGPUInstance instance,
}
int main() {
SDL_Window *window = NULL;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "SDL failed to initialise: %s\n", SDL_GetError());
return 1;
}
window = SDL_CreateWindow("SDL3 Example", 800, 600, SDL_WINDOW_VULKAN);
if (window == NULL) {
fprintf(stderr, "SDL window failed to initialise: %s\n", SDL_GetError());
return 1;
}
const char *driver = SDL_GetCurrentVideoDriver();
printf("Driver: %s\n", driver);
// We create a descriptor
WGPUInstanceDescriptor desc = {};
desc.nextInChain = NULL;