Implemement const-eval for some unpack routines.

This CL adds const-eval for unpack2x16snorm, unpack2x16unorm,
unpack4x8snorm and unpack4x8unorm.

Bug: tint:1581
Change-Id: Ieda938b797dfe3f8d8046101d12b99da69ad68f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108864
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
dan sinclair 2022-11-07 22:28:01 +00:00 committed by Dawn LUCI CQ
parent ec4b650adb
commit 1bdaded736
25 changed files with 263 additions and 153 deletions

View File

@ -550,10 +550,10 @@ fn transpose<M: num, N: num, T: f32_f16>(mat<M, N, T>) -> mat<N, M, T>
fn trunc<T: f32_f16>(T) -> T
fn trunc<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
fn unpack2x16float(u32) -> vec2<f32>
fn unpack2x16snorm(u32) -> vec2<f32>
fn unpack2x16unorm(u32) -> vec2<f32>
fn unpack4x8snorm(u32) -> vec4<f32>
fn unpack4x8unorm(u32) -> vec4<f32>
@const fn unpack2x16snorm(u32) -> vec2<f32>
@const fn unpack2x16unorm(u32) -> vec2<f32>
@const fn unpack4x8snorm(u32) -> vec4<f32>
@const fn unpack4x8unorm(u32) -> vec4<f32>
@stage("compute") fn workgroupBarrier()
fn textureDimensions<T: fiu32>(texture: texture_1d<T>) -> u32

View File

