writer/spirv: Fix [[override]] for zero-init defaults

These expressions were not emitted as spec-ops, failing new CTS tests.

Change-Id: I56e8f56a22de2b8dac9a8bd7a2d694d8d81dca35
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67480
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-10-26 10:05:02 +00:00
committed by Tint LUCI CQ
parent 0436d045ab
commit 6c4effe654
125 changed files with 1356 additions and 52 deletions

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : bool = bool();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,9 @@
#ifndef WGSL_SPEC_CONSTANT_1234
#define WGSL_SPEC_CONSTANT_1234 false
#endif
static const bool o = WGSL_SPEC_CONSTANT_1234;
[numthreads(1, 1, 1)]
void main() {
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
constant bool o [[function_constant(1234)]];
kernel void tint_symbol() {
return;
}

View File

@@ -0,0 +1,20 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %o "o"
OpName %main "main"
OpDecorate %o SpecId 1234
%bool = OpTypeBool
%o = OpSpecConstantFalse %bool
%void = OpTypeVoid
%3 = OpTypeFunction %void
%main = OpFunction %void None %3
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : bool = bool();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : f32 = f32();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,9 @@
#ifndef WGSL_SPEC_CONSTANT_1234
#define WGSL_SPEC_CONSTANT_1234 0.0f
#endif
static const float o = WGSL_SPEC_CONSTANT_1234;
[numthreads(1, 1, 1)]
void main() {
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
constant float o [[function_constant(1234)]];
kernel void tint_symbol() {
return;
}

View File

@@ -0,0 +1,20 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %o "o"
OpName %main "main"
OpDecorate %o SpecId 1234
%float = OpTypeFloat 32
%o = OpSpecConstant %float 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%main = OpFunction %void None %3
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : f32 = f32();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : i32 = i32();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,9 @@
#ifndef WGSL_SPEC_CONSTANT_1234
#define WGSL_SPEC_CONSTANT_1234 0
#endif
static const int o = WGSL_SPEC_CONSTANT_1234;
[numthreads(1, 1, 1)]
void main() {
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
constant int o [[function_constant(1234)]];
kernel void tint_symbol() {
return;
}

View File

@@ -0,0 +1,20 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %o "o"
OpName %main "main"
OpDecorate %o SpecId 1234
%int = OpTypeInt 32 1
%o = OpSpecConstant %int 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%main = OpFunction %void None %3
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : i32 = i32();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : u32 = u32();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}

View File

@@ -0,0 +1,9 @@
#ifndef WGSL_SPEC_CONSTANT_1234
#define WGSL_SPEC_CONSTANT_1234 0u
#endif
static const uint o = WGSL_SPEC_CONSTANT_1234;
[numthreads(1, 1, 1)]
void main() {
return;
}

View File

@@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
constant uint o [[function_constant(1234)]];
kernel void tint_symbol() {
return;
}

View File

@@ -0,0 +1,20 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 7
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %o "o"
OpName %main "main"
OpDecorate %o SpecId 1234
%uint = OpTypeInt 32 0
%o = OpSpecConstant %uint 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%main = OpFunction %void None %3
%6 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,6 @@
[[override(1234)]] let o : u32 = u32();
[[stage(compute), workgroup_size(1)]]
fn main() {
_ = o;
}