/*
Crafter®.Graphics
Copyright (C) 2026 Catcrafts®
catcrafts.net
*/

module;
module Crafter.Graphics:ShaderBindingTableWebGPU_impl;

import :ShaderBindingTableWebGPU;
import std;

using namespace Crafter;

WebGPUShader::WebGPUShader(const std::filesystem::path& wgslPath,
                           std::string fn,
                           WebGPURTStage s)
    : entryFn(std::move(fn)), stage(s) {
    std::ifstream f(wgslPath, std::ios::binary | std::ios::ate);
    if (!f.is_open()) {
        std::println("WebGPUShader: cannot open {}", wgslPath.string());
        return;
    }
    auto size = f.tellg();
    if (size <= 0) {
        std::println("WebGPUShader: empty file {}", wgslPath.string());
        return;
    }
    f.seekg(0, std::ios::beg);
    source.resize(static_cast<std::size_t>(size));
    f.read(source.data(), size);
}
