mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 14:08:04 +00:00
tint: Fix HLSL emission for out-of-order storage / uniform buffers
Recent changes to DecomposeMemoryAccess meant we lost the dependency information between the user of a module-scope variable of the storage / uniform address space and the variable. Add dependency information to ast::InternalAttribute so this can be tracked. This change also means that symbol renaming after the DecomposeMemoryAccess should work. Fixed: tint:1860 Change-Id: Icfa2925f95c2ac50702522df514cd11bde727546 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122660 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
fd387a37c3
commit
63d0fabeb1
10
test/tint/bug/tint/1860.wgsl
Normal file
10
test/tint/bug/tint/1860.wgsl
Normal file
@@ -0,0 +1,10 @@
|
||||
@vertex
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4(declared_after_usage.f);
|
||||
}
|
||||
|
||||
struct DeclaredAfterUsage {
|
||||
f : f32,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var <uniform> declared_after_usage : DeclaredAfterUsage;
|
||||
18
test/tint/bug/tint/1860.wgsl.expected.dxc.hlsl
Normal file
18
test/tint/bug/tint/1860.wgsl.expected.dxc.hlsl
Normal file
@@ -0,0 +1,18 @@
|
||||
struct tint_symbol {
|
||||
float4 value : SV_Position;
|
||||
};
|
||||
|
||||
cbuffer cbuffer_declared_after_usage : register(b0, space0) {
|
||||
uint4 declared_after_usage[1];
|
||||
};
|
||||
|
||||
float4 main_inner() {
|
||||
return float4((asfloat(declared_after_usage[0].x)).xxxx);
|
||||
}
|
||||
|
||||
tint_symbol main() {
|
||||
const float4 inner_result = main_inner();
|
||||
tint_symbol wrapper_result = (tint_symbol)0;
|
||||
wrapper_result.value = inner_result;
|
||||
return wrapper_result;
|
||||
}
|
||||
18
test/tint/bug/tint/1860.wgsl.expected.fxc.hlsl
Normal file
18
test/tint/bug/tint/1860.wgsl.expected.fxc.hlsl
Normal file
@@ -0,0 +1,18 @@
|
||||
struct tint_symbol {
|
||||
float4 value : SV_Position;
|
||||
};
|
||||
|
||||
cbuffer cbuffer_declared_after_usage : register(b0, space0) {
|
||||
uint4 declared_after_usage[1];
|
||||
};
|
||||
|
||||
float4 main_inner() {
|
||||
return float4((asfloat(declared_after_usage[0].x)).xxxx);
|
||||
}
|
||||
|
||||
tint_symbol main() {
|
||||
const float4 inner_result = main_inner();
|
||||
tint_symbol wrapper_result = (tint_symbol)0;
|
||||
wrapper_result.value = inner_result;
|
||||
return wrapper_result;
|
||||
}
|
||||
25
test/tint/bug/tint/1860.wgsl.expected.glsl
Normal file
25
test/tint/bug/tint/1860.wgsl.expected.glsl
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 310 es
|
||||
|
||||
struct DeclaredAfterUsage {
|
||||
float f;
|
||||
uint pad;
|
||||
uint pad_1;
|
||||
uint pad_2;
|
||||
};
|
||||
|
||||
layout(binding = 0, std140) uniform declared_after_usage_block_ubo {
|
||||
DeclaredAfterUsage inner;
|
||||
} declared_after_usage;
|
||||
|
||||
vec4 tint_symbol() {
|
||||
return vec4(declared_after_usage.inner.f);
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_PointSize = 1.0;
|
||||
vec4 inner_result = tint_symbol();
|
||||
gl_Position = inner_result;
|
||||
gl_Position.y = -(gl_Position.y);
|
||||
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||
return;
|
||||
}
|
||||
22
test/tint/bug/tint/1860.wgsl.expected.msl
Normal file
22
test/tint/bug/tint/1860.wgsl.expected.msl
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
struct tint_symbol_1 {
|
||||
float4 value [[position]];
|
||||
};
|
||||
|
||||
struct DeclaredAfterUsage {
|
||||
/* 0x0000 */ float f;
|
||||
};
|
||||
|
||||
float4 tint_symbol_inner(const constant DeclaredAfterUsage* const tint_symbol_2) {
|
||||
return float4((*(tint_symbol_2)).f);
|
||||
}
|
||||
|
||||
vertex tint_symbol_1 tint_symbol(const constant DeclaredAfterUsage* tint_symbol_3 [[buffer(0)]]) {
|
||||
float4 const inner_result = tint_symbol_inner(tint_symbol_3);
|
||||
tint_symbol_1 wrapper_result = {};
|
||||
wrapper_result.value = inner_result;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
58
test/tint/bug/tint/1860.wgsl.expected.spvasm
Normal file
58
test/tint/bug/tint/1860.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,58 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 28
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Vertex %main "main" %value %vertex_point_size
|
||||
OpName %value "value"
|
||||
OpName %vertex_point_size "vertex_point_size"
|
||||
OpName %declared_after_usage_block "declared_after_usage_block"
|
||||
OpMemberName %declared_after_usage_block 0 "inner"
|
||||
OpName %DeclaredAfterUsage "DeclaredAfterUsage"
|
||||
OpMemberName %DeclaredAfterUsage 0 "f"
|
||||
OpName %declared_after_usage "declared_after_usage"
|
||||
OpName %main_inner "main_inner"
|
||||
OpName %main "main"
|
||||
OpDecorate %value BuiltIn Position
|
||||
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||
OpDecorate %declared_after_usage_block Block
|
||||
OpMemberDecorate %declared_after_usage_block 0 Offset 0
|
||||
OpMemberDecorate %DeclaredAfterUsage 0 Offset 0
|
||||
OpDecorate %declared_after_usage NonWritable
|
||||
OpDecorate %declared_after_usage DescriptorSet 0
|
||||
OpDecorate %declared_after_usage Binding 0
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%5 = OpConstantNull %v4float
|
||||
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||
%_ptr_Output_float = OpTypePointer Output %float
|
||||
%8 = OpConstantNull %float
|
||||
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||
%DeclaredAfterUsage = OpTypeStruct %float
|
||||
%declared_after_usage_block = OpTypeStruct %DeclaredAfterUsage
|
||||
%_ptr_Uniform_declared_after_usage_block = OpTypePointer Uniform %declared_after_usage_block
|
||||
%declared_after_usage = OpVariable %_ptr_Uniform_declared_after_usage_block Uniform
|
||||
%13 = OpTypeFunction %v4float
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
||||
%void = OpTypeVoid
|
||||
%22 = OpTypeFunction %void
|
||||
%float_1 = OpConstant %float 1
|
||||
%main_inner = OpFunction %v4float None %13
|
||||
%15 = OpLabel
|
||||
%19 = OpAccessChain %_ptr_Uniform_float %declared_after_usage %uint_0 %uint_0
|
||||
%20 = OpLoad %float %19
|
||||
%21 = OpCompositeConstruct %v4float %20 %20 %20 %20
|
||||
OpReturnValue %21
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %void None %22
|
||||
%25 = OpLabel
|
||||
%26 = OpFunctionCall %v4float %main_inner
|
||||
OpStore %value %26
|
||||
OpStore %vertex_point_size %float_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
10
test/tint/bug/tint/1860.wgsl.expected.wgsl
Normal file
10
test/tint/bug/tint/1860.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,10 @@
|
||||
@vertex
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4(declared_after_usage.f);
|
||||
}
|
||||
|
||||
struct DeclaredAfterUsage {
|
||||
f : f32,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> declared_after_usage : DeclaredAfterUsage;
|
||||
Reference in New Issue
Block a user