这是indexloc提供的服务,不要输入任何密码
Skip to content

Sampling non-float textures is forbidden in HLSL #1162

@kvark

Description

@kvark

Currently, the spec has GPUTextureComponentType that has to be provided for "sampled" texture types. @eseaflower pointed to an issue with HLSL that non-float textures can't be sampled at all in gfx-rs/wgpu#999 (comment)

Looking at the documentation, I see that only "float" types are permitted here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/samplelevel-s-float-float-int-uint-

Technically, we can work around this by issuing Load instructions, but this requires a bunch of logic and information about the texture dimensions and sampler wrapping modes, so it would be very unfortunate if we had to do this.

I think we should just restrict this in WGSL by defining the textureSample* to only work on f32 textures and return vec4<f32> correspondingly.

There is another problem with "sampled-texture" binding in WebGPU now: these textures can't really be sampled (if we go with the restriction), so binding them via this type is awkward and confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions