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

Increase the limits of the WebGPU pipeline so that large GND terrain geometry may be rendered #229

Merged
merged 2 commits into from
Dec 15, 2023
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: 2 additions & 2 deletions Core/NativeClient/Renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ end
function Renderer:DrawMesh(renderPass, mesh)
local vertexBufferSize = #mesh.vertexPositions * ffi.sizeof("float")
local colorBufferSize = #mesh.vertexColors * ffi.sizeof("float")
local indexBufferSize = #mesh.triangleConnections * ffi.sizeof("uint16_t")
local indexBufferSize = #mesh.triangleConnections * ffi.sizeof("uint32_t")
local diffuseTexCoordsBufferSize = mesh.diffuseTextureCoords and (#mesh.diffuseTextureCoords * ffi.sizeof("float"))
or GPU.MAX_VERTEX_COUNT

RenderPassEncoder:SetVertexBuffer(renderPass, 0, mesh.vertexBuffer, 0, vertexBufferSize)
RenderPassEncoder:SetVertexBuffer(renderPass, 1, mesh.colorBuffer, 0, colorBufferSize)
RenderPassEncoder:SetVertexBuffer(renderPass, 2, mesh.diffuseTexCoordsBuffer, 0, diffuseTexCoordsBufferSize)
RenderPassEncoder:SetIndexBuffer(renderPass, mesh.indexBuffer, ffi.C.WGPUIndexFormat_Uint16, 0, indexBufferSize)
RenderPassEncoder:SetIndexBuffer(renderPass, mesh.indexBuffer, ffi.C.WGPUIndexFormat_Uint32, 0, indexBufferSize)

RenderPassEncoder:SetBindGroup(renderPass, 0, self.bindGroup, 0, nil)

Expand Down
4 changes: 2 additions & 2 deletions Core/NativeClient/WebGPU/Buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Buffer:CreateVertexBuffer(wgpuDevice, entries)
end

function Buffer:CreateIndexBuffer(wgpuDevice, indices)
local rawBufferSizeInBytes = #indices * ffi.sizeof("uint16_t") -- Assumes there won't be too many trianglces per mesh
local rawBufferSizeInBytes = #indices * ffi.sizeof("uint32_t") -- Assumes there won't be too many trianglces per mesh
local alignedBufferSizeInBytes = Buffer.GetAlignedSize(rawBufferSizeInBytes)

local bufferDescriptor = ffi.new("WGPUBufferDescriptor")
Expand All @@ -53,7 +53,7 @@ function Buffer:CreateIndexBuffer(wgpuDevice, indices)
webgpu.bindings.wgpu_device_get_queue(wgpuDevice),
buffer,
0,
ffi.new("uint16_t[?]", alignedBufferSizeInBytes, indices),
ffi.new("uint32_t[?]", alignedBufferSizeInBytes, indices),
alignedBufferSizeInBytes
)

Expand Down
2 changes: 1 addition & 1 deletion Core/NativeClient/WebGPU/GPU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local glfw = require("glfw")
local webgpu = require("webgpu")

local GPU = {
MAX_VERTEX_COUNT = 65536, -- Should be configurable (later)
MAX_VERTEX_COUNT = 200000, -- Should be configurable (later)
}

function GPU:CreateInstance()
Expand Down