mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
Reduce shader complexity for external textures
Do more math on the CPU to avoid per-fragment ALU operations. Use a mat3x2 instead of mat2x3 to avoid padding. Fixed: dawn:1614 Change-Id: Ib0e0f7d44ed9aa16eaca712f6553214fad141feb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116060 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Brandon1 Jones <brandon1.jones@intel.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
b6fb41cc32
commit
be367b73ae
@@ -209,67 +209,106 @@ MaybeError ExternalTextureBase::Initialize(DeviceBase* device,
|
||||
const float* dstFn = descriptor->dstTransferFunctionParameters;
|
||||
std::copy(dstFn, dstFn + 7, params.gammaEncodingParams.begin());
|
||||
|
||||
// These scale factors perform part of the cropping operation. These default to 1, so we can use
|
||||
// them directly for performing rotation in the matrix later.
|
||||
float xScale = descriptor->visibleRect.width;
|
||||
float yScale = descriptor->visibleRect.height;
|
||||
// Unlike WGSL, which stores matrices in column vectors, the following arithmetic uses row
|
||||
// vectors, so elements are stored in the following order:
|
||||
// ┌ ┐
|
||||
// │ 0, 1, 2 │
|
||||
// │ 3, 4, 5 │
|
||||
// └ ┘
|
||||
// The matrix is transposed at the end.
|
||||
using mat2x3 = std::array<float, 6>;
|
||||
|
||||
// In the shader, we must convert UV coordinates from the {0, 1} space to the {-0.5, 0.5} space
|
||||
// to do rotation. Ideally, we want to combine the rotate, flip-Y operations in a single matrix
|
||||
// operation - but this is complicated because scaling most easily occurs in the {0, 1} space.
|
||||
// We can work around this and perform scaling in the {-0.5, 0.5} space by multiplying the
|
||||
// needed conversion constant "+ 0.5" by the scale factor. We then can do this all within a
|
||||
// single matrix operation by calculating and adding this value to the offset specified in the
|
||||
// matrix. For reference, this is the entire operation needed is:
|
||||
//
|
||||
// newCoords = vec3<f32>((coord - 0.5f), 1.0f) * coordTransformationMatrix) + (scaleFactor *
|
||||
// 0.5)
|
||||
//
|
||||
// Because we combine the ending (scaleFactor * 0.5) into the crop offset within the matrix, the
|
||||
// shader is actually:
|
||||
//
|
||||
// newCoords = vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix;
|
||||
//
|
||||
// TODO(dawn:1614): Incorporate the "- 0.5f" into the matrix.
|
||||
float xOffset = descriptor->visibleRect.x + 0.5f * xScale;
|
||||
float yOffset = descriptor->visibleRect.y + 0.5f * yScale;
|
||||
// Multiplies the two mat2x3 matrices, by treating the RHS matrix as a mat3x3 where the last row
|
||||
// is [0, 0, 1].
|
||||
auto Mul = [&](const mat2x3& lhs, const mat2x3& rhs) {
|
||||
auto& a = lhs[0];
|
||||
auto& b = lhs[1];
|
||||
auto& c = lhs[2];
|
||||
auto& d = lhs[3];
|
||||
auto& e = lhs[4];
|
||||
auto& f = lhs[5];
|
||||
auto& g = rhs[0];
|
||||
auto& h = rhs[1];
|
||||
auto& i = rhs[2];
|
||||
auto& j = rhs[3];
|
||||
auto& k = rhs[4];
|
||||
auto& l = rhs[5];
|
||||
// ┌ ┐ ┌ ┐
|
||||
// │ a, b, c │ │ g, h, i │
|
||||
// │ d, e, f │ x │ j, k, l │
|
||||
// └ ┘ │ 0, 0, 1 │
|
||||
// └ ┘
|
||||
return mat2x3{
|
||||
a * g + b * j, //
|
||||
a * h + b * k, //
|
||||
a * i + b * l + c, //
|
||||
d * g + e * j, //
|
||||
d * h + e * k, //
|
||||
d * i + e * l + f, //
|
||||
};
|
||||
};
|
||||
|
||||
// Flip-Y can be done by simply negating the scaling factor in the y-plane. The position of the
|
||||
// y-plane scaling factor in the matrix can be different depending on the rotation.
|
||||
float flipY = 1;
|
||||
auto Scale = [&](const mat2x3& m, float x, float y) {
|
||||
return Mul(mat2x3{x, 0, 0, 0, y, 0}, m);
|
||||
};
|
||||
|
||||
auto Translate = [&](const mat2x3& m, float x, float y) {
|
||||
return Mul(mat2x3{1, 0, x, 0, 1, y}, m);
|
||||
};
|
||||
|
||||
mat2x3 coordTransformMatrix = {
|
||||
1, 0, 0, //
|
||||
0, 1, 0, //
|
||||
};
|
||||
|
||||
// Offset the coordinates so the center texel is at the origin, so we can apply rotations and
|
||||
// y-flips. After translation, coordinates range from [-0.5 .. +0.5] in both U and V.
|
||||
coordTransformMatrix = Translate(coordTransformMatrix, -0.5, -0.5);
|
||||
|
||||
// If the texture needs flipping, mirror in Y.
|
||||
if (descriptor->flipY) {
|
||||
flipY = -1;
|
||||
coordTransformMatrix = Scale(coordTransformMatrix, 1, -1);
|
||||
}
|
||||
|
||||
// This block creates a 2x3 matrix which when multiplied by UV coordinates in a shader performs
|
||||
// rotation, flip-Y and cropping operations.
|
||||
// Apply rotations as needed.
|
||||
switch (descriptor->rotation) {
|
||||
case wgpu::ExternalTextureRotation::Rotate0Degrees:
|
||||
params.coordTransformMatrix = {xScale, 0.0, //
|
||||
xOffset, 0.0, //
|
||||
0.0, flipY * yScale, //
|
||||
yOffset, 0.0};
|
||||
break;
|
||||
case wgpu::ExternalTextureRotation::Rotate90Degrees:
|
||||
params.coordTransformMatrix = {0.0, flipY * yScale, //
|
||||
xOffset, 0.0, //
|
||||
-xScale, 0.0, //
|
||||
yOffset, 0.0};
|
||||
coordTransformMatrix = Mul(mat2x3{0, +1, 0, // x' = y
|
||||
-1, 0, 0}, // y' = -x
|
||||
coordTransformMatrix);
|
||||
break;
|
||||
case wgpu::ExternalTextureRotation::Rotate180Degrees:
|
||||
params.coordTransformMatrix = {-xScale, 0.0, //
|
||||
xOffset, 0.0, //
|
||||
0.0, flipY * -yScale, //
|
||||
yOffset, 0.0};
|
||||
coordTransformMatrix = Mul(mat2x3{-1, 0, 0, // x' = -x
|
||||
0, -1, 0}, // y' = -y
|
||||
coordTransformMatrix);
|
||||
break;
|
||||
case wgpu::ExternalTextureRotation::Rotate270Degrees:
|
||||
params.coordTransformMatrix = {0.0, flipY * -yScale, //
|
||||
xOffset, 0.0, //
|
||||
xScale, 0.0, //
|
||||
yOffset, 0.0};
|
||||
coordTransformMatrix = Mul(mat2x3{0, -1, 0, // x' = -y
|
||||
+1, 0, 0}, // y' = x
|
||||
coordTransformMatrix);
|
||||
break;
|
||||
}
|
||||
|
||||
// Offset the coordinates so the bottom-left texel is at origin.
|
||||
// After translation, coordinates range from [0 .. 1] in both U and V.
|
||||
coordTransformMatrix = Translate(coordTransformMatrix, 0.5, 0.5);
|
||||
|
||||
// Finally, scale and translate based on the visible rect. This applies cropping.
|
||||
coordTransformMatrix =
|
||||
Scale(coordTransformMatrix, descriptor->visibleRect.width, descriptor->visibleRect.height);
|
||||
coordTransformMatrix =
|
||||
Translate(coordTransformMatrix, descriptor->visibleRect.x, descriptor->visibleRect.y);
|
||||
|
||||
// Transpose the mat2x3 into column vectors for use by WGSL.
|
||||
params.coordTransformMatrix[0] = coordTransformMatrix[0];
|
||||
params.coordTransformMatrix[1] = coordTransformMatrix[3];
|
||||
params.coordTransformMatrix[2] = coordTransformMatrix[1];
|
||||
params.coordTransformMatrix[3] = coordTransformMatrix[4];
|
||||
params.coordTransformMatrix[4] = coordTransformMatrix[2];
|
||||
params.coordTransformMatrix[5] = coordTransformMatrix[5];
|
||||
|
||||
DAWN_TRY(device->GetQueue()->WriteBuffer(mParamsBuffer.Get(), 0, ¶ms,
|
||||
sizeof(ExternalTextureParams)));
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct ExternalTextureParams {
|
||||
std::array<float, 8> gammaDecodingParams = {};
|
||||
std::array<float, 8> gammaEncodingParams = {};
|
||||
std::array<float, 12> gamutConversionMatrix = {};
|
||||
std::array<float, 8> coordTransformMatrix = {};
|
||||
std::array<float, 6> coordTransformMatrix = {};
|
||||
};
|
||||
|
||||
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
||||
|
||||
@@ -374,23 +374,24 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipSinglePlane) {
|
||||
utils::RGBA8 lowerRightColor;
|
||||
};
|
||||
|
||||
std::array<RotationExpectation, 8> expectations = {
|
||||
{{wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen,
|
||||
utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue},
|
||||
{wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kRed,
|
||||
utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack},
|
||||
{wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue,
|
||||
utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen},
|
||||
{wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kBlack,
|
||||
utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed},
|
||||
{wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed,
|
||||
utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack},
|
||||
{wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kBlue,
|
||||
utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen},
|
||||
{wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack,
|
||||
utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed},
|
||||
{wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen,
|
||||
utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}}};
|
||||
std::array<RotationExpectation, 8> expectations = {{
|
||||
{wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen,
|
||||
utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue},
|
||||
{wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kRed,
|
||||
utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack},
|
||||
{wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue,
|
||||
utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen},
|
||||
{wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kBlack,
|
||||
utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed},
|
||||
{wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed,
|
||||
utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack},
|
||||
{wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kBlue,
|
||||
utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen},
|
||||
{wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack,
|
||||
utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed},
|
||||
{wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen,
|
||||
utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue},
|
||||
}};
|
||||
|
||||
for (const RotationExpectation& exp : expectations) {
|
||||
// Pipeline Creation
|
||||
|
||||
@@ -263,7 +263,7 @@ struct MultiplanarExternalTexture::State {
|
||||
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
|
||||
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
|
||||
b.Member("gamutConversionMatrix", b.ty.mat3x3<f32>()),
|
||||
b.Member("coordTransformationMatrix", b.ty.mat2x3<f32>())};
|
||||
b.Member("coordTransformationMatrix", b.ty.mat3x2<f32>())};
|
||||
|
||||
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
||||
|
||||
@@ -316,12 +316,9 @@ struct MultiplanarExternalTexture::State {
|
||||
const ast::CallExpression* plane_1_call = nullptr;
|
||||
switch (call_type) {
|
||||
case sem::BuiltinType::kTextureSampleBaseClampToEdge:
|
||||
// TODO(dawn:1614): Change this statement to incorporate the "- 0.5" into the
|
||||
// matrix.
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("modifiedCoords",
|
||||
b.Mul(b.vec3<f32>(b.Sub("coord", f32(0.5)), f32(1.0f)),
|
||||
b.MemberAccessor("params", "coordTransformationMatrix")))));
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
"modifiedCoords", b.Mul(b.MemberAccessor("params", "coordTransformationMatrix"),
|
||||
b.vec3<f32>("coord", 1_a)))));
|
||||
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
"plane0_dims",
|
||||
|
||||
@@ -138,7 +138,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -194,7 +194,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -249,7 +249,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -268,7 +268,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -333,7 +333,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -348,7 +348,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -418,7 +418,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -511,7 +511,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -603,7 +603,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -622,7 +622,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -702,7 +702,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -717,7 +717,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -807,7 +807,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(4) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -844,7 +844,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -918,7 +918,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -933,7 +933,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1011,7 +1011,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1031,7 +1031,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1104,7 +1104,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1119,7 +1119,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1199,7 +1199,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1218,7 +1218,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1303,7 +1303,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1327,7 +1327,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1408,7 +1408,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1423,7 +1423,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1509,7 +1509,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1524,7 +1524,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1598,7 +1598,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<u32> {
|
||||
@@ -1650,7 +1650,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1667,7 +1667,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
@@ -1746,7 +1746,7 @@ struct ExternalTextureParams {
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
coordTransformationMatrix : mat2x3<f32>,
|
||||
coordTransformationMatrix : mat3x2<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1766,7 +1766,7 @@ 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 = (vec3<f32>((coord - 0.5f), 1.0f) * params.coordTransformationMatrix);
|
||||
let modifiedCoords = (params.coordTransformationMatrix * vec3<f32>(coord, 1));
|
||||
let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
|
||||
let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
|
||||
let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
|
||||
|
||||
Reference in New Issue
Block a user