Skip to content

Small code thing, and small note #1

@BrickDesignerNL

Description

@BrickDesignerNL

In the HTML file in this part of the code

        const getDevice = async () => {
            const adapter = await navigator.gpu.requestAdapter();
            const requiredLimits = {};
            const maxBufferSizeInSDModel = 1073741824;
            requiredLimits.maxStorageBufferBindingSize = maxBufferSizeInSDModel;
            requiredLimits.maxBufferSize = maxBufferSizeInSDModel;
            
            return await adapter.requestDevice({
                requiredLimits: requiredLimits,
                requiredFeatures: ["shader-f16"],
                powerPreference: "high-performance"
            });
        };

My interpretation of https://www.w3.org/TR/webgpu/ is that powerPreference: "high-performance" should be part of the navigator.gpu.requestAdapter() options instead of the adapter.requestDevice() options.

        const getDevice = async () => {
            const adapter = await navigator.gpu.requestAdapter({
                powerPreference: "high-performance"
            });
            const requiredLimits = {};
            const maxBufferSizeInSDModel = 1073741824;
            requiredLimits.maxStorageBufferBindingSize = maxBufferSizeInSDModel;
            requiredLimits.maxBufferSize = maxBufferSizeInSDModel;
            
            return await adapter.requestDevice({
                requiredLimits: requiredLimits,
                requiredFeatures: ["shader-f16"]
            });
        };

side note:
I've noticed that when I add forceFallbackAdapter: true to the options of navigator.gpu.requestAdapter() the maxStorageBufferBindingSize of 1073741824 (1GB) is actually available on my machine, but then shader-f16 is missing in the feature set. The normal setting gives a maxStorageBufferBindingSize of 134217728 128MB and shader-f16.

So it might be useful for some projects to test if a different adapter request, could lead to having a higher limit for the feature you prefer to use.

Anyhow, thank you for your project, I've learned a lot from it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions