Skip to content

Commit f479fd7

Browse files
committed
Fix bottom borders
Parameters were incorrect
1 parent f29ec17 commit f479fd7

File tree

11 files changed

+53
-40
lines changed

11 files changed

+53
-40
lines changed

packages/arisu-app/plugin/render.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ local Instance = require("arisu-gfx.instance")
1616
---@field overlayPipeline gfx.Pipeline
1717
---@field overlayVertex gfx.Buffer
1818
---@field overlayIndex gfx.Buffer
19+
---@field depthBuffer gfx.Texture
1920
---@field ui? arisu.Element
2021
---@field layoutTree? arisu.Layout
2122
---@field computedLayout? arisu.ComputedLayout
@@ -77,11 +78,11 @@ function RenderPlugin:register(window)
7778

7879
local quadPipeline = self.device:createPipeline({
7980
vertex = {
80-
module = { type = "glsl", source = io.open("packages/arisu/shaders/main.vert.glsl", "r"):read("*a") },
81+
module = { type = "glsl", source = io.open("packages/arisu-app/shaders/main.vert.glsl", "r"):read("*a") },
8182
buffers = { vertexDescriptor }
8283
},
8384
fragment = {
84-
module = { type = "glsl", source = io.open("packages/arisu/shaders/main.frag.glsl", "r"):read("*a") },
85+
module = { type = "glsl", source = io.open("packages/arisu-app/shaders/main.frag.glsl", "r"):read("*a") },
8586
targets = {
8687
{
8788
blend = gfx.BlendState.ALPHA_BLENDING,
@@ -122,6 +123,12 @@ function RenderPlugin:register(window)
122123
}
123124
})
124125

126+
local depthBuffer = self.device:createTexture({
127+
extents = { dim = "2d", width = window.width, height = window.height },
128+
format = gfx.TextureFormat.Depth24Plus,
129+
usages = { "RENDER_ATTACHMENT" }
130+
})
131+
125132
-- Initialize shared resources
126133
if not self.mainCtx then
127134
local textureManager = TextureManager.new(self.device)
@@ -145,7 +152,8 @@ function RenderPlugin:register(window)
145152
overlayPipeline = overlayPipeline,
146153
overlayVertex = overlayVertex,
147154
overlayIndex = overlayIndex,
148-
nIndices = 0
155+
nIndices = 0,
156+
depthBuffer = depthBuffer
149157
}
150158

151159
self.contexts[window] = ctx
@@ -175,7 +183,10 @@ function RenderPlugin:draw(ctx)
175183
texture = ctx.swapchain:getCurrentTexture()
176184
}
177185
},
178-
depthStencilAttachment = { op = { type = "clear", depth = 1 } }
186+
depthStencilAttachment = {
187+
op = { type = "clear", depth = 1 },
188+
texture = ctx.depthBuffer
189+
}
179190
})
180191
encoder:setPipeline(ctx.quadPipeline)
181192
encoder:setBindGroup(0, self.sharedResources.bindGroup)

