mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
Add ExternalTexture Rotate and FlipY Functionality
Adds functionality to Dawn and Tint to rotate and flip-Y external textures through the shader transform. Tests are included. Bug: chromium:1316671 Change-Id: I40a6b67eaeb2a348f469e4879eeb585bc40537b2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110181 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
94706ecba7
commit
85ceb08d5c
@@ -258,10 +258,11 @@ struct MultiplanarExternalTexture::State {
|
||||
utils::Vector ext_tex_params_member_list{
|
||||
b.Member("numPlanes", b.ty.u32()),
|
||||
b.Member("doYuvToRgbConversionOnly", b.ty.u32()),
|
||||
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32())),
|
||||
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4<f32>()),
|
||||
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
|
||||
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
|
||||
b.Member("gamutConversionMatrix", b.ty.mat3x3(b.ty.f32()))};
|
||||
b.Member("gamutConversionMatrix", b.ty.mat3x3<f32>()),
|
||||
b.Member("rotationMatrix", b.ty.mat2x2<f32>())};
|
||||
|
||||
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
||||
|
||||
@@ -314,22 +315,27 @@ struct MultiplanarExternalTexture::State {
|
||||
const ast::CallExpression* plane_1_call = nullptr;
|
||||
switch (call_type) {
|
||||
case sem::BuiltinType::kTextureSampleBaseClampToEdge:
|
||||
stmts.Push(b.Decl(b.Let("modifiedCoords",
|
||||
b.Add(b.Mul(b.Sub("coord", f32(0.5)),
|
||||
b.MemberAccessor("params", "rotationMatrix")),
|
||||
f32(0.5)))));
|
||||
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
"plane0_dims",
|
||||
b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane0", 0_a)))));
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("plane0_half_texel", b.Div(b.vec2<f32>(0.5_a), "plane0_dims"))));
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("plane0_clamped", b.Call("clamp", "coord", "plane0_half_texel",
|
||||
b.Sub(1_a, "plane0_half_texel")))));
|
||||
stmts.Push(b.Decl(
|
||||
b.Let("plane0_clamped", b.Call("clamp", "modifiedCoords", "plane0_half_texel",
|
||||
b.Sub(1_a, "plane0_half_texel")))));
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
"plane1_dims",
|
||||
b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane1", 0_a)))));
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("plane1_half_texel", b.Div(b.vec2<f32>(0.5_a), "plane1_dims"))));
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("plane1_clamped", b.Call("clamp", "coord", "plane1_half_texel",
|
||||
b.Sub(1_a, "plane1_half_texel")))));
|
||||
stmts.Push(b.Decl(
|
||||
b.Let("plane1_clamped", b.Call("clamp", "modifiedCoords", "plane1_half_texel",
|
||||
b.Sub(1_a, "plane1_half_texel")))));
|
||||
|
||||
// textureSampleLevel(plane0, smp, plane0_clamped, 0.0);
|
||||
single_plane_call =
|
||||
|
||||
@@ -138,6 +138,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -193,6 +194,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -247,6 +249,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -265,12 +268,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -329,6 +333,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -343,12 +348,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -412,6 +418,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -504,6 +511,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -595,6 +603,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -613,12 +622,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -692,6 +702,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -706,12 +717,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -795,6 +807,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(4) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -831,12 +844,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -904,6 +918,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -918,12 +933,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -995,6 +1011,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1014,12 +1031,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1086,6 +1104,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1100,12 +1119,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1179,6 +1199,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1197,12 +1218,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1281,6 +1303,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1304,12 +1327,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1384,6 +1408,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1398,12 +1423,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1483,6 +1509,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1497,12 +1524,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1570,6 +1598,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<u32> {
|
||||
@@ -1621,6 +1650,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1637,12 +1667,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
@@ -1715,6 +1746,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
rotationMatrix : mat2x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1734,12 +1766,13 @@ 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> {
|
||||
let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
|
||||
let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
|
||||
let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
|
||||
let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1)) {
|
||||
color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
|
||||
|
||||
Reference in New Issue
Block a user