Skip to content

Commit e03683a

Browse files
committed
More gfx stuff
1 parent b2b0499 commit e03683a

File tree

8 files changed

+43
-37
lines changed

8 files changed

+43
-37
lines changed

packages/arisu-gfx/buffer/gl.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ local ffi = require("ffi")
66
local GLBuffer = {}
77
GLBuffer.__index = GLBuffer
88

9-
function GLBuffer.new()
9+
---@param descriptor gfx.BufferDescriptor
10+
function GLBuffer.new(descriptor)
1011
local handle = ffi.new("GLuint[1]")
1112
gl.createBuffers(1, handle)
1213
return setmetatable({ id = handle[0] }, GLBuffer)

packages/arisu-gfx/buffer/vk.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local vk = require("arisu-vulkan")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---@alias gfx.BufferUsage
2+
--- | "COPY_DST"
3+
--- | "COPY_SRC"
4+
--- | "VERTEX"
5+
--- | "INDEX"
6+
7+
---@class gfx.BufferDescriptor
8+
---@field size number
9+
---@field usages gfx.BufferUsage[]
10+
local BufferDescriptor = {}
11+
BufferDescriptor.__index = BufferDescriptor
12+
13+
function BufferDescriptor.new()
14+
return setmetatable({}, BufferDescriptor)
15+
end
16+
17+
---@param size number
18+
function BufferDescriptor:withSize(size)
19+
self.size = size
20+
return self
21+
end
22+
23+
---@param usages gfx.BufferUsage[]
24+
function BufferDescriptor:withUsages(usages)
25+
self.usages = usages
26+
return self
27+
end
28+
29+
return BufferDescriptor

packages/arisu-gfx/context/win32.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local kernel32 = require("arisu-win32..kernel32")
33
local wgl = require("arisu-win32.wgl")
44
local gdi = require("arisu-win32.gdi")
55

6-
---@class Win32Context: Context
6+
---@class Win32Context
77
---@field display user32.HDC
88
---@field ctx wgl.HGLRC
99
local Win32Context = {}

packages/arisu-gfx/init.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
local util = require("arisu-util")
22

3-
---@alias PresentMode "immediate" | "vsync"
4-
53
---@class gfx.Context
64
---@field new fun(window: winit.Window, sharedCtx: gfx.Context?): gfx.Context
75
---@field makeCurrent fun(self: gfx.Context): boolean

packages/arisu-gfx/vertex_layout.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ local ffi = require("ffi")
33
---@alias AttributeType "f32" | "i32"
44
---@alias Attribute { type: "f32" | "i32", size: number, offset: number, normalized: boolean }
55

6-
---@class gfx.VertexLayoutDescriptor
6+
---@class gfx.VertexLayout
77
---@field attributes Attribute[]
88
---@field stride number?
9-
local VertexLayoutDescriptor = {}
10-
VertexLayoutDescriptor.__index = VertexLayoutDescriptor
9+
local VertexLayout = {}
10+
VertexLayout.__index = VertexLayout
1111

12-
function VertexLayoutDescriptor.new()
13-
return setmetatable({ attributes = {}, stride = 0 }, VertexLayoutDescriptor)
12+
function VertexLayout.new()
13+
return setmetatable({ attributes = {}, stride = 0 }, VertexLayout)
1414
end
1515

1616
---@param attribute Attribute
17-
function VertexLayoutDescriptor:withAttribute(attribute)
17+
function VertexLayout:withAttribute(attribute)
1818
table.insert(self.attributes, attribute)
1919
return self
2020
end
2121

22-
function VertexLayoutDescriptor:withStride(stride)
22+
function VertexLayout:withStride(stride)
2323
self.stride = stride
2424
return self
2525
end
2626

27-
function VertexLayoutDescriptor:getStride()
27+
function VertexLayout:getStride()
2828
if self.stride and self.stride > 0 then
2929
return self.stride
3030
end
@@ -47,4 +47,4 @@ function VertexLayoutDescriptor:getStride()
4747
return maxEnd
4848
end
4949

50-
return VertexLayoutDescriptor
50+
return VertexLayout

packages/arisu/gl/vao.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function VAO:unbind()
2121
end
2222

2323
---@param buffer gfx.gl.Buffer
24-
---@param descriptor gfx.VertexLayoutDescriptor
24+
---@param descriptor gfx.VertexLayout
2525
---@param bindingIndex number?
2626
function VAO:setVertexBuffer(buffer, descriptor, bindingIndex)
2727
bindingIndex = bindingIndex or 0

packages/arisu/init.lua

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -974,27 +974,4 @@ function App:update(message, window)
974974
end
975975
end
976976

977-
local vk = require("arisu-vulkan")
978-
local ffi = require("ffi")
979-
980-
local gpuDevice ---@type vk.PhysicalDevice?
981-
for _, physicalDevice in ipairs(vk.enumeratePhysicalDevices()) do
982-
local properties = vk.getPhysicalDeviceProperties(physicalDevice)
983-
if properties.deviceType == vk.PhysicalDeviceType.DISCRETE_GPU then
984-
gpuDevice = physicalDevice
985-
break
986-
end
987-
end
988-
989-
if gpuDevice then
990-
print("Using discrete GPU for compute")
991-
local device = vk.createDevice(gpuDevice)
992-
local buffer = vk.createBuffer(device, { size = 200, usage = vk.BufferUsage.STORAGE_BUFFER })
993-
994-
local shader = vk.createShaderModule(device, {
995-
codeSize = 2123,
996-
pCode = ffi.cast("const unsigned int*", "foo")
997-
})
998-
end
999-
1000977
Arisu.run(App)

0 commit comments

Comments
 (0)