packages/arisu-app/plugin/ui.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ local function generateLayoutQuads(layout, parentX, parentY, vertices, indices,
116116

117117
-- Bottom border
118118
if borderBottom and borderBottom.width and borderBottom.width > 0 and borderBottom.style ~= "none" then
119-
addBorderQuad(x, y + height - borderBottom.width, width, z, borderBottom.width, borderBottom.color,
120-
windowWidth,
121-
windowHeight, vertices, indices)
119+
addBorderQuad(x, y + height - borderBottom.width, width, borderBottom.width, borderBottom.color, z,
120+
windowWidth, windowHeight,
121+
vertices, indices)
122122
end
123123

124124
-- Left border

packages/arisu-gfx/command_buffer/gl.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ end
2727
---@param op gfx.DepthOp
2828
local function executeDepthOp(op)
2929
if op.type == "clear" then
30+
gl.depthMask(true)
3031
gl.clearDepthf(op.depth)
3132
gl.clear(gl.DEPTH_BUFFER_BIT)
3233
end
@@ -89,13 +90,15 @@ function GLCommandBuffer:execute()
8990
vao = vaos[texture.context]
9091
vao:bind()
9192

93+
assert(texture.framebuffer == 0, "Unimplemented: support for different frame buffers")
9294
gl.bindFramebuffer(gl.FRAMEBUFFER, texture.framebuffer)
9395
executeOp(attachment.op)
9496
end
9597

9698
-- TODO: Support separate depth/stencil textures
9799
local depthStencilAttachment = command.descriptor.depthStencilAttachment
98100
if depthStencilAttachment then
101+
local texture = depthStencilAttachment.texture --[[@as gfx.gl.Texture]]
99102
executeDepthOp(depthStencilAttachment.op)
100103
end
101104
elseif command.type == "setPipeline" then

packages/arisu-gfx/command_encoder.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
---@class gfx.RenderPassDescriptor
1919
---@field colorAttachments { op: gfx.LoadOp, texture: gfx.Texture }[]
20-
---@field depthStencilAttachment? { op: gfx.DepthOp } # TODO: This will probably store texture later
20+
---@field depthStencilAttachment? { op: gfx.DepthOp, texture: gfx.Texture }
2121

2222
---@class gfx.CommandEncoder
2323
---@field finish fun(self: gfx.CommandEncoder): gfx.CommandBuffer

packages/arisu-gfx/device/gl.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ function GLDevice:createBindGroup(entries)
4242
return GLBindGroup.new(entries)
4343
end
4444

45-
---@param desc gfx.SamplerDescriptor
46-
function GLDevice:createSampler(desc)
45+
---@param descriptor gfx.SamplerDescriptor
46+
function GLDevice:createSampler(descriptor)
4747
self.ctx:makeCurrent()
48-
return GLSampler.new(desc)
48+
return GLSampler.new(descriptor)
4949
end
5050

51-
---@param desc gfx.TextureDescriptor
52-
function GLDevice:createTexture(desc)
51+
---@param descriptor gfx.TextureDescriptor
52+
function GLDevice:createTexture(descriptor)
5353
self.ctx:makeCurrent()
54-
return GLTexture.new(self, desc)
54+
return GLTexture.new(self, descriptor)
5555
end
5656

5757
return GLDevice

packages/arisu-gfx/texture/gl.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ GLTexture.__index = GLTexture
1111

1212
local glInternalFormatMap = {
1313
[gfx.TextureFormat.Rgba8UNorm] = gl.RGBA8,
14+
[gfx.TextureFormat.Depth24Plus] = gl.DEPTH_COMPONENT24,
1415
}
1516

1617
local glFormatMap = {

packages/arisu-opengl/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ return {
198198
TEXTURE_3D = 0x806F,
199199

200200
RGBA8 = 0x8058,
201+
DEPTH_COMPONENT24 = 0x81A6,
201202

202203
RG = 0x8227,
203204
RGB = 0x1907,
@@ -261,6 +262,8 @@ return {
261262
UNPACK_ROW_LENGTH = 0x0CF2,
262263
UNPACK_IMAGE_HEIGHT = 0x806E,
263264

265+
CULL_FACE = 0x0B44,
266+
264267
--- @param type gl.ShaderType
265268
--- @param src string
266269
--- @return number

packages/arisu/init.lua

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,6 @@ local Image = require("arisu-image")
44

55
-- local Compute = require("arisu.tools.compute")
66

7-
do
8-
local ffi = require("ffi")
9-
local gl = require("arisu-opengl")
10-
11-
gl.enable(gl.DEBUG_OUTPUT)
12-
gl.enable(gl.DEBUG_OUTPUT_SYNCHRONOUS)
13-
14-
gl.debugMessageCallback(function(source, type, id, severity, length, message)
15-
print("debug message calblack")
16-
end)
17-
18-
gl.debugMessageControl(gl.DONT_CARE, gl.DONT_CARE, gl.DONT_CARE, 0, nil, 1)
19-
end
20-
217
local Arisu = require("arisu-app")
228
local Element = require("arisu-app.ui.element")
239

0 commit comments

Comments
 (0)