Hash :
4b69ba93
Author :
Date :
2025-04-28T16:45:56
WGPU: upload texture bind groups and configured samplers
GLSL samplers are split into separate sampler/texture variables
in WGSL. Before this CL, the WGSL translator generated shaders
that look like:
@group(1) @binding(@@@@@@) var ANGLE_sampler_samp2D :
sampler;
@group(1) @binding(@@@@@@) var ANGLE_texture_samp2D :
texture_2d<f32>;
@group(1) @binding(@@@@@@) var ANGLE_sampler_sampCube :
sampler;
@group(1) @binding(@@@@@@) var ANGLE_texture_sampCube :
texture_cube<f32>;
This CL replaces those with actual binding numbers
@group(1) @binding(0) var ANGLE_sampler_samp2D :
sampler;
@group(1) @binding(1) var ANGLE_texture_samp2D :
texture_2d<f32>;
...
Such that @binding(n*2) is the WGSL sampler variable corresponding
to the n-th GLSL sampler and @binding(n*2+1) is the WGSL texture
variable corresponding to the n-th GLSL sampler.
This CL then generates binding group layouts matching the above,
and uploads textures and configured samplers in bind groups.
This makes some of the deqp_gles2 tests 2d texture tests pass,
though some fail because they need a flipped y coordinate.
Not yet supported:
1. arrays of samplers
2. shadow samplers
3. cube textures
Bug: angleproject:389145696
Change-Id: I2ab18ae5ebb4d1289101266bd9451576aa04ce2a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6382272
Reviewed-by: Liza Burakova <liza@chromium.org>
Auto-Submit: Matthew Denton <mpdenton@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
//
// Copyright 2024 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// wgpu_wgsl_util.h: Utilities to manipulate previously translated WGSL.
//
#ifndef LIBANGLE_RENDERER_WGPU_WGPU_WGSL_UTIL_H_
#define LIBANGLE_RENDERER_WGPU_WGPU_WGSL_UTIL_H_
#include "common/PackedGLEnums_autogen.h"
#include "libANGLE/Program.h"
namespace rx
{
namespace webgpu
{
// Replaces location markers in the WGSL source with actual locations, for
// `shaderVars` which is a vector of either gl::ProgramInputs or gl::ProgramOutputs, and for
// `mergedVaryings` which get assigned sequentially increasing locations. There should be at most
// vertex and fragment shader stages or this function will not assign locations correctly.
//
// Also assigns sampler bindings, which are split into two separate sampler/texture
// variables in WGSL and are assigned binding numbers as such:
// @binding(n*2) for the WGSL sampler variable corresponding to the n-th GLSL sampler
// @binding(n*2+1) for the WGSL texture variable corresponding to the n-th GLSL sampler.
template <typename T>
std::string WgslAssignLocationsAndSamplerBindings(const gl::ProgramExecutable &executable,
const std::string &shaderSource,
const std::vector<T> shaderVars,
const gl::ProgramMergedVaryings &mergedVaryings,
gl::ShaderType shaderType);
} // namespace webgpu
} // namespace rx
#endif /* LIBANGLE_RENDERER_WGPU_WGPU_WGSL_UTIL_H_ */