Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a flaky test for the WebGPU renderer #342

Merged
merged 1 commit into from
Jan 28, 2024
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
4 changes: 3 additions & 1 deletion Core/NativeClient/WebGPU/Mesh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ local UnlitMeshMaterial = require("Core.NativeClient.WebGPU.Materials.UnlitMeshM

local uuid = require("uuid")

local Mesh = {}
local Mesh = {
NUM_BUFFERS_PER_MESH = 5, -- Positions, indices, colors, diffuse UVs, normals
}

function Mesh:Construct(name)
local globallyUniqueID = uuid.createMersenneTwistedUUID() -- Might be overkill, but oh well...
Expand Down
15 changes: 9 additions & 6 deletions Tests/NativeClient/Renderer.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,16 @@ describe("Renderer", function()
it("should remove all existing meshes from the scene", function()
local scene = require("Core.NativeClient.DebugDraw.Scenes.wgpu")
Renderer:LoadSceneObjects(scene)
assertEquals(#Renderer.meshes, 9)
assertEquals(#Renderer.meshes, #scene.meshes)

-- A bit sketchy, but oh well... Better: Track wgpu calls (again)? Maybe later, seems redundant
_G.assertCallsFunction(function()
Renderer:ResetScene()
end, Renderer.DestroyMeshGeometry, 42)
assertEquals(#Renderer.meshes, 0)
etrace.clear()
Renderer:ResetScene()
local events = etrace.filter()

assertEquals(#events, #scene.meshes * Mesh.NUM_BUFFERS_PER_MESH)
for index = 1, #scene.meshes * Mesh.NUM_BUFFERS_PER_MESH, 1 do
assertEquals(events[index].name, "GPU_BUFFER_DESTROY")
end
end)

it("should reset the scene lighting to its default values", function()
Expand Down
Loading