From 2d9b0a35509b5ffa7960c8f5eb5cc3be860c33b9 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 27 Sep 2019 15:14:18 -0600 Subject: [PATCH 1/2] HLSL: Fix #1912: add attribute syntax for overriding image formats. --- .../hlsl.format.rwtexture.frag.out | 297 ++++++++++++++++++ Test/hlsl.format.rwtexture.frag | 37 +++ glslang/MachineIndependent/Constant.cpp | 0 glslang/MachineIndependent/ShaderLang.cpp | 0 glslang/MachineIndependent/SymbolTable.cpp | 0 glslang/MachineIndependent/SymbolTable.h | 0 glslang/MachineIndependent/attribute.h | 42 ++- glslang/MachineIndependent/parseVersions.h | 0 gtests/Hlsl.FromFile.cpp | 1 + hlsl/hlslAttributes.cpp | 41 +++ hlsl/hlslGrammar.cpp | 0 hlsl/hlslGrammar.h | 0 hlsl/hlslParseHelper.cpp | 43 +++ hlsl/hlslParseHelper.h | 0 14 files changed, 460 insertions(+), 1 deletion(-) create mode 100755 Test/baseResults/hlsl.format.rwtexture.frag.out create mode 100755 Test/hlsl.format.rwtexture.frag mode change 100755 => 100644 glslang/MachineIndependent/Constant.cpp mode change 100755 => 100644 glslang/MachineIndependent/ShaderLang.cpp mode change 100755 => 100644 glslang/MachineIndependent/SymbolTable.cpp mode change 100755 => 100644 glslang/MachineIndependent/SymbolTable.h mode change 100755 => 100644 glslang/MachineIndependent/parseVersions.h mode change 100644 => 100755 gtests/Hlsl.FromFile.cpp mode change 100755 => 100644 hlsl/hlslGrammar.cpp mode change 100755 => 100644 hlsl/hlslGrammar.h mode change 100644 => 100755 hlsl/hlslParseHelper.cpp mode change 100755 => 100644 hlsl/hlslParseHelper.h diff --git a/Test/baseResults/hlsl.format.rwtexture.frag.out b/Test/baseResults/hlsl.format.rwtexture.frag.out new file mode 100755 index 0000000000..2ecd5148d1 --- /dev/null +++ b/Test/baseResults/hlsl.format.rwtexture.frag.out @@ -0,0 +1,297 @@ +hlsl.format.rwtexture.frag +Shader version: 500 +gl_FragCoord origin is upper left +using depth_any +0:? Sequence +0:30 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Function Parameters: +0:? Sequence +0:33 move second child to first child ( temp 4-component vector of float) +0:33 Color: direct index for structure ( temp 4-component vector of float) +0:33 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:33 Constant: +0:33 0 (const int) +0:33 Constant: +0:33 1.000000 +0:33 1.000000 +0:33 1.000000 +0:33 1.000000 +0:34 move second child to first child ( temp float) +0:34 Depth: direct index for structure ( temp float) +0:34 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:34 Constant: +0:34 1 (const int) +0:34 Constant: +0:34 1.000000 +0:36 Branch: Return with expression +0:36 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Function Definition: main( ( temp void) +0:30 Function Parameters: +0:? Sequence +0:30 Sequence +0:30 move second child to first child ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Function Call: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) +0:30 Color: direct index for structure ( temp 4-component vector of float) +0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Constant: +0:30 0 (const int) +0:30 move second child to first child ( temp float) +0:? '@entryPointOutput.Depth' ( out float FragDepth) +0:30 Depth: direct index for structure ( temp float) +0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Constant: +0:30 1 (const int) +0:? Linker Objects +0:? 'g_sSamp' (layout( binding=0) uniform sampler) +0:? 'g_tTex1df4' (layout( binding=0 rgba32f) uniform image1D) +0:? 'g_tTex1di4' (layout( rg32f) uniform iimage1D) +0:? 'g_tTex1du4' (layout( rgba8_snorm) uniform uimage1D) +0:? 'g_tTex2df4' (layout( rgba8i) uniform image2D) +0:? 'g_tTex2di4' (layout( r11f_g11f_b10f) uniform iimage2D) +0:? 'g_tTex2du4' (layout( r8_snorm) uniform uimage2D) +0:? 'g_tTex3df4' (layout( rg8) uniform image3D) +0:? 'g_tTex3di4' (layout( rgba16i) uniform iimage3D) +0:? 'g_tTex3du4' (layout( r8i) uniform uimage3D) +0:? 'g_tTex1df4a' (layout( rgba8ui) uniform image1DArray) +0:? 'g_tTex1di4a' (layout( rg32ui) uniform iimage1DArray) +0:? 'g_tTex1du4a' (layout( r16ui) uniform uimage1DArray) +0:? 'g_tTex2df4a' (layout( rgb10_a2ui) uniform image2DArray) +0:? 'g_tTex2di4a' (layout( r8ui) uniform iimage2DArray) +0:? 'g_tTex2du4a' (layout( rgba16f) uniform uimage2DArray) +0:? '@entryPointOutput.Depth' ( out float FragDepth) +0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) + + +Linked fragment stage: + + +Shader version: 500 +gl_FragCoord origin is upper left +using depth_any +0:? Sequence +0:30 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Function Parameters: +0:? Sequence +0:33 move second child to first child ( temp 4-component vector of float) +0:33 Color: direct index for structure ( temp 4-component vector of float) +0:33 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:33 Constant: +0:33 0 (const int) +0:33 Constant: +0:33 1.000000 +0:33 1.000000 +0:33 1.000000 +0:33 1.000000 +0:34 move second child to first child ( temp float) +0:34 Depth: direct index for structure ( temp float) +0:34 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:34 Constant: +0:34 1 (const int) +0:34 Constant: +0:34 1.000000 +0:36 Branch: Return with expression +0:36 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Function Definition: main( ( temp void) +0:30 Function Parameters: +0:? Sequence +0:30 Sequence +0:30 move second child to first child ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Function Call: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) +0:30 Color: direct index for structure ( temp 4-component vector of float) +0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Constant: +0:30 0 (const int) +0:30 move second child to first child ( temp float) +0:? '@entryPointOutput.Depth' ( out float FragDepth) +0:30 Depth: direct index for structure ( temp float) +0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:30 Constant: +0:30 1 (const int) +0:? Linker Objects +0:? 'g_sSamp' (layout( binding=0) uniform sampler) +0:? 'g_tTex1df4' (layout( binding=0 rgba32f) uniform image1D) +0:? 'g_tTex1di4' (layout( rg32f) uniform iimage1D) +0:? 'g_tTex1du4' (layout( rgba8_snorm) uniform uimage1D) +0:? 'g_tTex2df4' (layout( rgba8i) uniform image2D) +0:? 'g_tTex2di4' (layout( r11f_g11f_b10f) uniform iimage2D) +0:? 'g_tTex2du4' (layout( r8_snorm) uniform uimage2D) +0:? 'g_tTex3df4' (layout( rg8) uniform image3D) +0:? 'g_tTex3di4' (layout( rgba16i) uniform iimage3D) +0:? 'g_tTex3du4' (layout( r8i) uniform uimage3D) +0:? 'g_tTex1df4a' (layout( rgba8ui) uniform image1DArray) +0:? 'g_tTex1di4a' (layout( rg32ui) uniform iimage1DArray) +0:? 'g_tTex1du4a' (layout( r16ui) uniform uimage1DArray) +0:? 'g_tTex2df4a' (layout( rgb10_a2ui) uniform image2DArray) +0:? 'g_tTex2di4a' (layout( r8ui) uniform iimage2DArray) +0:? 'g_tTex2du4a' (layout( rgba16f) uniform uimage2DArray) +0:? '@entryPointOutput.Depth' ( out float FragDepth) +0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80007 +// Id's are bound by 85 + + Capability Shader + Capability Image1D + Capability StorageImageExtendedFormats + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 29 33 + ExecutionMode 4 OriginUpperLeft + ExecutionMode 4 DepthReplacing + Source HLSL 500 + Name 4 "main" + Name 8 "PS_OUTPUT" + MemberName 8(PS_OUTPUT) 0 "Color" + MemberName 8(PS_OUTPUT) 1 "Depth" + Name 10 "@main(" + Name 13 "psout" + Name 26 "flattenTemp" + Name 29 "@entryPointOutput.Color" + Name 33 "@entryPointOutput.Depth" + Name 38 "g_sSamp" + Name 41 "g_tTex1df4" + Name 44 "g_tTex1di4" + Name 48 "g_tTex1du4" + Name 51 "g_tTex2df4" + Name 54 "g_tTex2di4" + Name 57 "g_tTex2du4" + Name 60 "g_tTex3df4" + Name 63 "g_tTex3di4" + Name 66 "g_tTex3du4" + Name 69 "g_tTex1df4a" + Name 72 "g_tTex1di4a" + Name 75 "g_tTex1du4a" + Name 78 "g_tTex2df4a" + Name 81 "g_tTex2di4a" + Name 84 "g_tTex2du4a" + Decorate 29(@entryPointOutput.Color) Location 0 + Decorate 33(@entryPointOutput.Depth) BuiltIn FragDepth + Decorate 38(g_sSamp) DescriptorSet 0 + Decorate 38(g_sSamp) Binding 0 + Decorate 41(g_tTex1df4) DescriptorSet 0 + Decorate 41(g_tTex1df4) Binding 0 + Decorate 44(g_tTex1di4) DescriptorSet 0 + Decorate 44(g_tTex1di4) Binding 0 + Decorate 48(g_tTex1du4) DescriptorSet 0 + Decorate 48(g_tTex1du4) Binding 0 + Decorate 51(g_tTex2df4) DescriptorSet 0 + Decorate 51(g_tTex2df4) Binding 0 + Decorate 54(g_tTex2di4) DescriptorSet 0 + Decorate 54(g_tTex2di4) Binding 0 + Decorate 57(g_tTex2du4) DescriptorSet 0 + Decorate 57(g_tTex2du4) Binding 0 + Decorate 60(g_tTex3df4) DescriptorSet 0 + Decorate 60(g_tTex3df4) Binding 0 + Decorate 63(g_tTex3di4) DescriptorSet 0 + Decorate 63(g_tTex3di4) Binding 0 + Decorate 66(g_tTex3du4) DescriptorSet 0 + Decorate 66(g_tTex3du4) Binding 0 + Decorate 69(g_tTex1df4a) DescriptorSet 0 + Decorate 69(g_tTex1df4a) Binding 0 + Decorate 72(g_tTex1di4a) DescriptorSet 0 + Decorate 72(g_tTex1di4a) Binding 0 + Decorate 75(g_tTex1du4a) DescriptorSet 0 + Decorate 75(g_tTex1du4a) Binding 0 + Decorate 78(g_tTex2df4a) DescriptorSet 0 + Decorate 78(g_tTex2df4a) Binding 0 + Decorate 81(g_tTex2di4a) DescriptorSet 0 + Decorate 81(g_tTex2di4a) Binding 0 + Decorate 84(g_tTex2du4a) DescriptorSet 0 + Decorate 84(g_tTex2du4a) Binding 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8(PS_OUTPUT): TypeStruct 7(fvec4) 6(float) + 9: TypeFunction 8(PS_OUTPUT) + 12: TypePointer Function 8(PS_OUTPUT) + 14: TypeInt 32 1 + 15: 14(int) Constant 0 + 16: 6(float) Constant 1065353216 + 17: 7(fvec4) ConstantComposite 16 16 16 16 + 18: TypePointer Function 7(fvec4) + 20: 14(int) Constant 1 + 21: TypePointer Function 6(float) + 28: TypePointer Output 7(fvec4) +29(@entryPointOutput.Color): 28(ptr) Variable Output + 32: TypePointer Output 6(float) +33(@entryPointOutput.Depth): 32(ptr) Variable Output + 36: TypeSampler + 37: TypePointer UniformConstant 36 + 38(g_sSamp): 37(ptr) Variable UniformConstant + 39: TypeImage 6(float) 1D nonsampled format:Rgba32f + 40: TypePointer UniformConstant 39 + 41(g_tTex1df4): 40(ptr) Variable UniformConstant + 42: TypeImage 14(int) 1D nonsampled format:Rg32f + 43: TypePointer UniformConstant 42 + 44(g_tTex1di4): 43(ptr) Variable UniformConstant + 45: TypeInt 32 0 + 46: TypeImage 45(int) 1D nonsampled format:Rgba8Snorm + 47: TypePointer UniformConstant 46 + 48(g_tTex1du4): 47(ptr) Variable UniformConstant + 49: TypeImage 6(float) 2D nonsampled format:Rgba8i + 50: TypePointer UniformConstant 49 + 51(g_tTex2df4): 50(ptr) Variable UniformConstant + 52: TypeImage 14(int) 2D nonsampled format:R11fG11fB10f + 53: TypePointer UniformConstant 52 + 54(g_tTex2di4): 53(ptr) Variable UniformConstant + 55: TypeImage 45(int) 2D nonsampled format:R8Snorm + 56: TypePointer UniformConstant 55 + 57(g_tTex2du4): 56(ptr) Variable UniformConstant + 58: TypeImage 6(float) 3D nonsampled format:Rg8 + 59: TypePointer UniformConstant 58 + 60(g_tTex3df4): 59(ptr) Variable UniformConstant + 61: TypeImage 14(int) 3D nonsampled format:Rgba16i + 62: TypePointer UniformConstant 61 + 63(g_tTex3di4): 62(ptr) Variable UniformConstant + 64: TypeImage 45(int) 3D nonsampled format:R8i + 65: TypePointer UniformConstant 64 + 66(g_tTex3du4): 65(ptr) Variable UniformConstant + 67: TypeImage 6(float) 1D array nonsampled format:Rgba8ui + 68: TypePointer UniformConstant 67 + 69(g_tTex1df4a): 68(ptr) Variable UniformConstant + 70: TypeImage 14(int) 1D array nonsampled format:Rg32ui + 71: TypePointer UniformConstant 70 + 72(g_tTex1di4a): 71(ptr) Variable UniformConstant + 73: TypeImage 45(int) 1D array nonsampled format:R16ui + 74: TypePointer UniformConstant 73 + 75(g_tTex1du4a): 74(ptr) Variable UniformConstant + 76: TypeImage 6(float) 2D array nonsampled format:Rgb10a2ui + 77: TypePointer UniformConstant 76 + 78(g_tTex2df4a): 77(ptr) Variable UniformConstant + 79: TypeImage 14(int) 2D array nonsampled format:R8ui + 80: TypePointer UniformConstant 79 + 81(g_tTex2di4a): 80(ptr) Variable UniformConstant + 82: TypeImage 45(int) 2D array nonsampled format:Rgba16f + 83: TypePointer UniformConstant 82 + 84(g_tTex2du4a): 83(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 26(flattenTemp): 12(ptr) Variable Function + 27:8(PS_OUTPUT) FunctionCall 10(@main() + Store 26(flattenTemp) 27 + 30: 18(ptr) AccessChain 26(flattenTemp) 15 + 31: 7(fvec4) Load 30 + Store 29(@entryPointOutput.Color) 31 + 34: 21(ptr) AccessChain 26(flattenTemp) 20 + 35: 6(float) Load 34 + Store 33(@entryPointOutput.Depth) 35 + Return + FunctionEnd + 10(@main():8(PS_OUTPUT) Function None 9 + 11: Label + 13(psout): 12(ptr) Variable Function + 19: 18(ptr) AccessChain 13(psout) 15 + Store 19 17 + 22: 21(ptr) AccessChain 13(psout) 20 + Store 22 16 + 23:8(PS_OUTPUT) Load 13(psout) + ReturnValue 23 + FunctionEnd diff --git a/Test/hlsl.format.rwtexture.frag b/Test/hlsl.format.rwtexture.frag new file mode 100755 index 0000000000..d92f590662 --- /dev/null +++ b/Test/hlsl.format.rwtexture.frag @@ -0,0 +1,37 @@ +SamplerState g_sSamp : register(s0); + +[[spv::format_rgba32f]] RWTexture1D g_tTex1df4 : register(t0); +[[spv::format_rg32f]] RWTexture1D g_tTex1di4; +[[spv::format_rgba8snorm]] RWTexture1D g_tTex1du4; + +[[spv::format_rgba8i]] RWTexture2D g_tTex2df4; +[[spv::format_r11fg11fb10f]] RWTexture2D g_tTex2di4; +[[spv::format_r8snorm]] RWTexture2D g_tTex2du4; + +[[spv::format_rg8]] RWTexture3D g_tTex3df4; +[[spv::format_rgba16i]] RWTexture3D g_tTex3di4; +[[spv::format_r8i]] RWTexture3D g_tTex3du4; + +[[spv::format_rgba8ui]] RWTexture1DArray g_tTex1df4a; +[[spv::format_rg32ui]] RWTexture1DArray g_tTex1di4a; +[[spv::format_r16ui]] RWTexture1DArray g_tTex1du4a; + +[[spv::format_rgb10a2ui]] RWTexture2DArray g_tTex2df4a; +[[spv::format_r8ui]] RWTexture2DArray g_tTex2di4a; +[[spv::format_rgba16f]] RWTexture2DArray g_tTex2du4a; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/glslang/MachineIndependent/Constant.cpp b/glslang/MachineIndependent/Constant.cpp old mode 100755 new mode 100644 diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp old mode 100755 new mode 100644 diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp old mode 100755 new mode 100644 diff --git a/glslang/MachineIndependent/SymbolTable.h b/glslang/MachineIndependent/SymbolTable.h old mode 100755 new mode 100644 diff --git a/glslang/MachineIndependent/attribute.h b/glslang/MachineIndependent/attribute.h index 844ce45806..92f3d63432 100644 --- a/glslang/MachineIndependent/attribute.h +++ b/glslang/MachineIndependent/attribute.h @@ -76,7 +76,47 @@ namespace glslang { EatMaxIterations, EatIterationMultiple, EatPeelCount, - EatPartialCount + EatPartialCount, + EatFormatRgba32f, + EatFormatRgba16f, + EatFormatR32f, + EatFormatRgba8, + EatFormatRgba8Snorm, + EatFormatRg32f, + EatFormatRg16f, + EatFormatR11fG11fB10f, + EatFormatR16f, + EatFormatRgba16, + EatFormatRgb10A2, + EatFormatRg16, + EatFormatRg8, + EatFormatR16, + EatFormatR8, + EatFormatRgba16Snorm, + EatFormatRg16Snorm, + EatFormatRg8Snorm, + EatFormatR16Snorm, + EatFormatR8Snorm, + EatFormatRgba32i, + EatFormatRgba16i, + EatFormatRgba8i, + EatFormatR32i, + EatFormatRg32i, + EatFormatRg16i, + EatFormatRg8i, + EatFormatR16i, + EatFormatR8i, + EatFormatRgba32ui, + EatFormatRgba16ui, + EatFormatRgba8ui, + EatFormatR32ui, + EatFormatRgb10a2ui, + EatFormatRg32ui, + EatFormatRg16ui, + EatFormatRg8ui, + EatFormatR16ui, + EatFormatR8ui, + EatFormatUnknown }; class TIntermAggregate; diff --git a/glslang/MachineIndependent/parseVersions.h b/glslang/MachineIndependent/parseVersions.h old mode 100755 new mode 100644 diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp old mode 100644 new mode 100755 index 7738c8042f..59c687d870 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -230,6 +230,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.hull.void.tesc", "main"}, {"hlsl.hull.ctrlpt-1.tesc", "main"}, {"hlsl.hull.ctrlpt-2.tesc", "main"}, + {"hlsl.format.rwtexture.frag", "main"}, {"hlsl.groupid.comp", "main"}, {"hlsl.identifier.sample.frag", "main"}, {"hlsl.if.frag", "PixelShaderFunction"}, diff --git a/hlsl/hlslAttributes.cpp b/hlsl/hlslAttributes.cpp index 261cec346f..05d4ae3694 100644 --- a/hlsl/hlslAttributes.cpp +++ b/hlsl/hlslAttributes.cpp @@ -58,6 +58,47 @@ namespace glslang { return EatConstantId; else if (name == "push_constant") return EatPushConstant; + } else if (nameSpace == "spv") { + if (name == "format_rgba32f") return EatFormatRgba32f; + if (name == "format_rgba16f") return EatFormatRgba16f; + if (name == "format_r32f") return EatFormatR32f; + if (name == "format_rgba8") return EatFormatRgba8; + if (name == "format_rgba8snorm") return EatFormatRgba8Snorm; + if (name == "format_rg32f") return EatFormatRg32f; + if (name == "format_rg16f") return EatFormatRg16f; + if (name == "format_r11fg11fb10f") return EatFormatR11fG11fB10f; + if (name == "format_r16f") return EatFormatR16f; + if (name == "format_rgba16") return EatFormatRgba16; + if (name == "format_rgb10a2") return EatFormatRgb10A2; + if (name == "format_rg16") return EatFormatRg16; + if (name == "format_rg8") return EatFormatRg8; + if (name == "format_r16") return EatFormatR16; + if (name == "format_r8") return EatFormatR8; + if (name == "format_rgba16snorm") return EatFormatRgba16Snorm; + if (name == "format_rg16snorm") return EatFormatRg16Snorm; + if (name == "format_rg8snorm") return EatFormatRg8Snorm; + if (name == "format_r16snorm") return EatFormatR16Snorm; + if (name == "format_r8snorm") return EatFormatR8Snorm; + if (name == "format_rgba32i") return EatFormatRgba32i; + if (name == "format_rgba16i") return EatFormatRgba16i; + if (name == "format_rgba8i") return EatFormatRgba8i; + if (name == "format_r32i") return EatFormatR32i; + if (name == "format_rg32i") return EatFormatRg32i; + if (name == "format_rg16i") return EatFormatRg16i; + if (name == "format_rg8i") return EatFormatRg8i; + if (name == "format_r16i") return EatFormatR16i; + if (name == "format_r8i") return EatFormatR8i; + if (name == "format_rgba32ui") return EatFormatRgba32ui; + if (name == "format_rgba16ui") return EatFormatRgba16ui; + if (name == "format_rgba8ui") return EatFormatRgba8ui; + if (name == "format_r32ui") return EatFormatR32ui; + if (name == "format_rgb10a2ui") return EatFormatRgb10a2ui; + if (name == "format_rg32ui") return EatFormatRg32ui; + if (name == "format_rg16ui") return EatFormatRg16ui; + if (name == "format_rg8ui") return EatFormatRg8ui; + if (name == "format_r16ui") return EatFormatR16ui; + if (name == "format_r8ui") return EatFormatR8ui; + return EatFormatUnknown; } else if (nameSpace.size() > 0) return EatNone; diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp old mode 100755 new mode 100644 diff --git a/hlsl/hlslGrammar.h b/hlsl/hlslGrammar.h old mode 100755 new mode 100644 diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp old mode 100644 new mode 100755 index 1549e3a4ce..8d389f5db0 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -1950,6 +1950,49 @@ void HlslParseContext::transferTypeAttributes(const TSourceLoc& loc, const TAttr setSpecConstantId(loc, type.getQualifier(), value); } break; + + // image formats + case EatFormatRgba32f: type.getQualifier().layoutFormat = ElfRgba32f; break; + case EatFormatRgba16f: type.getQualifier().layoutFormat = ElfRgba16f; break; + case EatFormatR32f: type.getQualifier().layoutFormat = ElfR32f; break; + case EatFormatRgba8: type.getQualifier().layoutFormat = ElfRgba8; break; + case EatFormatRgba8Snorm: type.getQualifier().layoutFormat = ElfRgba8Snorm; break; + case EatFormatRg32f: type.getQualifier().layoutFormat = ElfRg32f; break; + case EatFormatRg16f: type.getQualifier().layoutFormat = ElfRg16f; break; + case EatFormatR11fG11fB10f: type.getQualifier().layoutFormat = ElfR11fG11fB10f; break; + case EatFormatR16f: type.getQualifier().layoutFormat = ElfR16f; break; + case EatFormatRgba16: type.getQualifier().layoutFormat = ElfRgba16; break; + case EatFormatRgb10A2: type.getQualifier().layoutFormat = ElfRgb10A2; break; + case EatFormatRg16: type.getQualifier().layoutFormat = ElfRg16; break; + case EatFormatRg8: type.getQualifier().layoutFormat = ElfRg8; break; + case EatFormatR16: type.getQualifier().layoutFormat = ElfR16; break; + case EatFormatR8: type.getQualifier().layoutFormat = ElfR8; break; + case EatFormatRgba16Snorm: type.getQualifier().layoutFormat = ElfRgba16Snorm; break; + case EatFormatRg16Snorm: type.getQualifier().layoutFormat = ElfRg16Snorm; break; + case EatFormatRg8Snorm: type.getQualifier().layoutFormat = ElfRg8Snorm; break; + case EatFormatR16Snorm: type.getQualifier().layoutFormat = ElfR16Snorm; break; + case EatFormatR8Snorm: type.getQualifier().layoutFormat = ElfR8Snorm; break; + case EatFormatRgba32i: type.getQualifier().layoutFormat = ElfRgba32i; break; + case EatFormatRgba16i: type.getQualifier().layoutFormat = ElfRgba16i; break; + case EatFormatRgba8i: type.getQualifier().layoutFormat = ElfRgba8i; break; + case EatFormatR32i: type.getQualifier().layoutFormat = ElfR32i; break; + case EatFormatRg32i: type.getQualifier().layoutFormat = ElfRg32i; break; + case EatFormatRg16i: type.getQualifier().layoutFormat = ElfRg16i; break; + case EatFormatRg8i: type.getQualifier().layoutFormat = ElfRg8i; break; + case EatFormatR16i: type.getQualifier().layoutFormat = ElfR16i; break; + case EatFormatR8i: type.getQualifier().layoutFormat = ElfR8i; break; + case EatFormatRgba32ui: type.getQualifier().layoutFormat = ElfRgba32ui; break; + case EatFormatRgba16ui: type.getQualifier().layoutFormat = ElfRgba16ui; break; + case EatFormatRgba8ui: type.getQualifier().layoutFormat = ElfRgba8ui; break; + case EatFormatR32ui: type.getQualifier().layoutFormat = ElfR32ui; break; + case EatFormatRgb10a2ui: type.getQualifier().layoutFormat = ElfRgb10a2ui; break; + case EatFormatRg32ui: type.getQualifier().layoutFormat = ElfRg32ui; break; + case EatFormatRg16ui: type.getQualifier().layoutFormat = ElfRg16ui; break; + case EatFormatRg8ui: type.getQualifier().layoutFormat = ElfRg8ui; break; + case EatFormatR16ui: type.getQualifier().layoutFormat = ElfR16ui; break; + case EatFormatR8ui: type.getQualifier().layoutFormat = ElfR8ui; break; + case EatFormatUnknown: type.getQualifier().layoutFormat = ElfNone; break; + default: if (! allowEntry) warn(loc, "attribute does not apply to a type", "", ""); diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h old mode 100755 new mode 100644 From 8a97d38913949b5c5c640882bb73c1c775c7293d Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Sun, 29 Sep 2019 18:02:19 -0600 Subject: [PATCH 2/2] HLSL: Fix #1912: add attribute syntax for nonreadable/nonwritable --- .../hlsl.format.rwtexture.frag.out | 366 ++++++++++++++---- Test/hlsl.format.rwtexture.frag | 32 +- glslang/MachineIndependent/attribute.h | 4 +- hlsl/hlslAttributes.cpp | 4 +- hlsl/hlslParseHelper.cpp | 3 + 5 files changed, 323 insertions(+), 86 deletions(-) mode change 100755 => 100644 Test/baseResults/hlsl.format.rwtexture.frag.out mode change 100755 => 100644 Test/hlsl.format.rwtexture.frag diff --git a/Test/baseResults/hlsl.format.rwtexture.frag.out b/Test/baseResults/hlsl.format.rwtexture.frag.out old mode 100755 new mode 100644 index 2ecd5148d1..7ab53299be --- a/Test/baseResults/hlsl.format.rwtexture.frag.out +++ b/Test/baseResults/hlsl.format.rwtexture.frag.out @@ -3,47 +3,47 @@ Shader version: 500 gl_FragCoord origin is upper left using depth_any 0:? Sequence -0:30 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Function Parameters: +0:56 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Function Parameters: 0:? Sequence -0:33 move second child to first child ( temp 4-component vector of float) -0:33 Color: direct index for structure ( temp 4-component vector of float) -0:33 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:33 Constant: -0:33 0 (const int) -0:33 Constant: -0:33 1.000000 -0:33 1.000000 -0:33 1.000000 -0:33 1.000000 -0:34 move second child to first child ( temp float) -0:34 Depth: direct index for structure ( temp float) -0:34 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:34 Constant: -0:34 1 (const int) -0:34 Constant: -0:34 1.000000 -0:36 Branch: Return with expression -0:36 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Function Definition: main( ( temp void) -0:30 Function Parameters: +0:59 move second child to first child ( temp 4-component vector of float) +0:59 Color: direct index for structure ( temp 4-component vector of float) +0:59 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:59 Constant: +0:59 0 (const int) +0:59 Constant: +0:59 1.000000 +0:59 1.000000 +0:59 1.000000 +0:59 1.000000 +0:60 move second child to first child ( temp float) +0:60 Depth: direct index for structure ( temp float) +0:60 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:60 Constant: +0:60 1 (const int) +0:60 Constant: +0:60 1.000000 +0:62 Branch: Return with expression +0:62 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Function Definition: main( ( temp void) +0:56 Function Parameters: 0:? Sequence -0:30 Sequence -0:30 move second child to first child ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Function Call: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 move second child to first child ( temp 4-component vector of float) +0:56 Sequence +0:56 move second child to first child ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Function Call: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 move second child to first child ( temp 4-component vector of float) 0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) -0:30 Color: direct index for structure ( temp 4-component vector of float) -0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Constant: -0:30 0 (const int) -0:30 move second child to first child ( temp float) +0:56 Color: direct index for structure ( temp 4-component vector of float) +0:56 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Constant: +0:56 0 (const int) +0:56 move second child to first child ( temp float) 0:? '@entryPointOutput.Depth' ( out float FragDepth) -0:30 Depth: direct index for structure ( temp float) -0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Constant: -0:30 1 (const int) +0:56 Depth: direct index for structure ( temp float) +0:56 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Constant: +0:56 1 (const int) 0:? Linker Objects 0:? 'g_sSamp' (layout( binding=0) uniform sampler) 0:? 'g_tTex1df4' (layout( binding=0 rgba32f) uniform image1D) @@ -52,15 +52,40 @@ using depth_any 0:? 'g_tTex2df4' (layout( rgba8i) uniform image2D) 0:? 'g_tTex2di4' (layout( r11f_g11f_b10f) uniform iimage2D) 0:? 'g_tTex2du4' (layout( r8_snorm) uniform uimage2D) -0:? 'g_tTex3df4' (layout( rg8) uniform image3D) -0:? 'g_tTex3di4' (layout( rgba16i) uniform iimage3D) -0:? 'g_tTex3du4' (layout( r8i) uniform uimage3D) +0:? 'g_tTex3df4' (layout( rg8) readonly uniform image3D) +0:? 'g_tTex3di4' (layout( rgba16i) writeonly uniform iimage3D) +0:? 'g_tTex3du4' (layout( r8i) readonly writeonly uniform uimage3D) 0:? 'g_tTex1df4a' (layout( rgba8ui) uniform image1DArray) 0:? 'g_tTex1di4a' (layout( rg32ui) uniform iimage1DArray) 0:? 'g_tTex1du4a' (layout( r16ui) uniform uimage1DArray) 0:? 'g_tTex2df4a' (layout( rgb10_a2ui) uniform image2DArray) 0:? 'g_tTex2di4a' (layout( r8ui) uniform iimage2DArray) 0:? 'g_tTex2du4a' (layout( rgba16f) uniform uimage2DArray) +0:? 'g_tTex01' (layout( rgba8) uniform iimage2DArray) +0:? 'g_tTex02' (layout( rg16f) uniform iimage2DArray) +0:? 'g_tTex03' (layout( r16f) uniform iimage2DArray) +0:? 'g_tTex04' (layout( rgb10_a2) uniform iimage2DArray) +0:? 'g_tTex05' (layout( rg16) uniform iimage2DArray) +0:? 'g_tTex06' (layout( r32f) uniform iimage2DArray) +0:? 'g_tTex07' (layout( rgba16) uniform iimage2DArray) +0:? 'g_tTex08' (layout( r16) uniform iimage2DArray) +0:? 'g_tTex09' (layout( r8) uniform iimage2DArray) +0:? 'g_tTex10' (layout( rgba16_snorm) uniform iimage2DArray) +0:? 'g_tTex11' (layout( rg16_snorm) uniform iimage2DArray) +0:? 'g_tTex12' (layout( r16_snorm) uniform iimage2DArray) +0:? 'g_tTex13' (layout( r8_snorm) uniform iimage2DArray) +0:? 'g_tTex14' (layout( rgba32i) uniform iimage2DArray) +0:? 'g_tTex15' (layout( r32i) uniform iimage2DArray) +0:? 'g_tTex16' (layout( r32ui) uniform iimage2DArray) +0:? 'g_tTex17' (layout( rg16i) uniform iimage2DArray) +0:? 'g_tTex18' (layout( r16i) uniform iimage2DArray) +0:? 'g_tTex19' (layout( rg32i) uniform iimage2DArray) +0:? 'g_tTex20' (layout( rg8i) uniform iimage2DArray) +0:? 'g_tTex21' (layout( rg8ui) uniform iimage2DArray) +0:? 'g_tTex22' (layout( rgba32ui) uniform iimage2DArray) +0:? 'g_tTex23' (layout( rgba16ui) uniform iimage2DArray) +0:? 'g_tTex24' (layout( rg32ui) uniform iimage2DArray) +0:? 'g_tTex25' (layout( rg16ui) uniform iimage2DArray) 0:? '@entryPointOutput.Depth' ( out float FragDepth) 0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) @@ -72,47 +97,47 @@ Shader version: 500 gl_FragCoord origin is upper left using depth_any 0:? Sequence -0:30 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Function Parameters: +0:56 Function Definition: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Function Parameters: 0:? Sequence -0:33 move second child to first child ( temp 4-component vector of float) -0:33 Color: direct index for structure ( temp 4-component vector of float) -0:33 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:33 Constant: -0:33 0 (const int) -0:33 Constant: -0:33 1.000000 -0:33 1.000000 -0:33 1.000000 -0:33 1.000000 -0:34 move second child to first child ( temp float) -0:34 Depth: direct index for structure ( temp float) -0:34 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:34 Constant: -0:34 1 (const int) -0:34 Constant: -0:34 1.000000 -0:36 Branch: Return with expression -0:36 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Function Definition: main( ( temp void) -0:30 Function Parameters: +0:59 move second child to first child ( temp 4-component vector of float) +0:59 Color: direct index for structure ( temp 4-component vector of float) +0:59 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:59 Constant: +0:59 0 (const int) +0:59 Constant: +0:59 1.000000 +0:59 1.000000 +0:59 1.000000 +0:59 1.000000 +0:60 move second child to first child ( temp float) +0:60 Depth: direct index for structure ( temp float) +0:60 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:60 Constant: +0:60 1 (const int) +0:60 Constant: +0:60 1.000000 +0:62 Branch: Return with expression +0:62 'psout' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Function Definition: main( ( temp void) +0:56 Function Parameters: 0:? Sequence -0:30 Sequence -0:30 move second child to first child ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Function Call: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 move second child to first child ( temp 4-component vector of float) +0:56 Sequence +0:56 move second child to first child ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Function Call: @main( ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 move second child to first child ( temp 4-component vector of float) 0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) -0:30 Color: direct index for structure ( temp 4-component vector of float) -0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Constant: -0:30 0 (const int) -0:30 move second child to first child ( temp float) +0:56 Color: direct index for structure ( temp 4-component vector of float) +0:56 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Constant: +0:56 0 (const int) +0:56 move second child to first child ( temp float) 0:? '@entryPointOutput.Depth' ( out float FragDepth) -0:30 Depth: direct index for structure ( temp float) -0:30 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) -0:30 Constant: -0:30 1 (const int) +0:56 Depth: direct index for structure ( temp float) +0:56 'flattenTemp' ( temp structure{ temp 4-component vector of float Color, temp float Depth}) +0:56 Constant: +0:56 1 (const int) 0:? Linker Objects 0:? 'g_sSamp' (layout( binding=0) uniform sampler) 0:? 'g_tTex1df4' (layout( binding=0 rgba32f) uniform image1D) @@ -121,21 +146,46 @@ using depth_any 0:? 'g_tTex2df4' (layout( rgba8i) uniform image2D) 0:? 'g_tTex2di4' (layout( r11f_g11f_b10f) uniform iimage2D) 0:? 'g_tTex2du4' (layout( r8_snorm) uniform uimage2D) -0:? 'g_tTex3df4' (layout( rg8) uniform image3D) -0:? 'g_tTex3di4' (layout( rgba16i) uniform iimage3D) -0:? 'g_tTex3du4' (layout( r8i) uniform uimage3D) +0:? 'g_tTex3df4' (layout( rg8) readonly uniform image3D) +0:? 'g_tTex3di4' (layout( rgba16i) writeonly uniform iimage3D) +0:? 'g_tTex3du4' (layout( r8i) readonly writeonly uniform uimage3D) 0:? 'g_tTex1df4a' (layout( rgba8ui) uniform image1DArray) 0:? 'g_tTex1di4a' (layout( rg32ui) uniform iimage1DArray) 0:? 'g_tTex1du4a' (layout( r16ui) uniform uimage1DArray) 0:? 'g_tTex2df4a' (layout( rgb10_a2ui) uniform image2DArray) 0:? 'g_tTex2di4a' (layout( r8ui) uniform iimage2DArray) 0:? 'g_tTex2du4a' (layout( rgba16f) uniform uimage2DArray) +0:? 'g_tTex01' (layout( rgba8) uniform iimage2DArray) +0:? 'g_tTex02' (layout( rg16f) uniform iimage2DArray) +0:? 'g_tTex03' (layout( r16f) uniform iimage2DArray) +0:? 'g_tTex04' (layout( rgb10_a2) uniform iimage2DArray) +0:? 'g_tTex05' (layout( rg16) uniform iimage2DArray) +0:? 'g_tTex06' (layout( r32f) uniform iimage2DArray) +0:? 'g_tTex07' (layout( rgba16) uniform iimage2DArray) +0:? 'g_tTex08' (layout( r16) uniform iimage2DArray) +0:? 'g_tTex09' (layout( r8) uniform iimage2DArray) +0:? 'g_tTex10' (layout( rgba16_snorm) uniform iimage2DArray) +0:? 'g_tTex11' (layout( rg16_snorm) uniform iimage2DArray) +0:? 'g_tTex12' (layout( r16_snorm) uniform iimage2DArray) +0:? 'g_tTex13' (layout( r8_snorm) uniform iimage2DArray) +0:? 'g_tTex14' (layout( rgba32i) uniform iimage2DArray) +0:? 'g_tTex15' (layout( r32i) uniform iimage2DArray) +0:? 'g_tTex16' (layout( r32ui) uniform iimage2DArray) +0:? 'g_tTex17' (layout( rg16i) uniform iimage2DArray) +0:? 'g_tTex18' (layout( r16i) uniform iimage2DArray) +0:? 'g_tTex19' (layout( rg32i) uniform iimage2DArray) +0:? 'g_tTex20' (layout( rg8i) uniform iimage2DArray) +0:? 'g_tTex21' (layout( rg8ui) uniform iimage2DArray) +0:? 'g_tTex22' (layout( rgba32ui) uniform iimage2DArray) +0:? 'g_tTex23' (layout( rgba16ui) uniform iimage2DArray) +0:? 'g_tTex24' (layout( rg32ui) uniform iimage2DArray) +0:? 'g_tTex25' (layout( rg16ui) uniform iimage2DArray) 0:? '@entryPointOutput.Depth' ( out float FragDepth) 0:? '@entryPointOutput.Color' (layout( location=0) out 4-component vector of float) // Module Version 10000 // Generated by (magic number): 80007 -// Id's are bound by 85 +// Id's are bound by 160 Capability Shader Capability Image1D @@ -171,6 +221,31 @@ using depth_any Name 78 "g_tTex2df4a" Name 81 "g_tTex2di4a" Name 84 "g_tTex2du4a" + Name 87 "g_tTex01" + Name 90 "g_tTex02" + Name 93 "g_tTex03" + Name 96 "g_tTex04" + Name 99 "g_tTex05" + Name 102 "g_tTex06" + Name 105 "g_tTex07" + Name 108 "g_tTex08" + Name 111 "g_tTex09" + Name 114 "g_tTex10" + Name 117 "g_tTex11" + Name 120 "g_tTex12" + Name 123 "g_tTex13" + Name 126 "g_tTex14" + Name 129 "g_tTex15" + Name 132 "g_tTex16" + Name 135 "g_tTex17" + Name 138 "g_tTex18" + Name 141 "g_tTex19" + Name 144 "g_tTex20" + Name 147 "g_tTex21" + Name 150 "g_tTex22" + Name 153 "g_tTex23" + Name 156 "g_tTex24" + Name 159 "g_tTex25" Decorate 29(@entryPointOutput.Color) Location 0 Decorate 33(@entryPointOutput.Depth) BuiltIn FragDepth Decorate 38(g_sSamp) DescriptorSet 0 @@ -189,10 +264,14 @@ using depth_any Decorate 57(g_tTex2du4) Binding 0 Decorate 60(g_tTex3df4) DescriptorSet 0 Decorate 60(g_tTex3df4) Binding 0 + Decorate 60(g_tTex3df4) NonWritable Decorate 63(g_tTex3di4) DescriptorSet 0 Decorate 63(g_tTex3di4) Binding 0 + Decorate 63(g_tTex3di4) NonReadable Decorate 66(g_tTex3du4) DescriptorSet 0 Decorate 66(g_tTex3du4) Binding 0 + Decorate 66(g_tTex3du4) NonWritable + Decorate 66(g_tTex3du4) NonReadable Decorate 69(g_tTex1df4a) DescriptorSet 0 Decorate 69(g_tTex1df4a) Binding 0 Decorate 72(g_tTex1di4a) DescriptorSet 0 @@ -205,6 +284,56 @@ using depth_any Decorate 81(g_tTex2di4a) Binding 0 Decorate 84(g_tTex2du4a) DescriptorSet 0 Decorate 84(g_tTex2du4a) Binding 0 + Decorate 87(g_tTex01) DescriptorSet 0 + Decorate 87(g_tTex01) Binding 0 + Decorate 90(g_tTex02) DescriptorSet 0 + Decorate 90(g_tTex02) Binding 0 + Decorate 93(g_tTex03) DescriptorSet 0 + Decorate 93(g_tTex03) Binding 0 + Decorate 96(g_tTex04) DescriptorSet 0 + Decorate 96(g_tTex04) Binding 0 + Decorate 99(g_tTex05) DescriptorSet 0 + Decorate 99(g_tTex05) Binding 0 + Decorate 102(g_tTex06) DescriptorSet 0 + Decorate 102(g_tTex06) Binding 0 + Decorate 105(g_tTex07) DescriptorSet 0 + Decorate 105(g_tTex07) Binding 0 + Decorate 108(g_tTex08) DescriptorSet 0 + Decorate 108(g_tTex08) Binding 0 + Decorate 111(g_tTex09) DescriptorSet 0 + Decorate 111(g_tTex09) Binding 0 + Decorate 114(g_tTex10) DescriptorSet 0 + Decorate 114(g_tTex10) Binding 0 + Decorate 117(g_tTex11) DescriptorSet 0 + Decorate 117(g_tTex11) Binding 0 + Decorate 120(g_tTex12) DescriptorSet 0 + Decorate 120(g_tTex12) Binding 0 + Decorate 123(g_tTex13) DescriptorSet 0 + Decorate 123(g_tTex13) Binding 0 + Decorate 126(g_tTex14) DescriptorSet 0 + Decorate 126(g_tTex14) Binding 0 + Decorate 129(g_tTex15) DescriptorSet 0 + Decorate 129(g_tTex15) Binding 0 + Decorate 132(g_tTex16) DescriptorSet 0 + Decorate 132(g_tTex16) Binding 0 + Decorate 135(g_tTex17) DescriptorSet 0 + Decorate 135(g_tTex17) Binding 0 + Decorate 138(g_tTex18) DescriptorSet 0 + Decorate 138(g_tTex18) Binding 0 + Decorate 141(g_tTex19) DescriptorSet 0 + Decorate 141(g_tTex19) Binding 0 + Decorate 144(g_tTex20) DescriptorSet 0 + Decorate 144(g_tTex20) Binding 0 + Decorate 147(g_tTex21) DescriptorSet 0 + Decorate 147(g_tTex21) Binding 0 + Decorate 150(g_tTex22) DescriptorSet 0 + Decorate 150(g_tTex22) Binding 0 + Decorate 153(g_tTex23) DescriptorSet 0 + Decorate 153(g_tTex23) Binding 0 + Decorate 156(g_tTex24) DescriptorSet 0 + Decorate 156(g_tTex24) Binding 0 + Decorate 159(g_tTex25) DescriptorSet 0 + Decorate 159(g_tTex25) Binding 0 2: TypeVoid 3: TypeFunction 2 6: TypeFloat 32 @@ -272,6 +401,81 @@ using depth_any 82: TypeImage 45(int) 2D array nonsampled format:Rgba16f 83: TypePointer UniformConstant 82 84(g_tTex2du4a): 83(ptr) Variable UniformConstant + 85: TypeImage 14(int) 2D array nonsampled format:Rgba8 + 86: TypePointer UniformConstant 85 + 87(g_tTex01): 86(ptr) Variable UniformConstant + 88: TypeImage 14(int) 2D array nonsampled format:Rg16f + 89: TypePointer UniformConstant 88 + 90(g_tTex02): 89(ptr) Variable UniformConstant + 91: TypeImage 14(int) 2D array nonsampled format:R16f + 92: TypePointer UniformConstant 91 + 93(g_tTex03): 92(ptr) Variable UniformConstant + 94: TypeImage 14(int) 2D array nonsampled format:Rgb10A2 + 95: TypePointer UniformConstant 94 + 96(g_tTex04): 95(ptr) Variable UniformConstant + 97: TypeImage 14(int) 2D array nonsampled format:Rg16 + 98: TypePointer UniformConstant 97 + 99(g_tTex05): 98(ptr) Variable UniformConstant + 100: TypeImage 14(int) 2D array nonsampled format:R32f + 101: TypePointer UniformConstant 100 + 102(g_tTex06): 101(ptr) Variable UniformConstant + 103: TypeImage 14(int) 2D array nonsampled format:Rgba16 + 104: TypePointer UniformConstant 103 + 105(g_tTex07): 104(ptr) Variable UniformConstant + 106: TypeImage 14(int) 2D array nonsampled format:R16 + 107: TypePointer UniformConstant 106 + 108(g_tTex08): 107(ptr) Variable UniformConstant + 109: TypeImage 14(int) 2D array nonsampled format:R8 + 110: TypePointer UniformConstant 109 + 111(g_tTex09): 110(ptr) Variable UniformConstant + 112: TypeImage 14(int) 2D array nonsampled format:Rgba16Snorm + 113: TypePointer UniformConstant 112 + 114(g_tTex10): 113(ptr) Variable UniformConstant + 115: TypeImage 14(int) 2D array nonsampled format:Rg16Snorm + 116: TypePointer UniformConstant 115 + 117(g_tTex11): 116(ptr) Variable UniformConstant + 118: TypeImage 14(int) 2D array nonsampled format:R16Snorm + 119: TypePointer UniformConstant 118 + 120(g_tTex12): 119(ptr) Variable UniformConstant + 121: TypeImage 14(int) 2D array nonsampled format:R8Snorm + 122: TypePointer UniformConstant 121 + 123(g_tTex13): 122(ptr) Variable UniformConstant + 124: TypeImage 14(int) 2D array nonsampled format:Rgba32i + 125: TypePointer UniformConstant 124 + 126(g_tTex14): 125(ptr) Variable UniformConstant + 127: TypeImage 14(int) 2D array nonsampled format:R32i + 128: TypePointer UniformConstant 127 + 129(g_tTex15): 128(ptr) Variable UniformConstant + 130: TypeImage 14(int) 2D array nonsampled format:R32ui + 131: TypePointer UniformConstant 130 + 132(g_tTex16): 131(ptr) Variable UniformConstant + 133: TypeImage 14(int) 2D array nonsampled format:Rg16i + 134: TypePointer UniformConstant 133 + 135(g_tTex17): 134(ptr) Variable UniformConstant + 136: TypeImage 14(int) 2D array nonsampled format:R16i + 137: TypePointer UniformConstant 136 + 138(g_tTex18): 137(ptr) Variable UniformConstant + 139: TypeImage 14(int) 2D array nonsampled format:Rg32i + 140: TypePointer UniformConstant 139 + 141(g_tTex19): 140(ptr) Variable UniformConstant + 142: TypeImage 14(int) 2D array nonsampled format:Rg8i + 143: TypePointer UniformConstant 142 + 144(g_tTex20): 143(ptr) Variable UniformConstant + 145: TypeImage 14(int) 2D array nonsampled format:Rg8ui + 146: TypePointer UniformConstant 145 + 147(g_tTex21): 146(ptr) Variable UniformConstant + 148: TypeImage 14(int) 2D array nonsampled format:Rgba32ui + 149: TypePointer UniformConstant 148 + 150(g_tTex22): 149(ptr) Variable UniformConstant + 151: TypeImage 14(int) 2D array nonsampled format:Rgba16ui + 152: TypePointer UniformConstant 151 + 153(g_tTex23): 152(ptr) Variable UniformConstant + 154: TypeImage 14(int) 2D array nonsampled format:Rg32ui + 155: TypePointer UniformConstant 154 + 156(g_tTex24): 155(ptr) Variable UniformConstant + 157: TypeImage 14(int) 2D array nonsampled format:Rg16ui + 158: TypePointer UniformConstant 157 + 159(g_tTex25): 158(ptr) Variable UniformConstant 4(main): 2 Function None 3 5: Label 26(flattenTemp): 12(ptr) Variable Function diff --git a/Test/hlsl.format.rwtexture.frag b/Test/hlsl.format.rwtexture.frag old mode 100755 new mode 100644 index d92f590662..87ee7de784 --- a/Test/hlsl.format.rwtexture.frag +++ b/Test/hlsl.format.rwtexture.frag @@ -8,9 +8,9 @@ SamplerState g_sSamp : register(s0); [[spv::format_r11fg11fb10f]] RWTexture2D g_tTex2di4; [[spv::format_r8snorm]] RWTexture2D g_tTex2du4; -[[spv::format_rg8]] RWTexture3D g_tTex3df4; -[[spv::format_rgba16i]] RWTexture3D g_tTex3di4; -[[spv::format_r8i]] RWTexture3D g_tTex3du4; +[[spv::format_rg8]] [[spv::nonwritable]] RWTexture3D g_tTex3df4; +[[spv::format_rgba16i]] [[spv::nonreadable]] RWTexture3D g_tTex3di4; +[[spv::format_r8i]] [[spv::nonwritable]] [[spv::nonreadable]] RWTexture3D g_tTex3du4; [[spv::format_rgba8ui]] RWTexture1DArray g_tTex1df4a; [[spv::format_rg32ui]] RWTexture1DArray g_tTex1di4a; @@ -20,6 +20,32 @@ SamplerState g_sSamp : register(s0); [[spv::format_r8ui]] RWTexture2DArray g_tTex2di4a; [[spv::format_rgba16f]] RWTexture2DArray g_tTex2du4a; +[[spv::format_rgba8 ]] RWTexture2DArray g_tTex01; +[[spv::format_rg16f ]] RWTexture2DArray g_tTex02; +[[spv::format_r16f ]] RWTexture2DArray g_tTex03; +[[spv::format_rgb10a2 ]] RWTexture2DArray g_tTex04; +[[spv::format_rg16 ]] RWTexture2DArray g_tTex05; +[[spv::format_r32f ]] RWTexture2DArray g_tTex06; +[[spv::format_rgba16 ]] RWTexture2DArray g_tTex07; +[[spv::format_r16 ]] RWTexture2DArray g_tTex08; +[[spv::format_r8 ]] RWTexture2DArray g_tTex09; +[[spv::format_rgba16snorm ]] RWTexture2DArray g_tTex10; +[[spv::format_rg16snorm ]] RWTexture2DArray g_tTex11; +[[spv::format_r16snorm ]] RWTexture2DArray g_tTex12; +[[spv::format_r8snorm ]] RWTexture2DArray g_tTex13; +[[spv::format_rgba32i ]] RWTexture2DArray g_tTex14; +[[spv::format_r32i ]] RWTexture2DArray g_tTex15; +[[spv::format_r32ui ]] RWTexture2DArray g_tTex16; +[[spv::format_rg16i ]] RWTexture2DArray g_tTex17; +[[spv::format_r16i ]] RWTexture2DArray g_tTex18; +[[spv::format_rg32i ]] RWTexture2DArray g_tTex19; +[[spv::format_rg8i ]] RWTexture2DArray g_tTex20; +[[spv::format_rg8ui ]] RWTexture2DArray g_tTex21; +[[spv::format_rgba32ui ]] RWTexture2DArray g_tTex22; +[[spv::format_rgba16ui ]] RWTexture2DArray g_tTex23; +[[spv::format_rg32ui ]] RWTexture2DArray g_tTex24; +[[spv::format_rg16ui ]] RWTexture2DArray g_tTex25; + struct PS_OUTPUT { float4 Color : SV_Target0; diff --git a/glslang/MachineIndependent/attribute.h b/glslang/MachineIndependent/attribute.h index 92f3d63432..38a943d283 100644 --- a/glslang/MachineIndependent/attribute.h +++ b/glslang/MachineIndependent/attribute.h @@ -116,7 +116,9 @@ namespace glslang { EatFormatRg8ui, EatFormatR16ui, EatFormatR8ui, - EatFormatUnknown + EatFormatUnknown, + EatNonWritable, + EatNonReadable }; class TIntermAggregate; diff --git a/hlsl/hlslAttributes.cpp b/hlsl/hlslAttributes.cpp index 05d4ae3694..0cc0d3f4fc 100644 --- a/hlsl/hlslAttributes.cpp +++ b/hlsl/hlslAttributes.cpp @@ -98,7 +98,9 @@ namespace glslang { if (name == "format_rg8ui") return EatFormatRg8ui; if (name == "format_r16ui") return EatFormatR16ui; if (name == "format_r8ui") return EatFormatR8ui; - return EatFormatUnknown; + + if (name == "nonwritable") return EatNonWritable; + if (name == "nonreadable") return EatNonReadable; } else if (nameSpace.size() > 0) return EatNone; diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 8d389f5db0..be665ac00d 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -1993,6 +1993,9 @@ void HlslParseContext::transferTypeAttributes(const TSourceLoc& loc, const TAttr case EatFormatR8ui: type.getQualifier().layoutFormat = ElfR8ui; break; case EatFormatUnknown: type.getQualifier().layoutFormat = ElfNone; break; + case EatNonWritable: type.getQualifier().readonly = true; break; + case EatNonReadable: type.getQualifier().writeonly = true; break; + default: if (! allowEntry) warn(loc, "attribute does not apply to a type", "", "");