mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
tint: Allow signed / unsigned texture builtin params
Bug: tint:1526 Change-Id: I301a9ba6e94b162a1ffb436be3e3212b723b7401 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106682 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
d96f7c22ed
commit
da5424b617
@@ -58,8 +58,8 @@ struct MultiplanarExternalTexture::State {
|
||||
/// Symbol for the ExternalTextureParams struct
|
||||
Symbol params_struct_sym;
|
||||
|
||||
/// Symbol for the textureLoadExternal function
|
||||
Symbol texture_load_external_sym;
|
||||
/// Symbol for the textureLoadExternal functions
|
||||
utils::Hashmap<const sem::CallTarget*, Symbol, 2> texture_load_external_fns;
|
||||
|
||||
/// Symbol for the textureSampleExternal function
|
||||
Symbol texture_sample_external_sym;
|
||||
@@ -199,7 +199,7 @@ struct MultiplanarExternalTexture::State {
|
||||
|
||||
switch (builtin->Type()) {
|
||||
case sem::BuiltinType::kTextureLoad:
|
||||
return createTextureLoad(expr, syms);
|
||||
return createTextureLoad(call, syms);
|
||||
case sem::BuiltinType::kTextureSampleLevel:
|
||||
return createTextureSampleLevel(expr, syms);
|
||||
case sem::BuiltinType::kTextureSampleBaseClampToEdge:
|
||||
@@ -307,11 +307,11 @@ struct MultiplanarExternalTexture::State {
|
||||
case sem::BuiltinType::kTextureSampleLevel:
|
||||
// TODO(crbug.com/tint/1671): DEPRECATED
|
||||
// textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
|
||||
single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_a);
|
||||
// textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
|
||||
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_a);
|
||||
// textureSampleLevel(plane1, smp, coord, 0.0);
|
||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0_f);
|
||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0_a);
|
||||
break;
|
||||
case sem::BuiltinType::kTextureSampleBaseClampToEdge:
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
@@ -333,19 +333,19 @@ struct MultiplanarExternalTexture::State {
|
||||
|
||||
// textureSampleLevel(plane0, smp, plane0_clamped, 0.0);
|
||||
single_plane_call =
|
||||
b.Call("textureSampleLevel", "plane0", "smp", "plane0_clamped", 0_f);
|
||||
b.Call("textureSampleLevel", "plane0", "smp", "plane0_clamped", 0_a);
|
||||
// textureSampleLevel(plane0, smp, plane0_clamped, 0.0);
|
||||
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "plane0_clamped", 0_f);
|
||||
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "plane0_clamped", 0_a);
|
||||
// textureSampleLevel(plane1, smp, plane1_clamped, 0.0);
|
||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "plane1_clamped", 0_f);
|
||||
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "plane1_clamped", 0_a);
|
||||
break;
|
||||
case sem::BuiltinType::kTextureLoad:
|
||||
// textureLoad(plane0, coord, 0);
|
||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_a);
|
||||
// textureLoad(plane0, coord, 0);
|
||||
plane_0_call = b.Call("textureLoad", "plane0", "coord", 0_i);
|
||||
plane_0_call = b.Call("textureLoad", "plane0", "coord", 0_a);
|
||||
// textureLoad(plane1, coord, 0);
|
||||
plane_1_call = b.Call("textureLoad", "plane1", "coord", 0_i);
|
||||
plane_1_call = b.Call("textureLoad", "plane1", "coord", 0_a);
|
||||
break;
|
||||
default:
|
||||
TINT_ICE(Transform, b.Diagnostics()) << "unhandled builtin: " << call_type;
|
||||
@@ -356,7 +356,7 @@ struct MultiplanarExternalTexture::State {
|
||||
|
||||
// if ((params.numPlanes == 1u))
|
||||
stmts.Push(
|
||||
b.If(b.Equal(b.MemberAccessor("params", "numPlanes"), b.Expr(1_u)),
|
||||
b.If(b.Equal(b.MemberAccessor("params", "numPlanes"), b.Expr(1_a)),
|
||||
b.Block(
|
||||
// color = textureLoad(plane0, coord, 0).rgb;
|
||||
b.Assign("color", b.MemberAccessor(single_plane_call, "rgb"))),
|
||||
@@ -365,12 +365,12 @@ struct MultiplanarExternalTexture::State {
|
||||
// params.yuvToRgbConversionMatrix;
|
||||
b.Assign("color",
|
||||
b.Mul(b.vec4<f32>(b.MemberAccessor(plane_0_call, "r"),
|
||||
b.MemberAccessor(plane_1_call, "rg"), 1_f),
|
||||
b.MemberAccessor(plane_1_call, "rg"), 1_a),
|
||||
b.MemberAccessor("params", "yuvToRgbConversionMatrix")))))));
|
||||
|
||||
// if (params.doYuvToRgbConversionOnly == 0u)
|
||||
stmts.Push(
|
||||
b.If(b.Equal(b.MemberAccessor("params", "doYuvToRgbConversionOnly"), b.Expr(0_u)),
|
||||
b.If(b.Equal(b.MemberAccessor("params", "doYuvToRgbConversionOnly"), b.Expr(0_a)),
|
||||
b.Block(
|
||||
// color = gammaConversion(color, gammaDecodeParams);
|
||||
b.Assign("color", b.Call("gammaCorrection", "color",
|
||||
@@ -383,7 +383,7 @@ struct MultiplanarExternalTexture::State {
|
||||
b.MemberAccessor("params", "gammaEncodeParams"))))));
|
||||
|
||||
// return vec4<f32>(color, 1.f);
|
||||
stmts.Push(b.Return(b.vec4<f32>("color", 1_f)));
|
||||
stmts.Push(b.Return(b.vec4<f32>("color", 1_a)));
|
||||
|
||||
return stmts;
|
||||
}
|
||||
@@ -485,44 +485,48 @@ struct MultiplanarExternalTexture::State {
|
||||
}
|
||||
|
||||
/// Creates the textureLoadExternal function if needed and returns a call expression to it.
|
||||
/// @param expr the call expression being transformed
|
||||
/// @param call the call expression being transformed
|
||||
/// @param syms the expanded symbols to be used in the new call
|
||||
/// @returns a call expression to textureLoadExternal
|
||||
const ast::CallExpression* createTextureLoad(const ast::CallExpression* expr,
|
||||
NewBindingSymbols syms) {
|
||||
const ast::Expression* plane_0_binding_param = ctx.Clone(expr->args[0]);
|
||||
|
||||
if (expr->args.Length() != 2) {
|
||||
const ast::CallExpression* createTextureLoad(const sem::Call* call, NewBindingSymbols syms) {
|
||||
if (call->Arguments().Length() != 2) {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "expected textureLoad call with a texture_external "
|
||||
"to have 2 parameters, found "
|
||||
<< expr->args.Length() << " parameters";
|
||||
<< "expected textureLoad call with a texture_external to have 2 arguments, found "
|
||||
<< call->Arguments().Length() << " arguments";
|
||||
}
|
||||
|
||||
// TextureLoadExternal calls the gammaCorrection function, so ensure it
|
||||
// exists.
|
||||
auto& args = call->Arguments();
|
||||
|
||||
// TextureLoadExternal calls the gammaCorrection function, so ensure it exists.
|
||||
if (!gamma_correction_sym.IsValid()) {
|
||||
createGammaCorrectionFn();
|
||||
}
|
||||
|
||||
if (!texture_load_external_sym.IsValid()) {
|
||||
texture_load_external_sym = b.Symbols().New("textureLoadExternal");
|
||||
auto texture_load_external_sym = texture_load_external_fns.GetOrCreate(call->Target(), [&] {
|
||||
auto& sig = call->Target()->Signature();
|
||||
auto* coord_ty = sig.Parameter(sem::ParameterUsage::kCoords)->Type();
|
||||
|
||||
// Emit the textureLoadExternal function.
|
||||
auto name = b.Symbols().New("textureLoadExternal");
|
||||
|
||||
// Emit the textureLoadExternal() function.
|
||||
b.Func(
|
||||
texture_load_external_sym,
|
||||
name,
|
||||
utils::Vector{
|
||||
b.Param("plane0", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("coord", b.ty.vec2(b.ty.i32())),
|
||||
b.Param("coord", CreateASTTypeFor(ctx, coord_ty)),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()), //
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad));
|
||||
}
|
||||
|
||||
return b.Call(texture_load_external_sym, plane_0_binding_param, syms.plane_1,
|
||||
ctx.Clone(expr->args[1]), syms.params);
|
||||
return name;
|
||||
});
|
||||
|
||||
auto plane_0_binding_arg = ctx.Clone(args[0]->Declaration());
|
||||
|
||||
return b.Call(texture_load_external_sym, plane_0_binding_arg, syms.plane_1,
|
||||
ctx.Clone(args[1]->Declaration()), syms.params);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -291,17 +291,17 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0).r, textureSampleLevel(plane1, smp, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -373,17 +373,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -445,17 +445,17 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0).r, textureSampleLevel(plane1, smp, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -527,17 +527,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -564,7 +564,9 @@ TEST_F(MultiplanarExternalTextureTest, BasicTextureLoad) {
|
||||
|
||||
@fragment
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoad(ext_tex, vec2<i32>(1, 1));
|
||||
var signed = textureLoad(ext_tex, vec2<i32>(1));
|
||||
var unsigned = textureLoad(ext_tex, vec2<u32>(1));
|
||||
return signed + unsigned;
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -604,22 +606,39 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn textureLoadExternal_1(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<u32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoadExternal(ext_tex, ext_tex_plane_1, vec2<i32>(1, 1), ext_tex_params);
|
||||
var signed = textureLoadExternal(ext_tex, ext_tex_plane_1, vec2<i32>(1), ext_tex_params);
|
||||
var unsigned = textureLoadExternal_1(ext_tex, ext_tex_plane_1, vec2<u32>(1), ext_tex_params);
|
||||
return (signed + unsigned);
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -635,7 +654,9 @@ TEST_F(MultiplanarExternalTextureTest, BasicTextureLoad_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
@fragment
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoad(ext_tex, vec2<i32>(1, 1));
|
||||
var signed = textureLoad(ext_tex, vec2<i32>(1));
|
||||
var unsigned = textureLoad(ext_tex, vec2<u32>(1));
|
||||
return signed + unsigned;
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var ext_tex : texture_external;
|
||||
@@ -675,22 +696,39 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn textureLoadExternal_1(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<u32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureLoadExternal(ext_tex, ext_tex_plane_1, vec2<i32>(1, 1), ext_tex_params);
|
||||
var signed = textureLoadExternal(ext_tex, ext_tex_plane_1, vec2<i32>(1), ext_tex_params);
|
||||
var unsigned = textureLoadExternal_1(ext_tex, ext_tex_plane_1, vec2<u32>(1), ext_tex_params);
|
||||
return (signed + unsigned);
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
@@ -753,32 +791,32 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0).r, textureSampleLevel(plane1, smp, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -850,32 +888,32 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -937,32 +975,32 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0).r, textureSampleLevel(plane1, smp, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -1034,32 +1072,32 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureLoad(plane0, coord, 0i).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -1150,17 +1188,17 @@ fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0).r, textureSampleLevel(plane1, smp, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -1260,17 +1298,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
@fragment
|
||||
@@ -1347,17 +1385,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -1443,17 +1481,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -1529,17 +1567,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(s : sampler, t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams) {
|
||||
@@ -1626,17 +1664,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_2 : texture_2d<f32>, ext_tex_params_2 : ExternalTextureParams, s : sampler, t2 : texture_2d<f32>, ext_tex_plane_1_3 : texture_2d<f32>, ext_tex_params_3 : ExternalTextureParams) {
|
||||
@@ -1733,17 +1771,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_2 : texture_2d<f32>, ext_tex_params_2 : ExternalTextureParams, s : sampler, t2 : texture_2d<f32>, ext_tex_plane_1_3 : texture_2d<f32>, ext_tex_params_3 : ExternalTextureParams) {
|
||||
@@ -1827,17 +1865,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn nested(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -1926,17 +1964,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn nested(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -2066,17 +2104,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -2163,17 +2201,17 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).rgb;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0.0f).r, textureSampleLevel(plane1, smp, plane1_clamped, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, plane0_clamped, 0).r, textureSampleLevel(plane1, smp, plane1_clamped, 0).rg, 1) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
if ((params.doYuvToRgbConversionOnly == 0)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return vec4<f32>(color, 1.0f);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
|
||||
@@ -166,6 +166,32 @@ struct Robustness::State {
|
||||
auto* coords_arg = expr->args[static_cast<size_t>(coords_idx)];
|
||||
auto* coords_ty = builtin->Parameters()[static_cast<size_t>(coords_idx)]->Type();
|
||||
|
||||
auto width_of = [&](const sem::Type* ty) {
|
||||
if (auto* vec = ty->As<sem::Vector>()) {
|
||||
return vec->Width();
|
||||
}
|
||||
return 1u;
|
||||
};
|
||||
auto scalar_or_vec_ty = [&](const ast::Type* scalar, uint32_t width) -> const ast::Type* {
|
||||
if (width > 1) {
|
||||
return b.ty.vec(scalar, width);
|
||||
}
|
||||
return scalar;
|
||||
};
|
||||
auto scalar_or_vec = [&](const ast::Expression* scalar,
|
||||
uint32_t width) -> const ast::Expression* {
|
||||
if (width > 1) {
|
||||
return b.Construct(b.ty.vec(nullptr, width), scalar);
|
||||
}
|
||||
return scalar;
|
||||
};
|
||||
auto cast_to_signed = [&](const ast::Expression* val, uint32_t width) {
|
||||
return b.Construct(scalar_or_vec_ty(b.ty.i32(), width), val);
|
||||
};
|
||||
auto cast_to_unsigned = [&](const ast::Expression* val, uint32_t width) {
|
||||
return b.Construct(scalar_or_vec_ty(b.ty.u32(), width), val);
|
||||
};
|
||||
|
||||
// If the level is provided, then we need to clamp this. As the level is
|
||||
// used by textureDimensions() and the texture[Load|Store]() calls, we need
|
||||
// to clamp both usages.
|
||||
@@ -174,41 +200,68 @@ struct Robustness::State {
|
||||
std::function<const ast::Expression*()> level_arg;
|
||||
if (level_idx >= 0) {
|
||||
level_arg = [&] {
|
||||
auto* arg = expr->args[static_cast<size_t>(level_idx)];
|
||||
auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0_i);
|
||||
auto* max = ctx.dst->Sub(num_levels, 1_i);
|
||||
auto* clamped = b.Call("clamp", ctx.Clone(arg), zero, max);
|
||||
return clamped;
|
||||
const auto* arg = expr->args[static_cast<size_t>(level_idx)];
|
||||
const auto* target_ty =
|
||||
builtin->Parameters()[static_cast<size_t>(level_idx)]->Type();
|
||||
const auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
|
||||
|
||||
// TODO(crbug.com/tint/1526) remove when num_levels returns u32
|
||||
num_levels = cast_to_unsigned(num_levels, 1u);
|
||||
|
||||
const auto* unsigned_max = b.Sub(num_levels, 1_a);
|
||||
if (target_ty->is_signed_integer_scalar()) {
|
||||
const auto* signed_max = cast_to_signed(unsigned_max, 1u);
|
||||
return b.Call("clamp", ctx.Clone(arg), 0_a, signed_max);
|
||||
} else {
|
||||
return b.Call("min", ctx.Clone(arg), unsigned_max);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Clamp the coordinates argument
|
||||
{
|
||||
auto* texture_dims =
|
||||
const auto* target_ty = coords_ty;
|
||||
const auto width = width_of(target_ty);
|
||||
const auto* texture_dims =
|
||||
level_arg ? b.Call("textureDimensions", ctx.Clone(texture_arg), level_arg())
|
||||
: b.Call("textureDimensions", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Construct(CreateASTTypeFor(ctx, coords_ty));
|
||||
auto* max =
|
||||
ctx.dst->Sub(texture_dims, b.Construct(CreateASTTypeFor(ctx, coords_ty), 1_i));
|
||||
auto* clamped_coords = b.Call("clamp", ctx.Clone(coords_arg), zero, max);
|
||||
ctx.Replace(coords_arg, clamped_coords);
|
||||
|
||||
// TODO(crbug.com/tint/1526) remove when texture_dims returns u32 or vecN<u32>
|
||||
texture_dims = cast_to_unsigned(texture_dims, width);
|
||||
|
||||
// texture_dims is u32 or vecN<u32>
|
||||
const auto* unsigned_max = b.Sub(texture_dims, scalar_or_vec(b.Expr(1_a), width));
|
||||
if (target_ty->is_signed_scalar_or_vector()) {
|
||||
const auto* zero = scalar_or_vec(b.Expr(0_a), width);
|
||||
const auto* signed_max = cast_to_signed(unsigned_max, width);
|
||||
ctx.Replace(coords_arg, b.Call("clamp", ctx.Clone(coords_arg), zero, signed_max));
|
||||
} else {
|
||||
ctx.Replace(coords_arg, b.Call("min", ctx.Clone(coords_arg), unsigned_max));
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp the array_index argument, if provided
|
||||
if (array_idx >= 0) {
|
||||
auto* target_ty = builtin->Parameters()[static_cast<size_t>(array_idx)]->Type();
|
||||
auto* arg = expr->args[static_cast<size_t>(array_idx)];
|
||||
auto* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0_i);
|
||||
auto* max = ctx.dst->Sub(num_layers, 1_i);
|
||||
auto* clamped = b.Call("clamp", ctx.Clone(arg), zero, max);
|
||||
ctx.Replace(arg, clamped);
|
||||
|
||||
// TODO(crbug.com/tint/1526) remove when num_layers returns u32
|
||||
num_layers = cast_to_unsigned(num_layers, 1u);
|
||||
|
||||
const auto* unsigned_max = b.Sub(num_layers, 1_a);
|
||||
if (target_ty->is_signed_integer_scalar()) {
|
||||
const auto* signed_max = cast_to_signed(unsigned_max, 1u);
|
||||
ctx.Replace(arg, b.Call("clamp", ctx.Clone(arg), 0_a, signed_max));
|
||||
} else {
|
||||
ctx.Replace(arg, b.Call("min", ctx.Clone(arg), unsigned_max));
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp the level argument, if provided
|
||||
if (level_idx >= 0) {
|
||||
auto* arg = expr->args[static_cast<size_t>(level_idx)];
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_i));
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_a));
|
||||
}
|
||||
|
||||
return nullptr; // Clone, which will use the argument replacements above.
|
||||
|
||||
@@ -787,12 +787,12 @@ TEST_F(RobustnessTest, TextureLoad_Clamp) {
|
||||
@group(0) @binding(0) var tex_depth_2d_arr : texture_depth_2d_array;
|
||||
@group(0) @binding(0) var tex_external : texture_external;
|
||||
|
||||
fn f() {
|
||||
fn signed() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
|
||||
textureLoad(tex_1d, 1, level_idx);
|
||||
textureLoad(tex_1d, 1i, level_idx);
|
||||
textureLoad(tex_2d, vec2<i32>(1, 2), level_idx);
|
||||
textureLoad(tex_2d_arr, vec2<i32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_3d, vec3<i32>(1, 2, 3), level_idx);
|
||||
@@ -801,6 +801,21 @@ fn f() {
|
||||
textureLoad(tex_depth_2d_arr, vec2<i32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_external, vec2<i32>(1, 2));
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
var array_idx : u32;
|
||||
var level_idx : u32;
|
||||
var sample_idx : u32;
|
||||
|
||||
textureLoad(tex_1d, 1u, level_idx);
|
||||
textureLoad(tex_2d, vec2<u32>(1, 2), level_idx);
|
||||
textureLoad(tex_2d_arr, vec2<u32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_3d, vec3<u32>(1, 2, 3), level_idx);
|
||||
textureLoad(tex_ms_2d, vec2<u32>(1, 2), sample_idx);
|
||||
textureLoad(tex_depth_2d, vec2<u32>(1, 2), level_idx);
|
||||
textureLoad(tex_depth_2d_arr, vec2<u32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_external, vec2<u32>(1, 2));
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect =
|
||||
@@ -821,18 +836,32 @@ fn f() {
|
||||
|
||||
@group(0) @binding(0) var tex_external : texture_external;
|
||||
|
||||
fn f() {
|
||||
fn signed() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i))) - i32(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i))) - vec3<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1i))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_depth_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1i))));
|
||||
textureLoad(tex_1d, clamp(1i, 0, i32((u32(textureDimensions(tex_1d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_1d)) - 1))))) - 1))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_1d)) - 1))));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_2d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d)) - 1))))) - vec2(1)))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d)) - 1))));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_2d_arr, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d_arr)) - 1))))) - vec2(1)))), clamp(array_idx, 0, i32((u32(textureNumLayers(tex_2d_arr)) - 1))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d_arr)) - 1))));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3(0), vec3<i32>((vec3<u32>(textureDimensions(tex_3d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_3d)) - 1))))) - vec3(1)))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_3d)) - 1))));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_ms_2d)) - vec2(1)))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_depth_2d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d)) - 1))))) - vec2(1)))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d)) - 1))));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d_arr)) - 1))))) - vec2(1)))), clamp(array_idx, 0, i32((u32(textureNumLayers(tex_depth_2d_arr)) - 1))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d_arr)) - 1))));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_external)) - vec2(1)))));
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
var array_idx : u32;
|
||||
var level_idx : u32;
|
||||
var sample_idx : u32;
|
||||
textureLoad(tex_1d, min(1u, (u32(textureDimensions(tex_1d, min(level_idx, (u32(textureNumLevels(tex_1d)) - 1)))) - 1)), min(level_idx, (u32(textureNumLevels(tex_1d)) - 1)));
|
||||
textureLoad(tex_2d, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_2d, min(level_idx, (u32(textureNumLevels(tex_2d)) - 1)))) - vec2(1))), min(level_idx, (u32(textureNumLevels(tex_2d)) - 1)));
|
||||
textureLoad(tex_2d_arr, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_2d_arr, min(level_idx, (u32(textureNumLevels(tex_2d_arr)) - 1)))) - vec2(1))), min(array_idx, (u32(textureNumLayers(tex_2d_arr)) - 1)), min(level_idx, (u32(textureNumLevels(tex_2d_arr)) - 1)));
|
||||
textureLoad(tex_3d, min(vec3<u32>(1, 2, 3), (vec3<u32>(textureDimensions(tex_3d, min(level_idx, (u32(textureNumLevels(tex_3d)) - 1)))) - vec3(1))), min(level_idx, (u32(textureNumLevels(tex_3d)) - 1)));
|
||||
textureLoad(tex_ms_2d, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_ms_2d)) - vec2(1))), sample_idx);
|
||||
textureLoad(tex_depth_2d, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_depth_2d, min(level_idx, (u32(textureNumLevels(tex_depth_2d)) - 1)))) - vec2(1))), min(level_idx, (u32(textureNumLevels(tex_depth_2d)) - 1)));
|
||||
textureLoad(tex_depth_2d_arr, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_depth_2d_arr, min(level_idx, (u32(textureNumLevels(tex_depth_2d_arr)) - 1)))) - vec2(1))), min(array_idx, (u32(textureNumLayers(tex_depth_2d_arr)) - 1)), min(level_idx, (u32(textureNumLevels(tex_depth_2d_arr)) - 1)));
|
||||
textureLoad(tex_external, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_external)) - vec2(1))));
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -844,12 +873,12 @@ fn f() {
|
||||
// Clamp textureLoad() coord, array_index and level values
|
||||
TEST_F(RobustnessTest, TextureLoad_Clamp_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
fn signed() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
|
||||
textureLoad(tex_1d, 1, level_idx);
|
||||
textureLoad(tex_1d, 1i, level_idx);
|
||||
textureLoad(tex_2d, vec2<i32>(1, 2), level_idx);
|
||||
textureLoad(tex_2d_arr, vec2<i32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_3d, vec3<i32>(1, 2, 3), level_idx);
|
||||
@@ -859,6 +888,21 @@ fn f() {
|
||||
textureLoad(tex_external, vec2<i32>(1, 2));
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
var array_idx : u32;
|
||||
var level_idx : u32;
|
||||
var sample_idx : u32;
|
||||
|
||||
textureLoad(tex_1d, 1u, level_idx);
|
||||
textureLoad(tex_2d, vec2<u32>(1, 2), level_idx);
|
||||
textureLoad(tex_2d_arr, vec2<u32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_3d, vec3<u32>(1, 2, 3), level_idx);
|
||||
textureLoad(tex_ms_2d, vec2<u32>(1, 2), sample_idx);
|
||||
textureLoad(tex_depth_2d, vec2<u32>(1, 2), level_idx);
|
||||
textureLoad(tex_depth_2d_arr, vec2<u32>(1, 2), array_idx, level_idx);
|
||||
textureLoad(tex_external, vec2<u32>(1, 2));
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex_1d : texture_1d<f32>;
|
||||
@group(0) @binding(0) var tex_2d : texture_2d<f32>;
|
||||
@group(0) @binding(0) var tex_2d_arr : texture_2d_array<f32>;
|
||||
@@ -871,18 +915,32 @@ fn f() {
|
||||
|
||||
auto* expect =
|
||||
R"(
|
||||
fn f() {
|
||||
fn signed() {
|
||||
var array_idx : i32;
|
||||
var level_idx : i32;
|
||||
var sample_idx : i32;
|
||||
textureLoad(tex_1d, clamp(1, i32(), (textureDimensions(tex_1d, clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i))) - i32(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_1d) - 1i)));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d, clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_2d) - 1i)));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_2d_arr) - 1i)));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3<i32>(), (textureDimensions(tex_3d, clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i))) - vec3<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_3d) - 1i)));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_ms_2d) - vec2<i32>(1i))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i))) - vec2<i32>(1i))), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d) - 1i)));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i))) - vec2<i32>(1i))), clamp(array_idx, 0i, (textureNumLayers(tex_depth_2d_arr) - 1i)), clamp(level_idx, 0i, (textureNumLevels(tex_depth_2d_arr) - 1i)));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2<i32>(), (textureDimensions(tex_external) - vec2<i32>(1i))));
|
||||
textureLoad(tex_1d, clamp(1i, 0, i32((u32(textureDimensions(tex_1d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_1d)) - 1))))) - 1))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_1d)) - 1))));
|
||||
textureLoad(tex_2d, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_2d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d)) - 1))))) - vec2(1)))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d)) - 1))));
|
||||
textureLoad(tex_2d_arr, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_2d_arr, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d_arr)) - 1))))) - vec2(1)))), clamp(array_idx, 0, i32((u32(textureNumLayers(tex_2d_arr)) - 1))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_2d_arr)) - 1))));
|
||||
textureLoad(tex_3d, clamp(vec3<i32>(1, 2, 3), vec3(0), vec3<i32>((vec3<u32>(textureDimensions(tex_3d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_3d)) - 1))))) - vec3(1)))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_3d)) - 1))));
|
||||
textureLoad(tex_ms_2d, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_ms_2d)) - vec2(1)))), sample_idx);
|
||||
textureLoad(tex_depth_2d, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_depth_2d, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d)) - 1))))) - vec2(1)))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d)) - 1))));
|
||||
textureLoad(tex_depth_2d_arr, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_depth_2d_arr, clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d_arr)) - 1))))) - vec2(1)))), clamp(array_idx, 0, i32((u32(textureNumLayers(tex_depth_2d_arr)) - 1))), clamp(level_idx, 0, i32((u32(textureNumLevels(tex_depth_2d_arr)) - 1))));
|
||||
textureLoad(tex_external, clamp(vec2<i32>(1, 2), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex_external)) - vec2(1)))));
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
var array_idx : u32;
|
||||
var level_idx : u32;
|
||||
var sample_idx : u32;
|
||||
textureLoad(tex_1d, min(1u, (u32(textureDimensions(tex_1d, min(level_idx, (u32(textureNumLevels(tex_1d)) - 1)))) - 1)), min(level_idx, (u32(textureNumLevels(tex_1d)) - 1)));
|
||||
textureLoad(tex_2d, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_2d, min(level_idx, (u32(textureNumLevels(tex_2d)) - 1)))) - vec2(1))), min(level_idx, (u32(textureNumLevels(tex_2d)) - 1)));
|
||||
textureLoad(tex_2d_arr, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_2d_arr, min(level_idx, (u32(textureNumLevels(tex_2d_arr)) - 1)))) - vec2(1))), min(array_idx, (u32(textureNumLayers(tex_2d_arr)) - 1)), min(level_idx, (u32(textureNumLevels(tex_2d_arr)) - 1)));
|
||||
textureLoad(tex_3d, min(vec3<u32>(1, 2, 3), (vec3<u32>(textureDimensions(tex_3d, min(level_idx, (u32(textureNumLevels(tex_3d)) - 1)))) - vec3(1))), min(level_idx, (u32(textureNumLevels(tex_3d)) - 1)));
|
||||
textureLoad(tex_ms_2d, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_ms_2d)) - vec2(1))), sample_idx);
|
||||
textureLoad(tex_depth_2d, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_depth_2d, min(level_idx, (u32(textureNumLevels(tex_depth_2d)) - 1)))) - vec2(1))), min(level_idx, (u32(textureNumLevels(tex_depth_2d)) - 1)));
|
||||
textureLoad(tex_depth_2d_arr, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_depth_2d_arr, min(level_idx, (u32(textureNumLevels(tex_depth_2d_arr)) - 1)))) - vec2(1))), min(array_idx, (u32(textureNumLayers(tex_depth_2d_arr)) - 1)), min(level_idx, (u32(textureNumLevels(tex_depth_2d_arr)) - 1)));
|
||||
textureLoad(tex_external, min(vec2<u32>(1, 2), (vec2<u32>(textureDimensions(tex_external)) - vec2(1))));
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex_1d : texture_1d<f32>;
|
||||
@@ -918,12 +976,19 @@ TEST_F(RobustnessTest, TextureStore_Clamp) {
|
||||
|
||||
@group(0) @binding(3) var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
|
||||
fn f() {
|
||||
textureStore(tex1d, 10, vec4<i32>());
|
||||
fn signed() {
|
||||
textureStore(tex1d, 10i, vec4<i32>());
|
||||
textureStore(tex2d, vec2<i32>(10, 20), vec4<i32>());
|
||||
textureStore(tex2d_arr, vec2<i32>(10, 20), 50, vec4<i32>());
|
||||
textureStore(tex2d_arr, vec2<i32>(10, 20), 50i, vec4<i32>());
|
||||
textureStore(tex3d, vec3<i32>(10, 20, 30), vec4<i32>());
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
textureStore(tex1d, 10u, vec4<i32>());
|
||||
textureStore(tex2d, vec2<u32>(10, 20), vec4<i32>());
|
||||
textureStore(tex2d_arr, vec2<u32>(10, 20), 50u, vec4<i32>());
|
||||
textureStore(tex3d, vec3<u32>(10, 20, 30), vec4<i32>());
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
@@ -935,11 +1000,18 @@ fn f() {
|
||||
|
||||
@group(0) @binding(3) var tex3d : texture_storage_3d<rgba8sint, write>;
|
||||
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1i))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1i))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1i))), clamp(50, 0i, (textureNumLayers(tex2d_arr) - 1i)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1i))), vec4<i32>());
|
||||
fn signed() {
|
||||
textureStore(tex1d, clamp(10i, 0, i32((u32(textureDimensions(tex1d)) - 1))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex2d)) - vec2(1)))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex2d_arr)) - vec2(1)))), clamp(50i, 0, i32((u32(textureNumLayers(tex2d_arr)) - 1))), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3(0), vec3<i32>((vec3<u32>(textureDimensions(tex3d)) - vec3(1)))), vec4<i32>());
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
textureStore(tex1d, min(10u, (u32(textureDimensions(tex1d)) - 1)), vec4<i32>());
|
||||
textureStore(tex2d, min(vec2<u32>(10, 20), (vec2<u32>(textureDimensions(tex2d)) - vec2(1))), vec4<i32>());
|
||||
textureStore(tex2d_arr, min(vec2<u32>(10, 20), (vec2<u32>(textureDimensions(tex2d_arr)) - vec2(1))), min(50u, (u32(textureNumLayers(tex2d_arr)) - 1)), vec4<i32>());
|
||||
textureStore(tex3d, min(vec3<u32>(10, 20, 30), (vec3<u32>(textureDimensions(tex3d)) - vec3(1))), vec4<i32>());
|
||||
}
|
||||
)";
|
||||
|
||||
@@ -951,13 +1023,20 @@ fn f() {
|
||||
// Clamp textureStore() coord, array_index and level values
|
||||
TEST_F(RobustnessTest, TextureStore_Clamp_OutOfOrder) {
|
||||
auto* src = R"(
|
||||
fn f() {
|
||||
textureStore(tex1d, 10, vec4<i32>());
|
||||
fn signed() {
|
||||
textureStore(tex1d, 10i, vec4<i32>());
|
||||
textureStore(tex2d, vec2<i32>(10, 20), vec4<i32>());
|
||||
textureStore(tex2d_arr, vec2<i32>(10, 20), 50, vec4<i32>());
|
||||
textureStore(tex2d_arr, vec2<i32>(10, 20), 50i, vec4<i32>());
|
||||
textureStore(tex3d, vec3<i32>(10, 20, 30), vec4<i32>());
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
textureStore(tex1d, 10u, vec4<i32>());
|
||||
textureStore(tex2d, vec2<u32>(10, 20), vec4<i32>());
|
||||
textureStore(tex2d_arr, vec2<u32>(10, 20), 50u, vec4<i32>());
|
||||
textureStore(tex3d, vec3<u32>(10, 20, 30), vec4<i32>());
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
|
||||
@group(0) @binding(1) var tex2d : texture_storage_2d<rgba8sint, write>;
|
||||
@@ -969,11 +1048,18 @@ fn f() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
fn f() {
|
||||
textureStore(tex1d, clamp(10, i32(), (textureDimensions(tex1d) - i32(1i))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d) - vec2<i32>(1i))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2<i32>(), (textureDimensions(tex2d_arr) - vec2<i32>(1i))), clamp(50, 0i, (textureNumLayers(tex2d_arr) - 1i)), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3<i32>(), (textureDimensions(tex3d) - vec3<i32>(1i))), vec4<i32>());
|
||||
fn signed() {
|
||||
textureStore(tex1d, clamp(10i, 0, i32((u32(textureDimensions(tex1d)) - 1))), vec4<i32>());
|
||||
textureStore(tex2d, clamp(vec2<i32>(10, 20), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex2d)) - vec2(1)))), vec4<i32>());
|
||||
textureStore(tex2d_arr, clamp(vec2<i32>(10, 20), vec2(0), vec2<i32>((vec2<u32>(textureDimensions(tex2d_arr)) - vec2(1)))), clamp(50i, 0, i32((u32(textureNumLayers(tex2d_arr)) - 1))), vec4<i32>());
|
||||
textureStore(tex3d, clamp(vec3<i32>(10, 20, 30), vec3(0), vec3<i32>((vec3<u32>(textureDimensions(tex3d)) - vec3(1)))), vec4<i32>());
|
||||
}
|
||||
|
||||
fn unsigned() {
|
||||
textureStore(tex1d, min(10u, (u32(textureDimensions(tex1d)) - 1)), vec4<i32>());
|
||||
textureStore(tex2d, min(vec2<u32>(10, 20), (vec2<u32>(textureDimensions(tex2d)) - vec2(1))), vec4<i32>());
|
||||
textureStore(tex2d_arr, min(vec2<u32>(10, 20), (vec2<u32>(textureDimensions(tex2d_arr)) - vec2(1))), min(50u, (u32(textureNumLayers(tex2d_arr)) - 1)), vec4<i32>());
|
||||
textureStore(tex3d, min(vec3<u32>(10, 20, 30), (vec3<u32>(textureDimensions(tex3d)) - vec3(1))), vec4<i32>());
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var tex1d : texture_storage_1d<rgba8sint, write>;
|
||||
|
||||
Reference in New Issue
Block a user