mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 11:21:40 +00:00
Update spirv-reader docs: supports texture and sampler func args
Change-Id: I893f050e3377c2aebe933a55d6e75c505c3e23d2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113560 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Auto-Submit: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
parent
ca01ec4689
commit
24c8440eb6
@ -158,9 +158,6 @@ texture builtin.
|
|||||||
|
|
||||||
### Passing textures and samplers into helper functions
|
### Passing textures and samplers into helper functions
|
||||||
|
|
||||||
Note: Bug https://crbug.com/tint/1039 is open to support passing
|
|
||||||
textures and samplers as function arguments.
|
|
||||||
|
|
||||||
Glslang generates SPIR-V where texture and sampler formal parameters
|
Glslang generates SPIR-V where texture and sampler formal parameters
|
||||||
are as pointer-to-UniformConstant.
|
are as pointer-to-UniformConstant.
|
||||||
|
|
||||||
@ -168,9 +165,12 @@ WGSL models them as passing texture and sampler values themselves,
|
|||||||
conceptually as opaque handles. This is similar to GLSL, but unlike
|
conceptually as opaque handles. This is similar to GLSL, but unlike
|
||||||
SPIR-V.
|
SPIR-V.
|
||||||
|
|
||||||
The tracing logic described in the previous section does not know
|
To support textures and samplers as arguments to user-defined functions,
|
||||||
what to do when it bottoms out on a formal parameter,
|
we extend the tracing logic so it knows to bottom out at OpFunctionParameter.
|
||||||
e.g. OpFunctionParameter.
|
|
||||||
|
Also, code that generates function declarations now understands formal
|
||||||
|
parameters declared as a pointer to uniform-constant as
|
||||||
|
well as direct image and sampler values.
|
||||||
|
|
||||||
Example GLSL compute shader:
|
Example GLSL compute shader:
|
||||||
|
|
||||||
@ -253,35 +253,6 @@ What the SPIR-V Reader currently generates:
|
|||||||
|
|
||||||
@group(0) @binding(1) var s : sampler;
|
@group(0) @binding(1) var s : sampler;
|
||||||
|
|
||||||
fn helper_t21_p1_(imparam : ptr<none, void>, sparam : ptr<none, void>) -> vec4<f32> {
|
|
||||||
let x_24 : vec4<f32> = textureSampleLevel(imparam, sparam, vec2<f32>(0.0f, 0.0f), 0.0f);
|
|
||||||
return x_24;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main_1() {
|
|
||||||
var v : vec4<f32>;
|
|
||||||
let x_31 : vec4<f32> = helper_t21_p1_(&(im), &(s));
|
|
||||||
v = x_31;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@compute @workgroup_size(1i, 1i, 1i)
|
|
||||||
fn main() {
|
|
||||||
main_1();
|
|
||||||
}
|
|
||||||
|
|
||||||
with an error:
|
|
||||||
|
|
||||||
error: function parameter of pointer type cannot be in 'none' address space
|
|
||||||
|
|
||||||
Instead, the generated WGSL should have formal parameters with texture
|
|
||||||
and sampler types, rather than as pointers to them. So the generated WGSL
|
|
||||||
should look like this instead:
|
|
||||||
|
|
||||||
@group(0) @binding(0) var im : texture_2d<f32>;
|
|
||||||
|
|
||||||
@group(0) @binding(1) var s : sampler;
|
|
||||||
|
|
||||||
fn helper_t21_p1_(imparam : texture_2d<f32>, sparam : sampler) -> vec4<f32> {
|
fn helper_t21_p1_(imparam : texture_2d<f32>, sparam : sampler) -> vec4<f32> {
|
||||||
let x_24 : vec4<f32> = textureSampleLevel(imparam, sparam, vec2<f32>(0.0f, 0.0f), 0.0f);
|
let x_24 : vec4<f32> = textureSampleLevel(imparam, sparam, vec2<f32>(0.0f, 0.0f), 0.0f);
|
||||||
return x_24;
|
return x_24;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user