webgpu triangle
This commit is contained in:
parent
64116cd980
commit
5553ded476
22 changed files with 2107 additions and 42 deletions
|
|
@ -46,3 +46,42 @@ export namespace Crafter {
|
|||
};
|
||||
}
|
||||
#endif // !CRAFTER_GRAPHICS_WINDOW_DOM
|
||||
|
||||
#ifdef CRAFTER_GRAPHICS_WINDOW_DOM
|
||||
import std;
|
||||
import :RenderPass;
|
||||
import :Window;
|
||||
import :WebGPU;
|
||||
import :PipelineRTWebGPU;
|
||||
import :RenderingElement3D;
|
||||
|
||||
export namespace Crafter {
|
||||
// DOM-mode RT pass — dispatches the megakernel pipeline at frame Record
|
||||
// time. Picks up the current TLAS for the frame and the application's
|
||||
// raygen-side push data (typically empty in v1; pass via window.passes
|
||||
// wiring if needed later).
|
||||
struct RTPass : RenderPass {
|
||||
PipelineRTWebGPU* pipeline;
|
||||
// Optional per-dispatch push data forwarded after the standard
|
||||
// RTDispatchHeader. Null means "no extra data".
|
||||
const void* pushPtr = nullptr;
|
||||
std::uint32_t pushBytes = 0;
|
||||
|
||||
RTPass(PipelineRTWebGPU* p) : pipeline(p) {}
|
||||
|
||||
void Record(WebGPUCommandEncoderRef /*cmd*/, std::uint32_t frameIdx, Window& window) override {
|
||||
const std::uint32_t gx = (window.width + 7u) / 8u;
|
||||
const std::uint32_t gy = (window.height + 7u) / 8u;
|
||||
auto& tlas = RenderingElement3D::tlases[frameIdx];
|
||||
WebGPU::wgpuDispatchRT(
|
||||
pipeline->pipelineHandle,
|
||||
pushPtr,
|
||||
static_cast<std::int32_t>(pushBytes),
|
||||
tlas.buffer.handle,
|
||||
static_cast<std::int32_t>(tlas.builtInstanceCount),
|
||||
static_cast<std::int32_t>(gx),
|
||||
static_cast<std::int32_t>(gy));
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // CRAFTER_GRAPHICS_WINDOW_DOM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue