Skip to content

Commit

Permalink
Merge pull request #1890 from KhronosGroup/fix-1889
Browse files Browse the repository at this point in the history
Fixup names of anonymous inner structs.
  • Loading branch information
HansKristian-Work committed Mar 10, 2022
2 parents 0b51794 + 4ab5bbb commit d5c3bd8
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
struct anon_aa
{
int foo;
};

struct anon_ab
{
int foo;
};

struct anon_a
{
anon_aa _aa;
anon_ab ab;
};

struct anon_ba
{
int foo;
};

struct anon_bb
{
int foo;
};

struct anon_b
{
anon_ba _ba;
anon_bb bb;
};

struct VertexData
{
anon_a _a;
anon_b b;
};

struct anon_ca
{
int foo;
};

struct anon_c
{
anon_ca _ca;
};

struct anon_da
{
int foo;
};

struct anon_d
{
anon_da da;
};

struct anon_e
{
int a;
};

cbuffer UBO : register(b0)
{
anon_c _16_c : packoffset(c0);
anon_d _16_d : packoffset(c1);
};

RWByteAddressBuffer _19 : register(u1);

static VertexData _3;

struct SPIRV_Cross_Input
{
anon_a VertexData__a : TEXCOORD0;
anon_b VertexData_b : TEXCOORD2;
};

void frag_main()
{
}

void main(SPIRV_Cross_Input stage_input)
{
_3._a = stage_input.VertexData__a;
_3.b = stage_input.VertexData_b;
frag_main();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct anon_aa
{
int foo;
};

struct anon_ab
{
int foo;
};

struct anon_a
{
anon_aa _aa;
anon_ab ab;
};

struct anon_ba
{
int foo;
};

struct anon_bb
{
int foo;
};

struct anon_b
{
anon_ba _ba;
anon_bb bb;
};

struct VertexData
{
anon_a _a;
anon_b b;
};

struct anon_ca
{
int foo;
};

struct anon_c
{
anon_ca _ca;
};

struct anon_da
{
int foo;
};

struct anon_d
{
anon_da da;
};

struct UBO
{
anon_c _c;
anon_d d;
};

struct anon_e
{
int a;
};

struct SSBO
{
anon_e _m0;
anon_e _e;
anon_e f;
};

fragment void main0()
{
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#version 450

struct anon_aa
{
int foo;
};

struct anon_ab
{
int foo;
};

struct anon_a
{
anon_aa _aa;
anon_ab ab;
};

struct anon_ba
{
int foo;
};

struct anon_bb
{
int foo;
};

struct anon_b
{
anon_ba _ba;
anon_bb bb;
};

struct anon_ca
{
int foo;
};

struct anon_c
{
anon_ca _ca;
};

struct anon_da
{
int foo;
};

struct anon_d
{
anon_da da;
};

struct anon_e
{
int a;
};

void main()
{
}

83 changes: 83 additions & 0 deletions shaders-hlsl-no-opt/asm/frag/anonymous-inner-struct-names.asm.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 27
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %_
OpExecutionMode %main OriginUpperLeft
OpSource GLSL 450
OpName %main "main"
OpMemberName %AA 0 "foo"
OpMemberName %AB 0 "foo"
OpMemberName %A 0 "_aa"
OpMemberName %A 1 "ab"
OpMemberName %BA 0 "foo"
OpMemberName %BB 0 "foo"
OpMemberName %B 0 "_ba"
OpMemberName %B 1 "bb"
OpName %VertexData "VertexData"
OpMemberName %VertexData 0 "_a"
OpMemberName %VertexData 1 "b"
OpName %_ ""
OpMemberName %CA 0 "foo"
OpMemberName %C 0 "_ca"
OpMemberName %DA 0 "foo"
OpMemberName %D 0 "da"
OpName %UBO "UBO"
OpMemberName %UBO 0 "_c"
OpMemberName %UBO 1 "d"
OpName %__0 ""
OpMemberName %E 0 "a"
OpName %SSBO "SSBO"
;OpMemberName %SSBO 0 "e" Test that we don't try to assign bogus aliases.
OpMemberName %SSBO 1 "_e"
OpMemberName %SSBO 2 "f"
OpName %__1 ""
OpDecorate %VertexData Block
OpDecorate %_ Location 0
OpMemberDecorate %CA 0 Offset 0
OpMemberDecorate %C 0 Offset 0
OpMemberDecorate %DA 0 Offset 0
OpMemberDecorate %D 0 Offset 0
OpMemberDecorate %UBO 0 Offset 0
OpMemberDecorate %UBO 1 Offset 16
OpDecorate %UBO Block
OpDecorate %__0 DescriptorSet 0
OpDecorate %__0 Binding 0
OpMemberDecorate %E 0 Offset 0
OpMemberDecorate %SSBO 0 Offset 0
OpMemberDecorate %SSBO 1 Offset 4
OpMemberDecorate %SSBO 2 Offset 8
OpDecorate %SSBO BufferBlock
OpDecorate %__1 DescriptorSet 0
OpDecorate %__1 Binding 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%AA = OpTypeStruct %int
%AB = OpTypeStruct %int
%A = OpTypeStruct %AA %AB
%BA = OpTypeStruct %int
%BB = OpTypeStruct %int
%B = OpTypeStruct %BA %BB
%VertexData = OpTypeStruct %A %B
%_ptr_Input_VertexData = OpTypePointer Input %VertexData
%_ = OpVariable %_ptr_Input_VertexData Input
%CA = OpTypeStruct %int
%C = OpTypeStruct %CA
%DA = OpTypeStruct %int
%D = OpTypeStruct %DA
%UBO = OpTypeStruct %C %D
%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO
%__0 = OpVariable %_ptr_Uniform_UBO Uniform
%E = OpTypeStruct %int
%SSBO = OpTypeStruct %E %E %E
%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO
%__1 = OpVariable %_ptr_Uniform_SSBO Uniform
%main = OpFunction %void None %3
%5 = OpLabel
OpReturn
OpFunctionEnd

0 comments on commit d5c3bd8

Please sign in to comment.