writer/hlsl: Simplify emission logic, clean up output

And fix issues where global variables would not be emitted unless they were transitively referenced by an entry point.

This change requires crbug.com/tint/697 to be fixed before landing.

Change-Id: I712bd9d369e08c9a3cdfb0f114c3609584f91f28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54241
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-06-16 09:19:36 +00:00
committed by Ben Clayton
parent 944c5617ca
commit 5d2f34ecf2
935 changed files with 3850 additions and 6868 deletions

View File

@@ -6,26 +6,6 @@ struct tint_symbol_1 {
struct tint_symbol_2 {
float4 value : SV_Position;
};
struct tint_symbol_3 {
float4 value : SV_Target0;
};
struct SimParams {
float deltaT;
float rule1Distance;
float rule2Distance;
float rule3Distance;
float rule1Scale;
float rule2Scale;
float rule3Scale;
};
struct tint_symbol_5 {
uint3 gl_GlobalInvocationID : SV_DispatchThreadID;
};
ConstantBuffer<SimParams> params : register(b0, space0);
RWByteAddressBuffer particlesA : register(u1, space0);
RWByteAddressBuffer particlesB : register(u2, space0);
tint_symbol_2 vert_main(tint_symbol_1 tint_symbol) {
const float2 a_particlePos = tint_symbol.a_particlePos;
@@ -37,11 +17,33 @@ tint_symbol_2 vert_main(tint_symbol_1 tint_symbol) {
return tint_symbol_8;
}
struct tint_symbol_3 {
float4 value : SV_Target0;
};
tint_symbol_3 frag_main() {
const tint_symbol_3 tint_symbol_9 = {float4(1.0f, 1.0f, 1.0f, 1.0f)};
return tint_symbol_9;
}
struct SimParams {
float deltaT;
float rule1Distance;
float rule2Distance;
float rule3Distance;
float rule1Scale;
float rule2Scale;
float rule3Scale;
};
ConstantBuffer<SimParams> params : register(b0, space0);
RWByteAddressBuffer particlesA : register(u1, space0);
RWByteAddressBuffer particlesB : register(u2, space0);
struct tint_symbol_5 {
uint3 gl_GlobalInvocationID : SV_DispatchThreadID;
};
[numthreads(1, 1, 1)]
void comp_main(tint_symbol_5 tint_symbol_4) {
const uint3 gl_GlobalInvocationID = tint_symbol_4.gl_GlobalInvocationID;
@@ -113,4 +115,3 @@ void comp_main(tint_symbol_5 tint_symbol_4) {
particlesB.Store2(((16u * index) + 8u), asuint(vVel));
return;
}

View File

@@ -1,6 +1,9 @@
struct Uniforms {
float4x4 modelViewProjectionMatrix;
};
ConstantBuffer<Uniforms> uniforms : register(b0, space0);
struct VertexInput {
float4 cur_position;
float4 color;
@@ -17,14 +20,6 @@ struct tint_symbol_2 {
float4 vtxFragColor : TEXCOORD0;
float4 Position : SV_Position;
};
struct tint_symbol_4 {
float4 fragColor : TEXCOORD0;
};
struct tint_symbol_5 {
float4 value : SV_Target0;
};
ConstantBuffer<Uniforms> uniforms : register(b0, space0);
tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
const VertexInput input = {tint_symbol.cur_position, tint_symbol.color};
@@ -35,9 +30,15 @@ tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
return tint_symbol_6;
}
struct tint_symbol_4 {
float4 fragColor : TEXCOORD0;
};
struct tint_symbol_5 {
float4 value : SV_Target0;
};
tint_symbol_5 frag_main(tint_symbol_4 tint_symbol_3) {
const float4 fragColor = tint_symbol_3.fragColor;
const tint_symbol_5 tint_symbol_7 = {fragColor};
return tint_symbol_7;
}

View File

@@ -6,4 +6,3 @@ float main() {
void ep() {
return;
}

View File

@@ -1,14 +1,13 @@
void bar() {
}
struct tint_symbol {
float4 value : SV_Target0;
};
void bar() {
}
tint_symbol main() {
float2 a = float2(0.0f, 0.0f);
bar();
const tint_symbol tint_symbol_1 = {float4(0.400000006f, 0.400000006f, 0.800000012f, 1.0f)};
return tint_symbol_1;
}

View File

@@ -1,10 +1,10 @@
struct main_out {
float4 gl_Position : SV_Position;
};
SKIP: FAILED
main_out main() {
main_out tint_out = (main_out)0;
tint_out.gl_Position = float4(0.0f, 0.0f, 0.0f, 0.0f);
return tint_out;
}
../src/writer/hlsl/generator_impl.cc:1726 internal compiler error: unhandled storage class out
********************************************************************
* The tint shader compiler has encountered an unexpected error. *
* *
* Please help us fix this issue by submitting a bug report at *
* crbug.com/tint with the source program that triggered the bug. *
********************************************************************

View File

@@ -1,22 +1,23 @@
static const float2 pos[3] = {float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)};
struct tint_symbol_1 {
uint VertexIndex : SV_VertexID;
};
struct tint_symbol_2 {
float4 value : SV_Position;
};
struct tint_symbol_3 {
float4 value : SV_Target0;
};
static const float2 pos[3] = {float2(0.0f, 0.5f), float2(-0.5f, -0.5f), float2(0.5f, -0.5f)};
tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol) {
const uint VertexIndex = tint_symbol.VertexIndex;
const tint_symbol_2 tint_symbol_4 = {float4(pos[VertexIndex], 0.0f, 1.0f)};
return tint_symbol_4;
}
struct tint_symbol_3 {
float4 value : SV_Target0;
};
tint_symbol_3 frag_main() {
const tint_symbol_3 tint_symbol_5 = {float4(1.0f, 0.0f, 0.0f, 1.0f)};
return tint_symbol_5;
}