@ -2168,6 +2168,68 @@ ConstEval::Result ConstEval::step(const sem::Type* ty,
return TransformElements(builder, ty, transform, args[0], args[1]);
}
ConstEval::Result ConstEval::unpack2x16snorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
auto* inner_ty = sem::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 2> els;
els.Reserve(2);
for (size_t i = 0; i < 2; ++i) {
auto val = f32(
std::max(static_cast<float>(int16_t((e >> (16 * i)) & 0x0000'ffff)) / 32767.f, -1.f));
els.Push(CreateElement(builder, inner_ty, val));
}
return CreateComposite(builder, ty, std::move(els));
}
ConstEval::Result ConstEval::unpack2x16unorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
auto* inner_ty = sem::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 2> els;
els.Reserve(2);
for (size_t i = 0; i < 2; ++i) {
auto val = f32(static_cast<float>(uint16_t((e >> (16 * i)) & 0x0000'ffff)) / 65535.f);
els.Push(CreateElement(builder, inner_ty, val));
}
return CreateComposite(builder, ty, std::move(els));
}
ConstEval::Result ConstEval::unpack4x8snorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
auto* inner_ty = sem::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 4> els;
els.Reserve(4);
for (size_t i = 0; i < 4; ++i) {
auto val =
f32(std::max(static_cast<float>(int8_t((e >> (8 * i)) & 0x0000'00ff)) / 127.f, -1.f));
els.Push(CreateElement(builder, inner_ty, val));
}
return CreateComposite(builder, ty, std::move(els));
}
ConstEval::Result ConstEval::unpack4x8unorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
auto* inner_ty = sem::Type::DeepestElementOf(ty);
auto e = args[0]->As<u32>().value;
utils::Vector<const sem::Constant*, 4> els;
els.Reserve(4);
for (size_t i = 0; i < 4; ++i) {
auto val = f32(static_cast<float>(uint8_t((e >> (8 * i)) & 0x0000'00ff)) / 255.f);
els.Push(CreateElement(builder, inner_ty, val));
}
return CreateComposite(builder, ty, std::move(els));
}
ConstEval::Result ConstEval::quantizeToF16(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {

View File

@ -638,6 +638,42 @@ class ConstEval {
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// unpack2x16snorm builtin
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
Result unpack2x16snorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// unpack2x16unorm builtin
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
Result unpack2x16unorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// unpack4x8snorm builtin
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
Result unpack4x8snorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// unpack4x8unorm builtin
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
Result unpack4x8unorm(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// quantizeToF16 builtin
/// @param ty the expression type
/// @param args the input arguments

View File

@ -9,7 +9,7 @@
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// See the License for the empecific language governing permissions and
// limitations under the License.
#include "src/tint/resolver/const_eval_test.h"
@ -1335,6 +1335,74 @@ INSTANTIATE_TEST_SUITE_P( //
StepCases<f32>(),
StepCases<f16>()))));
std::vector<Case> Unpack4x8snormCases() {
return {
C({Val(u32(0x0000'0000))}, Vec(f32(0), f32(0), f32(0), f32(0))),
C({Val(u32(0x8100'0000))}, Vec(f32(0), f32(0), f32(0), f32(-1))),
C({Val(u32(0x7f00'0000))}, Vec(f32(0), f32(0), f32(0), f32(1))),
C({Val(u32(0x0081'0000))}, Vec(f32(0), f32(0), f32(-1), f32(0))),
C({Val(u32(0x0000'7f00))}, Vec(f32(0), f32(1), f32(0), f32(0))),
C({Val(u32(0x0000'0081))}, Vec(f32(-1), f32(0), f32(0), f32(0))),
C({Val(u32(0x817f'817f))}, Vec(f32(1), f32(-1), f32(1), f32(-1))),
C({Val(u32(0x816d'937f))},
Vec(f32(1), f32(-0.8582677165354), f32(0.8582677165354), f32(-1))),
};
}
INSTANTIATE_TEST_SUITE_P( //
Unpack4x8snorm,
ResolverConstEvalBuiltinTest,
testing::Combine(testing::Values(sem::BuiltinType::kUnpack4X8Snorm),
testing::ValuesIn(Unpack4x8snormCases())));
std::vector<Case> Unpack4x8unormCases() {
return {
C({Val(u32(0x0000'0000))}, Vec(f32(0), f32(0), f32(0), f32(0))),
C({Val(u32(0xff00'0000))}, Vec(f32(0), f32(0), f32(0), f32(1))),
C({Val(u32(0x00ff'0000))}, Vec(f32(0), f32(0), f32(1), f32(0))),
C({Val(u32(0x0000'ff00))}, Vec(f32(0), f32(1), f32(0), f32(0))),
C({Val(u32(0x0000'00ff))}, Vec(f32(1), f32(0), f32(0), f32(0))),
C({Val(u32(0x00ff'00ff))}, Vec(f32(1), f32(0), f32(1), f32(0))),
C({Val(u32(0x0066'00ff))}, Vec(f32(1), f32(0), f32(0.4), f32(0))),
};
}
INSTANTIATE_TEST_SUITE_P( //
Unpack4x8unorm,
ResolverConstEvalBuiltinTest,
testing::Combine(testing::Values(sem::BuiltinType::kUnpack4X8Unorm),
testing::ValuesIn(Unpack4x8unormCases())));
std::vector<Case> Unpack2x16snormCases() {
return {
C({Val(u32(0x0000'0000))}, Vec(f32(0), f32(0))),
C({Val(u32(0x8001'0000))}, Vec(f32(0), f32(-1))),
C({Val(u32(0x7fff'0000))}, Vec(f32(0), f32(1))),
C({Val(u32(0x0000'8001))}, Vec(f32(-1), f32(0))),
C({Val(u32(0x0000'7fff))}, Vec(f32(1), f32(0))),
C({Val(u32(0x8001'7fff))}, Vec(f32(1), f32(-1))),
C({Val(u32(0x8001'7fff))}, Vec(f32(1), f32(-1))),
C({Val(u32(0x4000'999a))}, Vec(f32(-0.80001220740379), f32(0.500015259254737))).FloatComp(),
};
}
INSTANTIATE_TEST_SUITE_P( //
Unpack2x16snorm,
ResolverConstEvalBuiltinTest,
testing::Combine(testing::Values(sem::BuiltinType::kUnpack2X16Snorm),
testing::ValuesIn(Unpack2x16snormCases())));
std::vector<Case> Unpack2x16unormCases() {
return {
C({Val(u32(0xffff'0000))}, Vec(f32(0), f32(1))),
C({Val(u32(0x0000'ffff))}, Vec(f32(1), f32(0))),
C({Val(u32(0x0000'6666))}, Vec(f32(0.4), f32(0))),
C({Val(u32(0x0000'ffff))}, Vec(f32(1), f32(0))),
};
}
INSTANTIATE_TEST_SUITE_P( //
Unpack2x16unorm,
ResolverConstEvalBuiltinTest,
testing::Combine(testing::Values(sem::BuiltinType::kUnpack2X16Unorm),
testing::ValuesIn(Unpack2x16unormCases())));
std::vector<Case> QuantizeToF16Cases() {
(void)E({Vec(0_f, 0_f)}, ""); // Currently unused, but will be soon.
return {

View File

@ -13838,7 +13838,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[952],
/* return matcher indices */ &kMatcherIndices[134],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::unpack4x8unorm,
},
{
/* [459] */
@ -13850,7 +13850,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[962],
/* return matcher indices */ &kMatcherIndices[134],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::unpack4x8snorm,
},
{
/* [460] */
@ -13862,7 +13862,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[963],
/* return matcher indices */ &kMatcherIndices[132],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::unpack2x16unorm,
},
{
/* [461] */
@ -13874,7 +13874,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[973],
/* return matcher indices */ &kMatcherIndices[132],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::unpack2x16snorm,
},
{
/* [462] */

View File

@ -1,11 +1,5 @@
float2 tint_unpack2x16snorm(uint param_0) {
int j = int(param_0);
int2 i = int2(j << 16, j) >> 16;
return clamp(float2(i) / 32767.0, -1.0, 1.0);
}
void unpack2x16snorm_b4aea6() {
float2 res = tint_unpack2x16snorm(1u);
float2 res = float2(3.05185094e-05f, 0.0f);
}
struct tint_symbol {

View File

@ -1,11 +1,5 @@
float2 tint_unpack2x16snorm(uint param_0) {
int j = int(param_0);
int2 i = int2(j << 16, j) >> 16;
return clamp(float2(i) / 32767.0, -1.0, 1.0);
}
void unpack2x16snorm_b4aea6() {
float2 res = tint_unpack2x16snorm(1u);
float2 res = float2(3.05185094e-05f, 0.0f);
}
struct tint_symbol {

View File

@ -1,7 +1,7 @@
#version 310 es
void unpack2x16snorm_b4aea6() {
vec2 res = unpackSnorm2x16(1u);
vec2 res = vec2(3.05185094e-05f, 0.0f);
}
vec4 vertex_main() {
@ -21,7 +21,7 @@ void main() {
precision mediump float;
void unpack2x16snorm_b4aea6() {
vec2 res = unpackSnorm2x16(1u);
vec2 res = vec2(3.05185094e-05f, 0.0f);
}
void fragment_main() {
@ -35,7 +35,7 @@ void main() {
#version 310 es
void unpack2x16snorm_b4aea6() {
vec2 res = unpackSnorm2x16(1u);
vec2 res = vec2(3.05185094e-05f, 0.0f);
}
void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal;
void unpack2x16snorm_b4aea6() {
float2 res = unpack_snorm2x16_to_float(1u);
float2 res = float2(3.05185094e-05f, 0.0f);
}
struct tint_symbol {

View File

@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 35
; Bound: 33
; Schema: 0
OpCapability Shader
%15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@ -32,38 +31,37 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%float_3_05185094en05 = OpConstant %float 3.05185094e-05
%15 = OpConstantComposite %v2float %float_3_05185094en05 %8
%_ptr_Function_v2float = OpTypePointer Function %v2float
%20 = OpConstantNull %v2float
%21 = OpTypeFunction %v4float
%18 = OpConstantNull %v2float
%19 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%unpack2x16snorm_b4aea6 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v2float Function %20
%13 = OpExtInst %v2float %15 UnpackSnorm2x16 %uint_1
OpStore %res %13
%res = OpVariable %_ptr_Function_v2float Function %18
OpStore %res %15
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %21
%23 = OpLabel
%24 = OpFunctionCall %void %unpack2x16snorm_b4aea6
%vertex_main_inner = OpFunction %v4float None %19
%21 = OpLabel
%22 = OpFunctionCall %void %unpack2x16snorm_b4aea6
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
%26 = OpLabel
%27 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %27
%24 = OpLabel
%25 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
%30 = OpLabel
%31 = OpFunctionCall %void %unpack2x16snorm_b4aea6
%28 = OpLabel
%29 = OpFunctionCall %void %unpack2x16snorm_b4aea6
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
%33 = OpLabel
%34 = OpFunctionCall %void %unpack2x16snorm_b4aea6
%31 = OpLabel
%32 = OpFunctionCall %void %unpack2x16snorm_b4aea6
OpReturn
OpFunctionEnd

View File

@ -1,11 +1,5 @@
float2 tint_unpack2x16unorm(uint param_0) {
uint j = param_0;
uint2 i = uint2(j & 0xffff, j >> 16);
return float2(i) / 65535.0;
}
void unpack2x16unorm_7699c0() {
float2 res = tint_unpack2x16unorm(1u);
float2 res = float2(1.52590219e-05f, 0.0f);
}
struct tint_symbol {

View File

@ -1,11 +1,5 @@
float2 tint_unpack2x16unorm(uint param_0) {
uint j = param_0;
uint2 i = uint2(j & 0xffff, j >> 16);
return float2(i) / 65535.0;
}
void unpack2x16unorm_7699c0() {
float2 res = tint_unpack2x16unorm(1u);
float2 res = float2(1.52590219e-05f, 0.0f);
}
struct tint_symbol {

View File

@ -1,7 +1,7 @@
#version 310 es
void unpack2x16unorm_7699c0() {
vec2 res = unpackUnorm2x16(1u);
vec2 res = vec2(1.52590219e-05f, 0.0f);
}
vec4 vertex_main() {
@ -21,7 +21,7 @@ void main() {
precision mediump float;
void unpack2x16unorm_7699c0() {
vec2 res = unpackUnorm2x16(1u);
vec2 res = vec2(1.52590219e-05f, 0.0f);
}
void fragment_main() {
@ -35,7 +35,7 @@ void main() {
#version 310 es
void unpack2x16unorm_7699c0() {
vec2 res = unpackUnorm2x16(1u);
vec2 res = vec2(1.52590219e-05f, 0.0f);
}
void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal;
void unpack2x16unorm_7699c0() {
float2 res = unpack_unorm2x16_to_float(1u);
float2 res = float2(1.52590219e-05f, 0.0f);
}
struct tint_symbol {

View File

@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 35
; Bound: 33
; Schema: 0
OpCapability Shader
%15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@ -32,38 +31,37 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%float_1_52590219en05 = OpConstant %float 1.52590219e-05
%15 = OpConstantComposite %v2float %float_1_52590219en05 %8
%_ptr_Function_v2float = OpTypePointer Function %v2float
%20 = OpConstantNull %v2float
%21 = OpTypeFunction %v4float
%18 = OpConstantNull %v2float
%19 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%unpack2x16unorm_7699c0 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v2float Function %20
%13 = OpExtInst %v2float %15 UnpackUnorm2x16 %uint_1
OpStore %res %13
%res = OpVariable %_ptr_Function_v2float Function %18
OpStore %res %15
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %21
%23 = OpLabel
%24 = OpFunctionCall %void %unpack2x16unorm_7699c0
%vertex_main_inner = OpFunction %v4float None %19
%21 = OpLabel
%22 = OpFunctionCall %void %unpack2x16unorm_7699c0
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
%26 = OpLabel
%27 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %27
%24 = OpLabel
%25 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
%30 = OpLabel
%31 = OpFunctionCall %void %unpack2x16unorm_7699c0
%28 = OpLabel
%29 = OpFunctionCall %void %unpack2x16unorm_7699c0
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
%33 = OpLabel
%34 = OpFunctionCall %void %unpack2x16unorm_7699c0
%31 = OpLabel
%32 = OpFunctionCall %void %unpack2x16unorm_7699c0
OpReturn
OpFunctionEnd

View File

@ -1,11 +1,5 @@
float4 tint_unpack4x8snorm(uint param_0) {
int j = int(param_0);
int4 i = int4(j << 24, j << 16, j << 8, j) >> 24;
return clamp(float4(i) / 127.0, -1.0, 1.0);
}
void unpack4x8snorm_523fb3() {
float4 res = tint_unpack4x8snorm(1u);
float4 res = float4(0.007874016f, 0.0f, 0.0f, 0.0f);
}
struct tint_symbol {

View File

@ -1,11 +1,5 @@
float4 tint_unpack4x8snorm(uint param_0) {
int j = int(param_0);
int4 i = int4(j << 24, j << 16, j << 8, j) >> 24;
return clamp(float4(i) / 127.0, -1.0, 1.0);
}
void unpack4x8snorm_523fb3() {
float4 res = tint_unpack4x8snorm(1u);
float4 res = float4(0.007874016f, 0.0f, 0.0f, 0.0f);
}
struct tint_symbol {

View File

@ -1,7 +1,7 @@
#version 310 es
void unpack4x8snorm_523fb3() {
vec4 res = unpackSnorm4x8(1u);
vec4 res = vec4(0.007874016f, 0.0f, 0.0f, 0.0f);
}
vec4 vertex_main() {
@ -21,7 +21,7 @@ void main() {
precision mediump float;
void unpack4x8snorm_523fb3() {
vec4 res = unpackSnorm4x8(1u);
vec4 res = vec4(0.007874016f, 0.0f, 0.0f, 0.0f);
}
void fragment_main() {
@ -35,7 +35,7 @@ void main() {
#version 310 es
void unpack4x8snorm_523fb3() {
vec4 res = unpackSnorm4x8(1u);
vec4 res = vec4(0.007874016f, 0.0f, 0.0f, 0.0f);
}
void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal;
void unpack4x8snorm_523fb3() {
float4 res = unpack_snorm4x8_to_float(1u);
float4 res = float4(0.007874016f, 0.0f, 0.0f, 0.0f);
}
struct tint_symbol {

View File

@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 33
; Bound: 31
; Schema: 0
OpCapability Shader
%14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@ -31,37 +30,36 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%float_0_00787401572 = OpConstant %float 0.00787401572
%14 = OpConstantComposite %v4float %float_0_00787401572 %8 %8 %8
%_ptr_Function_v4float = OpTypePointer Function %v4float
%19 = OpTypeFunction %v4float
%17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%unpack4x8snorm_523fb3 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
%13 = OpExtInst %v4float %14 UnpackSnorm4x8 %uint_1
OpStore %res %13
OpStore %res %14
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %19
%21 = OpLabel
%22 = OpFunctionCall %void %unpack4x8snorm_523fb3
%vertex_main_inner = OpFunction %v4float None %17
%19 = OpLabel
%20 = OpFunctionCall %void %unpack4x8snorm_523fb3
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
%24 = OpLabel
%25 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %25
%22 = OpLabel
%23 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
%28 = OpLabel
%29 = OpFunctionCall %void %unpack4x8snorm_523fb3
%26 = OpLabel
%27 = OpFunctionCall %void %unpack4x8snorm_523fb3
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
%31 = OpLabel
%32 = OpFunctionCall %void %unpack4x8snorm_523fb3
%29 = OpLabel
%30 = OpFunctionCall %void %unpack4x8snorm_523fb3
OpReturn
OpFunctionEnd

View File

@ -1,11 +1,5 @@
float4 tint_unpack4x8unorm(uint param_0) {
uint j = param_0;
uint4 i = uint4(j & 0xff, (j >> 8) & 0xff, (j >> 16) & 0xff, j >> 24);
return float4(i) / 255.0;
}
void unpack4x8unorm_750c74() {
float4 res = tint_unpack4x8unorm(1u);
float4 res = float4(0.003921569f, 0.0f, 0.0f, 0.0f);
}
struct tint_symbol {

View File

@ -1,11 +1,5 @@
float4 tint_unpack4x8unorm(uint param_0) {
uint j = param_0;
uint4 i = uint4(j & 0xff, (j >> 8) & 0xff, (j >> 16) & 0xff, j >> 24);
return float4(i) / 255.0;
}
void unpack4x8unorm_750c74() {
float4 res = tint_unpack4x8unorm(1u);
float4 res = float4(0.003921569f, 0.0f, 0.0f, 0.0f);
}
struct tint_symbol {

View File

@ -1,7 +1,7 @@
#version 310 es
void unpack4x8unorm_750c74() {
vec4 res = unpackUnorm4x8(1u);
vec4 res = vec4(0.003921569f, 0.0f, 0.0f, 0.0f);
}
vec4 vertex_main() {
@ -21,7 +21,7 @@ void main() {
precision mediump float;
void unpack4x8unorm_750c74() {
vec4 res = unpackUnorm4x8(1u);
vec4 res = vec4(0.003921569f, 0.0f, 0.0f, 0.0f);
}
void fragment_main() {
@ -35,7 +35,7 @@ void main() {
#version 310 es
void unpack4x8unorm_750c74() {
vec4 res = unpackUnorm4x8(1u);
vec4 res = vec4(0.003921569f, 0.0f, 0.0f, 0.0f);
}
void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal;
void unpack4x8unorm_750c74() {
float4 res = unpack_unorm4x8_to_float(1u);
float4 res = float4(0.003921569f, 0.0f, 0.0f, 0.0f);
}
struct tint_symbol {

View File

@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 33
; Bound: 31
; Schema: 0
OpCapability Shader
%14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@ -31,37 +30,36 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%float_0_00392156886 = OpConstant %float 0.00392156886
%14 = OpConstantComposite %v4float %float_0_00392156886 %8 %8 %8
%_ptr_Function_v4float = OpTypePointer Function %v4float
%19 = OpTypeFunction %v4float
%17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%unpack4x8unorm_750c74 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
%13 = OpExtInst %v4float %14 UnpackUnorm4x8 %uint_1
OpStore %res %13
OpStore %res %14
OpReturn
OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %19
%21 = OpLabel
%22 = OpFunctionCall %void %unpack4x8unorm_750c74
%vertex_main_inner = OpFunction %v4float None %17
%19 = OpLabel
%20 = OpFunctionCall %void %unpack4x8unorm_750c74
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
%24 = OpLabel
%25 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %25
%22 = OpLabel
%23 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
%28 = OpLabel
%29 = OpFunctionCall %void %unpack4x8unorm_750c74
%26 = OpLabel
%27 = OpFunctionCall %void %unpack4x8unorm_750c74
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
%31 = OpLabel
%32 = OpFunctionCall %void %unpack4x8unorm_750c74
%29 = OpLabel
%30 = OpFunctionCall %void %unpack4x8unorm_750c74
OpReturn
OpFunctionEnd