mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Skip Gamma and Gamut conversions for BT.709->SRGB
This introduces a new field 'doYuvToRgbConversionOnly' in ExternalTextureParams to have the WGSL only do yuv->rgb conversion for better performance. User studies shows that users don't really care about the Gamma difference between 2.4 and 2.2. https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/color_space.cc;l=1022;drc=a1dbb594a6741a400db35fe3678e77bad2504ea4 Bug: dawn:1082 Bug: dawn:1466 Change-Id: I61c0fe65c5969d8a61c267c202c8dd64c259ed8a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92901 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
This commit is contained in:
@@ -10,6 +10,7 @@ struct GammaTransferParams {
|
||||
};
|
||||
struct ExternalTextureParams {
|
||||
uint numPlanes;
|
||||
uint doYuvToRgbConversionOnly;
|
||||
float3x4 yuvToRgbConversionMatrix;
|
||||
GammaTransferParams gammaDecodeParams;
|
||||
GammaTransferParams gammaEncodeParams;
|
||||
@@ -36,9 +37,11 @@ float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, i
|
||||
} else {
|
||||
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = mul(color, params.gamutConversionMatrix);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = mul(color, params.gamutConversionMatrix);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return float4(color, 1.0f);
|
||||
}
|
||||
|
||||
@@ -71,7 +74,8 @@ float3x3 tint_symbol_7(uint4 buffer[11], uint offset) {
|
||||
|
||||
ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
|
||||
const uint scalar_offset_14 = ((offset + 0u)) / 4;
|
||||
const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u))};
|
||||
const uint scalar_offset_15 = ((offset + 4u)) / 4;
|
||||
const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u))};
|
||||
return tint_symbol_10;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ struct GammaTransferParams {
|
||||
|
||||
struct ExternalTextureParams {
|
||||
/* 0x0000 */ uint numPlanes;
|
||||
/* 0x0004 */ int8_t tint_pad[12];
|
||||
/* 0x0004 */ uint doYuvToRgbConversionOnly;
|
||||
/* 0x0008 */ int8_t tint_pad[8];
|
||||
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
|
||||
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
|
||||
@@ -35,9 +36,11 @@ float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<fl
|
||||
} else {
|
||||
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
if ((params.doYuvToRgbConversionOnly == 0u)) {
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
}
|
||||
return float4(color, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 132
|
||||
; Bound: 137
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%27 = OpExtInstImport "GLSL.std.450"
|
||||
@@ -16,8 +16,9 @@
|
||||
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||
OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
|
||||
OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
|
||||
OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
|
||||
OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
|
||||
OpName %GammaTransferParams "GammaTransferParams"
|
||||
OpMemberName %GammaTransferParams 0 "G"
|
||||
OpMemberName %GammaTransferParams 1 "A"
|
||||
@@ -27,8 +28,8 @@
|
||||
OpMemberName %GammaTransferParams 5 "E"
|
||||
OpMemberName %GammaTransferParams 6 "F"
|
||||
OpMemberName %GammaTransferParams 7 "padding"
|
||||
OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
|
||||
OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
|
||||
OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
|
||||
OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
|
||||
OpName %ext_tex_params "ext_tex_params"
|
||||
OpName %arg_0 "arg_0"
|
||||
OpName %gammaCorrection "gammaCorrection"
|
||||
@@ -53,10 +54,11 @@
|
||||
OpDecorate %ext_tex_plane_1 Binding 1
|
||||
OpDecorate %ExternalTextureParams Block
|
||||
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
||||
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||
OpMemberDecorate %ExternalTextureParams 2 Offset 64
|
||||
OpMemberDecorate %ExternalTextureParams 1 Offset 4
|
||||
OpMemberDecorate %ExternalTextureParams 2 Offset 16
|
||||
OpMemberDecorate %ExternalTextureParams 2 ColMajor
|
||||
OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
|
||||
OpMemberDecorate %ExternalTextureParams 3 Offset 64
|
||||
OpMemberDecorate %GammaTransferParams 0 Offset 0
|
||||
OpMemberDecorate %GammaTransferParams 1 Offset 4
|
||||
OpMemberDecorate %GammaTransferParams 2 Offset 8
|
||||
@@ -65,10 +67,10 @@
|
||||
OpMemberDecorate %GammaTransferParams 5 Offset 20
|
||||
OpMemberDecorate %GammaTransferParams 6 Offset 24
|
||||
OpMemberDecorate %GammaTransferParams 7 Offset 28
|
||||
OpMemberDecorate %ExternalTextureParams 3 Offset 96
|
||||
OpMemberDecorate %ExternalTextureParams 4 Offset 128
|
||||
OpMemberDecorate %ExternalTextureParams 4 ColMajor
|
||||
OpMemberDecorate %ExternalTextureParams 4 MatrixStride 16
|
||||
OpMemberDecorate %ExternalTextureParams 4 Offset 96
|
||||
OpMemberDecorate %ExternalTextureParams 5 Offset 128
|
||||
OpMemberDecorate %ExternalTextureParams 5 ColMajor
|
||||
OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
|
||||
OpDecorate %ext_tex_params NonWritable
|
||||
OpDecorate %ext_tex_params DescriptorSet 1
|
||||
OpDecorate %ext_tex_params Binding 2
|
||||
@@ -90,7 +92,7 @@
|
||||
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
|
||||
%v3float = OpTypeVector %float 3
|
||||
%mat3v3float = OpTypeMatrix %v3float 3
|
||||
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
|
||||
%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
|
||||
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
||||
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
||||
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||
@@ -106,12 +108,13 @@
|
||||
%78 = OpConstantNull %int
|
||||
%v2float = OpTypeVector %float 2
|
||||
%float_1 = OpConstant %float 1
|
||||
%92 = OpConstantNull %uint
|
||||
%void = OpTypeVoid
|
||||
%105 = OpTypeFunction %void
|
||||
%109 = OpConstantNull %v2int
|
||||
%110 = OpTypeFunction %void
|
||||
%114 = OpConstantNull %v2int
|
||||
%_ptr_Function_v2int = OpTypePointer Function %v2int
|
||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||
%119 = OpTypeFunction %v4float
|
||||
%124 = OpTypeFunction %v4float
|
||||
%gammaCorrection = OpFunction %v3float None %21
|
||||
%v = OpFunctionParameter %v3float
|
||||
%params = OpFunctionParameter %GammaTransferParams
|
||||
@@ -172,62 +175,69 @@
|
||||
%85 = OpCompositeExtract %float %84 0
|
||||
%86 = OpCompositeExtract %float %84 1
|
||||
%88 = OpCompositeConstruct %v4float %81 %85 %86 %float_1
|
||||
%89 = OpCompositeExtract %mat3v4float %params_0 1
|
||||
%89 = OpCompositeExtract %mat3v4float %params_0 2
|
||||
%90 = OpVectorTimesMatrix %v3float %88 %89
|
||||
OpStore %color %90
|
||||
OpBranch %74
|
||||
%74 = OpLabel
|
||||
%92 = OpLoad %v3float %color
|
||||
%93 = OpCompositeExtract %GammaTransferParams %params_0 2
|
||||
%91 = OpFunctionCall %v3float %gammaCorrection %92 %93
|
||||
OpStore %color %91
|
||||
%94 = OpCompositeExtract %mat3v3float %params_0 4
|
||||
%95 = OpLoad %v3float %color
|
||||
%96 = OpMatrixTimesVector %v3float %94 %95
|
||||
%91 = OpCompositeExtract %uint %params_0 1
|
||||
%93 = OpIEqual %bool %91 %92
|
||||
OpSelectionMerge %94 None
|
||||
OpBranchConditional %93 %95 %94
|
||||
%95 = OpLabel
|
||||
%97 = OpLoad %v3float %color
|
||||
%98 = OpCompositeExtract %GammaTransferParams %params_0 3
|
||||
%96 = OpFunctionCall %v3float %gammaCorrection %97 %98
|
||||
OpStore %color %96
|
||||
%98 = OpLoad %v3float %color
|
||||
%99 = OpCompositeExtract %GammaTransferParams %params_0 3
|
||||
%97 = OpFunctionCall %v3float %gammaCorrection %98 %99
|
||||
OpStore %color %97
|
||||
%99 = OpCompositeExtract %mat3v3float %params_0 5
|
||||
%100 = OpLoad %v3float %color
|
||||
%101 = OpCompositeExtract %float %100 0
|
||||
%102 = OpCompositeExtract %float %100 1
|
||||
%103 = OpCompositeExtract %float %100 2
|
||||
%104 = OpCompositeConstruct %v4float %101 %102 %103 %float_1
|
||||
OpReturnValue %104
|
||||
%101 = OpMatrixTimesVector %v3float %99 %100
|
||||
OpStore %color %101
|
||||
%103 = OpLoad %v3float %color
|
||||
%104 = OpCompositeExtract %GammaTransferParams %params_0 4
|
||||
%102 = OpFunctionCall %v3float %gammaCorrection %103 %104
|
||||
OpStore %color %102
|
||||
OpBranch %94
|
||||
%94 = OpLabel
|
||||
%105 = OpLoad %v3float %color
|
||||
%106 = OpCompositeExtract %float %105 0
|
||||
%107 = OpCompositeExtract %float %105 1
|
||||
%108 = OpCompositeExtract %float %105 2
|
||||
%109 = OpCompositeConstruct %v4float %106 %107 %108 %float_1
|
||||
OpReturnValue %109
|
||||
OpFunctionEnd
|
||||
%textureLoad_8acf41 = OpFunction %void None %105
|
||||
%108 = OpLabel
|
||||
%arg_1 = OpVariable %_ptr_Function_v2int Function %109
|
||||
%textureLoad_8acf41 = OpFunction %void None %110
|
||||
%113 = OpLabel
|
||||
%arg_1 = OpVariable %_ptr_Function_v2int Function %114
|
||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||
OpStore %arg_1 %109
|
||||
%113 = OpLoad %11 %arg_0
|
||||
%114 = OpLoad %11 %ext_tex_plane_1
|
||||
%115 = OpLoad %v2int %arg_1
|
||||
%116 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||
%112 = OpFunctionCall %v4float %textureLoadExternal %113 %114 %115 %116
|
||||
OpStore %res %112
|
||||
OpStore %arg_1 %114
|
||||
%118 = OpLoad %11 %arg_0
|
||||
%119 = OpLoad %11 %ext_tex_plane_1
|
||||
%120 = OpLoad %v2int %arg_1
|
||||
%121 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||
%117 = OpFunctionCall %v4float %textureLoadExternal %118 %119 %120 %121
|
||||
OpStore %res %117
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%vertex_main_inner = OpFunction %v4float None %119
|
||||
%121 = OpLabel
|
||||
%122 = OpFunctionCall %void %textureLoad_8acf41
|
||||
%vertex_main_inner = OpFunction %v4float None %124
|
||||
%126 = OpLabel
|
||||
%127 = OpFunctionCall %void %textureLoad_8acf41
|
||||
OpReturnValue %5
|
||||
OpFunctionEnd
|
||||
%vertex_main = OpFunction %void None %105
|
||||
%124 = OpLabel
|
||||
%125 = OpFunctionCall %v4float %vertex_main_inner
|
||||
OpStore %value %125
|
||||
%vertex_main = OpFunction %void None %110
|
||||
%129 = OpLabel
|
||||
%130 = OpFunctionCall %v4float %vertex_main_inner
|
||||
OpStore %value %130
|
||||
OpStore %vertex_point_size %float_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%fragment_main = OpFunction %void None %105
|
||||
%127 = OpLabel
|
||||
%128 = OpFunctionCall %void %textureLoad_8acf41
|
||||
%fragment_main = OpFunction %void None %110
|
||||
%132 = OpLabel
|
||||
%133 = OpFunctionCall %void %textureLoad_8acf41
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%compute_main = OpFunction %void None %105
|
||||
%130 = OpLabel
|
||||
%131 = OpFunctionCall %void %textureLoad_8acf41
|
||||
%compute_main = OpFunction %void None %110
|
||||
%135 = OpLabel
|
||||
%136 = OpFunctionCall %void %textureLoad_8acf41
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user